-
Notifications
You must be signed in to change notification settings - Fork 235
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
feat: IPA Accumulator in Builder #9846
base: master
Are you sure you want to change the base?
Changes from all commits
4b2f1cd
3a6bdad
ed12d5b
b948683
beb03a4
39b0b76
20a6933
b3ebdeb
98e8018
87163af
f1a429d
c86252b
cb40e08
68e8acb
3c83148
ee98551
113ba04
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. | ||
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,21 @@ 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()))}; | ||
// Add IPA Claim to public inputs of circuit | ||
Builder* builder = r.get_context(); | ||
builder->add_ipa_claim(output_claim.get_witness_indices()); | ||
|
||
// 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."); | ||
|
||
IPA<NativeCurve>::compute_opening_proof(ck, { challenge_poly, opening_pair }, prover_transcript); | ||
|
||
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, | ||
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... |
||
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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ template <typename FF, typename CommitmentKey_> class ProvingKey_ { | |
public: | ||
size_t circuit_size; | ||
bool contains_pairing_point_accumulator; | ||
PairingPointAccumPubInputIndices pairing_point_accumulator_public_input_indices; | ||
PairingPointAccumulatorPubInputIndices pairing_point_accumulator_public_input_indices; | ||
bb::EvaluationDomain<FF> evaluation_domain; | ||
std::shared_ptr<CommitmentKey_> commitment_key; | ||
size_t num_public_inputs; | ||
|
@@ -152,7 +152,7 @@ class VerificationKey_ : public PrecomputedCommitments { | |
using Commitment = typename VerifierCommitmentKey::Commitment; | ||
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key; | ||
bool contains_pairing_point_accumulator = false; | ||
PairingPointAccumPubInputIndices pairing_point_accumulator_public_input_indices = {}; | ||
PairingPointAccumulatorPubInputIndices pairing_point_accumulator_public_input_indices = {}; | ||
uint64_t pub_inputs_offset = 0; | ||
|
||
bool operator==(const VerificationKey_&) const = default; | ||
|
@@ -379,6 +379,9 @@ MegaZKRecursiveFlavor_<UltraCircuitBuilder>>; | |
template <typename T> | ||
concept HasDataBus = IsMegaFlavor<T>; | ||
|
||
template <typename T> | ||
concept DoesRecursiveIPA = IsAnyOf<T, UltraFlavor, UltraFlavorWithZK>; | ||
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. not ultra keccak because that will only be called on the root rollup circuit which will just verify the IPA claim. |
||
|
||
template <typename T> | ||
concept IsRecursiveFlavor = IsAnyOf<T, UltraRecursiveFlavor_<UltraCircuitBuilder>, | ||
UltraRecursiveFlavor_<MegaCircuitBuilder>, | ||
|
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.
the evaluation is always 0 for our case I believe, so it doesn't have any witness indices