-
Notifications
You must be signed in to change notification settings - Fork 598
feat: translation evaluations with zk #12222
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
ead1afc
d9d9a1f
5504006
acc8a51
4d4349e
3aa169b
6628ec7
a51d492
bfaab51
b4eaa6b
b21a2b2
bcc3284
ae74a81
8af3dbf
7d8e932
a18fc20
98f29b0
9eec4c3
7d2a2ee
bfe9f09
896cd45
8731224
e08c1fe
790a71d
c9b6d5f
44ea7b1
e1704c7
f449343
2b498f0
77fc71d
e5aab7d
8bad944
5285563
3112079
80f3630
233b355
06efe1f
471a9ad
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 |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ template <typename Flavor> class SmallSubgroupIPATest : public ::testing::Test { | |
|
|
||
| // A helper to evaluate the four IPA witness polynomials at x, x*g, x, x | ||
| std::array<FF, NUM_SMALL_IPA_EVALUATIONS> evaluate_small_ipa_witnesses( | ||
| const std::array<Polynomial<FF>, 4>& witness_polynomials) | ||
| const std::array<Polynomial<FF>, NUM_SMALL_IPA_EVALUATIONS>& witness_polynomials) | ||
| { | ||
| // Hard-coded pattern of evaluation: (x, x*g, x, x) | ||
| return { witness_polynomials[0].evaluate(evaluation_challenge), | ||
|
|
@@ -289,25 +289,19 @@ TYPED_TEST(SmallSubgroupIPATest, TranslationMaskingTermConsistency) | |
| const FF evaluation_challenge_x = FF::random_element(); | ||
| const FF batching_challenge_v = FF::random_element(); | ||
|
|
||
| const FF claimed_inner_product = Prover::compute_claimed_translation_inner_product( | ||
|
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. no need to compute the claimed inner product separately since it's done inside the constructor |
||
| translation_data, evaluation_challenge_x, batching_challenge_v); | ||
|
|
||
| Prover small_subgroup_ipa_prover(translation_data, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| claimed_inner_product, | ||
| prover_transcript, | ||
| ck); | ||
| Prover small_subgroup_ipa_prover( | ||
| translation_data, evaluation_challenge_x, batching_challenge_v, prover_transcript, ck); | ||
| small_subgroup_ipa_prover.prove(); | ||
|
|
||
| const std::array<FF, NUM_SMALL_IPA_EVALUATIONS> small_ipa_evaluations = | ||
| this->evaluate_small_ipa_witnesses(small_subgroup_ipa_prover.get_witness_polynomials()); | ||
|
|
||
| bool consistency_checked = Verifier::check_eccvm_evaluations_consistency(small_ipa_evaluations, | ||
| this->evaluation_challenge, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| claimed_inner_product); | ||
| bool consistency_checked = | ||
| Verifier::check_eccvm_evaluations_consistency(small_ipa_evaluations, | ||
| this->evaluation_challenge, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| small_subgroup_ipa_prover.claimed_inner_product); | ||
|
|
||
| EXPECT_TRUE(consistency_checked); | ||
| } | ||
|
|
@@ -348,24 +342,19 @@ TYPED_TEST(SmallSubgroupIPATest, TranslationMaskingTermConsistencyFailure) | |
| const FF evaluation_challenge_x = FF::random_element(); | ||
| const FF batching_challenge_v = FF::random_element(); | ||
|
|
||
| const FF claimed_inner_product = FF::random_element(); | ||
|
|
||
| Prover small_subgroup_ipa_prover(translation_data, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| claimed_inner_product, | ||
| prover_transcript, | ||
| ck); | ||
| Prover small_subgroup_ipa_prover( | ||
| translation_data, evaluation_challenge_x, batching_challenge_v, prover_transcript, ck); | ||
| small_subgroup_ipa_prover.prove(); | ||
|
|
||
| const std::array<FF, NUM_SMALL_IPA_EVALUATIONS> small_ipa_evaluations = | ||
| this->evaluate_small_ipa_witnesses(small_subgroup_ipa_prover.get_witness_polynomials()); | ||
|
|
||
| bool consistency_checked = Verifier::check_eccvm_evaluations_consistency(small_ipa_evaluations, | ||
| this->evaluation_challenge, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| claimed_inner_product); | ||
| bool consistency_checked = | ||
| Verifier::check_eccvm_evaluations_consistency(small_ipa_evaluations, | ||
| this->evaluation_challenge, | ||
| evaluation_challenge_x, | ||
| batching_challenge_v, | ||
| /*tampered claimed inner product = */ FF::random_element()); | ||
|
|
||
| EXPECT_TRUE(!consistency_checked); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #pragma once | ||
|
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. It makes sense to isolate other methods shared by prover and verifier, decided to not pollute this PR with such changes |
||
|
|
||
| #include "barretenberg/common/ref_array.hpp" | ||
| #include "barretenberg/constants.hpp" | ||
|
|
||
| #include <array> | ||
| #include <string> | ||
|
|
||
| namespace bb { | ||
|
|
||
| /** | ||
| * @brief Shared by Prover and Verifier. `label_prefix` is either `Libra:` or `Translation:`. | ||
| */ | ||
| inline std::array<std::string, NUM_SMALL_IPA_EVALUATIONS> get_evaluation_labels(const std::string& label_prefix) | ||
iakovenkos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| return { label_prefix + "concatenation_eval", | ||
| label_prefix + "grand_sum_shift_eval", | ||
| label_prefix + "grand_sum_eval", | ||
| label_prefix + "quotient_eval" }; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief The verification of Grand Sum Identity requires the evaluations G(r), A(g * r), A(r), Q(r). Shared by Prover | ||
| * and Verifier. | ||
| */ | ||
| template <typename FF> | ||
| inline std::array<FF, NUM_SMALL_IPA_EVALUATIONS> compute_evaluation_points(const FF& small_ipa_evaluation_challenge, | ||
| const FF& subgroup_generator) | ||
| { | ||
| return { small_ipa_evaluation_challenge, | ||
| small_ipa_evaluation_challenge * subgroup_generator, | ||
| small_ipa_evaluation_challenge, | ||
| small_ipa_evaluation_challenge }; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Contains commitments to polynomials [G], [A], and [Q]. See \ref SmallSubgroupIPAProver docs. | ||
| */ | ||
| template <typename Commitment> struct SmallSubgroupIPACommitments { | ||
| Commitment concatenated, grand_sum, quotient; | ||
| // The grand sum commitment is returned twice since we are opening the corresponding polynomial at 2 points. | ||
| RefArray<Commitment, NUM_SMALL_IPA_EVALUATIONS> get_all() | ||
| { | ||
| return { concatenated, grand_sum, grand_sum, quotient }; // {[G], [A], [A], [Q]} | ||
| }; | ||
| }; | ||
| } // namespace bb | ||
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.
realized that the claimed sum could be computed here, makes ECCVMProver integration slightly cleaner