-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Remove the VerificationKey
from ProverInstance
#4908
Changes from 4 commits
aae675e
abb67f1
38107b1
aa35587
23152c6
a41cc3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
using RecursiveFlavor = UltraRecursiveFlavor_<BuilderType>; | ||
using RecursiveVerifier = UltraRecursiveVerifier_<RecursiveFlavor>; | ||
using OuterBuilder = BuilderType; | ||
using VerificationKey = typename RecursiveVerifier::VerificationKey; | ||
|
||
// Helper for getting composer for prover/verifier of recursive (outer) circuit | ||
template <typename BuilderT> static auto get_outer_composer() | ||
|
@@ -133,8 +132,7 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
// Compute native verification key | ||
InnerComposer inner_composer; | ||
auto instance = inner_composer.create_prover_instance(inner_circuit); | ||
auto prover = inner_composer.create_prover(instance); // A prerequisite for computing VK | ||
auto verification_key = instance->verification_key; | ||
auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(instance->proving_key); | ||
// Instantiate the recursive verifier using the native verification key | ||
RecursiveVerifier verifier{ &outer_circuit, verification_key }; | ||
|
||
|
@@ -149,7 +147,8 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
} | ||
|
||
/** | ||
* @brief Construct a recursive verification circuit for the proof of an inner circuit then call check_circuit on it | ||
* @brief Construct a recursive verification circuit for the proof of an inner circuit then call check_circuit on | ||
it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried running format.sh? This doesn't seem to be in line with our formatting, but I'm not sure |
||
* | ||
*/ | ||
static void test_recursive_verification() | ||
|
@@ -164,9 +163,11 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
auto inner_prover = inner_composer.create_prover(instance); | ||
auto inner_proof = inner_prover.construct_proof(); | ||
|
||
auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(instance->proving_key); | ||
|
||
// Create a recursive verification circuit for the proof of the inner circuit | ||
OuterBuilder outer_circuit; | ||
RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; | ||
RecursiveVerifier verifier{ &outer_circuit, verification_key }; | ||
auto pairing_points = verifier.verify_proof(inner_proof); | ||
info("Recursive Verifier Ultra: num gates = ", outer_circuit.num_gates); | ||
|
||
|
@@ -175,7 +176,7 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
|
||
// 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->verification_key); | ||
auto native_verifier = inner_composer.create_verifier(verification_key); | ||
auto native_result = native_verifier.verify_proof(inner_proof); | ||
auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(), | ||
pairing_points[1].get_value()); | ||
|
@@ -194,7 +195,8 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
auto composer = get_outer_composer<OuterBuilder>(); | ||
auto instance = composer.create_prover_instance(outer_circuit); | ||
auto prover = composer.create_prover(instance); | ||
auto verifier = composer.create_verifier(instance->verification_key); | ||
auto verifier_instance = composer.create_verifier_instance(instance); | ||
auto verifier = composer.create_verifier(verifier_instance->verification_key); | ||
auto proof = prover.construct_proof(); | ||
bool verified = verifier.verify_proof(proof); | ||
|
||
|
@@ -204,7 +206,8 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
|
||
/** | ||
* @brief Construct a verifier circuit for a proof whose data has been tampered with. Expect failure | ||
* TODO(bberg #656): For now we get a "bad" proof by arbitrarily tampering with bits in a valid proof. It would be | ||
* TODO(bberg #656): For now we get a "bad" proof by arbitrarily tampering with bits in a valid proof. It would | ||
be | ||
* much nicer to explicitly change meaningful components, e.g. such that one of the multilinear evaluations is | ||
* wrong. This is difficult now but should be straightforward if the proof is a struct. | ||
*/ | ||
|
@@ -226,9 +229,11 @@ template <typename BuilderType> class RecursiveVerifierTest : public testing::Te | |
inner_prover.transcript->serialize_full_transcript(); | ||
inner_proof = inner_prover.export_proof(); | ||
|
||
auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(instance->proving_key); | ||
|
||
// Create a recursive verification circuit for the proof of the inner circuit | ||
OuterBuilder outer_circuit; | ||
RecursiveVerifier verifier{ &outer_circuit, instance->verification_key }; | ||
RecursiveVerifier verifier{ &outer_circuit, verification_key }; | ||
verifier.verify_proof(inner_proof); | ||
|
||
// We expect the circuit check to fail due to the bad proof | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,6 @@ template <class Flavor> class ProverInstance_ { | |
|
||
sorted_polynomials = construct_sorted_list_polynomials<Flavor>(circuit, dyadic_circuit_size); | ||
|
||
verification_key = std::make_shared<VerificationKey>(proving_key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the verification key was removed from the prover, should we keep the field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's correct, we don't need to, removed |
||
commitment_key = proving_key->commitment_key; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the recursive verifiers (except PG which doesnt have inner and outer),
get_outer_composer
uses a constexpr if clause to figure out the right type for the composer. Before, this was enough, as we were computing the verfication key through the composer. The most simple way to get the right type for teh verification key here is to create aVerifierInstance
to limit the scope of this PR, as we are planning to refactor the recursive verfiers anyways.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a "TODO" just in case?