Barretenberg
The ZK-SNARK library at the core of Aztec
|
Implements the circuit form of a cryptographic sponge over prime fields. Implements the sponge specification from the Community Cryptographic Specification Project see https://github.com/C2SP/C2SP/blob/792c1254124f625d459bfe34417e8f6bdd02eb28/poseidon-sponge.md (Note: this spec was not accepted into the C2SP repo, we might want to reference something else!) More...
#include <sponge.hpp>
Public Types | |
enum | Mode { ABSORB , SQUEEZE } |
Defines what phase of the sponge algorithm we are in. More... | |
using | field_t = stdlib::field_t< Builder > |
Public Member Functions | |
FieldSponge (Builder &builder_, field_t domain_iv=0) | |
std::array< field_t, rate > | perform_duplex () |
void | absorb (const field_t &input) |
field_t | squeeze () |
Static Public Member Functions | |
template<size_t out_len> | |
static std::array< field_t, out_len > | hash_internal (Builder &builder, std::span< const field_t > input) |
Use the sponge to hash an input string. | |
static field_t | hash_internal (Builder &builder, std::span< const field_t > input) |
Public Attributes | |
std::array< field_t, t > | state |
std::array< field_t, rate > | cache |
size_t | cache_size = 0 |
Mode | mode = Mode::ABSORB |
Builder * | builder |
Implements the circuit form of a cryptographic sponge over prime fields. Implements the sponge specification from the Community Cryptographic Specification Project see https://github.com/C2SP/C2SP/blob/792c1254124f625d459bfe34417e8f6bdd02eb28/poseidon-sponge.md (Note: this spec was not accepted into the C2SP repo, we might want to reference something else!)
Note: If we ever use this sponge class for more than 1 hash functions, we should move this out of poseidon2
and into its own directory
field_t | |
rate | |
capacity | |
t | |
Permutation |
Definition at line 34 of file sponge.hpp.
using bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::field_t = stdlib::field_t<Builder> |
Definition at line 47 of file sponge.hpp.
enum bb::stdlib::FieldSponge::Mode |
Defines what phase of the sponge algorithm we are in.
ABSORB: 'absorbing' field elements into the sponge SQUEEZE: compressing the sponge and extracting a field element
Enumerator | |
---|---|
ABSORB | |
SQUEEZE |
Definition at line 43 of file sponge.hpp.
|
inline |
Definition at line 58 of file sponge.hpp.
|
inline |
Definition at line 93 of file sponge.hpp.
|
inlinestatic |
Use the sponge to hash an input string.
out_len | |
is_variable_length. | Distinguishes between hashes where the preimage length is constant/not constant |
input |
Definition at line 151 of file sponge.hpp.
|
inlinestatic |
Definition at line 178 of file sponge.hpp.
|
inline |
Definition at line 67 of file sponge.hpp.
|
inline |
Definition at line 113 of file sponge.hpp.
Builder* bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::builder |
Definition at line 56 of file sponge.hpp.
std::array<field_t, rate> bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::cache |
Definition at line 53 of file sponge.hpp.
size_t bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::cache_size = 0 |
Definition at line 54 of file sponge.hpp.
Mode bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::mode = Mode::ABSORB |
Definition at line 55 of file sponge.hpp.
std::array<field_t, t> bb::stdlib::FieldSponge< rate, capacity, t, Permutation, Builder >::state |
Definition at line 50 of file sponge.hpp.