Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation > Class Template Reference

Implements 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...
 

Public Member Functions

 FieldSponge (FF domain_iv=0)
 
std::array< FF, rate > perform_duplex ()
 
void absorb (const FF &input)
 
FF squeeze ()
 

Static Public Member Functions

template<size_t out_len>
static std::array< FF, out_len > hash_internal (std::span< const FF > input)
 Use the sponge to hash an input string.
 
template<size_t out_len>
static std::array< FF, out_len > hash_internal (std::span< const FF > input, FF iv)
 
static FF hash_internal (std::span< const FF > input)
 
static FF hash_internal (std::span< const FF > input, FF iv)
 

Public Attributes

std::array< FF, t > state
 
std::array< FF, rate > cache
 
size_t cache_size = 0
 
Mode mode = Mode::ABSORB
 

Detailed Description

template<typename FF, size_t rate, size_t capacity, size_t t, typename Permutation>
class bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >

Implements 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

Template Parameters
FF
rate
capacity
t
Permutation

Definition at line 32 of file sponge.hpp.

Member Enumeration Documentation

◆ Mode

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
enum bb::crypto::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 41 of file sponge.hpp.

Constructor & Destructor Documentation

◆ FieldSponge()

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::FieldSponge ( FF  domain_iv = 0)
inline

Definition at line 54 of file sponge.hpp.

Member Function Documentation

◆ absorb()

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
void bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::absorb ( const FF input)
inline

Definition at line 81 of file sponge.hpp.

◆ hash_internal() [1/4]

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
template<size_t out_len>
static std::array< FF, out_len > bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::hash_internal ( std::span< const FF input)
inlinestatic

Use the sponge to hash an input string.

Template Parameters
out_len
Parameters
input
Returns
std::array<FF, out_len>

Definition at line 137 of file sponge.hpp.

◆ hash_internal() [2/4]

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
static FF bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::hash_internal ( std::span< const FF input)
inlinestatic

Definition at line 160 of file sponge.hpp.

◆ hash_internal() [3/4]

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
template<size_t out_len>
static std::array< FF, out_len > bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::hash_internal ( std::span< const FF input,
FF  iv 
)
inlinestatic

Definition at line 144 of file sponge.hpp.

◆ hash_internal() [4/4]

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
static FF bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::hash_internal ( std::span< const FF input,
FF  iv 
)
inlinestatic

Definition at line 161 of file sponge.hpp.

◆ perform_duplex()

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
std::array< FF, rate > bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::perform_duplex ( )
inline

Definition at line 62 of file sponge.hpp.

◆ squeeze()

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
FF bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::squeeze ( )
inline

Definition at line 101 of file sponge.hpp.

Member Data Documentation

◆ cache

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
std::array<FF, rate> bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::cache

Definition at line 50 of file sponge.hpp.

◆ cache_size

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
size_t bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::cache_size = 0

Definition at line 51 of file sponge.hpp.

◆ mode

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
Mode bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::mode = Mode::ABSORB

Definition at line 52 of file sponge.hpp.

◆ state

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
std::array<FF, t> bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::state

Definition at line 47 of file sponge.hpp.


The documentation for this class was generated from the following file: