Skip to content

Commit

Permalink
updated test to include failing case
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxia01 committed Jan 12, 2024
1 parent 8aa065f commit 6f02598
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ TEST(Poseidon2, HashBufferConsistencyCheck)
// element
barretenberg::fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"));

auto input_vec = to_buffer(a); // takes field element and converts it to 32 bytes
// takes field element and converts it to 32 bytes
auto input_vec = to_buffer(a);
barretenberg::fr result1 = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash_buffer(input_vec);
input_vec.erase(input_vec.begin()); // erase first byte since we want 31 bytes
barretenberg::fr result2 = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash_buffer(input_vec);

std::vector<barretenberg::fr> input{ a };
auto expected = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash(input);

barretenberg::fr result = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash_buffer(input_vec);

EXPECT_EQ(result, expected);
EXPECT_NE(result1, expected);
EXPECT_EQ(result2, expected);
}
} // namespace poseidon2_tests

0 comments on commit 6f02598

Please sign in to comment.