176 std::vector<FF> input = { 1, 2, 3, 4 };
180 EXPECT_EQ(result, bb_result);
184 EXPECT_EQ(result, bb_result);
187 { { C::precomputed_first_row, 1 } },
195 check_relation<poseidon2_hash>(
trace);
200 std::vector<FF> input = { 1, 2, 3, 4 };
205 { { C::precomputed_first_row, 1 } },
211 check_interaction<Poseidon2TraceBuilder, lookup_poseidon2_hash_poseidon2_perm_settings>(
trace);
215 check_relation<poseidon2_hash>(
trace);
216 check_relation<poseidon2_perm>(
trace);
217 check_all_interactions<Poseidon2TraceBuilder>(
trace);
222 std::vector<FF> input = { 1, 2, 3, 4 };
227 { { C::precomputed_first_row, 1 } },
234 (check_interaction<Poseidon2TraceBuilder, lookup_poseidon2_hash_poseidon2_perm_settings>(
trace)),
235 "Failed.*POSEIDON2_PERM. Could not find tuple in destination.");
239 check_relation<poseidon2_hash>(
trace);
283 .WillOnce(ReturnRef(
inputs[0]))
284 .WillOnce(ReturnRef(
inputs[1]))
285 .WillOnce(ReturnRef(
inputs[2]))
286 .WillOnce(ReturnRef(
inputs[3]));
287 EXPECT_CALL(
memory, set).Times(4);
290 std::vector<FF> outputs = {
FF(
"0x224785a48a72c75e2cbb698143e71d5d41bd89a2b9a7185871e39a54ce5785b1"),
291 FF(
"0x225bb800db22c4f4b09ace45cb484d42b0dd7dfe8708ee26aacde6f2c1fb2cb8"),
292 FF(
"0x1180f4260e60b4264c987b503075ea8374b53ed06c5145f8c21c2aadb5087d21"),
293 FF(
"0x16c877b5b9c04d873218804ccbf65d0eeb12db447f66c9ca26fec380055df7e9") };
300 { C::execution_sel, 1 },
301 { C::execution_sel_exec_dispatch_poseidon2_perm, 1 },
320 for (uint32_t i = 0; i <
inputs.size(); ++i) {
324 trace.
set(C::memory_tag, i,
static_cast<uint32_t
>(
inputs[i].get_tag()));
327 uint32_t write_index = i +
static_cast<uint32_t
>(
inputs.size());
329 trace.
set(C::memory_value, write_index, outputs[i]);
330 trace.
set(C::memory_sel, write_index, 1);
331 trace.
set(C::memory_rw, write_index, 1);
339 check_all_interactions<Poseidon2TraceBuilder>(
trace);
340 check_relation<poseidon2_mem>(
trace);
347 MemoryValue::from<FF>(1), MemoryValue::from<FF>(2), MemoryValue::from<uint64_t>(3), MemoryValue::from<FF>(4)
352 .WillOnce(ReturnRef(
inputs[0]))
353 .WillOnce(ReturnRef(
inputs[1]))
354 .WillOnce(ReturnRef(
inputs[2]))
355 .WillOnce(ReturnRef(
inputs[3]));
362 { C::execution_sel, 1 },
363 { C::execution_sel_exec_dispatch_poseidon2_perm, 1 },
366 { C::execution_sel_opcode_error, 1 },
383 for (uint32_t i = 0; i <
inputs.size(); ++i) {
387 trace.
set(C::memory_tag, i,
static_cast<uint32_t
>(
inputs[i].get_tag()));
392 "Poseidon2Exception.* input tag is not FF");
399 check_relation<poseidon2_mem>(
trace);
400 check_all_interactions<Poseidon2TraceBuilder>(
trace);
411 { C::execution_sel, 1 },
412 { C::execution_sel_exec_dispatch_poseidon2_perm, 1 },
415 { C::execution_sel_opcode_error, 1 },
425 { C::gt_input_a,
static_cast<uint64_t
>(
src_address) + 3 },
432 "Poseidon2Exception.* src or dst address out of range");
440 check_relation<poseidon2_mem>(
trace);
441 check_all_interactions<Poseidon2TraceBuilder>(
trace);
464 { { C::precomputed_first_row, 1 } },
468 { C::poseidon2_hash_sel, 0 },
469 { C::poseidon2_hash_start, 1 },
470 { C::poseidon2_hash_end, 0 },
472 { C::poseidon2_hash_input_0,
FF(0xDEADBEEF) },
473 { C::poseidon2_hash_input_1,
FF(0xCAFEBABE) },
474 { C::poseidon2_hash_input_2,
FF(0x12345678) },
475 { C::poseidon2_hash_output,
FF(0x999999) },
476 { C::poseidon2_hash_num_perm_rounds_rem, 2 },
477 { C::poseidon2_hash_input_len, 4 },
478 { C::poseidon2_hash_padding, 2 },
484 "SEL_ON_START_OR_END");
501 FF real_artifact_hash =
FF(0x1111);
502 FF real_private_functions_root =
FF(0x2222);
503 FF real_bytecode_commitment =
FF(0x3333);
514 FF attacker_artifact =
FF(0xAAAA);
515 FF attacker_private_root =
FF(0xBBBB);
516 FF attacker_bytecode = real_bytecode_commitment;
522 ASSERT_NE(fake_class_id, real_class_id);
531 attacker_klass.
id = fake_class_id;
542 { { C::precomputed_first_row, 1 }, { C::precomputed_zero, 0 } },
554 check_relation<poseidon2_hash>(
trace);
555 check_relation<class_id_derivation>(
trace);
560 uint32_t class_id_row = 0;
563 { C::class_id_derivation_sel, 1 },
564 { C::class_id_derivation_class_id, fake_class_id },
565 { C::class_id_derivation_artifact_hash, real_artifact_hash },
566 { C::class_id_derivation_private_functions_root, real_private_functions_root },
567 { C::class_id_derivation_public_bytecode_commitment, real_bytecode_commitment },
569 { C::class_id_derivation_const_four, 4 },
578 { C::poseidon2_hash_sel, 0 },
579 { C::poseidon2_hash_start, 1 },
580 { C::poseidon2_hash_end, 0 },
582 { C::poseidon2_hash_input_1, real_artifact_hash },
583 { C::poseidon2_hash_input_2, real_private_functions_root },
584 { C::poseidon2_hash_output, fake_class_id },
585 { C::poseidon2_hash_num_perm_rounds_rem, 2 },
586 { C::poseidon2_hash_input_len, 4 },
587 { C::poseidon2_hash_padding, 2 },
595 "SEL_ON_START_OR_END");
598 check_relation<class_id_derivation>(
trace);