barretenberg
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
crypto::generator_data< Curve > Class Template Reference

class that stores precomputed generators used for Pedersen commitments and Pedersen hashes More...

#include <generator_data.hpp>

Public Types

using Group = typename Curve::Group
 
using AffineElement = typename Curve::AffineElement
 
using GeneratorList = std::vector< AffineElement >
 
using GeneratorView = std::span< AffineElement const >
 

Public Member Functions

GeneratorView get (const size_t num_generators, const size_t generator_offset=0, const std::string_view domain_separator=DEFAULT_DOMAIN_SEPARATOR) const
 

Static Public Member Functions

static constexpr std::array< AffineElement, DEFAULT_NUM_GENERATORS > make_precomputed_generators ()
 
static generator_dataget_default_generators ()
 

Static Public Attributes

static constexpr size_t DEFAULT_NUM_GENERATORS = 8
 
static constexpr std::string_view DEFAULT_DOMAIN_SEPARATOR = "DEFAULT_DOMAIN_SEPARATOR"
 
static constexpr std::array< AffineElement, DEFAULT_NUM_GENERATORS > precomputed_generators
 Precompute a small number of generators at compile time. For small pedersen commitments + pedersen hashes, this prevents us from having to derive generators at runtime.
 

Detailed Description

template<typename Curve>
class crypto::generator_data< Curve >

class that stores precomputed generators used for Pedersen commitments and Pedersen hashes

We create distinct sets of generators via the use of a domain separator. This enables the use of context-specific commitments and hashes. For example, a circuit that generates commitments foo = commit({ a, b }) and bar = commit({c, d}) where foo and bar should not collide.

The goal of generator_data is twofold:

  1. Prevent redundant computation of the same generators at runtime (i.e. store in a singleton object)
  2. Compute a small number of default generators at compile-time, so that short processes that require a small number of generators do not have to execute the expensive g1::derive_generators method

We store generators in a key:value map, where the key is the domain separator and the value is the vector of associated generators. Pedersen methods take in a pointer to a generator_data object.

generator_data contains a static instantiation of the class: default_data. The intention is for default_data to be used as a singleton class. All Pedersen methods that require a *generator_data parameter (from now on referred to as "generator context") should default to using default_data.

Q: Why make the generator context an input parameter when it defaults to default_data? A: This is not thread-safe. Each process that uses a generator_data object may extend generator_data if more generators are required. i.e. either each process must use an independent generator_data object or the author must KNOW that generator_data will not be extended by any process

Template Parameters
Curve

Member Data Documentation

◆ precomputed_generators

template<typename Curve >
constexpr std::array<AffineElement, DEFAULT_NUM_GENERATORS> crypto::generator_data< Curve >::precomputed_generators
inlinestaticconstexpr
Initial value:
=
make_precomputed_generators()

Precompute a small number of generators at compile time. For small pedersen commitments + pedersen hashes, this prevents us from having to derive generators at runtime.


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