-
Notifications
You must be signed in to change notification settings - Fork 598
fix: make vk metadata actual witnesses #12459
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
Changes from all commits
caa01aa
b76a659
4850c58
6aa925b
ae76566
6691011
36f35e3
e80a744
d781a07
2e9ec7f
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 |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ { | |
| * portability of our circuits. | ||
| */ | ||
| class VerificationKey | ||
| : public VerificationKey_<ECCVMFlavor::PrecomputedEntities<Commitment>, VerifierCommitmentKey> { | ||
| : public VerificationKey_<FF, ECCVMFlavor::PrecomputedEntities<Commitment>, VerifierCommitmentKey> { | ||
|
Contributor
Author
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. for recursive flavors, we use FF, which is the stdlib scalar field of the group. |
||
| public: | ||
| VerificationKey(const size_t circuit_size, const size_t num_public_inputs) | ||
| { | ||
|
|
@@ -108,10 +108,11 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ { | |
| { | ||
| this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>( | ||
| builder, native_key->circuit_size, native_key->pcs_verification_key); | ||
| this->circuit_size = native_key->circuit_size; | ||
| this->log_circuit_size = numeric::get_msb(this->circuit_size); | ||
| this->num_public_inputs = native_key->num_public_inputs; | ||
| this->pub_inputs_offset = native_key->pub_inputs_offset; | ||
| this->circuit_size = FF::from_witness(builder, native_key->circuit_size); | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb. | ||
| this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size)); | ||
|
Contributor
Author
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. probably need constraints between circuit_size and log_circuit_size, or maybe we can just get rid of storing log_circuit_size at all |
||
| this->num_public_inputs = FF::from_witness(builder, native_key->num_public_inputs); | ||
| this->pub_inputs_offset = FF::from_witness(builder, native_key->pub_inputs_offset); | ||
|
|
||
| for (auto [native_commitment, commitment] : zip_view(native_key->get_all(), this->get_all())) { | ||
| commitment = Commitment::from_witness(builder, native_commitment); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ ECCVMRecursiveVerifier_<Flavor>::verify_proof(const ECCVMProof& proof) | |
| commitments.z_perm = transcript->template receive_from_prover<Commitment>(commitment_labels.z_perm); | ||
|
|
||
| // Execute Sumcheck Verifier | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Suspicious get_value(). | ||
|
Contributor
Author
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. added these TODOs in places which I thought were suspicious. |
||
| const size_t log_circuit_size = numeric::get_msb(static_cast<uint32_t>(circuit_size.get_value())); | ||
| auto sumcheck = SumcheckVerifier<Flavor>(log_circuit_size, transcript); | ||
| const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,22 +47,27 @@ template <typename Flavor> void OinkRecursiveVerifier_<Flavor>::verify() | |
| 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"); | ||
|
Contributor
Author
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. this part is irrelevant since it will be rewritten by my other PR
Contributor
Author
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. nvm, it causes BadProofFailure to fail |
||
|
|
||
| if (static_cast<uint32_t>(circuit_size.get_value()) != verification_key->verification_key->circuit_size) { | ||
| if (static_cast<uint32_t>(circuit_size.get_value()) != | ||
| static_cast<uint32_t>(verification_key->verification_key->circuit_size.get_value())) { | ||
| throw_or_abort("OinkRecursiveVerifier::verify: proof circuit size does not match verification key"); | ||
| } | ||
| if (static_cast<uint32_t>(public_input_size.get_value()) != verification_key->verification_key->num_public_inputs) { | ||
| const std::string message = "OinkRecursiveVerifier::verify: proof public input size (" + | ||
| std::to_string(static_cast<uint32_t>(public_input_size.get_value())) + | ||
| ") does not match verification key public input size (" + | ||
| std::to_string(verification_key->verification_key->num_public_inputs) + ")"; | ||
| if (static_cast<uint32_t>(public_input_size.get_value()) != | ||
| static_cast<uint32_t>(verification_key->verification_key->num_public_inputs.get_value())) { | ||
| const std::string message = | ||
| "OinkRecursiveVerifier::verify: proof public input size (" + | ||
| std::to_string(static_cast<uint32_t>(public_input_size.get_value())) + | ||
| ") does not match verification key public input size (" + | ||
| std::to_string(static_cast<uint32_t>(verification_key->verification_key->num_public_inputs.get_value())) + | ||
| ")"; | ||
| throw_or_abort(message); | ||
| } | ||
| if (static_cast<uint32_t>(pub_inputs_offset.get_value()) != verification_key->verification_key->pub_inputs_offset) { | ||
| if (static_cast<uint32_t>(pub_inputs_offset.get_value()) != | ||
| static_cast<uint32_t>(verification_key->verification_key->pub_inputs_offset.get_value())) { | ||
| throw_or_abort("OinkRecursiveVerifier::verify: proof public input offset does not match verification key"); | ||
| } | ||
|
|
||
| std::vector<FF> public_inputs; | ||
| for (size_t i = 0; i < verification_key->verification_key->num_public_inputs; ++i) { | ||
| for (size_t i = 0; i < static_cast<size_t>(static_cast<uint32_t>(public_input_size.get_value())); ++i) { | ||
| public_inputs.emplace_back( | ||
| transcript->template receive_from_prover<FF>(domain_separator + "public_input_" + std::to_string(i))); | ||
| } | ||
|
|
@@ -109,12 +114,13 @@ template <typename Flavor> void OinkRecursiveVerifier_<Flavor>::verify() | |
| } | ||
| } | ||
|
|
||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Suspicious get_value(). | ||
| const FF public_input_delta = compute_public_input_delta<Flavor>( | ||
| public_inputs, | ||
| beta, | ||
| gamma, | ||
| circuit_size, | ||
| static_cast<uint32_t>(verification_key->verification_key->pub_inputs_offset)); | ||
| static_cast<uint32_t>(verification_key->verification_key->pub_inputs_offset.get_value())); | ||
|
|
||
| // Get commitment to permutation and lookup grand products | ||
| commitments.z_perm = transcript->template receive_from_prover<Commitment>(domain_separator + labels.z_perm); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,10 @@ template <IsRecursiveFlavor Flavor_, size_t NUM_> struct RecursiveDeciderVerific | |
| { | ||
| size_t max_log_circuit_size{ 0 }; | ||
| for (auto key : _data) { | ||
| max_log_circuit_size = | ||
| std::max(max_log_circuit_size, static_cast<size_t>(key->verification_key->log_circuit_size)); | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Suspicious get_value. | ||
| max_log_circuit_size = std::max( | ||
| max_log_circuit_size, | ||
| static_cast<size_t>(static_cast<uint32_t>(key->verification_key->log_circuit_size.get_value()))); | ||
|
Contributor
Author
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. should've added the TODO here too |
||
| } | ||
| return max_log_circuit_size; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ std::array<typename Flavor::GroupElement, 2> TranslatorRecursiveVerifier_<Flavor | |
| CommitmentLabels commitment_labels; | ||
|
|
||
| const FF circuit_size = transcript->template receive_from_prover<FF>("circuit_size"); | ||
|
Contributor
Author
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. maybe circuit_size in the eccvm and translator flavors can also be removed from the proof at some point |
||
| if (static_cast<uint32_t>(circuit_size.get_value()) != key->circuit_size) { | ||
| if (static_cast<uint32_t>(circuit_size.get_value()) != static_cast<uint32_t>(key->circuit_size.get_value())) { | ||
| throw_or_abort( | ||
| "TranslatorRecursiveVerifier::verify_proof: proof circuit size does not match verification key!"); | ||
| } | ||
|
|
@@ -103,6 +103,7 @@ std::array<typename Flavor::GroupElement, 2> TranslatorRecursiveVerifier_<Flavor | |
| commitments.z_perm = transcript->template receive_from_prover<Commitment>(commitment_labels.z_perm); | ||
|
|
||
| // Execute Sumcheck Verifier | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Suspicious get_value(). | ||
| const size_t log_circuit_size = numeric::get_msb(static_cast<uint32_t>(circuit_size.get_value())); | ||
| auto sumcheck = Sumcheck(log_circuit_size, transcript); | ||
| FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ class MegaFlavor { | |
| * @brief A base class labelling precomputed entities and (ordered) subsets of interest. | ||
| * @details Used to build the proving key and verification key. | ||
| */ | ||
| template <typename DataType_> class PrecomputedEntities : public PrecomputedEntitiesBase { | ||
| template <typename DataType_> class PrecomputedEntities { | ||
| public: | ||
| bool operator==(const PrecomputedEntities&) const = default; | ||
| using DataType = DataType_; | ||
|
|
@@ -429,7 +429,7 @@ class MegaFlavor { | |
| * circuits. | ||
| * @todo TODO(https://github.com/AztecProtocol/barretenberg/issues/876) | ||
| */ | ||
| class VerificationKey : public VerificationKey_<PrecomputedEntities<Commitment>, VerifierCommitmentKey> { | ||
| class VerificationKey : public VerificationKey_<uint64_t, PrecomputedEntities<Commitment>, VerifierCommitmentKey> { | ||
|
Contributor
Author
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. for native flavors, we use uint64_t |
||
| public: | ||
| // Data pertaining to transfer of databus return data via public inputs of the proof being recursively verified | ||
| DatabusPropagationData databus_propagation_data; | ||
|
|
||
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.
I have no idea if this change is necessary. In the plonk recursive VK, this is just a bool...
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.
also unsure for the PairingPointAccumulatorPubInputIndices and some of the other stuff too.