Skip to content

Commit c76dbf6

Browse files
ajgaraAgustin
and
Agustin
authored
Fix verifier and CairoAIR config (#578)
* Fix verifier and CairoAIR config * Add test to make sure authentication paths are being checked * Cargo format * Fix clippy for feature metal --------- Co-authored-by: Agustin <[email protected]>
1 parent 9825074 commit c76dbf6

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

provers/cairo/src/air.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ impl AIR for CairoAIR {
637637
) -> Self {
638638
debug_assert!(trace_length.is_power_of_two());
639639

640-
let mut trace_columns = 34 + 4 + 15 + 4;
640+
let mut trace_columns = 59;
641641
let mut transition_degrees = vec![
642642
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // Flags 0-14.
643643
1, // Flag 15
@@ -803,7 +803,7 @@ impl AIR for CairoAIR {
803803
fn number_auxiliary_rap_columns(&self) -> usize {
804804
// RANGE_CHECK_COL_i + MEMORY_INCREASING_i + MEMORY_CONSISTENCY_i + PERMUTATION_ARGUMENT_COL_i +
805805
// + PERMUTATION_ARGUMENT_RANGE_CHECK_COL_i
806-
4 + 5 + 5 + 5 + 4
806+
23
807807
}
808808

809809
fn compute_transition(

provers/cairo/src/tests/integration_tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,34 @@ fn test_prove_cairo_fibonacci_5() {
3939
test_prove_cairo_program(&cairo0_program_path("fibonacci_5.json"), &None, layout);
4040
}
4141

42+
#[test_log::test]
43+
fn test_verifier_rejects_wrong_authentication_paths() {
44+
// Setup
45+
let proof_options = ProofOptions::default_test_options();
46+
let program_content = std::fs::read(cairo0_program_path("fibonacci_5.json")).unwrap();
47+
let (main_trace, pub_inputs) =
48+
generate_prover_args(&program_content, &None, CairoLayout::Plain).unwrap();
49+
50+
// Generate the proof
51+
let mut proof = generate_cairo_proof(&main_trace, &pub_inputs, &proof_options).unwrap();
52+
53+
// Change order of authentication path hashes
54+
let query = 0;
55+
let merkle_tree = 0;
56+
let mut original_path = proof.deep_poly_openings[query].lde_trace_merkle_proofs[merkle_tree]
57+
.merkle_path
58+
.clone();
59+
original_path.swap(0, 1);
60+
// For the test to make sense, we have to make sure
61+
// that the two hashes are different.
62+
assert_ne!(original_path[0], original_path[1]);
63+
proof.deep_poly_openings[query].lde_trace_merkle_proofs[merkle_tree].merkle_path =
64+
original_path;
65+
66+
// Verifier should reject the proof
67+
assert!(!verify_cairo_proof(&proof, &pub_inputs, &proof_options));
68+
}
69+
4270
#[test_log::test]
4371
fn test_prove_cairo_fibonacci_1000() {
4472
let layout = CairoLayout::Plain;

provers/stark/src/verifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ where
355355
];
356356

357357
// Verify openings Open(tⱼ(D_LDE), 𝜐₀)
358-
proof
358+
result &= proof
359359
.lde_trace_merkle_roots
360360
.iter()
361361
.zip(&deep_poly_opening.lde_trace_merkle_proofs)

0 commit comments

Comments
 (0)