barretenberg
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
proof_system::plonk::stdlib::recursion::PedersenPreimageBuilder< Builder, bits_per_element > Struct Template Reference

Constructs a packed buffer of field elements to be fed into a Pedersen hash function Goal is to concatenate multiple inputs together into a single field element if the inputs are known to be small. Produces a vector of field elements where the maximum number of bits per element is bits_per_element. More...

#include <verification_key.hpp>

Public Types

using field_pt = field_t< Builder >
 
using witness_pt = witness_t< Builder >
 

Public Member Functions

 PedersenPreimageBuilder (Builder *ctx=nullptr)
 
field_pt hash ()
 
void add_element (const field_pt &element)
 
void add_element_with_existing_range_constraint (const field_pt &element, const size_t num_bits)
 
void slice_element (const field_pt &element, const size_t num_bits)
 Populate preimage_data with element whose size is known to be num_bits. preimage_data is treated as a bit-array where bits_per_element number of bits are packed into a single field element. slice_element will:
 

Public Attributes

Buildercontext
 
std::vector< field_ptpreimage_data
 preimage_data is a bit-array where bits_per_element number of bits are packed into a single field element
 
std::vector< field_ptwork_element
 work_element represents the leading element to be added into preimage_data. Vector is composed of field elements that represent bit chunks of a known length, such that the sum of the bit chunks < bits_per_element
 
size_t current_bit_counter = 0
 

Detailed Description

template<class Builder, size_t bits_per_element = 248>
struct proof_system::plonk::stdlib::recursion::PedersenPreimageBuilder< Builder, bits_per_element >

Constructs a packed buffer of field elements to be fed into a Pedersen hash function Goal is to concatenate multiple inputs together into a single field element if the inputs are known to be small. Produces a vector of field elements where the maximum number of bits per element is bits_per_element.

When calling pedersen::hash on the final buffer, we can skip the range checks normally performed in the hash method, because we know the sums of the scalar slices cannot exceed the field modulus. This requires bits_per_element < modulus bits

Template Parameters
Builder
bits_per_element

Member Function Documentation

◆ slice_element()

template<class Builder , size_t bits_per_element = 248>
void proof_system::plonk::stdlib::recursion::PedersenPreimageBuilder< Builder, bits_per_element >::slice_element ( const field_pt element,
const size_t  num_bits 
)
inline

Populate preimage_data with element whose size is known to be num_bits. preimage_data is treated as a bit-array where bits_per_element number of bits are packed into a single field element. slice_element will:

  1. determine how many bits are remaining in work_element
  2. if remaining bits > num_bits, slice element into 2 chunks hi/lo
  3. fill work_element with hi chunk (or the full element if possible)
  4. (if work_element is full) combine work_element chunks into a field element and push onto preimage_data
  1. (if required) create a new work_element and populate with lo
Parameters
element
num_bits

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