Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
poseidon2_constraint.test.cpp
Go to the documentation of this file.
2#include "acir_format.hpp"
5
6#include <cstdint>
7#include <gtest/gtest.h>
8#include <strings.h>
9#include <vector>
10
11namespace acir_format::tests {
12
13using namespace bb;
14
15class Poseidon2Tests : public ::testing::Test {
16 protected:
18};
20
25TEST_F(Poseidon2Tests, TestPoseidon2Permutation)
26{
28 poseidon2_constraint{
29 .state = {
34 },
35 .result = { 5, 6, 7, 8, },
36 .len = 4,
37 };
38
39 AcirFormat constraint_system{
40 .varnum = 9,
41 .num_acir_opcodes = 1,
42 .public_inputs = {},
43 .poseidon2_constraints = { poseidon2_constraint },
44 .original_opcode_indices = create_empty_original_opcode_indices(),
45 };
46 mock_opcode_indices(constraint_system);
47
48 WitnessVector witness{
49 1,
50 0,
51 1,
52 2,
53 3,
54 fr(std::string("0x01bd538c2ee014ed5141b29e9ae240bf8db3fe5b9a38629a9647cf8d76c01737")),
55 fr(std::string("0x239b62e7db98aa3a2a8f6a0d2fa1709e7a35959aa6c7034814d9daa90cbac662")),
56 fr(std::string("0x04cbb44c61d928ed06808456bf758cbf0c18d1e15a7b6dbc8245fa7515d5e3cb")),
57 fr(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")),
58 };
59
60 AcirProgram program{ constraint_system, witness };
61 auto builder = create_circuit(program);
62
63 EXPECT_TRUE(CircuitChecker::check(builder));
64}
65
66} // namespace acir_format::tests
acir_format::AcirFormatOriginalOpcodeIndices create_empty_original_opcode_indices()
void mock_opcode_indices(acir_format::AcirFormat &constraint_system)
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
AluTraceBuilder builder
Definition alu.test.cpp:123
field< Bn254FrParams > fr
UltraCircuitBuilder create_circuit(AcirProgram &program, const ProgramMetadata &metadata)
Specialization for creating an Ultra circuit from an acir program.
bb::SlabVector< bb::fr > WitnessVector
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
Definition ipa.test.cpp:123
std::vector< WitnessOrConstant< bb::fr > > state
static WitnessOrConstant from_index(uint32_t index)