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
45 // Outputs
52
53 static PublicInputs from(const std::vector<uint8_t>& data);
54
55 // A vector per public inputs column
57
58 // Flatten public input columns as a single vector
59 static std::vector<FF> columns_to_flat(std::vector<std::vector<FF>> const& columns);
60
61 // From flattened public inputs columns to vector per-column
62 // Reverse direction as the above but needs to be templated as
63 // recursive verifier needs it with a circuit type.
64 template <typename FF_> static std::vector<std::vector<FF_>> flat_to_columns(const std::vector<FF_>& input)
65 {
67 throw std::invalid_argument(
68 "Flattened public inputs vector size does not match the expected combined length.");
69 }
70
72
73 for (size_t i = 0; i < AVM_NUM_PUBLIC_INPUT_COLUMNS; ++i) {
74 typename std::vector<FF_>::const_iterator start =
75 input.begin() +
76 static_cast<typename std::vector<FF_>::difference_type>(i * AVM_PUBLIC_INPUTS_COLUMNS_MAX_LENGTH);
77 typename std::vector<FF_>::const_iterator end =
78 input.begin() +
79 static_cast<typename std::vector<FF_>::difference_type>((i + 1) * AVM_PUBLIC_INPUTS_COLUMNS_MAX_LENGTH);
80 cols[i] = std::vector<FF_>(start, end);
81 }
82
83 return cols;
84 }
85
86 bool operator==(const PublicInputs& other) const = default;
87
107 reverted);
108};
109
111// Hints (contracts)
126
141
152
161
163// Hints (merkle db)
167 // params
169 uint64_t index;
170 // return
171 std::vector<FF> path;
172
173 bool operator==(const GetSiblingPathHint& other) const = default;
174
176};
177
191
192template <typename LeafPreimage_> struct GetLeafPreimageHint {
194 // params (tree id will be implicit)
195 uint64_t index;
196 // return
197 LeafPreimage_ leafPreimage;
198
199 bool operator==(const GetLeafPreimageHint<LeafPreimage_>& other) const = default;
200
202};
203
206 // params
208 uint64_t index;
209 // return
211
212 bool operator==(const GetLeafValueHint& other) const = default;
213
215};
216
232
233// Hint for MerkleTreeDB.appendLeaves.
234// Note: only supported for NOTE_HASH_TREE and L1_TO_L2_MESSAGE_TREE.
246
248 // key
250 // current checkpoint evolution
253
254 bool operator==(const CheckpointActionNoStateChangeHint& other) const = default;
255
257};
258
261
263 // key
265 // current checkpoint evolution
268 // state evolution
271
272 bool operator==(const RevertCheckpointHint& other) const = default;
273
275};
276
278// Hints (other)
280
289
291 // TODO: add as needed.
292 std::vector<FF> noteHashes;
293 std::vector<FF> nullifiers;
295
296 bool operator==(const AccumulatedData& other) const = default;
297
299};
300
301// We are currently using this structure as the input to TX simulation.
302// That's why I'm not calling it TxHint. We can reconsider if the inner types seem to dirty.
327
331 // Contracts.
335 // Merkle DB.
350
351 bool operator==(const ExecutionHints& other) const = default;
352
354 tx,
370};
371
373// AVM Inputs
378
379 static AvmProvingInputs from(const std::vector<uint8_t>& data);
380 bool operator==(const AvmProvingInputs& other) const = default;
381
383};
384
385} // 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
GlobalVariables globalVariables
std::vector< ContractClassHint > contractClasses
std::vector< GetPreviousValueIndexHint > getPreviousValueIndexHints
std::vector< AppendLeavesHint > appendLeavesHints
MSGPACK_FIELDS(globalVariables, tx, 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
MSGPACK_FIELDS(globalVariables, startTreeSnapshots, startGasUsed, gasSettings, effectiveGasFees, feePayer, publicCallRequestArrayLengths, publicSetupCallRequests, publicAppLogicCallRequests, publicTeardownCallRequest, previousNonRevertibleAccumulatedDataArrayLengths, previousRevertibleAccumulatedDataArrayLengths, previousNonRevertibleAccumulatedData, previousRevertibleAccumulatedData, endTreeSnapshots, endGasUsed, accumulatedDataArrayLengths, accumulatedData, transactionFee, reverted)
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
static std::vector< std::vector< FF_ > > flat_to_columns(const std::vector< FF_ > &input)
PrivateToAvmAccumulatedDataArrayLengths previousRevertibleAccumulatedDataArrayLengths
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