Skip to content

Commit

Permalink
construct proofs in all rec v tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ledwards2225 committed Nov 30, 2023
1 parent a2aa9ac commit cf12dac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,37 +190,36 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi
RecursiveVerifier verifier(&outer_circuit, verification_key);
auto pairing_points = verifier.verify_proof(inner_proof);

// Check the recursive verifier circuit
// Check for a failure flag in the recursive verifier circuit
EXPECT_EQ(outer_circuit.failed(), false) << outer_circuit.err();
EXPECT_TRUE(outer_circuit.check_circuit());

// { // Construct and verify a proof of the recursive verifier circuit
// auto composer = get_composer<OuterBuilder>();
// auto instance = composer.create_instance(outer_circuit);
// auto prover = composer.create_prover(instance);
// auto verifier = composer.create_verifier(instance);
// auto proof = prover.construct_proof();
// bool verified = verifier.verify_proof(proof);
// ASSERT(verified);
// }

// Additional check 1: Perform native verification then perform the pairing on
// the outputs of the recursive verifier and check that the result agrees.

// Check 1: Perform native verification then perform the pairing on the outputs of the recursive
// verifier and check that the result agrees.
auto native_verifier = inner_composer.create_verifier(instance);
auto native_result = native_verifier.verify_proof(inner_proof);
auto recursive_result = native_verifier.pcs_verification_key->pairing_check(pairing_points[0].get_value(),
pairing_points[1].get_value());
EXPECT_EQ(recursive_result, native_result);

// Additional check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring
// Check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring
// the manifests produced by each agree.
auto recursive_manifest = verifier.transcript.get_manifest();
auto native_manifest = native_verifier.transcript.get_manifest();
// recursive_manifest.print();
// native_manifest.print();
for (size_t i = 0; i < recursive_manifest.size(); ++i) {
EXPECT_EQ(recursive_manifest[i], native_manifest[i]);
}

// Check 3: Construct and verify a proof of the recursive verifier circuit
{
auto composer = get_composer<OuterBuilder>();
auto instance = composer.create_instance(outer_circuit);
auto prover = composer.create_prover(instance);
auto verifier = composer.create_verifier(instance);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

ASSERT(verified);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,47 +174,36 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te
RecursiveVerifier verifier(&outer_circuit, verification_key);
auto pairing_points = verifier.verify_proof(inner_proof);

// Check the recursive verifier circuit
// Check for a failure flag in the recursive verifier circuit
EXPECT_EQ(outer_circuit.failed(), false) << outer_circuit.err();
// EXPECT_TRUE(outer_circuit.check_circuit());

{ // Construct and verify a proof of the recursive verifier circuit
auto composer = get_composer<OuterBuilder>();
auto instance = composer.create_instance(outer_circuit);
auto prover = composer.create_prover(instance);
auto verifier = composer.create_verifier(instance);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);
(void)verified;

auto prover_manifest = prover.transcript.get_manifest();
auto verifier_manifest = verifier.transcript.get_manifest();
// prover_manifest.print();
// verifier_manifest.print();
for (size_t i = 0; i < prover_manifest.size(); ++i) {
EXPECT_EQ(prover_manifest[i], verifier_manifest[i]);
}

ASSERT(verified);
}

// Additional check 1: Perform native verification then perform the pairing on the outputs of the recursive
// Check 1: Perform native verification then perform the pairing on the outputs of the recursive
// verifier and check that the result agrees.
auto native_verifier = inner_composer.create_verifier(instance);
auto native_result = native_verifier.verify_proof(inner_proof);
auto recursive_result = native_verifier.pcs_verification_key->pairing_check(pairing_points[0].get_value(),
pairing_points[1].get_value());
EXPECT_EQ(recursive_result, native_result);

// Additional check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring
// Check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring
// the manifests produced by each agree.
auto recursive_manifest = verifier.transcript.get_manifest();
auto native_manifest = native_verifier.transcript.get_manifest();
// recursive_manifest.print();
// native_manifest.print();
for (size_t i = 0; i < recursive_manifest.size(); ++i) {
EXPECT_EQ(recursive_manifest[i], native_manifest[i]);
}

// Check 3: Construct and verify a proof of the recursive verifier circuit
{
auto composer = get_composer<OuterBuilder>();
auto instance = composer.create_instance(outer_circuit);
auto prover = composer.create_prover(instance);
auto verifier = composer.create_verifier(instance);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

ASSERT(verified);
}
}

/**
Expand Down

0 comments on commit cf12dac

Please sign in to comment.