Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
poseidon2.test.cpp
Go to the documentation of this file.
1#include "poseidon2.hpp"
4#include <gtest/gtest.h>
5
6using namespace bb;
7
8namespace {
10}
11
12TEST(Poseidon2, HashBasicTests)
13{
14
19
20 std::vector<fr> input1{ a, b, c, d };
21 std::vector<fr> input2{ d, c, b, a };
22
26
27 EXPECT_EQ(r0, r1);
28 EXPECT_NE(r0, r2);
29}
30
31// N.B. these hardcoded values were extracted from the algorithm being tested. These are NOT independent test vectors!
32// TODO(@zac-williamson #3132): find independent test vectors we can compare against! (very hard to find given
33// flexibility of Poseidon's parametrisation)
34TEST(Poseidon2, HashConsistencyCheck)
35{
36 fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
37 fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
38 fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
39 fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
40
41 std::vector<fr> input{ a, b, c, d };
43
44 fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11"));
45
46 EXPECT_EQ(result, expected);
47}
FF a
FF b
numeric::RNG & engine
ContentAddressedIndexedTree< StoreType, Poseidon2HashPolicy > Poseidon2
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)
static field random_element(numeric::RNG *engine=nullptr) noexcept