barretenberg
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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, bool is_variable_length>
static std::array< FF, out_len > hash_internal (std::span< FF > input)
 Use the sponge to hash an input string.
 
template<size_t out_len>
static std::array< FF, out_len > hash_fixed_length (std::span< FF > input)
 
static FF hash_fixed_length (std::span< FF > input)
 
template<size_t out_len>
static std::array< FF, out_len > hash_variable_length (std::span< FF > input)
 
static FF hash_variable_length (std::span< FF > input)
 

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

Member Enumeration Documentation

◆ Mode

template<typename FF , size_t rate, size_t capacity, size_t t, typename Permutation >
enum 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

Member Function Documentation

◆ hash_internal()

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

Use the sponge to hash an input string.

Template Parameters
out_len
is_variable_length.Distinguishes between hashes where the preimage length is constant/not constant
Parameters
input
Returns
std::array<FF, out_len>

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