-
Notifications
You must be signed in to change notification settings - Fork 611
feat: IPA Accumulator in Builder #9846
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
4b2f1cd
3a6bdad
ed12d5b
b948683
beb03a4
39b0b76
20a6933
b3ebdeb
98e8018
87163af
f1a429d
c86252b
cb40e08
68e8acb
3c83148
ee98551
113ba04
36a7cf1
bc1e688
ef772ee
1c7e792
d1cd1cd
9d34263
e260b87
dfc0b81
ea3f929
f8e9197
2adab61
b96488c
346eba8
0f35e51
790fa11
13de7ef
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 |
|---|---|---|
|
|
@@ -749,20 +749,21 @@ template <typename Curve_> class IPA { | |
| } | ||
|
|
||
| /** | ||
| * @brief Takes two IPA claims and accumulates them into 1 IPA claim. | ||
| * @details We create an IPA accumulator by running the IPA recursive verifier on each claim. Then, we generate challenges, and use these challenges to compute the new accumulator. We also create the accumulated polynomial. | ||
| * @brief Takes two IPA claims and accumulates them into 1 IPA claim. Also computes IPA proof for the claim. | ||
|
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. modified so that accumulate just returns the IPA proof directly |
||
| * @details We create an IPA accumulator by running the IPA recursive verifier on each claim. Then, we generate challenges, and use these challenges to compute the new accumulator. We also create the accumulated polynomial, and generate the IPA proof for the accumulated claim. | ||
| * More details are described here: https://hackmd.io/IXoLIPhVT_ej8yhZ_Ehvuw?both. | ||
| * | ||
| * @param verifier_ck | ||
| * @param transcript_1 | ||
| * @param claim_1 | ||
| * @param transcript_2 | ||
| * @param claim_2 | ||
| * @return std::pair<OpeningClaim<Curve>, Polynomial<bb::fq>> | ||
| * @return std::pair<OpeningClaim<Curve>, HonkProof> | ||
| */ | ||
| static std::pair<OpeningClaim<Curve>, Polynomial<bb::fq>> accumulate(auto& transcript_1, OpeningClaim<Curve> claim_1, auto& transcript_2, OpeningClaim<Curve> claim_2) | ||
| static std::pair<OpeningClaim<Curve>, HonkProof> accumulate(const std::shared_ptr<CommitmentKey<curve::Grumpkin>>& ck, auto& transcript_1, OpeningClaim<Curve> claim_1, auto& transcript_2, OpeningClaim<Curve> claim_2) | ||
| requires Curve::is_stdlib_type | ||
| { | ||
| using NativeCurve = curve::Grumpkin; | ||
| using Builder = typename Curve::Builder; | ||
| // Step 1: Run the verifier for each IPA instance | ||
| VerifierAccumulator pair_1 = reduce_verify(claim_1, transcript_1); | ||
|
|
@@ -793,7 +794,23 @@ template <typename Curve_> class IPA { | |
| for (Fr u_inv_i : pair_2.u_challenges_inv) { | ||
| native_u_challenges_inv_2.push_back(bb::fq(u_inv_i.get_value())); | ||
| } | ||
| return {output_claim, create_challenge_poly(uint32_t(pair_1.log_poly_length.get_value()), native_u_challenges_inv_1, uint32_t(pair_2.log_poly_length.get_value()), native_u_challenges_inv_2, fq(alpha.get_value()))}; | ||
|
|
||
| // Compute proof for the claim | ||
| auto prover_transcript = std::make_shared<NativeTranscript>(); | ||
| const OpeningPair<NativeCurve> opening_pair{ bb::fq(output_claim.opening_pair.challenge.get_value()), | ||
| bb::fq(output_claim.opening_pair.evaluation.get_value()) }; | ||
| Polynomial<fq> challenge_poly = create_challenge_poly(uint32_t(pair_1.log_poly_length.get_value()), native_u_challenges_inv_1, uint32_t(pair_2.log_poly_length.get_value()), native_u_challenges_inv_2, fq(alpha.get_value())); | ||
|
|
||
| ASSERT(challenge_poly.evaluate(opening_pair.challenge) == opening_pair.evaluation && "Opening claim does not hold for challenge polynomial."); | ||
|
Contributor
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. Just checked that the string evaluates to true... nice trick. |
||
|
|
||
| IPA<NativeCurve>::compute_opening_proof(ck, { challenge_poly, opening_pair }, prover_transcript); | ||
|
|
||
| // Since we know this circuit will not have any more IPA claims to accumulate, add IPA Claim to public inputs of circuit and add the proof to the builder. | ||
| Builder* builder = r.get_context(); | ||
| builder->add_ipa_claim(output_claim.get_witness_indices()); | ||
| builder->ipa_proof = prover_transcript->proof_data; | ||
|
|
||
| return {output_claim, prover_transcript->proof_data}; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,8 @@ using namespace bb::join_split_example::proofs::notes::native; | |
| using key_pair = join_split_example::fixtures::grumpkin_key_pair; | ||
|
|
||
| auto create_account_leaf_data(fr const& account_alias_hash, | ||
| grumpkin::g1::affine_element const& owner_key, | ||
| grumpkin::g1::affine_element const& signing_key) | ||
| bb::grumpkin::g1::affine_element const& owner_key, | ||
|
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. had to add namespace stuff to avoid ambiguous errors...
Contributor
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. Hm, surprised by that. |
||
| bb::grumpkin::g1::affine_element const& signing_key) | ||
| { | ||
| return notes::native::account::account_note{ account_alias_hash, owner_key, signing_key }.commit(); | ||
| } | ||
|
|
@@ -869,7 +869,7 @@ TEST_P(test_allow_chain_to_other_users_fail, ) | |
| { | ||
| join_split_tx tx = simple_setup(); | ||
| tx.allow_chain = GetParam(); | ||
| tx.output_note[tx.allow_chain - 1].owner = grumpkin::g1::element::random_element(); // i.e. not owned by self. | ||
| tx.output_note[tx.allow_chain - 1].owner = bb::grumpkin::g1::element::random_element(); // i.e. not owned by self. | ||
| auto result = sign_and_verify_logic(tx, user.owner); | ||
| EXPECT_FALSE(result.valid); | ||
| EXPECT_EQ(result.err, "inter-user chaining disallowed"); | ||
|
|
@@ -1028,7 +1028,7 @@ TEST_F(join_split_tests, test_total_output_value_larger_than_total_input_value_f | |
| TEST_F(join_split_tests, test_different_input_note_owners_fails) | ||
| { | ||
| join_split_tx tx = simple_setup({ 1, 2 }); | ||
| tx.input_note[0].owner = grumpkin::g1::affine_element::hash_to_curve({ 1 }); | ||
| tx.input_note[0].owner = bb::grumpkin::g1::affine_element::hash_to_curve({ 1 }); | ||
|
|
||
| auto result = sign_and_verify_logic(tx, user.owner); | ||
| EXPECT_FALSE(result.valid); | ||
|
|
@@ -1073,7 +1073,7 @@ TEST_F(join_split_tests, test_different_note_account_required_vs_account_require | |
| TEST_F(join_split_tests, test_wrong_input_note_owner_fails) | ||
| { | ||
| join_split_tx tx = simple_setup(); | ||
| tx.input_note[0].owner = grumpkin::g1::element::random_element(); | ||
| tx.input_note[0].owner = bb::grumpkin::g1::element::random_element(); | ||
| tx.input_note[1].owner = tx.input_note[0].owner; | ||
|
|
||
| auto result = sign_and_verify_logic(tx, user.owner); | ||
|
|
@@ -1084,8 +1084,8 @@ TEST_F(join_split_tests, test_wrong_input_note_owner_fails) | |
| TEST_F(join_split_tests, test_random_output_note_owners) | ||
| { | ||
| join_split_tx tx = simple_setup(); | ||
| tx.output_note[0].owner = grumpkin::g1::element::random_element(); | ||
| tx.output_note[1].owner = grumpkin::g1::element::random_element(); | ||
| tx.output_note[0].owner = bb::grumpkin::g1::element::random_element(); | ||
| tx.output_note[1].owner = bb::grumpkin::g1::element::random_element(); | ||
|
|
||
| EXPECT_TRUE(sign_and_verify_logic(tx, user.owner).valid); | ||
| } | ||
|
|
@@ -1097,7 +1097,7 @@ TEST_F(join_split_tests, test_random_output_note_owners) | |
| TEST_F(join_split_tests, test_wrong_account_private_key_fails) | ||
| { | ||
| join_split_tx tx = simple_setup(); | ||
| tx.account_private_key = grumpkin::fr::random_element(); | ||
| tx.account_private_key = bb::grumpkin::fr::random_element(); | ||
|
|
||
| auto result = sign_and_verify_logic(tx, user.owner); | ||
| EXPECT_FALSE(result.valid); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.