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// Independent test vectors are validated via differential testing in stdlib/hash/poseidon2/poseidon2.test.cpp
32TEST(Poseidon2, HashConsistencyCheck)
33{
34 fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
35 fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
36 fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
37 fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));
38
39 std::vector<fr> input{ a, b, c, d };
41
42 fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11"));
43
44 EXPECT_EQ(result, expected);
45}
Native Poseidon2 hash function implementation.
Definition poseidon2.hpp:22
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
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
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
static field random_element(numeric::RNG *engine=nullptr) noexcept