circuits/TransactionVerifierCircuitTOTP.cpp¶
Source file of the circuit that validate the transaction as well as TOTP. More...
Functions¶
| Name | |
|---|---|
| bool | ValidateTransactionTOTP(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, pallas::scalar_field_type::value_type base_seed, pallas::scalar_field_type::value_type provided_totp) Validates the transaction and TOTP. |
Detailed Description¶
Source file of the circuit that validate the transaction as well as TOTP.
Date: 2025-01-30 Henrique A. Klein ([email protected])
Functions Documentation¶
function ValidateTransactionTOTP¶
bool ValidateTransactionTOTP(
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,
pallas::scalar_field_type::value_type base_seed,
pallas::scalar_field_type::value_type provided_totp
)
Validates the transaction and TOTP.
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
- base_seed The base seed used by TOTP
- provided_totp The TOTP
Return: True if transaction and TOTP are valid, false otherwise
Source code¶
#include "TransactionVerifierCircuitTOTP.hpp"
using namespace nil::crypto3::algebra::curves;
[[circuit]] bool ValidateTransactionTOTP(
[[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, //
[[private_input]] pallas::scalar_field_type::value_type base_seed, //
[[private_input]] pallas::scalar_field_type::value_type provided_totp )
{
bool ret = false;
// Only perform TOTP validation if base_seed is not zero
if ( base_seed != 0 )
{
// Generate elliptic curve point from seed and provided TOTP
auto generated_point = GeneratePointFromSeedAndTotp( base_seed, provided_totp, generator );
// Validate if generated point corresponds to some valid criteria
ret = ( generated_point == ( base_seed * generator + ( provided_totp * generator ) ) ); // Example check
}
if ( ret )
{
ret = ValidateTransactionValues( balance, amount, balance_scalar, amount_scalar, balance_commitment, amount_commitment,
expected_new_balance_commitment, generator, ranges );
}
return ret;
}
Updated on 2026-04-13 at 23:22:46 -0700