Barretenberg
The ZK-SNARK library at the core of Aztec
|
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 | |
constexpr | generator_data ()=default |
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 generator_data * | get_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::span< const AffineElement > | precomputed_generators |
We precompute and hard-code a small number of generators. For small pedersen commitments + pedersen hashes, this prevents us from having to derive generators at runtime. | |
Private Attributes | |
bool | initialized_precomputed_generators = false |
std::optional< std::map< std::string, GeneratorList > > | generator_map = {} |
Static Private Attributes | |
static constinit generator_data | default_data = generator_data() |
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:
g1::derive_generators
methodWe 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
Curve |
Definition at line 48 of file generator_data.hpp.
using bb::crypto::generator_data< Curve >::AffineElement = typename Curve::AffineElement |
Definition at line 51 of file generator_data.hpp.
using bb::crypto::generator_data< Curve >::GeneratorList = std::vector<AffineElement> |
Definition at line 52 of file generator_data.hpp.
using bb::crypto::generator_data< Curve >::GeneratorView = std::span<AffineElement const> |
Definition at line 53 of file generator_data.hpp.
using bb::crypto::generator_data< Curve >::Group = typename Curve::Group |
Definition at line 50 of file generator_data.hpp.
|
inlineconstexprdefault |
|
inline |
Definition at line 65 of file generator_data.hpp.
|
inlinestatic |
Definition at line 111 of file generator_data.hpp.
|
inlinestaticprivate |
Definition at line 115 of file generator_data.hpp.
|
inlinestaticconstexpr |
Definition at line 55 of file generator_data.hpp.
|
inlinestaticconstexpr |
Definition at line 54 of file generator_data.hpp.
|
mutableprivate |
Definition at line 130 of file generator_data.hpp.
|
mutableprivate |
Definition at line 126 of file generator_data.hpp.
|
staticconstexpr |
We precompute and hard-code a small number of generators. For small pedersen commitments + pedersen hashes, this prevents us from having to derive generators at runtime.
Definition at line 62 of file generator_data.hpp.