|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
AVM range check gadget for witness generation. More...
Namespaces | |
| namespace | testonly |
Functions | |
| std::string | to_string (AddressingEventError e) |
| CalldataProvider | make_calldata_provider (const ContextInterface &context) |
| ReturnDataProvider | make_return_data_provider (const ContextInterface &context, uint32_t rd_mem_offset_in_child, uint32_t rd_size) |
| InternalCallStackProvider | make_internal_call_stack_provider (const InternalCallStackManagerInterface &internal_call_stack_manager) |
| std::vector< FF > | encode_bytecode (std::span< const uint8_t > bytecode) |
Encodes the bytecode into a vector of field elements. Each field element represents 31 bytes of the bytecode. The field encoding is performed in big-endian order, i.e., the ith field element is 2^240 * bytecode[31*i] + 2^232 * bytecode[31*i + 1] + ... + 2^8 * bytecode[31*i + 30] + bytecode[31*i + 31]. | |
| FF | compute_public_bytecode_first_field (size_t bytecode_size) |
| FF | compute_public_bytecode_commitment (std::span< const uint8_t > bytecode) |
| FF | compute_contract_class_id (const FF &artifact_hash, const FF &private_fn_root, const FF &public_bytecode_commitment) |
| FF | hash_public_keys (const PublicKeys &public_keys) |
| FF | compute_contract_address (const ContractInstance &contract_instance) |
| FF | compute_calldata_hash (std::span< const FF > calldata) |
| FF | unconstrained_root_from_path (uint64_t domain_separator, const FF &leaf_value, const uint64_t leaf_index, std::span< const FF > path) |
| FF | unconstrained_compute_leaf_slot (const AztecAddress &contract_address, const FF &slot) |
| FF | unconstrained_silo_nullifier (const AztecAddress &contract_address, const FF &nullifier) |
| FF | unconstrained_silo_note_hash (const AztecAddress &contract_address, const FF ¬e_hash) |
| FF | unconstrained_make_unique_note_hash (const FF &siloed_note_hash, const FF &first_nullifier, uint64_t note_hash_counter) |
| std::ostream & | operator<< (std::ostream &os, const ClassIdLeafValue &v) |
| RetrievedBytecodesTree | build_retrieved_bytecodes_tree () |
| Instruction | deserialize_instruction (std::span< const uint8_t > bytecode, size_t pos) |
Attempts to deserialize the instruction at position pos in bytecode. Called by bytecode managers during instruction fetching to extract and check for parse errors. | |
| bool | check_tag (const Instruction &instruction) |
Checks whether the tag operand of an instruction is a valid MemoryTag. Called by bytecode managers during instruction fetching to check tag operands. | |
| std::array< uint32_t, 8 > | sha256_block (const std::array< uint32_t, 8 > &h_init, const std::array< uint32_t, 16 > &input) |
| constexpr uint32_t | ror (uint32_t val, uint32_t shift) |
| U256Decomposition | decompose_256 (const uint256_t &x) |
| U128Decomposition | decompose_128 (const uint128_t &x) |
| BENCHMARK (BM_WrittenSlotsTreeStack) -> Arg(1000) ->Arg(3000) ->Arg(6000) ->Arg(9000) ->Unit(benchmark::kMicrosecond) | |
| std::ostream & | operator<< (std::ostream &os, const WrittenPublicDataSlotLeafValue &v) |
| WrittenPublicDataSlotsTree | build_public_data_slots_tree () |
Variables | |
| constexpr std::array< std::array< uint8_t, 5 >, 5 > | keccak_rotation_len |
| constexpr std::array< std::array< uint8_t, 5 >, 5 > | keccak_pi_rho_x_coords |
| constexpr std::array< uint64_t, 24 > | keccak_round_constants |
| const std::optional< IndexedTreeSiloingParameters > | NO_SILOING = std::nullopt |
| const std::optional< uint64_t > | NO_PUBLIC_INPUTS_INDEX = std::nullopt |
| const std::vector< OperandType > | three_operand_format8 |
| const std::vector< OperandType > | three_operand_format16 |
| const std::vector< OperandType > | kernel_input_operand_format = { OperandType::INDIRECT8, OperandType::UINT16 } |
| const std::vector< OperandType > | external_call_format |
| constexpr uint32_t | round_constants [64] |
AVM range check gadget for witness generation.
Implements range constraint validation for the AVM simulation layer. Asserts that a given value fits within a specified number of bits and emits a RangeCheckEvent for downstream trace generation and proving.
| using bb::avm2::simulation::AppendLeavesHintKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, std::vector<FF> > |
Definition at line 22 of file db_types.hpp.
| using bb::avm2::simulation::CalldataProvider = typedef std::function<std::vector<FF>(uint32_t max_size)> |
Definition at line 11 of file call_stack_metadata_collector.hpp.
| using bb::avm2::simulation::CancellationTokenPtr = typedef std::shared_ptr<CancellationToken> |
Definition at line 79 of file cancellation_token.hpp.
| using bb::avm2::simulation::EmitPublicLogEvent = typedef std::variant<EmitPublicLogWriteEvent, CheckPointEventType> |
Definition at line 38 of file emit_public_log_event.hpp.
| using bb::avm2::simulation::GetBytecodeCommitmentKey = typedef std::tuple<uint32_t, ContractClassId> |
Definition at line 25 of file db_types.hpp.
| using bb::avm2::simulation::GetContractClassKey = typedef std::tuple<uint32_t, ContractClassId> |
Definition at line 24 of file db_types.hpp.
| using bb::avm2::simulation::GetContractInstanceKey = typedef std::tuple<uint32_t, AztecAddress> |
Definition at line 23 of file db_types.hpp.
| using bb::avm2::simulation::GetDebugFunctionNameKey = typedef std::tuple<AztecAddress, FunctionSelector> |
Definition at line 26 of file db_types.hpp.
| using bb::avm2::simulation::GetLeafPreimageKey = typedef std::tuple<AppendOnlyTreeSnapshot, index_t> |
Definition at line 18 of file db_types.hpp.
| using bb::avm2::simulation::GetLeafValueKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, index_t> |
Definition at line 19 of file db_types.hpp.
| using bb::avm2::simulation::GetPreviousValueIndexKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, FF> |
Definition at line 17 of file db_types.hpp.
| using bb::avm2::simulation::GetSiblingPathKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, index_t> |
Definition at line 16 of file db_types.hpp.
| using bb::avm2::simulation::index_t = typedef ::bb::crypto::merkle_tree::index_t |
| using bb::avm2::simulation::IndexedLeaf = typedef ::bb::crypto::merkle_tree::IndexedLeaf<LeafValueType> |
| using bb::avm2::simulation::IndexedTreeCheckEvent = typedef std::variant<IndexedTreeReadWriteEvent, CheckPointEventType> |
Definition at line 67 of file indexed_tree_check_event.hpp.
| using bb::avm2::simulation::InternalCallStackProvider = typedef std::function<std::vector<PC>()> |
Definition at line 13 of file call_stack_metadata_collector.hpp.
| using bb::avm2::simulation::KeccakF1600State = typedef std::array<std::array<uint64_t, 5>, 5> |
5x5 matrix of 64-bit words representing the Keccak state A[x][y].
Definition at line 27 of file keccakf1600_event.hpp.
| using bb::avm2::simulation::KeccakF1600StateMemValues = typedef std::array<std::array<MemoryValue, 5>, 5> |
5x5 matrix of MemoryValue representing the Keccak state (used during simulation).
Definition at line 29 of file keccakf1600_event.hpp.
| using bb::avm2::simulation::LogFn = typedef std::function<void(const std::string&)> |
Definition at line 22 of file debug_log.hpp.
| using bb::avm2::simulation::MerkleTreeId = typedef ::bb::world_state::MerkleTreeId |
| using bb::avm2::simulation::NoteHashTreeCheckEvent = typedef std::variant<NoteHashTreeReadWriteEvent, CheckPointEventType> |
Definition at line 48 of file note_hash_tree_check_event.hpp.
| using bb::avm2::simulation::NullifierTreeLeafPreimage = typedef crypto::merkle_tree::IndexedLeaf<crypto::merkle_tree::NullifierLeafValue> |
Definition at line 12 of file db_types.hpp.
| using bb::avm2::simulation::Operand = typedef TaggedValue |
Definition at line 28 of file serialization.hpp.
| using bb::avm2::simulation::poseidon2 = typedef crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams> |
Definition at line 9 of file contract_crypto.cpp.
| using bb::avm2::simulation::Poseidon2 = typedef crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams> |
Definition at line 10 of file merkle.cpp.
| using bb::avm2::simulation::Poseidon2Hash = typedef crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams> |
Definition at line 8 of file pure_poseidon2.cpp.
| using bb::avm2::simulation::Poseidon2Perm = typedef crypto::Poseidon2Permutation<crypto::Poseidon2Bn254ScalarFieldParams> |
Definition at line 9 of file pure_poseidon2.cpp.
| using bb::avm2::simulation::PublicDataTreeCheckEvent = typedef std::variant<PublicDataTreeReadWriteEvent, CheckPointEventType> |
Definition at line 42 of file public_data_tree_check_event.hpp.
| typedef crypto::merkle_tree::IndexedLeaf< crypto::merkle_tree::PublicDataLeafValue > bb::avm2::simulation::PublicDataTreeLeafPreimage |
Definition at line 34 of file update_check.test.cpp.
| typedef crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams > bb::avm2::simulation::RawPoseidon2 |
Definition at line 31 of file bytecode_hashing.test.cpp.
| using bb::avm2::simulation::RetrievedBytecodesTree = typedef IndexedMemoryTree<ClassIdLeafValue, aztec::RetrievedBytecodesMerkleHashPolicy> |
Definition at line 39 of file retrieved_bytecodes_tree.hpp.
| using bb::avm2::simulation::RetrievedBytecodesTreeLeafPreimage = typedef IndexedLeaf<ClassIdLeafValue> |
Definition at line 41 of file retrieved_bytecodes_tree.hpp.
| using bb::avm2::simulation::ReturnDataProvider = typedef std::function<std::vector<FF>(uint32_t max_size)> |
Definition at line 12 of file call_stack_metadata_collector.hpp.
| using bb::avm2::simulation::SequentialInsertHintNullifierTreeKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, NullifierLeafValue> |
Definition at line 21 of file db_types.hpp.
| using bb::avm2::simulation::SequentialInsertHintPublicDataTreeKey = typedef std::tuple<AppendOnlyTreeSnapshot, MerkleTreeId, PublicDataLeafValue> |
Definition at line 20 of file db_types.hpp.
| using bb::avm2::simulation::SequentialInsertionResult = typedef ::bb::world_state::SequentialInsertionResult<LeafValueType> |
| using bb::avm2::simulation::TxEvent = typedef std::variant<TxStartupEvent, TxPhaseEvent> |
Definition at line 98 of file tx_events.hpp.
Definition at line 82 of file tx_events.hpp.
| using bb::avm2::simulation::WrittenPublicDataSlotsTree = typedef IndexedMemoryTree<WrittenPublicDataSlotLeafValue, aztec::WrittenSlotsMerkleHashPolicy> |
Definition at line 39 of file written_slots_tree.hpp.
| using bb::avm2::simulation::WrittenPublicDataSlotsTreeLeafPreimage = typedef IndexedLeaf<WrittenPublicDataSlotLeafValue> |
Definition at line 42 of file written_slots_tree.hpp.
|
strong |
| Enumerator | |
|---|---|
| BASE_ADDRESS_INVALID | |
| RELATIVE_COMPUTATION_OOB | |
| INVALID_ADDRESS_AFTER_INDIRECTION | |
Definition at line 14 of file addressing_event.hpp.
|
strong |
| Enumerator | |
|---|---|
| ADD | |
| SUB | |
| MUL | |
| DIV | |
| FDIV | |
| EQ | |
| LT | |
| LTE | |
| NOT | |
| SHL | |
| SHR | |
| TRUNCATE | |
Definition at line 9 of file alu_event.hpp.
|
strong |
| Enumerator | |
|---|---|
| INSTANCE_NOT_FOUND | |
| TOO_MANY_BYTECODES | |
Definition at line 26 of file bytecode_events.hpp.
| Enumerator | |
|---|---|
| CREATE_CHECKPOINT | |
| COMMIT_CHECKPOINT | |
| REVERT_CHECKPOINT | |
Definition at line 7 of file checkpoint_event_type.hpp.
|
strong |
| Enumerator | |
|---|---|
| CD_COPY | |
| RD_COPY | |
Definition at line 18 of file data_copy_events.hpp.
|
strong |
| Enumerator | |
|---|---|
| NONE | |
| BYTECODE_RETRIEVAL | |
| INSTRUCTION_FETCHING | |
| ADDRESSING | |
| REGISTER_READ | |
| GAS | |
| OPCODE_EXECUTION | |
Definition at line 16 of file execution_event.hpp.
|
strong |
| Enumerator | |
|---|---|
| GREATER_THAN | |
| CANONICAL_DECOMPOSITION | |
Definition at line 9 of file field_gt_event.hpp.
| enum bb::avm2::simulation::HaltingMode : uint8_t |
| Enumerator | |
|---|---|
| UNDEFINED | |
| RETURN | |
| REVERT | |
| EXCEPTIONAL_HALT | |
Definition at line 18 of file execution.hpp.
|
strong |
| Enumerator | |
|---|---|
| PC_OUT_OF_RANGE | |
| OPCODE_OUT_OF_RANGE | |
| INSTRUCTION_OUT_OF_RANGE | |
| TAG_OUT_OF_RANGE | |
Definition at line 50 of file serialization.hpp.
|
strong |
| Enumerator | |
|---|---|
| READ | |
| WRITE | |
Definition at line 9 of file memory_event.hpp.
|
strong |
| Enumerator | |
|---|---|
| INDIRECT8 | |
| INDIRECT16 | |
| TAG | |
| UINT8 | |
| UINT16 | |
| UINT32 | |
| UINT64 | |
| UINT128 | |
| FF | |
Definition at line 19 of file serialization.hpp.
| bb::avm2::simulation::BENCHMARK | ( | BM_WrittenSlotsTreeStack | ) | -> Arg(1000) ->Arg(3000) ->Arg(6000) ->Arg(9000) ->Unit(benchmark::kMicrosecond) |
| WrittenPublicDataSlotsTree bb::avm2::simulation::build_public_data_slots_tree | ( | ) |
Definition at line 58 of file written_slots_tree.cpp.
| RetrievedBytecodesTree bb::avm2::simulation::build_retrieved_bytecodes_tree | ( | ) |
Definition at line 58 of file retrieved_bytecodes_tree.cpp.
| bool bb::avm2::simulation::check_tag | ( | const Instruction & | instruction | ) |
Checks whether the tag operand of an instruction is a valid MemoryTag. Called by bytecode managers during instruction fetching to check tag operands.
Check whether the instruction must have a tag operand and whether the operand value is in the value tag range. This is specified by OPCODE_WIRE_FORMAT. If the instruction does not have a valid wire opcode or the relevant tag operand is missing, we return false. However, we do not fully validate the instruction.
Note that this function must be called after successful instruction deserialization since it assumes a valid opcode (!OPCODE_OUT_OF_RANGE) and the correct number of operands (!INSTRUCTION_OUT_OF_RANGE).
Reads the wire format for the instruction's opcode (from get_wire_opcode_wire_format()) and looks for a tag operand. Instructions with no tags return true unconditionally (corresponding to sel_has_tag = 0 in instr_fetching.pil, where tag validation is skipped). Otherwise we check:
| instruction | The deserialized instruction to validate. |
| instruction | The instruction to be checked upon. |
Definition at line 468 of file serialization.cpp.
Definition at line 111 of file contract_crypto.cpp.
| FF bb::avm2::simulation::compute_contract_address | ( | const ContractInstance & | contract_instance | ) |
Definition at line 93 of file contract_crypto.cpp.
| FF bb::avm2::simulation::compute_contract_class_id | ( | const FF & | artifact_hash, |
| const FF & | private_fn_root, | ||
| const FF & | public_bytecode_commitment | ||
| ) |
Definition at line 72 of file contract_crypto.cpp.
| FF bb::avm2::simulation::compute_public_bytecode_commitment | ( | std::span< const uint8_t > | bytecode | ) |
Definition at line 64 of file contract_crypto.cpp.
| FF bb::avm2::simulation::compute_public_bytecode_first_field | ( | size_t | bytecode_size | ) |
Definition at line 54 of file contract_crypto.cpp.
| U128Decomposition bb::avm2::simulation::decompose_128 | ( | const uint128_t & | x | ) |
Definition at line 13 of file uint_decomposition.cpp.
| U256Decomposition bb::avm2::simulation::decompose_256 | ( | const uint256_t & | x | ) |
Definition at line 6 of file uint_decomposition.cpp.
| Instruction bb::avm2::simulation::deserialize_instruction | ( | std::span< const uint8_t > | bytecode, |
| size_t | pos | ||
| ) |
Attempts to deserialize the instruction at position pos in bytecode. Called by bytecode managers during instruction fetching to extract and check for parse errors.
Parsing of an instruction in the supplied bytecode at byte position pos. This checks that the WireOpCode value is in the defined range and extracts the operands for each WireOpCode based on the specification from OPCODE_WIRE_FORMAT.
If no error is thrown, reads the opcode byte at pos, then deserializes each operand in the order defined by the wire format for that opcode (from get_wire_opcode_wire_format()). The addressing mode (INDIRECT8 or INDIRECT16 operand type) is extracted separately and not included in the returned operands vector.
| InstrDeserializationError | if:
|
| bytecode | The raw bytecode bytes. |
| pos | The program counter (pc) to start at. |
| bytecode | The bytecode to be parsed as a vector of bytes/uint8_t. |
| pos | The program counter (pc) to start from. |
| InstrDeserializationError | exception when the pos, opcode byte, or instruction is out-of-range. |
Definition at line 252 of file serialization.cpp.
| std::vector< FF > bb::avm2::simulation::encode_bytecode | ( | std::span< const uint8_t > | bytecode | ) |
Encodes the bytecode into a vector of field elements. Each field element represents 31 bytes of the bytecode. The field encoding is performed in big-endian order, i.e., the ith field element is 2^240 * bytecode[31*i] + 2^232 * bytecode[31*i + 1] + ... + 2^8 * bytecode[31*i + 30] + bytecode[31*i + 31].
bufferAsFields.| bytecode | The bytecode to encode. |
Definition at line 21 of file contract_crypto.cpp.
| FF bb::avm2::simulation::hash_public_keys | ( | const PublicKeys & | public_keys | ) |
Definition at line 77 of file contract_crypto.cpp.
| CalldataProvider bb::avm2::simulation::make_calldata_provider | ( | const ContextInterface & | context | ) |
Definition at line 118 of file call_stack_metadata_collector.cpp.
| InternalCallStackProvider bb::avm2::simulation::make_internal_call_stack_provider | ( | const InternalCallStackManagerInterface & | internal_call_stack_manager | ) |
Definition at line 149 of file call_stack_metadata_collector.cpp.
| ReturnDataProvider bb::avm2::simulation::make_return_data_provider | ( | const ContextInterface & | context, |
| uint32_t | rd_mem_offset_in_child, | ||
| uint32_t | rd_size | ||
| ) |
Definition at line 130 of file call_stack_metadata_collector.cpp.
| std::ostream & bb::avm2::simulation::operator<< | ( | std::ostream & | os, |
| const ClassIdLeafValue & | v | ||
| ) |
Definition at line 17 of file retrieved_bytecodes_tree.cpp.
| std::ostream & bb::avm2::simulation::operator<< | ( | std::ostream & | os, |
| const WrittenPublicDataSlotLeafValue & | v | ||
| ) |
Definition at line 17 of file written_slots_tree.cpp.
|
constexpr |
Definition at line 11 of file sha256_compression.hpp.
| std::array< uint32_t, 8 > bb::avm2::simulation::sha256_block | ( | const std::array< uint32_t, 8 > & | h_init, |
| const std::array< uint32_t, 16 > & | input | ||
| ) |
Fill first 16 words with the message schedule
Extend the input data into the remaining 48 words
Initialize round variables with previous block output
Apply SHA-256 compression function to the message schedule
Add into previous block output and return
Definition at line 23 of file sha256_compression.cpp.
|
inline |
Definition at line 25 of file addressing_event.hpp.
| FF bb::avm2::simulation::unconstrained_compute_leaf_slot | ( | const AztecAddress & | contract_address, |
| const FF & | slot | ||
| ) |
Definition at line 30 of file merkle.cpp.
| FF bb::avm2::simulation::unconstrained_make_unique_note_hash | ( | const FF & | siloed_note_hash, |
| const FF & | first_nullifier, | ||
| uint64_t | note_hash_counter | ||
| ) |
Definition at line 45 of file merkle.cpp.
| FF bb::avm2::simulation::unconstrained_root_from_path | ( | uint64_t | domain_separator, |
| const FF & | leaf_value, | ||
| const uint64_t | leaf_index, | ||
| std::span< const FF > | path | ||
| ) |
Definition at line 12 of file merkle.cpp.
| FF bb::avm2::simulation::unconstrained_silo_note_hash | ( | const AztecAddress & | contract_address, |
| const FF & | note_hash | ||
| ) |
Definition at line 40 of file merkle.cpp.
| FF bb::avm2::simulation::unconstrained_silo_nullifier | ( | const AztecAddress & | contract_address, |
| const FF & | nullifier | ||
| ) |
Definition at line 35 of file merkle.cpp.
| const std::vector<OperandType> bb::avm2::simulation::external_call_format |
Definition at line 50 of file serialization.cpp.
|
constexpr |
Definition at line 31 of file keccakf1600.hpp.
|
constexpr |
Definition at line 20 of file keccakf1600.hpp.
|
constexpr |
Definition at line 41 of file keccakf1600.hpp.
| const std::vector<OperandType> bb::avm2::simulation::kernel_input_operand_format = { OperandType::INDIRECT8, OperandType::UINT16 } |
Definition at line 48 of file serialization.cpp.
| const std::optional< uint64_t > bb::avm2::simulation::NO_PUBLIC_INPUTS_INDEX = std::nullopt |
Definition at line 16 of file retrieved_bytecodes_tree_check.test.cpp.
| const std::optional<IndexedTreeSiloingParameters> bb::avm2::simulation::NO_SILOING = std::nullopt |
Definition at line 15 of file retrieved_bytecodes_tree_check.test.cpp.
|
constexpr |
Definition at line 11 of file sha256_compression.cpp.
| const std::vector<OperandType> bb::avm2::simulation::three_operand_format16 |
Definition at line 42 of file serialization.cpp.
| const std::vector<OperandType> bb::avm2::simulation::three_operand_format8 |
Definition at line 36 of file serialization.cpp.