Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
pure_poseidon2.cpp
Go to the documentation of this file.
1
#include "
barretenberg/vm2/simulation/standalone/pure_poseidon2.hpp
"
2
3
#include "
barretenberg/crypto/poseidon2/poseidon2.hpp
"
4
#include "
barretenberg/vm2/simulation/interfaces/memory.hpp
"
5
6
namespace
bb::avm2::simulation
{
7
8
using
Poseidon2Hash
=
crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>
;
9
using
Poseidon2Perm
=
crypto::Poseidon2Permutation<crypto::Poseidon2Bn254ScalarFieldParams>
;
10
11
std::array<FF, 4>
PurePoseidon2::permutation
(
const
std::array<FF, 4>& input)
12
{
13
return
Poseidon2Perm::permutation
(input);
14
}
15
16
FF
PurePoseidon2::hash
(
const
std::vector<FF>& input)
17
{
18
return
Poseidon2Hash::hash
(input);
19
}
20
21
void
PurePoseidon2::permutation
(
MemoryInterface
&
memory
,
MemoryAddress
src_address
,
MemoryAddress
dst_address
)
22
{
23
// TODO: Validate inputs (type, range)
24
const
std::array<FF, 4> input = {
25
memory
.get(
src_address
).as_ff(),
26
memory
.get(
src_address
+ 1).as_ff(),
27
memory
.get(
src_address
+ 2).as_ff(),
28
memory
.get(
src_address
+ 3).as_ff(),
29
};
30
const
std::array<FF, 4> output =
Poseidon2Perm::permutation
(input);
31
for
(uint32_t i = 0; i < 4; i++) {
32
memory
.set(
dst_address
+ i, MemoryValue::from<FF>(output[i]));
33
}
34
}
35
36
}
// namespace bb::avm2::simulation
bb::avm2::memory
Definition
memory.hpp:36
bb::avm2::simulation::MemoryInterface
Definition
memory.hpp:10
bb::avm2::simulation::PurePoseidon2::hash
FF hash(const std::vector< FF > &input) override
Definition
pure_poseidon2.cpp:16
bb::avm2::simulation::PurePoseidon2::permutation
std::array< FF, 4 > permutation(const std::array< FF, 4 > &input) override
Definition
pure_poseidon2.cpp:11
bb::crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams >
bb::crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams >::hash
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
bb::crypto::Poseidon2Permutation
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323.
Definition
poseidon2_permutation.hpp:23
bb::crypto::Poseidon2Permutation::permutation
static constexpr State permutation(const State &input)
Native form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
Definition
poseidon2_permutation.hpp:131
SStoreMutationOptions::src_address
@ src_address
CalldataCopyMutationOptions::dst_address
@ dst_address
poseidon2.hpp
bb::avm2::simulation
Definition
address_derivation_event.hpp:6
bb::avm2::MemoryAddress
uint32_t MemoryAddress
Definition
memory_types.hpp:11
bb::avm2::FF
AvmFlavorSettings::FF FF
Definition
field.hpp:10
pure_poseidon2.hpp
memory.hpp
src
barretenberg
vm2
simulation
standalone
pure_poseidon2.cpp
Generated by
1.9.8