Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
avm_inputs.hpp
Go to the documentation of this file.
1// NOTE: names are in camel-case because they matter to messagepack.
2// DO NOT use camel-case outside of these structures.
3#pragma once
4
5#include <cstdint>
6#include <ostream>
7#include <vector>
8
14
19#include "msgpack/adaptor/define_decl.hpp"
20
21namespace bb::avm2 {
22
24// Avm Circuit Public Inputs
26
29 // Inputs
47 // Outputs
54
55 static PublicInputs from(const std::vector<uint8_t>& data);
56
57 // A vector per public inputs column
59
60 // Flatten public input columns as a single vector
61 static std::vector<FF> columns_to_flat(std::vector<std::vector<FF>> const& columns);
62
63 // From flattened public inputs columns to vector per-column
64 // Reverse direction as the above but needs to be templated as
65 // recursive verifier needs it with a circuit type.
66 template <typename FF_> static std::vector<std::vector<FF_>> flat_to_columns(const std::vector<FF_>& input)
67 {
69 throw std::invalid_argument(
70 "Flattened public inputs vector size does not match the expected combined length.");
71 }
72
74
75 for (size_t i = 0; i < AVM_NUM_PUBLIC_INPUT_COLUMNS; ++i) {
76 typename std::vector<FF_>::const_iterator start =
77 input.begin() +
78 static_cast<typename std::vector<FF_>::difference_type>(i * AVM_PUBLIC_INPUTS_COLUMNS_MAX_LENGTH);
79 typename std::vector<FF_>::const_iterator end =
80 input.begin() +
81 static_cast<typename std::vector<FF_>::difference_type>((i + 1) * AVM_PUBLIC_INPUTS_COLUMNS_MAX_LENGTH);
82 cols[i] = std::vector<FF_>(start, end);
83 }
84
85 return cols;
86 }
87
88 bool operator==(const PublicInputs& other) const = default;
89
111 reverted);
112};
113
115// Hints (contracts)
130
145
156
165
167// Hints (merkle db)
171 // params
173 uint64_t index;
174 // return
175 std::vector<FF> path;
176
177 bool operator==(const GetSiblingPathHint& other) const = default;
178
180};
181
195
196template <typename LeafPreimage_> struct GetLeafPreimageHint {
198 // params (tree id will be implicit)
199 uint64_t index;
200 // return
201 LeafPreimage_ leafPreimage;
202
203 bool operator==(const GetLeafPreimageHint<LeafPreimage_>& other) const = default;
204
206};
207
210 // params
212 uint64_t index;
213 // return
215
216 bool operator==(const GetLeafValueHint& other) const = default;
217
219};
220
236
237// Hint for MerkleTreeDB.appendLeaves.
238// Note: only supported for NOTE_HASH_TREE and L1_TO_L2_MESSAGE_TREE.
250
252 // key
254 // current checkpoint evolution
257
258 bool operator==(const CheckpointActionNoStateChangeHint& other) const = default;
259
261};
262
265
267 // key
269 // current checkpoint evolution
272 // state evolution
275
276 bool operator==(const RevertCheckpointHint& other) const = default;
277
279};
280
282// Hints (other)
284
293
295 // TODO: add as needed.
296 std::vector<FF> noteHashes;
297 std::vector<FF> nullifiers;
299
300 bool operator==(const AccumulatedData& other) const = default;
301
303};
304
305// We are currently using this structure as the input to TX simulation.
306// That's why I'm not calling it TxHint. We can reconsider if the inner types seem to dirty.
331
335 // Protocol Contracts
337 // Contracts.
341 // Merkle DB.
356
357 bool operator==(const ExecutionHints& other) const = default;
358
360 tx,
377};
378
380// AVM Inputs
385
386 static AvmProvingInputs from(const std::vector<uint8_t>& data);
387 bool operator==(const AvmProvingInputs& other) const = default;
388
390};
391
392} // namespace bb::avm2
#define AVM_PUBLIC_INPUTS_COLUMNS_COMBINED_LENGTH
#define AVM_NUM_PUBLIC_INPUT_COLUMNS
#define AVM_PUBLIC_INPUTS_COLUMNS_MAX_LENGTH
const std::vector< FF > data
FF ContractClassId
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::vector< FF > nullifiers
MSGPACK_FIELDS(noteHashes, nullifiers, l2ToL1Messages)
std::vector< FF > noteHashes
bool operator==(const AccumulatedData &other) const =default
std::vector< ScopedL2ToL1Message > l2ToL1Messages
AppendOnlyTreeSnapshot stateAfter
AppendOnlyTreeSnapshot hintKey
std::vector< FF > leaves
bool operator==(const AppendLeavesHint &other) const =default
world_state::MerkleTreeId treeId
MSGPACK_FIELDS(hintKey, stateAfter, treeId, leaves)
static AvmProvingInputs from(const std::vector< uint8_t > &data)
MSGPACK_FIELDS(publicInputs, hints)
bool operator==(const AvmProvingInputs &other) const =default
bool operator==(const BytecodeCommitmentHint &other) const =default
MSGPACK_FIELDS(classId, commitment)
bool operator==(const CheckpointActionNoStateChangeHint &other) const =default
MSGPACK_FIELDS(actionCounter, oldCheckpointId, newCheckpointId)
MSGPACK_FIELDS(classId, artifactHash, privateFunctionsRoot, packedBytecode)
bool operator==(const ContractClassHint &other) const =default
std::vector< uint8_t > packedBytecode
ContractClassId currentContractClassId
MSGPACK_FIELDS(address, salt, deployer, currentContractClassId, originalContractClassId, initializationHash, publicKeys)
ContractClassId originalContractClassId
bool operator==(const ContractInstanceHint &other) const =default
std::vector< RevertCheckpointHint > revertCheckpointHints
std::vector< SequentialInsertHint< crypto::merkle_tree::NullifierLeafValue > > sequentialInsertHintsNullifierTree
ProtocolContracts protocolContracts
GlobalVariables globalVariables
std::vector< ContractClassHint > contractClasses
std::vector< GetPreviousValueIndexHint > getPreviousValueIndexHints
std::vector< AppendLeavesHint > appendLeavesHints
MSGPACK_FIELDS(globalVariables, tx, protocolContracts, contractInstances, contractClasses, bytecodeCommitments, startingTreeRoots, getSiblingPathHints, getPreviousValueIndexHints, getLeafPreimageHintsPublicDataTree, getLeafPreimageHintsNullifierTree, getLeafValueHints, sequentialInsertHintsPublicDataTree, sequentialInsertHintsNullifierTree, appendLeavesHints, createCheckpointHints, commitCheckpointHints, revertCheckpointHints)
std::vector< GetLeafPreimageHint< crypto::merkle_tree::IndexedLeaf< crypto::merkle_tree::NullifierLeafValue > > > getLeafPreimageHintsNullifierTree
std::vector< CommitCheckpointHint > commitCheckpointHints
std::vector< SequentialInsertHint< crypto::merkle_tree::PublicDataLeafValue > > sequentialInsertHintsPublicDataTree
std::vector< GetSiblingPathHint > getSiblingPathHints
std::vector< GetLeafValueHint > getLeafValueHints
std::vector< GetLeafPreimageHint< crypto::merkle_tree::IndexedLeaf< crypto::merkle_tree::PublicDataLeafValue > > > getLeafPreimageHintsPublicDataTree
std::vector< ContractInstanceHint > contractInstances
std::vector< BytecodeCommitmentHint > bytecodeCommitments
std::vector< CreateCheckpointHint > createCheckpointHints
TreeSnapshots startingTreeRoots
bool operator==(const ExecutionHints &other) const =default
bool operator==(const GetLeafPreimageHint< LeafPreimage_ > &other) const =default
MSGPACK_FIELDS(hintKey, index, leafPreimage)
AppendOnlyTreeSnapshot hintKey
MSGPACK_FIELDS(hintKey, treeId, index, value)
AppendOnlyTreeSnapshot hintKey
bool operator==(const GetLeafValueHint &other) const =default
world_state::MerkleTreeId treeId
world_state::MerkleTreeId treeId
MSGPACK_FIELDS(hintKey, treeId, value, index, alreadyPresent)
bool operator==(const GetPreviousValueIndexHint &other) const =default
MSGPACK_FIELDS(hintKey, treeId, index, path)
AppendOnlyTreeSnapshot hintKey
world_state::MerkleTreeId treeId
bool operator==(const GetSiblingPathHint &other) const =default
bool operator==(const PublicCallRequestWithCalldata &other) const =default
GlobalVariables globalVariables
static std::vector< FF > columns_to_flat(std::vector< std::vector< FF > > const &columns)
TreeSnapshots startTreeSnapshots
PrivateToAvmAccumulatedData previousRevertibleAccumulatedData
PublicCallRequestArrayLengths publicCallRequestArrayLengths
PrivateToAvmAccumulatedData previousNonRevertibleAccumulatedData
TreeSnapshots endTreeSnapshots
AvmAccumulatedDataArrayLengths accumulatedDataArrayLengths
std::vector< std::vector< FF > > to_columns() const
Serialization to columns.
static PublicInputs from(const std::vector< uint8_t > &data)
Msgpack deserialization.
PublicCallRequest publicTeardownCallRequest
std::array< PublicCallRequest, MAX_ENQUEUED_CALLS_PER_TX > publicSetupCallRequests
bool operator==(const PublicInputs &other) const =default
PrivateToAvmAccumulatedDataArrayLengths previousNonRevertibleAccumulatedDataArrayLengths
AvmAccumulatedData accumulatedData
MSGPACK_FIELDS(globalVariables, protocolContracts, startTreeSnapshots, startGasUsed, gasSettings, effectiveGasFees, feePayer, proverId, publicCallRequestArrayLengths, publicSetupCallRequests, publicAppLogicCallRequests, publicTeardownCallRequest, previousNonRevertibleAccumulatedDataArrayLengths, previousRevertibleAccumulatedDataArrayLengths, previousNonRevertibleAccumulatedData, previousRevertibleAccumulatedData, endTreeSnapshots, endGasUsed, accumulatedDataArrayLengths, accumulatedData, transactionFee, reverted)
static std::vector< std::vector< FF_ > > flat_to_columns(const std::vector< FF_ > &input)
PrivateToAvmAccumulatedDataArrayLengths previousRevertibleAccumulatedDataArrayLengths
ProtocolContracts protocolContracts
std::array< PublicCallRequest, MAX_ENQUEUED_CALLS_PER_TX > publicAppLogicCallRequests
AffinePoint masterOutgoingViewingPublicKey
AffinePoint masterIncomingViewingPublicKey
bool operator==(const PublicKeysHint &other) const =default
MSGPACK_FIELDS(masterNullifierPublicKey, masterIncomingViewingPublicKey, masterOutgoingViewingPublicKey, masterTaggingPublicKey)
AffinePoint masterTaggingPublicKey
AffinePoint masterNullifierPublicKey
MSGPACK_FIELDS(actionCounter, oldCheckpointId, newCheckpointId, stateBefore, stateAfter)
bool operator==(const RevertCheckpointHint &other) const =default
AppendOnlyTreeSnapshot stateAfter
crypto::merkle_tree::LeafUpdateWitnessData< Leaf > lowLeavesWitnessData
AppendOnlyTreeSnapshot hintKey
bool operator==(const SequentialInsertHint< Leaf > &other) const =default
crypto::merkle_tree::LeafUpdateWitnessData< Leaf > insertionWitnessData
world_state::MerkleTreeId treeId
MSGPACK_FIELDS(hintKey, treeId, leaf, lowLeavesWitnessData, insertionWitnessData, stateAfter)
std::optional< PublicCallRequestWithCalldata > teardownEnqueuedCall
AztecAddress feePayer
std::vector< PublicCallRequestWithCalldata > appLogicEnqueuedCalls
AccumulatedData revertibleAccumulatedData
GasFees effectiveGasFees
AccumulatedData nonRevertibleAccumulatedData
std::string hash
GasSettings gasSettings
MSGPACK_FIELDS(hash, gasSettings, effectiveGasFees, nonRevertibleAccumulatedData, revertibleAccumulatedData, setupEnqueuedCalls, appLogicEnqueuedCalls, teardownEnqueuedCall, gasUsedByPrivate, feePayer)
std::vector< PublicCallRequestWithCalldata > setupEnqueuedCalls
bool operator==(const Tx &other) const =default