Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
fixtures.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
12
13namespace bb::avm2::testing {
14
15std::vector<FF> random_fields(size_t n);
16
17// WARNING: Cryptographically insecure randomness routines for testing purposes only.
18std::vector<uint8_t> random_bytes(size_t n);
19
22
24
25// This generates a random instruction for a given wire opcode. The output will conform to
26// the wire format specified in WireOpCode_WIRE_FORMAT. The format specifies a vector of
27// OperandType and we generate a random value for each operand conforming to the OperandType.
28// For OperandTypes:
29// INDIRECT8, UINT8: single random byte
30// INDIRECT16, UINT16: 2 random bytes
31// UINTXX: random bytes conforming to the size in bytes of the operand
32// FF: random field
33// TAG: random tag within the enum MemoryTag range
34// We do not provide any guarantee beyond the above static format restrictions.
35// For instance, next pc destination in JUMP might overflow the bytecode, etc, ....
36// Also, immediate operands which correspond to an enum value might fall outside
37// the prescribed range (for instance: GETENVVAR_16 and GETCONTRACTINSTANCE).
38// Note that indirect value might have toggled bits which are not relevant to the
39// wire opcode. It is in principle not an issue as these bits are ignored during
40// address resolution.
45ContractClass random_contract_class(size_t bytecode_size = 20);
46
47// Simulates a minimal public tx (SET, SET, ADD, RETURN) end-to-end with the in-process
48// PublicTxSimulationTester harness, collecting hints and public inputs. This is the canonical
49// minimal-but-valid AvmProvingInputs used as a fixture by proving/verifier/hinting tests, generated
50// on the fly.
52
53// A routine which provides a minimal trace and public inputs which should provide
54// a good coverage over the different sub-traces but yet as short as necessary.
55// TODO: Enhance trace with values in other sub-traces. At the moment, only
56// alu contains non-zero values.
58
63bool skip_slow_tests();
64
65} // namespace bb::avm2::testing
std::vector< PublicCallRequestWithCalldata > random_enqueued_calls(size_t n)
Definition fixtures.cpp:63
ContractClass random_contract_class(size_t bytecode_size)
Definition fixtures.cpp:188
std::vector< uint8_t > random_bytes(size_t n)
Definition fixtures.cpp:36
Operand random_operand(OperandType operand_type)
Definition fixtures.cpp:80
bool skip_slow_tests()
Check if slow tests should be skipped.
Definition fixtures.cpp:244
AvmProvingInputs get_minimal_proving_inputs()
Definition fixtures.cpp:196
ContractInstance random_protocol_contract_instance()
Definition fixtures.cpp:181
Instruction random_instruction(WireOpCode w_opcode)
Definition fixtures.cpp:128
ContractInstance random_contract_instance()
Definition fixtures.cpp:162
TestTraceContainer empty_trace()
Definition fixtures.cpp:156
std::vector< ScopedL2ToL1Message > random_l2_to_l1_messages(size_t n)
Definition fixtures.cpp:46
std::vector< FF > random_fields(size_t n)
Definition fixtures.cpp:26
std::pair< tracegen::TraceContainer, PublicInputs > get_minimal_trace_with_pi()
Definition fixtures.cpp:230
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13