Skip to content

Commit

Permalink
Revert "chore: uncomment asserts in oink rec verifier (#8316)"
Browse files Browse the repository at this point in the history
This reverts commit a7f3144.
  • Loading branch information
ludamad authored Sep 3, 2024
1 parent 8d9947d commit 6c1d210
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 32 deletions.
26 changes: 10 additions & 16 deletions barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ TEST_F(AztecIVCTests, BasicFour)
};

/**
* @brief Check that the IVC fails if an intermediate fold proof is invalid
* @brief Check that the IVC fails to verify if an intermediate fold proof is invalid
* @details When accumulating 4 circuits, there are 3 fold proofs to verify (the first two are recursively verfied and
* the 3rd is verified as part of the IVC proof). Check that if any of one of these proofs is invalid, the IVC will
* fail.
* the 3rd is verified as part of the IVC proof). Check that if any of one of these proofs is invalid, the IVC will fail
* to verify.
*
*/
TEST_F(AztecIVCTests, BadProofFailure)
Expand All @@ -175,7 +175,7 @@ TEST_F(AztecIVCTests, BadProofFailure)
EXPECT_TRUE(ivc.prove_and_verify());
}

// The IVC throws an exception if the FIRST fold proof is tampered with
// The IVC fails to verify if the FIRST fold proof is tampered with
{
AztecIVC ivc;
ivc.trace_structure = TraceStructure::SMALL_TEST;
Expand All @@ -185,11 +185,6 @@ TEST_F(AztecIVCTests, BadProofFailure)
// Construct and accumulate a set of mocked private function execution circuits
size_t NUM_CIRCUITS = 4;
for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) {
if (idx == 3) { // At idx = 3, we've tampered with the one of the folding proofs so create the recursive
// folding verifier will throw an error.
EXPECT_ANY_THROW(circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5));
break;
}
auto circuit = circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5);
ivc.accumulate(circuit);

Expand All @@ -198,9 +193,11 @@ TEST_F(AztecIVCTests, BadProofFailure)
tamper_with_proof(ivc.verification_queue[0].proof); // tamper with first proof
}
}

EXPECT_FALSE(ivc.prove_and_verify());
}

// The IVC fails if the SECOND fold proof is tampered with
// The IVC fails to verify if the SECOND fold proof is tampered with
{
AztecIVC ivc;
ivc.trace_structure = TraceStructure::SMALL_TEST;
Expand All @@ -210,11 +207,6 @@ TEST_F(AztecIVCTests, BadProofFailure)
// Construct and accumulate a set of mocked private function execution circuits
size_t NUM_CIRCUITS = 4;
for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) {
if (idx == 3) { // At idx = 3, we've tampered with the one of the folding proofs so create the recursive
// folding verifier will throw an error.
EXPECT_ANY_THROW(circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5));
break;
}
auto circuit = circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5);
ivc.accumulate(circuit);

Expand All @@ -223,9 +215,11 @@ TEST_F(AztecIVCTests, BadProofFailure)
tamper_with_proof(ivc.verification_queue[1].proof); // tamper with second proof
}
}

EXPECT_FALSE(ivc.prove_and_verify());
}

// The IVC fails if the 3rd/FINAL fold proof is tampered with
// The IVC fails to verify if the 3rd/FINAL fold proof is tampered with
{
AztecIVC ivc;
ivc.trace_structure = TraceStructure::SMALL_TEST;
Expand Down
11 changes: 7 additions & 4 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST_F(ClientIVCTests, BasicThree)
};

/**
* @brief Check that the IVC fails if an intermediate fold proof is invalid
* @brief Check that the IVC fails to verify if an intermediate fold proof is invalid
*
*/
TEST_F(ClientIVCTests, BasicFailure)
Expand All @@ -128,10 +128,13 @@ TEST_F(ClientIVCTests, BasicFailure)
break;
}
}
// Accumulate another circuit; this involves recursive folding verification of the bad proof which throws an error
// because of circuit sizes don't match.

// Accumulate another circuit; this involves recursive folding verification of the bad proof
Builder circuit_2 = create_mock_circuit(ivc);
EXPECT_ANY_THROW(ivc.accumulate(circuit_2));
ivc.accumulate(circuit_2);

// The bad fold proof should result in an invalid witness in the final circuit and the IVC should fail to verify
EXPECT_FALSE(prove_and_verify(ivc));
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@ template <typename Flavor> void OinkRecursiveVerifier_<Flavor>::verify()
CommitmentLabels labels;

FF circuit_size = transcript->template receive_from_prover<FF>(domain_separator + "circuit_size");
FF public_input_size = transcript->template receive_from_prover<FF>(domain_separator + "public_input_size");
FF pub_inputs_offset = transcript->template receive_from_prover<FF>(domain_separator + "pub_inputs_offset");

if (static_cast<uint32_t>(circuit_size.get_value()) != instance->verification_key->circuit_size) {
throw_or_abort("OinkRecursiveVerifier::verify: proof circuit size does not match verification key");
}
if (static_cast<uint32_t>(public_input_size.get_value()) != instance->verification_key->num_public_inputs) {
throw_or_abort("OinkRecursiveVerifier::verify: proof public input size does not match verification key");
}
if (static_cast<uint32_t>(pub_inputs_offset.get_value()) != instance->verification_key->pub_inputs_offset) {
throw_or_abort("OinkRecursiveVerifier::verify: proof public input offset does not match verification key");
}
transcript->template receive_from_prover<FF>(domain_separator + "public_input_size");
transcript->template receive_from_prover<FF>(domain_separator + "pub_inputs_offset");

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1032): Uncomment these once it doesn't cause issues
// with the flows
// ASSERT(static_cast<uint32_t>(circuit_size.get_value()) == key->circuit_size);
// ASSERT(static_cast<uint32_t>(public_input_size.get_value()) == key->num_public_inputs);
// ASSERT(static_cast<uint32_t>(pub_inputs_offset.get_value()) == key->pub_inputs_offset);

std::vector<FF> public_inputs;
for (size_t i = 0; i < instance->verification_key->num_public_inputs; ++i) {
Expand Down

0 comments on commit 6c1d210

Please sign in to comment.