Skip to content

include/ProofSystem/SGProofCircuits/include/TransactionVerifierCircuit.hpp

Functions

Name
bool ValidateTransaction(uint64_t balance, uint64_t amount, pallas::scalar_field_type::value_type balance_scalar, pallas::scalar_field_type::value_type amount_scalar, typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type balance_commitment, typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type amount_commitment, typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type expected_new_balance_commitment, typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type generator, std::array< pallas::scalar_field_type::value_type, MAX_RANGES > ranges)
Circuit that validates the transaction.

Functions Documentation

function ValidateTransaction

bool ValidateTransaction(
    uint64_t balance,
    uint64_t amount,
    pallas::scalar_field_type::value_type balance_scalar,
    pallas::scalar_field_type::value_type amount_scalar,
    typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type balance_commitment,
    typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type amount_commitment,
    typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type expected_new_balance_commitment,
    typename pallas::template g1_type< nil::crypto3::algebra::curves::coordinates::affine >::value_type generator,
    std::array< pallas::scalar_field_type::value_type, MAX_RANGES > ranges
)

Circuit that validates the transaction.

Parameters:

  • balance The raw balance in integer form
  • amount The raw amount in integer form
  • balance_scalar The raw balance in scalar form
  • amount_scalar The raw amount in scalar form
  • balance_commitment The balance multiplied by a generator (mapped to a curve)
  • amount_commitment The amount multiplied by a generator (mapped to a curve)
  • expected_new_balance_commitment The new balance multiplied by a generator (mapped to a curve)
  • generator The generator that is used to map values to the curve
  • ranges Array of possible ranges of the amount

Return: True if transaction is valid, false otherwise

Source code

//
// Created by Kenneth Hurley on 9/24/24.
//

#ifndef TRANSACTIONVERIFIERCIRCUIT_HPP
#define TRANSACTIONVERIFIERCIRCUIT_HPP

#include <nil/crypto3/algebra/curves/pallas.hpp>
#include <nil/crypto3/algebra/random_element.hpp>
#include <cstdint>
#include <array>
#include "TransactionValidator.hpp"

using namespace nil::crypto3::algebra::curves;


[[circuit]] bool ValidateTransaction(
    [[private_input]] uint64_t                                                                        balance,                         //
    [[private_input]] uint64_t                                                                        amount,                          //
    [[private_input]] pallas::scalar_field_type::value_type                                           balance_scalar,                  //
    [[private_input]] pallas::scalar_field_type::value_type                                           amount_scalar,                   //
    typename pallas::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type balance_commitment,              //
    typename pallas::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type amount_commitment,               //
    typename pallas::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type expected_new_balance_commitment, //
    typename pallas::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type generator,                       //
    std::array<pallas::scalar_field_type::value_type, MAX_RANGES>                                     ranges );

#endif //TRANSACTIONVERIFIERCIRCUIT_HPP

Updated on 2026-04-26 at 17:04:52 -0700