Barretenberg
The ZK-SNARK library at the core of Aztec
|
Namespaces | |
namespace | aes128 |
namespace | blake_util |
namespace | element_default |
namespace | element_goblin |
namespace | field_conversion |
namespace | field_conversion_tests |
namespace | recursion |
Classes | |
class | address |
class | address_t |
class | bigfield |
class | Blake2s |
class | Blake3s |
struct | bn254 |
class | bool_t |
Implements boolean logic in-circuit. More... | |
class | byte_array |
Represents a dynamic array of bytes in-circuit. More... | |
class | cycle_group |
cycle_group represents a group Element of the proving system's embedded curve i.e. a curve with a cofactor 1 defined over a field equal to the circuit's native field Builder::FF More... | |
class | cycle_scalar |
cycle_scalar represents a member of the cycle curve SCALAR FIELD. This is NOT the native circuit field type. i.e. for a BN254 circuit, cycle_group will be Grumpkin and cycle_scalar will be Grumpkin::ScalarField (BN254 native field is BN254::ScalarField == Grumpkin::BaseField) More... | |
class | databus |
class | DataBusDepot |
Class for managing propagation of databus return data commitments used in consistency checks. More... | |
class | DynamicArray |
A dynamic array of field elements. More... | |
struct | ecdsa_signature |
class | field_t |
class | FieldSponge |
Implements the circuit form of 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... | |
class | goblin_field |
goblin_field wraps x/y coordinates of bn254 group elements when using goblin More... | |
struct | grumpkin |
Curve grumpkin in circuit setting. More... | |
class | keccak |
KECCAAAAAAAAAAK. More... | |
class | logic |
class | pedersen_commitment |
class | pedersen_hash |
stdlib class that evaluates in-circuit pedersen hashes, consistent with behavior in crypto::pedersen_hash More... | |
class | plookup_read |
class | poseidon2 |
stdlib class that evaluates in-circuit poseidon2 hashes, consistent with behavior in crypto::poseidon2 More... | |
class | Poseidon2Permutation |
class | Proof |
A simple wrapper around a vector of stdlib field elements representing a proof. More... | |
class | public_witness_t |
class | PublicInputComponent |
A wrapper class for serializing objects to and from the public inputs of a circuit. More... | |
class | ram_table |
class | rom_table |
class | safe_uint_t |
struct | schnorr_signature_bits |
struct | secp256k1 |
struct | secp256r1 |
class | SHA256 |
class | straus_lookup_table |
straus_lookup_table computes a lookup table of size 1 << table_bits More... | |
class | straus_scalar_slice |
straus_scalar_slice decomposes an input scalar into table_bits bit-slices. Used in batch_mul , which ses the Straus multiscalar multiplication algorithm. More... | |
class | twin_rom_table |
class | witness_t |
Concepts | |
concept | IsBigGroup |
concept | IsGoblinBigGroup |
concept | IsUltraArithmetic |
concept | IsSerializableToAndFromPublicInputs |
A concept defining requirements for types that are to be serialized to and from the public inputs of a circuit via the PublicInputComponent class. | |
Typedefs | |
template<typename C , typename Fq , typename Fr , typename G > | |
using | element = std::conditional_t< IsGoblinBigGroup< C, Fq, Fr, G >, element_goblin::goblin_element< C, goblin_field< C >, Fr, G >, element_default::element< C, Fq, Fr, G > > |
element wraps either element_default::element or element_goblin::goblin_element depending on parametrisation | |
Functions | |
template<typename Builder , typename Curve , typename Fq , typename Fr , typename G1 > | |
bool_t< Builder > | ecdsa_verify_signature (const stdlib::byte_array< Builder > &hashed_message, const G1 &public_key, const ecdsa_signature< Builder > &sig) |
Verify ECDSA signature. Returns bool_t(true/false) depending on whether the signature is valid or not. | |
template<typename Builder , typename Curve , typename Fq , typename Fr , typename G1 > | |
void | validate_inputs (const stdlib::byte_array< Builder > &hashed_message, const G1 &public_key, const ecdsa_signature< Builder > &sig) |
Validate the inputs used by the verification function and return messages if they produce an invalid circuit. | |
template<typename Builder > | |
void | generate_ecdsa_verification_test_circuit (Builder &builder, size_t num_iterations) |
Generate a simple ecdsa verification circuit for testing purposes. | |
template<typename C > | |
schnorr_signature_bits< C > | schnorr_convert_signature (C *context, const crypto::schnorr_signature &signature) |
Instantiate a witness containing the signature (s, e) as a quadruple of field_t elements (s_lo, s_hi, e_lo, e_hi). | |
template<typename C > | |
std::array< field_t< C >, 2 > | schnorr_verify_signature_internal (const byte_array< C > &message, const cycle_group< C > &pub_key, const schnorr_signature_bits< C > &sig) |
Make the computations needed to verify a signature (s, e), i.e., compute e' = hash(([s]g + [e]pub).x | message) and return e'. | |
template<typename C > | |
void | schnorr_verify_signature (const byte_array< C > &message, const cycle_group< C > &pub_key, const schnorr_signature_bits< C > &sig) |
Verify that a signature (s, e) is valid, i.e., compute e' = hash(([s]g + [e]pub).x | message) and check that e' == e is true. | |
template<typename C > | |
bool_t< C > | schnorr_signature_verification_result (const byte_array< C > &message, const cycle_group< C > &pub_key, const schnorr_signature_bits< C > &sig) |
Attempt to verify a signature (s, e) and return the result, i.e., compute e' = hash(([s]g + [e]pub).x | message) and return the boolean witness e' == e. | |
VERIFY_SIGNATURE_INTERNAL (bb::UltraCircuitBuilder) | |
VERIFY_SIGNATURE_INTERNAL (bb::MegaCircuitBuilder) | |
VERIFY_SIGNATURE (bb::UltraCircuitBuilder) | |
VERIFY_SIGNATURE (bb::MegaCircuitBuilder) | |
SIGNATURE_VERIFICATION_RESULT (bb::UltraCircuitBuilder) | |
SIGNATURE_VERIFICATION_RESULT (bb::MegaCircuitBuilder) | |
CONVERT_SIGNATURE (bb::UltraCircuitBuilder) | |
CONVERT_SIGNATURE (bb::MegaCircuitBuilder) | |
template<typename Builder > | |
void | generate_keccak_test_circuit (Builder &builder, size_t num_iterations) |
Generate a simple keccak circuit for testing purposes. | |
template void | generate_keccak_test_circuit (bb::UltraCircuitBuilder &, size_t) |
template void | generate_keccak_test_circuit (bb::MegaCircuitBuilder &, size_t) |
constexpr size_t | get_num_blocks (const size_t num_bits) |
template<typename B > | |
void | read (B &it, address &addr) |
template<typename B > | |
void | write (B &buf, address const &addr) |
template<typename C , typename T > | |
std::ostream & | operator<< (std::ostream &os, bigfield< T, C > const &v) |
template<typename C > | |
std::ostream & | operator<< (std::ostream &os, goblin_field< C > const &v) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, bool_t< T > const &v) |
template<typename Builder > | |
std::ostream & | operator<< (std::ostream &os, byte_array< Builder > const &arr) |
template<typename Builder , size_t SIZE> | |
field_t< Builder > | array_length (std::array< field_t< Builder >, SIZE > const &arr) |
template<typename Builder , size_t SIZE> | |
field_t< Builder > | array_pop (std::array< field_t< Builder >, SIZE > const &arr) |
template<typename Builder , size_t SIZE> | |
void | array_push (std::array< field_t< Builder >, SIZE > &arr, field_t< Builder > const &value) |
template<typename Builder , size_t SIZE> | |
size_t | array_push (std::array< std::optional< field_t< Builder > >, SIZE > &arr, field_t< Builder > const &value) |
template<typename T , size_t SIZE> | |
size_t | array_push (std::array< std::shared_ptr< T >, SIZE > &arr, std::shared_ptr< T > const &value) |
template<typename Builder , typename T , size_t SIZE> | |
void | array_push (std::array< T, SIZE > &arr, T const &value) |
template<typename Builder , size_t SIZE> | |
stdlib::bool_t< Builder > | is_array_empty (std::array< field_t< Builder >, SIZE > const &arr) |
template<typename Builder , size_t size_1, size_t size_2> | |
void | push_array_to_array (std::array< field_t< Builder >, size_1 > const &source, std::array< field_t< Builder >, size_2 > &target) |
template<typename T > | |
T * | validate_context (T *ptr) |
template<typename T , typename... Ts> | |
T * | validate_context (T *first, Ts *... rest) |
template<typename T , typename Container > | |
T * | validate_context (const Container &elements) |
template<typename Builder > | |
std::ostream & | operator<< (std::ostream &os, field_t< Builder > const &v) |
template<typename Builder > | |
std::ostream & | operator<< (std::ostream &os, cycle_group< Builder > const &v) |
template<typename Builder > | |
std::ostream & | operator<< (std::ostream &os, safe_uint_t< Builder > const &v) |
Optimizations:
using bb::stdlib::element = typedef std::conditional_t<IsGoblinBigGroup<C, Fq, Fr, G>, element_goblin::goblin_element<C, goblin_field<C>, Fr, G>, element_default::element<C, Fq, Fr, G> > |
element wraps either element_default::element or element_goblin::goblin_element depending on parametrisation
if C = MegaBuilder, G = bn254, Fq = bigfield<C, bb::Bn254FqParams>, Fr = field_t then we're cooking
Definition at line 1053 of file biggroup.hpp.
|
inline |
|
inline |
bb::stdlib::CONVERT_SIGNATURE | ( | bb::MegaCircuitBuilder | ) |
bb::stdlib::CONVERT_SIGNATURE | ( | bb::UltraCircuitBuilder | ) |
bool_t< Builder > bb::stdlib::ecdsa_verify_signature | ( | const stdlib::byte_array< Builder > & | hashed_message, |
const G1 & | public_key, | ||
const ecdsa_signature< Builder > & | sig | ||
) |
Verify ECDSA signature. Returns bool_t(true/false) depending on whether the signature is valid or not.
Fix the following notation:
Given a message \(m\), a couple \((r,s)\) is a valid signature for the message \(m\) with respect to the public key \(P\) if:
sig
is a valid signature for the public key public_key
. The function returns an in-circuit boolean value which bears witness to whether the signature verification was successfull or not. The boolean is NOT constrained to be equal to bool_t(true).Builder | |
Curve | |
Fq | |
Fr | |
G1 |
hashed_message | |
public_key | |
sig |
Definition at line 128 of file ecdsa_impl.hpp.
void bb::stdlib::generate_ecdsa_verification_test_circuit | ( | Builder & | builder, |
size_t | num_iterations | ||
) |
Generate a simple ecdsa verification circuit for testing purposes.
Builder |
builder | |
num_iterations | number of signature verifications to perform |
Definition at line 229 of file ecdsa_impl.hpp.
template void bb::stdlib::generate_keccak_test_circuit | ( | bb::MegaCircuitBuilder & | , |
size_t | |||
) |
template void bb::stdlib::generate_keccak_test_circuit | ( | bb::UltraCircuitBuilder & | , |
size_t | |||
) |
void bb::stdlib::generate_keccak_test_circuit | ( | Builder & | builder, |
size_t | num_iterations | ||
) |
Generate a simple keccak circuit for testing purposes.
Builder |
builder | |
num_iterations | number of hashes to perform |
Definition at line 794 of file keccak.cpp.
|
constexpr |
Definition at line 19 of file sha256.cpp.
stdlib::bool_t< Builder > bb::stdlib::is_array_empty | ( | std::array< field_t< Builder >, SIZE > const & | arr | ) |
|
inline |
Definition at line 1126 of file bigfield.hpp.
|
inline |
|
inline |
Definition at line 122 of file byte_array.hpp.
|
inline |
Definition at line 237 of file cycle_group.hpp.
|
inline |
Definition at line 204 of file goblin_field.hpp.
|
inline |
Definition at line 216 of file safe_uint.hpp.
void bb::stdlib::read | ( | B & | it, |
address & | addr | ||
) |
Definition at line 54 of file address.hpp.
schnorr_signature_bits< C > bb::stdlib::schnorr_convert_signature | ( | C * | context, |
const crypto::schnorr_signature & | signature | ||
) |
Instantiate a witness containing the signature (s, e) as a quadruple of field_t elements (s_lo, s_hi, e_lo, e_hi).
Definition at line 22 of file schnorr.cpp.
bool_t< C > bb::stdlib::schnorr_signature_verification_result | ( | const byte_array< C > & | message, |
const cycle_group< C > & | pub_key, | ||
const schnorr_signature_bits< C > & | sig | ||
) |
Attempt to verify a signature (s, e) and return the result, i.e., compute e' = hash(([s]g + [e]pub).x | message) and return the boolean witness e' == e.
Definition at line 90 of file schnorr.cpp.
void bb::stdlib::schnorr_verify_signature | ( | const byte_array< C > & | message, |
const cycle_group< C > & | pub_key, | ||
const schnorr_signature_bits< C > & | sig | ||
) |
Verify that a signature (s, e) is valid, i.e., compute e' = hash(([s]g + [e]pub).x | message) and check that e' == e is true.
Definition at line 75 of file schnorr.cpp.
std::array< field_t< C >, 2 > bb::stdlib::schnorr_verify_signature_internal | ( | const byte_array< C > & | message, |
const cycle_group< C > & | pub_key, | ||
const schnorr_signature_bits< C > & | sig | ||
) |
Make the computations needed to verify a signature (s, e), i.e., compute e' = hash(([s]g + [e]pub).x | message) and return e'.
Ultra: ~5018 gates, excluding gates required to init the Ultra range check (~1,169k for fixed/variable_base_mul, ~4k for blake2s) for a string of length = 34.
Definition at line 46 of file schnorr.cpp.
bb::stdlib::SIGNATURE_VERIFICATION_RESULT | ( | bb::MegaCircuitBuilder | ) |
bb::stdlib::SIGNATURE_VERIFICATION_RESULT | ( | bb::UltraCircuitBuilder | ) |
T * bb::stdlib::validate_context | ( | const Container & | elements | ) |
T * bb::stdlib::validate_context | ( | T * | first, |
Ts *... | rest | ||
) |
T * bb::stdlib::validate_context | ( | T * | ptr | ) |
void bb::stdlib::validate_inputs | ( | const stdlib::byte_array< Builder > & | hashed_message, |
const G1 & | public_key, | ||
const ecdsa_signature< Builder > & | sig | ||
) |
Validate the inputs used by the verification function and return messages if they produce an invalid circuit.
Builder | |
Curve | |
Fq | |
Fr | |
G1 |
hashed_message | |
public_key | |
sig | |
scalar_mul_result |
Definition at line 34 of file ecdsa_impl.hpp.
bb::stdlib::VERIFY_SIGNATURE | ( | bb::MegaCircuitBuilder | ) |
bb::stdlib::VERIFY_SIGNATURE | ( | bb::UltraCircuitBuilder | ) |
bb::stdlib::VERIFY_SIGNATURE_INTERNAL | ( | bb::MegaCircuitBuilder | ) |
bb::stdlib::VERIFY_SIGNATURE_INTERNAL | ( | bb::UltraCircuitBuilder | ) |
void bb::stdlib::write | ( | B & | buf, |
address const & | addr | ||
) |
Definition at line 62 of file address.hpp.