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// Independent test vectors are validated via differential testing in stdlib/hash/poseidon2/poseidon2.test.cpp
42TEST(Poseidon2Permutation, ConsistencyCheck)
43{
44 fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
45 fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
46 fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
47 fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
48
49 std::array<fr, 4> input{ a, b, c, d };
51
52 std::array<fr, 4> expected{
53 fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")),
54 fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")),
55 fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")),
56 fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")),
57 };
58 EXPECT_EQ(result, expected);
59}
static constexpr State permutation(const State &input)
Native form of Poseidon2 permutation (returns new state).
FF a
FF b
numeric::RNG & engine
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:217
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
field< Bn254FrParams > fr
Definition fr.hpp:155
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
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