Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
poseidon2_permutation.test.cpp
Go to the documentation of this file.
4#include <gtest/gtest.h>
5
6using namespace bb;
7
8namespace {
10}
11
12TEST(Poseidon2Permutation, TestVectors)
13{
14
18
19 EXPECT_EQ(result, expected);
20}
21
22TEST(Poseidon2Permutation, BasicTests)
23{
24
29
30 std::array<fr, 4> input1{ a, b, c, d };
31 std::array<fr, 4> input2{ d, c, b, a };
32
36
37 EXPECT_EQ(r0, r1);
38 EXPECT_NE(r0, r2);
39}
40
41// N.B. these hardcoded values were extracted from the algorithm being tested. These are NOT independent test vectors!
42// TODO(@zac-williamson #3132): find independent test vectors we can compare against! (very hard to find given
43// flexibility of Poseidon's parametrisation)
44TEST(Poseidon2Permutation, ConsistencyCheck)
45{
46 fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
47 fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
48 fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
49 fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
50
51 std::array<fr, 4> input{ a, b, c, d };
53
54 std::array<fr, 4> expected{
55 fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")),
56 fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")),
57 fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")),
58 fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")),
59 };
60 EXPECT_EQ(result, expected);
61}
static constexpr State permutation(const State &input)
Native form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
FF a
FF b
numeric::RNG & engine
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:190
Entry point for Barretenberg command-line interface.
TEST(MegaCircuitBuilder, CopyConstructor)
field< Bn254FrParams > fr
Definition fr.hpp:174
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static constexpr std::array< FF, t > TEST_VECTOR_OUTPUT
static constexpr std::array< FF, t > TEST_VECTOR_INPUT
static field random_element(numeric::RNG *engine=nullptr) noexcept