Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::stdlib::Blake3s< Builder > Class Template Reference

#include <blake3s.hpp>

Classes

struct  blake3_hasher
 
struct  output_t
 

Static Public Member Functions

static byte_array_ct hash (const byte_array_ct &input)
 

Private Types

enum  blake3_flags {
  CHUNK_START = 1 << 0 , CHUNK_END = 1 << 1 , PARENT = 1 << 2 , ROOT = 1 << 3 ,
  KEYED_HASH = 1 << 4 , DERIVE_KEY_CONTEXT = 1 << 5 , DERIVE_KEY_MATERIAL = 1 << 6
}
 
enum  blake3s_constant { BLAKE3_KEY_LEN = 32 , BLAKE3_OUT_LEN = 32 , BLAKE3_BLOCK_LEN = 64 , BLAKE3_CHUNK_LEN = 1024 }
 
using byte_array_ct = byte_array< Builder >
 
using field_ct = field_t< Builder >
 

Static Private Member Functions

static void compress_pre (field_t< Builder > state[BLAKE3_STATE_SIZE], const field_t< Builder > cv[8], const byte_array_ct &block, uint8_t block_len, uint8_t flags)
 
static void compress_in_place (field_t< Builder > cv[8], const byte_array_ct &block, uint8_t block_len, uint8_t flags)
 
static void compress_xof (const field_t< Builder > cv[8], const byte_array_ct &block, uint8_t block_len, uint8_t flags, byte_array_ct &out)
 
static uint8_t maybe_start_flag (const blake3_hasher *self)
 
static output_t make_output (const field_t< Builder > input_cv[8], const byte_array_ct &block, uint8_t block_len, uint8_t flags)
 
static void hasher_init (blake3_hasher *self)
 
static void hasher_update (blake3_hasher *self, const byte_array_ct &input, size_t input_len)
 
static void hasher_finalize (const blake3_hasher *self, byte_array_ct &out)
 

Static Private Attributes

static constexpr size_t BLAKE3_STATE_SIZE = stdlib::blake_util::BLAKE_STATE_SIZE
 
static constexpr std::array< uint32_t, 8 > IV
 

Detailed Description

template<typename Builder>
class bb::stdlib::Blake3s< Builder >

Definition at line 14 of file blake3s.hpp.

Member Typedef Documentation

◆ byte_array_ct

template<typename Builder >
using bb::stdlib::Blake3s< Builder >::byte_array_ct = byte_array<Builder>
private

Definition at line 15 of file blake3s.hpp.

◆ field_ct

template<typename Builder >
using bb::stdlib::Blake3s< Builder >::field_ct = field_t<Builder>
private

Definition at line 16 of file blake3s.hpp.

Member Enumeration Documentation

◆ blake3_flags

template<typename Builder >
enum bb::stdlib::Blake3s::blake3_flags
private
Enumerator
CHUNK_START 
CHUNK_END 
PARENT 
ROOT 
KEYED_HASH 
DERIVE_KEY_CONTEXT 
DERIVE_KEY_MATERIAL 

Definition at line 24 of file blake3s.hpp.

◆ blake3s_constant

template<typename Builder >
enum bb::stdlib::Blake3s::blake3s_constant
private
Enumerator
BLAKE3_KEY_LEN 
BLAKE3_OUT_LEN 
BLAKE3_BLOCK_LEN 
BLAKE3_CHUNK_LEN 

Definition at line 35 of file blake3s.hpp.

Member Function Documentation

◆ compress_in_place()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::compress_in_place ( field_t< Builder cv[8],
const byte_array_ct block,
uint8_t  block_len,
uint8_t  flags 
)
staticprivate

At this point in the algorithm, a malicious prover could tweak the add_normalise function in blake_util.hpp to create unexpected overflow in the state matrix. At the end of the compress_pre() function, there might be overflows in the elements of the first and third rows of the state matrix. But this wouldn't be a problem because in the below loop, while reading from the lookup table, we ensure that the overflow is ignored and the result is contrained to 32 bits.

Definition at line 55 of file blake3s.cpp.

◆ compress_pre()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::compress_pre ( field_t< Builder state[BLAKE3_STATE_SIZE],
const field_t< Builder cv[8],
const byte_array_ct block,
uint8_t  block_len,
uint8_t  flags 
)
staticprivate

Definition at line 21 of file blake3s.cpp.

◆ compress_xof()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::compress_xof ( const field_t< Builder cv[8],
const byte_array_ct block,
uint8_t  block_len,
uint8_t  flags,
byte_array_ct out 
)
staticprivate

The same note as in the above blake3_compress_in_place() function. Here too, reading from the lookup table ensures that correct 32-bit inputs are used.

Definition at line 77 of file blake3s.cpp.

◆ hash()

template<typename Builder >
byte_array< Builder > bb::stdlib::Blake3s< Builder >::hash ( const byte_array_ct input)
static

Definition at line 183 of file blake3s.cpp.

◆ hasher_finalize()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::hasher_finalize ( const blake3_hasher self,
byte_array_ct out 
)
staticprivate

Definition at line 171 of file blake3s.cpp.

◆ hasher_init()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::hasher_init ( blake3_hasher self)
staticprivate

Definition at line 126 of file blake3s.cpp.

◆ hasher_update()

template<typename Builder >
void bb::stdlib::Blake3s< Builder >::hasher_update ( blake3_hasher self,
const byte_array_ct input,
size_t  input_len 
)
staticprivate

Definition at line 142 of file blake3s.cpp.

◆ make_output()

template<typename Builder >
Blake3s< Builder >::output_t bb::stdlib::Blake3s< Builder >::make_output ( const field_t< Builder input_cv[8],
const byte_array_ct block,
uint8_t  block_len,
uint8_t  flags 
)
staticprivate

Definition at line 103 of file blake3s.cpp.

◆ maybe_start_flag()

template<typename Builder >
static uint8_t bb::stdlib::Blake3s< Builder >::maybe_start_flag ( const blake3_hasher self)
inlinestaticprivate

Definition at line 71 of file blake3s.hpp.

Member Data Documentation

◆ BLAKE3_STATE_SIZE

template<typename Builder >
constexpr size_t bb::stdlib::Blake3s< Builder >::BLAKE3_STATE_SIZE = stdlib::blake_util::BLAKE_STATE_SIZE
staticconstexprprivate

Definition at line 33 of file blake3s.hpp.

◆ IV

template<typename Builder >
constexpr std::array<uint32_t, 8> bb::stdlib::Blake3s< Builder >::IV
staticconstexprprivate
Initial value:
{ 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }

Definition at line 37 of file blake3s.hpp.


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