Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
graph_description_poseidon2s_permutation.test.cpp File Reference

Go to the source code of this file.

Typedefs

using Params = crypto::Poseidon2Bn254ScalarFieldParams
 
using Builder = UltraCircuitBuilder
 
using Permutation = stdlib::Poseidon2Permutation< Params, Builder >
 
using field_t = stdlib::field_t< Builder >
 
using witness_t = stdlib::witness_t< Builder >
 
using _curve = stdlib::bn254< Builder >
 
using byte_array_ct = _curve::byte_array_ct
 
using fr_ct = typename _curve::ScalarField
 
using witness_ct = typename _curve::witness_ct
 

Functions

bool check_in_input_vector (const std::vector< field_t > &input_vector, const uint32_t &real_var_index)
 Check if a variable index is present in the input vector.
 
void test_poseidon2s_circuit (size_t num_inputs=5)
 Test graph description for poseidon2 hash with random inputs.
 
void test_poseidon2s_hash_repeated_pairs (size_t num_inputs=5)
 Test graph description for repeated poseidon2 hash operations.
 
 TEST (boomerang_poseidon2s, test_graph_for_poseidon2s_one_permutation)
 Test graph description for a single poseidon2 permutation.
 
 TEST (boomerang_poseidon2s, test_graph_for_poseidon2s_two_permutations)
 Test graph description for two separate poseidon2 permutations.
 
 TEST (boomerang_poseidon2s, test_graph_for_poseidon2s)
 Test graph for poseidon2s with varying input sizes.
 
 TEST (boomerang_poseidon2s, test_graph_for_poseidon2s_for_one_input_size)
 Test graph for poseidon2s with default input size.
 
 TEST (boomerang_poseidon2s, test_graph_for_poseidon2s_hash_repeated_pairs)
 Test graph for poseidon2s with repeated hash operations.
 

Typedef Documentation

◆ _curve

◆ Builder

◆ byte_array_ct

◆ field_t

◆ fr_ct

using fr_ct = typename _curve::ScalarField

◆ Params

◆ Permutation

◆ witness_ct

◆ witness_t

Function Documentation

◆ check_in_input_vector()

bool check_in_input_vector ( const std::vector< field_t > &  input_vector,
const uint32_t &  real_var_index 
)

Check if a variable index is present in the input vector.

Static analyzer usually prints input and output variables as variables in one gate. In these tests output variables are not dangerous. We can filter them by checking that difference between their witness indexes and witness index of result <= 3

Parameters
input_vectorVector of field elements to check against
real_var_indexVariable index to find
Returns
true if the variable index is found in the input vector
false if the variable index is not found

Definition at line 43 of file graph_description_poseidon2s_permutation.test.cpp.

◆ TEST() [1/5]

TEST ( boomerang_poseidon2s  ,
test_graph_for_poseidon2s   
)

Test graph for poseidon2s with varying input sizes.

Definition at line 191 of file graph_description_poseidon2s_permutation.test.cpp.

◆ TEST() [2/5]

TEST ( boomerang_poseidon2s  ,
test_graph_for_poseidon2s_for_one_input_size   
)

Test graph for poseidon2s with default input size.

Definition at line 201 of file graph_description_poseidon2s_permutation.test.cpp.

◆ TEST() [3/5]

TEST ( boomerang_poseidon2s  ,
test_graph_for_poseidon2s_hash_repeated_pairs   
)

Test graph for poseidon2s with repeated hash operations.

Definition at line 209 of file graph_description_poseidon2s_permutation.test.cpp.

◆ TEST() [4/5]

TEST ( boomerang_poseidon2s  ,
test_graph_for_poseidon2s_one_permutation   
)

Test graph description for a single poseidon2 permutation.

The result should be one connected component with no variables in one gate, as permutation connects all variables through its internal structure

Definition at line 129 of file graph_description_poseidon2s_permutation.test.cpp.

◆ TEST() [5/5]

TEST ( boomerang_poseidon2s  ,
test_graph_for_poseidon2s_two_permutations   
)

Test graph description for two separate poseidon2 permutations.

The result should be two connected components (one for each permutation) with no variables in one gate, verifying that different input sets create separate components

Definition at line 158 of file graph_description_poseidon2s_permutation.test.cpp.

◆ test_poseidon2s_circuit()

void test_poseidon2s_circuit ( size_t  num_inputs = 5)

Test graph description for poseidon2 hash with random inputs.

The result should be one connected component, and only output variables must be in one gate

Parameters
num_inputsNumber of random inputs to generate

Definition at line 60 of file graph_description_poseidon2s_permutation.test.cpp.

◆ test_poseidon2s_hash_repeated_pairs()

void test_poseidon2s_hash_repeated_pairs ( size_t  num_inputs = 5)

Test graph description for repeated poseidon2 hash operations.

The result should be one connected component with repeated hashing of pairs, only output variables from each hash operation must be in one gate

Parameters
num_inputsNumber of hash iterations to perform

Definition at line 94 of file graph_description_poseidon2s_permutation.test.cpp.