Skip to content

Commit c53f4cf

Browse files
authored
feat: ultra rollup flows (#10162)
Adds new flows to bb main for UltraRollupFlavor. Modifies honk recursion constraint to be able to extract IPA claims and call accumulate on them. closes AztecProtocol/barretenberg#1153
1 parent 4a38edf commit c53f4cf

File tree

12 files changed

+67
-31
lines changed

12 files changed

+67
-31
lines changed

barretenberg/cpp/src/barretenberg/bb/main.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,12 @@ int main(int argc, char* argv[])
14651465
} else if (command == "prove_ultra_honk_output_all") {
14661466
std::string output_path = get_option(args, "-o", "./proofs");
14671467
prove_honk_output_all<UltraFlavor>(bytecode_path, witness_path, output_path, recursive);
1468+
} else if (command == "prove_ultra_rollup_honk_output_all") {
1469+
std::string output_path = get_option(args, "-o", "./proofs/proof");
1470+
prove_honk_output_all<UltraRollupFlavor>(bytecode_path, witness_path, output_path, recursive);
1471+
} else if (command == "prove_ultra_keccak_honk_output_all") {
1472+
std::string output_path = get_option(args, "-o", "./proofs/proof");
1473+
prove_honk_output_all<UltraKeccakFlavor>(bytecode_path, witness_path, output_path, recursive);
14681474
} else if (command == "prove_mega_honk_output_all") {
14691475
std::string output_path = get_option(args, "-o", "./proofs");
14701476
prove_honk_output_all<MegaFlavor>(bytecode_path, witness_path, output_path, recursive);
@@ -1526,9 +1532,9 @@ int main(int argc, char* argv[])
15261532
} else if (command == "prove_ultra_keccak_honk") {
15271533
std::string output_path = get_option(args, "-o", "./proofs/proof");
15281534
prove_honk<UltraKeccakFlavor>(bytecode_path, witness_path, output_path, recursive);
1529-
} else if (command == "prove_ultra_keccak_honk_output_all") {
1535+
} else if (command == "prove_ultra_rollup_honk") {
15301536
std::string output_path = get_option(args, "-o", "./proofs/proof");
1531-
prove_honk_output_all<UltraKeccakFlavor>(bytecode_path, witness_path, output_path, recursive);
1537+
prove_honk<UltraRollupFlavor>(bytecode_path, witness_path, output_path, recursive);
15321538
} else if (command == "verify_ultra_honk") {
15331539
return verify_honk<UltraFlavor>(proof_path, vk_path) ? 0 : 1;
15341540
} else if (command == "verify_ultra_keccak_honk") {
@@ -1539,6 +1545,9 @@ int main(int argc, char* argv[])
15391545
} else if (command == "write_vk_ultra_keccak_honk") {
15401546
std::string output_path = get_option(args, "-o", "./target/vk");
15411547
write_vk_honk<UltraKeccakFlavor>(bytecode_path, output_path, recursive);
1548+
} else if (command == "write_vk_ultra_rollup_honk") {
1549+
std::string output_path = get_option(args, "-o", "./target/vk");
1550+
write_vk_honk<UltraRollupFlavor>(bytecode_path, output_path, recursive);
15421551
} else if (command == "prove_mega_honk") {
15431552
std::string output_path = get_option(args, "-o", "./proofs/proof");
15441553
prove_honk<MegaFlavor>(bytecode_path, witness_path, output_path, recursive);
@@ -1553,12 +1562,15 @@ int main(int argc, char* argv[])
15531562
} else if (command == "vk_as_fields_ultra_honk") {
15541563
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
15551564
vk_as_fields_honk<UltraFlavor>(vk_path, output_path);
1556-
} else if (command == "vk_as_fields_mega_honk") {
1557-
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
1558-
vk_as_fields_honk<MegaFlavor>(vk_path, output_path);
15591565
} else if (command == "vk_as_fields_ultra_keccak_honk") {
15601566
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
15611567
vk_as_fields_honk<UltraKeccakFlavor>(vk_path, output_path);
1568+
} else if (command == "vk_as_fields_ultra_rollup_honk") {
1569+
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
1570+
vk_as_fields_honk<UltraRollupFlavor>(vk_path, output_path);
1571+
} else if (command == "vk_as_fields_mega_honk") {
1572+
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
1573+
vk_as_fields_honk<MegaFlavor>(vk_path, output_path);
15621574
} else {
15631575
std::cerr << "Unknown command: " << command << "\n";
15641576
return 1;

barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ template <typename Curve> class OpeningClaim {
6060
opening_pair.challenge.binary_basis_limbs[1].element.normalize().witness_index,
6161
opening_pair.challenge.binary_basis_limbs[2].element.normalize().witness_index,
6262
opening_pair.challenge.binary_basis_limbs[3].element.normalize().witness_index,
63-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1153): Uncomment this when we turn the
64-
// eval into witnesses.
65-
// opening_pair.evaluation.binary_basis_limbs[0].element.normalize().witness_index,
66-
// opening_pair.evaluation.binary_basis_limbs[1].element.normalize().witness_index,
67-
// opening_pair.evaluation.binary_basis_limbs[2].element.normalize().witness_index,
68-
// opening_pair.evaluation.binary_basis_limbs[3].element.normalize().witness_index,
63+
opening_pair.evaluation.binary_basis_limbs[0].element.normalize().witness_index,
64+
opening_pair.evaluation.binary_basis_limbs[1].element.normalize().witness_index,
65+
opening_pair.evaluation.binary_basis_limbs[2].element.normalize().witness_index,
66+
opening_pair.evaluation.binary_basis_limbs[3].element.normalize().witness_index,
6967
commitment.x.normalize().witness_index, // no idea if we need these normalize() calls...
7068
commitment.y.normalize().witness_index };
7169
}

barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini_impl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ std::vector<typename GeminiProver_<Curve>::Claim> GeminiProver_<Curve>::prove(
113113
std::move(batched_to_be_shifted),
114114
std::move(batched_concatenated));
115115

116+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constants from primitives.
116117
for (size_t l = 0; l < CONST_PROOF_SIZE_LOG_N - 1; l++) {
117118
if (l < log_n - 1) {
118119
transcript->send_to_verifier("Gemini:FOLD_" + std::to_string(l + 1),

barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ template <typename Curve_> class IPA {
200200

201201
// Iterate for log(poly_degree) rounds to compute the round commitments.
202202
auto log_poly_length = static_cast<size_t>(numeric::get_msb(poly_length));
203+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constant from IPA.
203204
if (log_poly_length > CONST_ECCVM_LOG_N) {
204205
throw_or_abort("IPA log_poly_length is too large");
205206
}

barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ TEST_F(IPATest, AIsZeroAfterOneRound)
159159

160160
// initialize an empty mock transcript
161161
auto transcript = std::make_shared<MockTranscript>();
162+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constant from IPA.
162163
const size_t num_challenges = CONST_ECCVM_LOG_N + 1;
163164
std::vector<uint256_t> random_vector(num_challenges);
164165

barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplemini.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ template <typename Curve> class ShpleminiVerifier_ {
469469

470470
// Initialize batching challenge as ν²
471471
Fr current_batching_challenge = shplonk_batching_challenge.sqr();
472+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constants from primitives.
472473
for (size_t j = 0; j < CONST_PROOF_SIZE_LOG_N - 1; ++j) {
473474
// Compute the scaling factor (ν²⁺ⁱ) / (z + r²⁽ⁱ⁺²⁾) for i = 0, … , d-2
474475
Fr scaling_factor = current_batching_challenge * inverse_vanishing_evals[j + 2];

barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "barretenberg/commitment_schemes/claim.hpp"
33
#include "barretenberg/commitment_schemes/commitment_key.hpp"
44
#include "barretenberg/commitment_schemes/verification_key.hpp"
5+
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
56
#include "barretenberg/transcript/transcript.hpp"
67

78
/**
@@ -224,7 +225,9 @@ template <typename Curve> class ShplonkVerifier_ {
224225
// [G] = [Q] - ∑ⱼ (1/zⱼ(r))[Bⱼ] + ( ∑ⱼ (1/zⱼ(r)) Tⱼ(r) )[1]
225226
// = [Q] - ∑ⱼ (1/zⱼ(r))[Bⱼ] + G₀ [1]
226227
// G₀ = ∑ⱼ ρʲ ⋅ vⱼ / (z − xⱼ )
227-
auto G_commitment_constant = Fr(0);
228+
Fr G_commitment_constant(0);
229+
230+
Fr evaluation(0);
228231

229232
// TODO(#673): The recursive and non-recursive (native) logic is completely separated via the following
230233
// conditional. Much of the logic could be shared, but I've chosen to do it this way since soon the "else"
@@ -274,6 +277,8 @@ template <typename Curve> class ShplonkVerifier_ {
274277
// [G] += G₀⋅[1] = [G] + (∑ⱼ νʲ ⋅ vⱼ / (z − xⱼ ))⋅[1]
275278
G_commitment = GroupElement::batch_mul(commitments, scalars);
276279

280+
// Set evaluation to constant witness
281+
evaluation.convert_constant_to_fixed_witness(z_challenge.get_context());
277282
} else {
278283
// [G] = [Q] - ∑ⱼ νʲ / (z − xⱼ )⋅[fⱼ] + G₀⋅[1]
279284
// = [Q] - [∑ⱼ νʲ ⋅ ( fⱼ(X) − vⱼ) / (z − xⱼ )]
@@ -309,7 +314,7 @@ template <typename Curve> class ShplonkVerifier_ {
309314
}
310315

311316
// Return opening pair (z, 0) and commitment [G]
312-
return { { z_challenge, Fr(0) }, G_commitment };
317+
return { { z_challenge, evaluation }, G_commitment };
313318
};
314319
/**
315320
* @brief Computes \f$ \frac{1}{z - r}, \frac{1}{z+r}, \ldots, \frac{1}{z+r^{2^{d-1}}} \f$.

barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ template <typename Curve> class ZeroMorphProver_ {
421421
transcript->send_to_verifier(label, q_k_commitment);
422422
}
423423
// Add buffer elements to remove log_N dependence in proof
424+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constants from primitives.
424425
for (size_t idx = log_N; idx < CONST_PROOF_SIZE_LOG_N; ++idx) {
425426
auto buffer_element = Commitment::one();
426427
std::string label = "ZM:C_q_" + std::to_string(idx);

barretenberg/cpp/src/barretenberg/plonk_honk_shared/types/aggregation_object_type.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using PairingPointAccumulatorIndices = std::array<uint32_t, PAIRING_POINT_ACCUMU
1414
// of the nested aggregation object.
1515
using PairingPointAccumulatorPubInputIndices = std::array<uint32_t, PAIRING_POINT_ACCUMULATOR_SIZE>;
1616

17-
static constexpr uint32_t IPA_CLAIM_SIZE = 6;
17+
static constexpr uint32_t IPA_CLAIM_SIZE = 10;
1818
using IPAClaimIndices = std::array<uint32_t, IPA_CLAIM_SIZE>;
1919
using IPAClaimPubInputIndices = std::array<uint32_t, IPA_CLAIM_SIZE>;
2020
} // namespace bb

barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
133133
// Extract the IPA claim from the public inputs
134134
// Parse out the nested IPA claim using key->ipa_claim_public_input_indices and runs the native IPA verifier.
135135
if constexpr (HasIPAAccumulator<Flavor>) {
136-
const auto recover_fq_from_public_inputs = [](std::array<FF, 4>& limbs) {
136+
const auto recover_fq_from_public_inputs = [](std::array<FF, Curve::BaseField::NUM_LIMBS>& limbs) {
137137
for (size_t k = 0; k < Curve::BaseField::NUM_LIMBS; k++) {
138138
limbs[k].create_range_constraint(Curve::BaseField::NUM_LIMB_BITS, "limb_" + std::to_string(k));
139139
}
@@ -142,18 +142,25 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
142142

143143
if (verification_key->verification_key->contains_ipa_claim) {
144144
OpeningClaim<grumpkin<Builder>> ipa_claim;
145-
std::array<FF, 4> bigfield_limbs;
146-
for (size_t k = 0; k < 4; k++) {
147-
bigfield_limbs[k] =
145+
std::array<FF, Curve::BaseField::NUM_LIMBS> challenge_bigfield_limbs;
146+
for (size_t k = 0; k < Curve::BaseField::NUM_LIMBS; k++) {
147+
challenge_bigfield_limbs[k] =
148148
verification_key
149149
->public_inputs[verification_key->verification_key->ipa_claim_public_input_indices[k]];
150150
}
151-
ipa_claim.opening_pair.challenge = recover_fq_from_public_inputs(bigfield_limbs);
152-
ipa_claim.opening_pair.evaluation = 0;
151+
std::array<FF, Curve::BaseField::NUM_LIMBS> evaluation_bigfield_limbs;
152+
for (size_t k = 0; k < Curve::BaseField::NUM_LIMBS; k++) {
153+
evaluation_bigfield_limbs[k] =
154+
verification_key
155+
->public_inputs[verification_key->verification_key
156+
->ipa_claim_public_input_indices[Curve::BaseField::NUM_LIMBS + k]];
157+
}
158+
ipa_claim.opening_pair.challenge = recover_fq_from_public_inputs(challenge_bigfield_limbs);
159+
ipa_claim.opening_pair.evaluation = recover_fq_from_public_inputs(evaluation_bigfield_limbs);
153160
ipa_claim.commitment = {
154-
verification_key->public_inputs[verification_key->verification_key->ipa_claim_public_input_indices[4]],
155-
verification_key->public_inputs[verification_key->verification_key->ipa_claim_public_input_indices[5]],
156-
false // WORKTODO: make this a witness?
161+
verification_key->public_inputs[verification_key->verification_key->ipa_claim_public_input_indices[8]],
162+
verification_key->public_inputs[verification_key->verification_key->ipa_claim_public_input_indices[9]],
163+
false
157164
};
158165
output.ipa_opening_claim = std::move(ipa_claim);
159166
}

0 commit comments

Comments
 (0)