|
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_tests |
| namespace | recursion |
| namespace | test_utils |
Classes | |
| class | bigfield |
| class | bigfield_test_access |
| 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 |
| Represents a member of the Grumpkin curve scalar field (i.e. BN254 base field). 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. 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 |
| In-circuit Pedersen commitment implementation. More... | |
| 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 |
| Circuit form of Poseidon2 permutation from https://eprint.iacr.org/2023/323. More... | |
| 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 | StdlibCodec |
| class | straus_lookup_table |
| straus_lookup_table computes a lookup table of size 1 << table_bits More... | |
| class | straus_scalar_slices |
straus_scalar_slices decomposes an input scalar into bit-slices of size table_bits. Used in batch_mul, which implements the Straus multiscalar multiplication algorithm. More... | |
| class | twin_rom_table |
| class | witness_t |
| struct | WycherproofTest |
Concepts | |
| concept | IsBigGroup |
| concept | IsGoblinBigGroup |
| 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 | |
| using | WycherproofSecp256k1 = WycherproofTest< bb::curve::SECP256K1 > |
| using | WycherproofSecp256r1 = WycherproofTest< bb::curve::SECP256R1 > |
| 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 > | |
| 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 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 > | |
| void | validate_split_in_field (const field_t< Builder > &lo, const field_t< Builder > &hi, const size_t lo_bits, const uint256_t &field_modulus) |
| Validates that lo + hi * 2^lo_bits < field_modulus. | |
| template<typename Builder > | |
| std::pair< field_t< Builder >, field_t< Builder > > | split_unique (const field_t< Builder > &field, const size_t lo_bits, const bool skip_range_constraints=false) |
| Split a bn254 scalar field element into unique lo and hi limbs. | |
| template std::pair< field_t< bb::UltraCircuitBuilder >, field_t< bb::UltraCircuitBuilder > > | split_unique (const field_t< bb::UltraCircuitBuilder > &field, const size_t lo_bits, const bool skip_range_constraints) |
| template std::pair< field_t< bb::MegaCircuitBuilder >, field_t< bb::MegaCircuitBuilder > > | split_unique (const field_t< bb::MegaCircuitBuilder > &field, const size_t lo_bits, const bool skip_range_constraints) |
| template void | validate_split_in_field (const field_t< bb::UltraCircuitBuilder > &lo, const field_t< bb::UltraCircuitBuilder > &hi, const size_t lo_bits, const uint256_t &field_modulus) |
| template void | validate_split_in_field (const field_t< bb::MegaCircuitBuilder > &lo, const field_t< bb::MegaCircuitBuilder > &hi, const size_t lo_bits, const uint256_t &field_modulus) |
| 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) |
Variables | |
| const std::vector< WycherproofSecp256k1 > | secp256k1_tests |
| Test for Secp256k1 ECDSA signatures taken from the Wycherproof project. | |
| const std::vector< WycherproofSecp256r1 > | secp256r1_tests |
| Test for Secp256r1 ECDSA signatures taken from the Wycherproof project. | |
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 1028 of file biggroup.hpp.
| using bb::stdlib::WycherproofSecp256k1 = typedef WycherproofTest<bb::curve::SECP256K1> |
Definition at line 35 of file ecdsa_tests_data.hpp.
| using bb::stdlib::WycherproofSecp256r1 = typedef WycherproofTest<bb::curve::SECP256R1> |
Definition at line 36 of file ecdsa_tests_data.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 74 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 169 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 1172 of file bigfield.hpp.
|
inline |
|
inline |
Definition at line 122 of file byte_array.hpp.
|
inline |
Definition at line 239 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.
| 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 | ) |
| template std::pair< field_t< bb::MegaCircuitBuilder >, field_t< bb::MegaCircuitBuilder > > bb::stdlib::split_unique | ( | const field_t< bb::MegaCircuitBuilder > & | field, |
| const size_t | lo_bits, | ||
| const bool | skip_range_constraints | ||
| ) |
| template std::pair< field_t< bb::UltraCircuitBuilder >, field_t< bb::UltraCircuitBuilder > > bb::stdlib::split_unique | ( | const field_t< bb::UltraCircuitBuilder > & | field, |
| const size_t | lo_bits, | ||
| const bool | skip_range_constraints | ||
| ) |
| std::pair< field_t< Builder >, field_t< Builder > > bb::stdlib::split_unique | ( | const field_t< Builder > & | field, |
| const size_t | lo_bits, | ||
| const bool | skip_range_constraints = false |
||
| ) |
Split a bn254 scalar field element into unique lo and hi limbs.
Splits field into a low and high limb at the given bit index with:
| field | The bn254 scalar field element to split |
| lo_bits | Number of bits for the low limb |
| skip_range_constraints | If true, skip range constraints (use when they're implicit, e.g., in lookups) |
Definition at line 47 of file field_utils.cpp.
| T * bb::stdlib::validate_context | ( | const Container & | elements | ) |
| T * bb::stdlib::validate_context | ( | T * | first, |
| Ts *... | rest | ||
| ) |
| T * bb::stdlib::validate_context | ( | T * | ptr | ) |
| template void bb::stdlib::validate_split_in_field | ( | const field_t< bb::MegaCircuitBuilder > & | lo, |
| const field_t< bb::MegaCircuitBuilder > & | hi, | ||
| const size_t | lo_bits, | ||
| const uint256_t & | field_modulus | ||
| ) |
| template void bb::stdlib::validate_split_in_field | ( | const field_t< bb::UltraCircuitBuilder > & | lo, |
| const field_t< bb::UltraCircuitBuilder > & | hi, | ||
| const size_t | lo_bits, | ||
| const uint256_t & | field_modulus | ||
| ) |
| void bb::stdlib::validate_split_in_field | ( | const field_t< Builder > & | lo, |
| const field_t< Builder > & | hi, | ||
| const size_t | lo_bits, | ||
| const uint256_t & | field_modulus | ||
| ) |
Validates that lo + hi * 2^lo_bits < field_modulus.
Can be used in conjunction with range constraints on lo and hi to establish a unique decomposition of a field element.
| lo | The low limb |
| hi | The high limb |
| lo_bits | The bit position at which the split occurred |
| field_modulus | The field modulus to validate against |
Definition at line 14 of file field_utils.cpp.
| 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 | ) |
| const std::vector<WycherproofSecp256k1> bb::stdlib::secp256k1_tests |
Test for Secp256k1 ECDSA signatures taken from the Wycherproof project.
Definition at line 42 of file ecdsa_tests_data.hpp.
| const std::vector<WycherproofSecp256r1> bb::stdlib::secp256r1_tests |
Test for Secp256r1 ECDSA signatures taken from the Wycherproof project.
Definition at line 97 of file ecdsa_tests_data.hpp.