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>

Static Public Member Functions

static FF hash_internal (std::span< const FF > input)
 Use the sponge to hash an input vector.
 
static FF hash_internal (std::span< const FF > input, FF iv)
 Use the sponge to hash an input vector with a custom IV.
 

Private Member Functions

 FieldSponge (FF domain_iv)
 
void perform_duplex ()
 
void absorb (const FF &input)
 
FF squeeze ()
 

Private Attributes

std::array< FF, t > state {}
 
std::array< FF, rate > cache {}
 
size_t cache_size = 0
 

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.

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)
inlineprivate

Definition at line 41 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)
inlineprivate

Definition at line 57 of file sponge.hpp.

◆ hash_internal() [1/2]

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

Use the sponge to hash an input vector.

Parameters
inputField elements (a_0, ..., a_{N-1})
Returns
Hash of the input, a single field element.

Definition at line 84 of file sponge.hpp.

◆ hash_internal() [2/2]

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

Use the sponge to hash an input vector with a custom IV.

Parameters
inputField elements (a_0, ..., a_{N-1})
ivInitial value for domain separation
Returns
Hash of the input, a single field element.

Definition at line 98 of file sponge.hpp.

◆ perform_duplex()

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
void bb::crypto::FieldSponge< FF, rate, capacity, t, Permutation >::perform_duplex ( )
inlineprivate

Definition at line 43 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 ( )
inlineprivate

Definition at line 71 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 {}
private

Definition at line 38 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
private

Definition at line 39 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 {}
private

Definition at line 35 of file sponge.hpp.


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