Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include "barretenberg/boomerang_value_detection/graph.hpp"
#include "barretenberg/crypto/poseidon2/poseidon2.hpp"
#include "barretenberg/crypto/poseidon2/poseidon2_params.hpp"
#include "barretenberg/stdlib/hash/poseidon2/poseidon2.hpp"
#include "barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.hpp"
#include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders.hpp"
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
#include "barretenberg/circuit_checker/circuit_checker.hpp"
#include "barretenberg/common/test.hpp"
#include "barretenberg/numeric/random/engine.hpp"
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. | |
using _curve = stdlib::bn254<Builder> |
Definition at line 26 of file graph_description_poseidon2s_permutation.test.cpp.
using Builder = UltraCircuitBuilder |
Definition at line 22 of file graph_description_poseidon2s_permutation.test.cpp.
using byte_array_ct = _curve::byte_array_ct |
Definition at line 27 of file graph_description_poseidon2s_permutation.test.cpp.
using field_t = stdlib::field_t<Builder> |
Definition at line 24 of file graph_description_poseidon2s_permutation.test.cpp.
using fr_ct = typename _curve::ScalarField |
Definition at line 28 of file graph_description_poseidon2s_permutation.test.cpp.
Definition at line 21 of file graph_description_poseidon2s_permutation.test.cpp.
using Permutation = stdlib::Poseidon2Permutation<Params, Builder> |
Definition at line 23 of file graph_description_poseidon2s_permutation.test.cpp.
using witness_ct = typename _curve::witness_ct |
Definition at line 29 of file graph_description_poseidon2s_permutation.test.cpp.
using witness_t = stdlib::witness_t<Builder> |
Definition at line 25 of file graph_description_poseidon2s_permutation.test.cpp.
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
input_vector | Vector of field elements to check against |
real_var_index | Variable index to find |
Definition at line 43 of file graph_description_poseidon2s_permutation.test.cpp.
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 | ( | 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 | ( | 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 | ( | 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 | ( | 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.
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
num_inputs | Number of random inputs to generate |
Definition at line 60 of file graph_description_poseidon2s_permutation.test.cpp.
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
num_inputs | Number of hash iterations to perform |
Definition at line 94 of file graph_description_poseidon2s_permutation.test.cpp.