1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
25using ::testing::StrictMock;
27using tracegen::BytecodeTraceBuilder;
28using tracegen::ClassIdDerivationTraceBuilder;
29using tracegen::Poseidon2TraceBuilder;
30using tracegen::TestTraceContainer;
32using simulation::ClassIdDerivation;
33using simulation::ClassIdDerivationEvent;
35using simulation::EventEmitter;
36using simulation::MockExecutionIdManager;
37using simulation::MockGreaterThan;
38using simulation::NoopEventEmitter;
39using simulation::Poseidon2;
40using simulation::Poseidon2HashEvent;
41using simulation::Poseidon2PermutationEvent;
42using simulation::Poseidon2PermutationMemoryEvent;
43using simulation::PurePoseidon2;
49ContractClassWithCommitment generate_contract_class()
51 return ContractClassWithCommitment{
55 .packed_bytecode = {},
60TEST(ClassIdDerivationConstrainingTest, EmptyRow)
65TEST(ClassIdDerivationConstrainingTest, Basic)
67 TestTraceContainer
trace;
68 ClassIdDerivationTraceBuilder
builder;
70 auto klass = generate_contract_class();
75 .artifact_hash = klass.artifact_hash,
76 .private_functions_root = klass.private_functions_root,
77 .public_bytecode_commitment = klass.public_bytecode_commitment } },
80 check_relation<class_id_derivation_relation>(trace);
83TEST(ClassIdDerivationPoseidonTest, WithHashInteraction)
89 StrictMock<MockGreaterThan>
mock_gt;
96 auto klass = generate_contract_class();
101 TestTraceContainer
trace({
102 { { C::precomputed_first_row, 1 } },
105 ClassIdDerivationTraceBuilder
builder;
112 .artifact_hash = klass.artifact_hash,
113 .private_functions_root = klass.private_functions_root,
114 .public_bytecode_commitment = klass.public_bytecode_commitment } },
StrictMock< MockGreaterThan > mock_gt
EventEmitter< Poseidon2PermutationMemoryEvent > perm_mem_event_emitter
EventEmitter< Poseidon2PermutationEvent > perm_event_emitter
EventEmitter< Poseidon2HashEvent > hash_event_emitter
Poseidon2TraceBuilder poseidon2_builder
StrictMock< MockClassIdDerivation > class_id_derivation
void process(const simulation::EventEmitterInterface< simulation::AluEvent >::Container &events, TraceContainer &trace)
Process the ALU events and populate the ALU relevant columns in the trace.
void process_hash(const simulation::EventEmitterInterface< simulation::Poseidon2HashEvent >::Container &hash_events, TraceContainer &trace)
Processes the hash events for the Poseidon2 hash function. It populates the columns for the poseidon2...
Native Poseidon2 hash function implementation.
ExecutionIdManager execution_id_manager
EventEmitter< DataCopyEvent > event_emitter
void check_interaction(tracegen::TestTraceContainer &trace)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
FF compute_contract_class_id(const FF &artifact_hash, const FF &private_fn_root, const FF &public_bytecode_commitment)
TestTraceContainer empty_trace()
lookup_settings< lookup_class_id_derivation_class_id_poseidon2_1_settings_ > lookup_class_id_derivation_class_id_poseidon2_1_settings
lookup_settings< lookup_class_id_derivation_class_id_poseidon2_0_settings_ > lookup_class_id_derivation_class_id_poseidon2_0_settings
static field random_element(numeric::RNG *engine=nullptr) noexcept