Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
7add7c7
[empty] Start merge-train. Choo choo.
Jul 25, 2025
042a9bc
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
f5ec98e
chore: remove `logic` operations from `uint` (#15975)
suyash67 Jul 25, 2025
a671f86
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
78021ea
chore: Modify the `MergeVerifier` so that it gets the subtable commit…
federicobarbacovi Jul 25, 2025
bfaaad4
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
43c3219
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
7f9ee70
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
069a1c4
fix: delete tar generated by test-vk-havent-changed script (#15988)
johnathan79717 Jul 25, 2025
95c7e7c
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
b26c28f
chore: replace q_arith with q_3 in memory relation (#15953)
johnathan79717 Jul 25, 2025
01ed70c
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
96868aa
chore: simplify `uint` logic by removing `witness_status` (#15976)
suyash67 Jul 25, 2025
e8bd564
Revert "chore: remove `logic` operations from `uint`" (#15997)
suyash67 Jul 25, 2025
efd3528
Revert "chore: simplify `uint` logic by removing `witness_status`" (#…
suyash67 Jul 25, 2025
fd26dff
feat: Add the last merged table to the public inputs of the hiding ci…
federicobarbacovi Jul 25, 2025
bb77341
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
71d9c68
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
4204b4b
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
32e687a
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
51627bb
Merge branch 'next' into merge-train/barretenberg
Jul 25, 2025
3bb4e9a
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
45132ab
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
fc25483
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
46b3510
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
c18ef5e
chore: combined `uint` audit (#16030)
suyash67 Jul 28, 2025
fde8bc0
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
44c81f4
chore: delete and ignore barretenberg/src/honk/keys/ (#16042)
johnathan79717 Jul 28, 2025
6e8eaec
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
bd0b716
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
b6a8791
Introduce PublicInputComponent for native pub inputs; remove some app…
federicobarbacovi Jul 28, 2025
751fbd8
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
2c9e1c1
Clean up PAIRING_POINTS_SIZE
federicobarbacovi Jul 28, 2025
e27ddf8
Clean up
federicobarbacovi Jul 28, 2025
780ddcd
Fix
federicobarbacovi Jul 28, 2025
e205d2e
fix: Fix tube proof construction (#16052)
federicobarbacovi Jul 28, 2025
8b7989c
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
14d6f62
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
48d8a8e
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
286d5bb
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
3528223
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
280c945
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
6607191
Merge branch 'next' into merge-train/barretenberg
Jul 28, 2025
220bfc9
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
aae3bc3
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
2a1726d
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
841c961
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
d4864ff
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
bc1c08a
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
63f7b79
Merge branch 'next' into merge-train/barretenberg
Jul 29, 2025
6dbbca6
feat: Link successive recursive Merge verifications (#16032)
federicobarbacovi Jul 29, 2025
5fc78be
Merge remote-tracking branch 'origin/merge-train/barretenberg' into f…
federicobarbacovi Jul 29, 2025
83eb43b
Remove appearances of IPA_CLAIM_SIZE
federicobarbacovi Jul 29, 2025
598ff0b
Remove appearances of PAIRING_POINTS_SIZE
federicobarbacovi Jul 29, 2025
dbdbc89
Remove includes
federicobarbacovi Jul 29, 2025
aac8269
Fixes
federicobarbacovi Jul 29, 2025
509138f
Reinstate tests
federicobarbacovi Jul 29, 2025
8384d5c
Clean up
federicobarbacovi Jul 30, 2025
76bee4d
[empty] Start merge-train. Choo choo.
Jul 30, 2025
04b8930
Merge branch 'next' into merge-train/barretenberg
Jul 30, 2025
277a05c
Merge branch 'next' into merge-train/barretenberg
Jul 30, 2025
9de9baf
Merge branch 'next' into merge-train/barretenberg
Jul 30, 2025
905534a
Merge branch 'next' into merge-train/barretenberg
Jul 31, 2025
04beb62
Merge branch 'next' into merge-train/barretenberg
Jul 31, 2025
19f0351
Merge branch 'next' into merge-train/barretenberg
Jul 31, 2025
25cd553
Merge branch 'next' into merge-train/barretenberg
Jul 31, 2025
59bc177
chore: civc tests refactor (#16086)
Jul 31, 2025
ef31ac7
Merge remote-tracking branch 'origin/merge-train/barretenberg' into f…
federicobarbacovi Jul 31, 2025
424c88f
Post merge fixes
federicobarbacovi Jul 31, 2025
8f7f2f2
Fix after merge
federicobarbacovi Jul 31, 2025
77e1b29
Add constants to file
federicobarbacovi Jul 31, 2025
77320f5
[empty] Start merge-train. Choo choo.
Aug 1, 2025
9722dca
Merge branch 'next' into merge-train/barretenberg
Aug 1, 2025
900e0d1
Merge branch 'next' into merge-train/barretenberg
Aug 1, 2025
25252b1
Merge branch 'next' into merge-train/barretenberg
Aug 1, 2025
87c9c16
Merge branch 'next' into merge-train/barretenberg
Aug 1, 2025
3296e7a
chore: add a `PG_TAIL` proof type and queue type (#16156)
kashbrti Aug 1, 2025
0e4391c
Merge branch 'next' into merge-train/barretenberg
Aug 1, 2025
3f036f2
Merge remote-tracking branch 'origin/merge-train/barretenberg' into f…
federicobarbacovi Aug 1, 2025
62aa28e
Move public inputs constants to their own file
federicobarbacovi Aug 1, 2025
66cf61d
Define constants for sizes of special public inputs
federicobarbacovi Aug 4, 2025
041b6f0
Merge remote-tracking branch 'origin/merge-train/barretenberg' into f…
federicobarbacovi Aug 4, 2025
6462691
Clean up
federicobarbacovi Aug 4, 2025
2483e4c
Merge remote-tracking branch 'origin/merge-train/barretenberg' into f…
federicobarbacovi Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "barretenberg/dsl/acir_proofs/honk_contract.hpp"
#include "barretenberg/dsl/acir_proofs/honk_zk_contract.hpp"
#include "barretenberg/honk/proof_system/types/proof.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/special_public_inputs/special_public_inputs.hpp"
#include "barretenberg/srs/global_crs.hpp"

namespace bb {
Expand Down Expand Up @@ -87,16 +87,22 @@ PubInputsProofAndKey<Flavor> _prove(const bool compute_vk,
UltraProver_<Flavor> prover{ proving_key, vk };

Proof concat_pi_and_proof = prover.construct_proof();
size_t num_inner_public_inputs = prover.proving_key->num_public_inputs();
// Loose check that the public inputs contain a pairing point accumulator, doesn't catch everything.
BB_ASSERT_GTE(prover.proving_key->num_public_inputs(),
PAIRING_POINTS_SIZE,
"Public inputs should contain a pairing point accumulator.");
num_inner_public_inputs -= PAIRING_POINTS_SIZE;
if constexpr (HasIPAAccumulator<Flavor>) {
BB_ASSERT_GTE(num_inner_public_inputs, IPA_CLAIM_SIZE, "Public inputs should contain an IPA claim.");
num_inner_public_inputs -= IPA_CLAIM_SIZE;
}
// Compute number of inner public inputs. Perform loose checks that the public inputs contain enough data.
auto num_inner_public_inputs = [&]() {
size_t num_public_inputs = prover.proving_key->num_public_inputs();
if constexpr (HasIPAAccumulator<Flavor>) {
BB_ASSERT_GTE(num_public_inputs,
RollupIO::PUBLIC_INPUTS_SIZE,
"Public inputs should contain a pairing point accumulator and an IPA claim.");
return num_public_inputs - RollupIO::PUBLIC_INPUTS_SIZE;
} else {
BB_ASSERT_GTE(num_public_inputs,
DefaultIO::PUBLIC_INPUTS_SIZE,
"Public inputs should contain a pairing point accumulator.");
return num_public_inputs - DefaultIO::PUBLIC_INPUTS_SIZE;
}
}();

// We split the inner public inputs, which are stored at the front of the proof, from the rest of the proof. Now,
// the "proof" refers to everything except the inner public inputs.
PublicInputsAndProof<Proof> public_inputs_and_proof{
Expand Down
5 changes: 4 additions & 1 deletion barretenberg/cpp/src/barretenberg/api/prove_tube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "barretenberg/common/map.hpp"
#include "barretenberg/honk/proof_system/types/proof.hpp"
#include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp"
#include "barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp"

namespace bb {
/**
Expand All @@ -17,6 +18,8 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)

using Builder = UltraCircuitBuilder;
using StdlibProof = ClientIVCRecursiveVerifier::StdlibProof;
using HidingKernelIO = stdlib::recursion::honk::HidingKernelIO<Builder>;
using RollupIO = stdlib::recursion::honk::RollupIO;

std::string proof_path = output_path + "/proof";

Expand All @@ -34,7 +37,7 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)
// The public inputs in the proof are propagated to the base rollup by making them public inputs of this circuit.
// Exclude the public inputs of the Hiding Kernel: the pairing points are handled separately, the ecc op tables are
// not needed after this point
auto num_inner_public_inputs = vk.mega->num_public_inputs - HidingKernelIO<Builder>::PUBLIC_INPUTS_SIZE;
auto num_inner_public_inputs = vk.mega->num_public_inputs - HidingKernelIO::PUBLIC_INPUTS_SIZE;
for (size_t i = 0; i < num_inner_public_inputs; i++) {
stdlib_proof.mega_proof[i].set_public();
}
Expand Down
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "barretenberg/bbapi/c_bind.hpp"
#include "barretenberg/common/thread.hpp"
#include "barretenberg/flavor/ultra_rollup_flavor.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/srs/factories/native_crs_factory.hpp"
#include "barretenberg/srs/global_crs.hpp"
#include <fstream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp"
#include "barretenberg/dsl/acir_format/serde/witness_stack.hpp"
#include "barretenberg/flavor/mega_flavor.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/ultra_honk/decider_proving_key.hpp"
#include "barretenberg/ultra_honk/ultra_prover.hpp"
#include "barretenberg/ultra_honk/ultra_verifier.hpp"
Expand Down
30 changes: 14 additions & 16 deletions barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#pragma once

#include "barretenberg/commitment_schemes/commitment_key.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/stdlib/primitives/curves/grumpkin.hpp"

Expand Down Expand Up @@ -64,8 +63,10 @@ template <typename Curve> class OpeningClaim {
// commitment to univariate polynomial p(X)
Commitment commitment;

// Size of public inputs representation of an opening claim over Grumpkin
static constexpr size_t PUBLIC_INPUTS_SIZE = IPA_CLAIM_SIZE;
static constexpr bool IS_GRUMPKIN =
std::is_same_v<Curve, curve::Grumpkin> || std::is_same_v<Curve, stdlib::grumpkin<UltraCircuitBuilder>>;
// Size of public inputs representation of an opening claim over Grumpkin: 2 * 4 + 2 = 10
static constexpr size_t PUBLIC_INPUTS_SIZE = IS_GRUMPKIN ? GRUMPKIN_OPENING_CLAIM_SIZE : INVALID_PUBLIC_INPUTS_SIZE;

/**
* @brief Set the witness indices for the opening claim to public
Expand All @@ -91,8 +92,6 @@ template <typename Curve> class OpeningClaim {
const std::span<const stdlib::field_t<Builder>, PUBLIC_INPUTS_SIZE>& limbs)
requires(std::is_same_v<Curve, stdlib::grumpkin<UltraCircuitBuilder>>)
{
BB_ASSERT_EQ(2 * Fr::PUBLIC_INPUTS_SIZE + Commitment::PUBLIC_INPUTS_SIZE, PUBLIC_INPUTS_SIZE);

const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
std::span<const stdlib::field_t<Builder>, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
Expand All @@ -111,19 +110,18 @@ template <typename Curve> class OpeningClaim {
* @note Implemented for native curve::Grumpkin for use with IPA.
*
*/
static OpeningClaim<Curve> reconstruct_from_public(const std::span<const bb::fr, IPA_CLAIM_SIZE>& ipa_claim_limbs)
static OpeningClaim<Curve> reconstruct_from_public(const std::span<const bb::fr, PUBLIC_INPUTS_SIZE>& limbs)
requires(std::is_same_v<Curve, curve::Grumpkin>)
{
size_t index = 0;
std::span<const bb::fr> challenge_limbs = ipa_claim_limbs.subspan(index, FQ_PUBLIC_INPUT_SIZE);
index += FQ_PUBLIC_INPUT_SIZE;
std::span<const bb::fr> evaluation_limbs = ipa_claim_limbs.subspan(index, FQ_PUBLIC_INPUT_SIZE);
index += FQ_PUBLIC_INPUT_SIZE;
std::span<const bb::fr> point_limbs = ipa_claim_limbs.subspan(index, 2 * FR_PUBLIC_INPUTS_SIZE);

auto challenge = fq::reconstruct_from_public(challenge_limbs);
auto evaluation = fq::reconstruct_from_public(evaluation_limbs);
typename Curve::AffineElement commitment = Curve::AffineElement::reconstruct_from_public(point_limbs);
const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
std::span<const bb::fr, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
std::span<const bb::fr, FIELD_SIZE> evaluation_limbs{ limbs.data() + FIELD_SIZE, FIELD_SIZE };
std::span<const bb::fr, COMMITMENT_SIZE> commitment_limbs{ limbs.data() + 2 * FIELD_SIZE, COMMITMENT_SIZE };

Fr challenge = Fr::reconstruct_from_public(challenge_limbs);
Fr evaluation = Fr::reconstruct_from_public(evaluation_limbs);
Commitment commitment = Commitment::reconstruct_from_public(commitment_limbs);

return OpeningClaim<Curve>{ { challenge, evaluation }, commitment };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "barretenberg/commitment_schemes/commitment_key.hpp"
#include "barretenberg/commitment_schemes/verification_key.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/stdlib/primitives/curves/grumpkin.hpp"

Expand All @@ -30,6 +29,8 @@ class PairingPoints {
using VerifierCK = VerifierCommitmentKey<curve::BN254>;

public:
static constexpr size_t PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE;

Point P0 = Point::infinity();
Point P1 = Point::infinity();

Expand All @@ -43,10 +44,13 @@ class PairingPoints {
* @brief Reconstruct the pairing points from limbs stored on the public inputs.
*
*/
static PairingPoints reconstruct_from_public(const std::span<const Fr, PAIRING_POINTS_SIZE>& limbs_in)
static PairingPoints reconstruct_from_public(const std::span<const Fr, PUBLIC_INPUTS_SIZE>& limbs_in)
{
Point P0 = Point::reconstruct_from_public(limbs_in.subspan(0, 2 * FQ_PUBLIC_INPUT_SIZE));
Point P1 = Point::reconstruct_from_public(limbs_in.subspan(2 * FQ_PUBLIC_INPUT_SIZE, 2 * FQ_PUBLIC_INPUT_SIZE));
const std::span<const bb::fr, Point::PUBLIC_INPUTS_SIZE> P0_limbs(limbs_in.data(), Point::PUBLIC_INPUTS_SIZE);
const std::span<const bb::fr, Point::PUBLIC_INPUTS_SIZE> P1_limbs(limbs_in.data() + Point::PUBLIC_INPUTS_SIZE,
Point::PUBLIC_INPUTS_SIZE);
Point P0 = Point::reconstruct_from_public(P0_limbs);
Point P1 = Point::reconstruct_from_public(P1_limbs);

return PairingPoints{ P0, P1 };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "barretenberg/flavor/ultra_recursive_flavor.hpp"
#include "barretenberg/flavor/ultra_rollup_recursive_flavor.hpp"
#include "barretenberg/flavor/ultra_zk_recursive_flavor.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp"
#include "barretenberg/stdlib/pairing_points.hpp"
#include "barretenberg/stdlib/primitives/bigfield/constants.hpp"
Expand Down Expand Up @@ -55,6 +54,9 @@ void create_dummy_vkey_and_proof(typename Flavor::CircuitBuilder& builder,
{
using Builder = typename Flavor::CircuitBuilder;
using NativeFlavor = typename Flavor::NativeFlavor;

static constexpr size_t IPA_CLAIM_SIZE = stdlib::recursion::honk::RollupIO::IpaClaim::PUBLIC_INPUTS_SIZE;

// Set vkey->circuit_size correctly based on the proof size
BB_ASSERT_EQ(proof_size, NativeFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS);
// a lambda that adds dummy commitments (libra and gemini)
Expand Down Expand Up @@ -83,10 +85,8 @@ void create_dummy_vkey_and_proof(typename Flavor::CircuitBuilder& builder,
// Third key field is the pub inputs offset
uint32_t pub_inputs_offset = NativeFlavor::has_zero_row ? 1 : 0;
builder.set_variable(key_fields[offset++].witness_index, pub_inputs_offset);
size_t num_inner_public_inputs = public_inputs_size - bb::PAIRING_POINTS_SIZE;
if constexpr (HasIPAAccumulator<Flavor>) {
num_inner_public_inputs -= bb::IPA_CLAIM_SIZE;
}
size_t num_inner_public_inputs = HasIPAAccumulator<Flavor> ? public_inputs_size - bb::RollupIO::PUBLIC_INPUTS_SIZE
: public_inputs_size - bb::DefaultIO::PUBLIC_INPUTS_SIZE;

for (size_t i = 0; i < Flavor::NUM_PRECOMPUTED_ENTITIES; ++i) {
set_dummy_commitment(offset);
Expand All @@ -110,7 +110,7 @@ void create_dummy_vkey_and_proof(typename Flavor::CircuitBuilder& builder,
// IPA claim
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1392): Don't use random elements here.
if constexpr (HasIPAAccumulator<Flavor>) {
for (size_t i = 0; i < bb::IPA_CLAIM_SIZE; i++) {
for (size_t i = 0; i < IPA_CLAIM_SIZE; i++) {
set_dummy_evaluation(offset);
}
}
Expand Down Expand Up @@ -257,11 +257,13 @@ HonkRecursionConstraintOutput<typename Flavor::CircuitBuilder> create_honk_recur
size_t size_of_proof_with_no_pub_inputs = input.proof.size();
size_t total_num_public_inputs = input.public_inputs.size();
if constexpr (HasIPAAccumulator<Flavor>) {
using RollupIO = stdlib::recursion::honk::RollupIO;
size_of_proof_with_no_pub_inputs -= RollupIO::PUBLIC_INPUTS_SIZE;
total_num_public_inputs += RollupIO::PUBLIC_INPUTS_SIZE;
} else {
size_of_proof_with_no_pub_inputs -= DefaultIO<Builder>::PUBLIC_INPUTS_SIZE;
total_num_public_inputs += DefaultIO<Builder>::PUBLIC_INPUTS_SIZE;
using DefaultIO = stdlib::recursion::honk::DefaultIO<Builder>;
size_of_proof_with_no_pub_inputs -= DefaultIO::PUBLIC_INPUTS_SIZE;
total_num_public_inputs += DefaultIO::PUBLIC_INPUTS_SIZE;
}

create_dummy_vkey_and_proof<Flavor>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "barretenberg/flavor/flavor.hpp"
#include "barretenberg/flavor/ultra_recursive_flavor.hpp"
#include "barretenberg/flavor/ultra_rollup_recursive_flavor.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp"
#include "barretenberg/stdlib/pairing_points.hpp"
#include "barretenberg/stdlib/primitives/bigfield/constants.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "barretenberg/flavor/flavor.hpp"
#include "barretenberg/flavor/ultra_recursive_flavor.hpp"
#include "barretenberg/flavor/ultra_rollup_recursive_flavor.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp"
#include "barretenberg/stdlib/pairing_points.hpp"
#include "barretenberg/stdlib/primitives/bigfield/constants.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/flavor/flavor.hpp"
#include "barretenberg/honk/proof_system/types/proof.hpp"
#include "barretenberg/honk/types/aggregation_object_type.hpp"
#include "barretenberg/serialize/msgpack.hpp"
#include "barretenberg/special_public_inputs/special_public_inputs.hpp"
#include "barretenberg/stdlib/proof/proof.hpp"
#include <barretenberg/common/container.hpp>
#include <cstdint>
Expand Down Expand Up @@ -46,10 +46,9 @@ class ProofSurgeon {

// Get public inputs by cutting them out of the proof
size_t num_public_inputs_to_extract =
static_cast<uint32_t>(verification_key->num_public_inputs) - bb::PAIRING_POINTS_SIZE;
if (ipa_accumulation) {
num_public_inputs_to_extract -= bb::IPA_CLAIM_SIZE;
}
ipa_accumulation
? static_cast<uint32_t>(verification_key->num_public_inputs) - bb::RollupIO::PUBLIC_INPUTS_SIZE
: static_cast<uint32_t>(verification_key->num_public_inputs) - bb::DefaultIO::PUBLIC_INPUTS_SIZE;
debug("proof size: ", proof.size());
debug("number of public inputs to extract: ", num_public_inputs_to_extract);
std::vector<FF> public_inputs =
Expand Down
13 changes: 4 additions & 9 deletions barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)
namespace bb {

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1478): Can we define this constant as part of the
// parameters and make it avaiable via the interface of field<T>?
// A point in Fq is represented with 4 public inputs
static constexpr size_t FQ_PUBLIC_INPUT_SIZE = 4;

class Bn254FqParams {
// There is a helper script in ecc/fields/parameter_helper.py that can be used to extract these parameters from the
// source code
Expand Down Expand Up @@ -166,15 +161,15 @@ class Bn254FqParams {
// The modulus is larger than BN254 scalar field modulus, so it maps to two BN254 scalars
static constexpr size_t NUM_BN254_SCALARS = 2;
static constexpr size_t MAX_BITS_PER_ENDOMORPHISM_SCALAR = 128;

// A point in Fq is represented as a bigfield element in the public inputs, so 4 public inputs
static constexpr size_t PUBLIC_INPUTS_SIZE = BIGFIELD_PUBLIC_INPUTS_SIZE;
};

using fq = field<Bn254FqParams>;

template <> template <> inline fq fq::reconstruct_from_public(const std::span<const bb::fr>& limbs)
template <> template <> inline fq fq::reconstruct_from_public(const std::span<const bb::fr, PUBLIC_INPUTS_SIZE>& limbs)
{
// A point in Fq is represented with 4 public inputs
BB_ASSERT_EQ(limbs.size(), FQ_PUBLIC_INPUT_SIZE, "Incorrect number of limbs");

const uint256_t limb = static_cast<uint256_t>(limbs[0]) +
(static_cast<uint256_t>(limbs[1]) << bb::stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION) +
(static_cast<uint256_t>(limbs[2]) << (bb::stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) +
Expand Down
12 changes: 5 additions & 7 deletions barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
#include <ostream>

#include "../../fields/field.hpp"
#include "barretenberg/honk/types/public_inputs_type.hpp"

// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)

namespace bb {

// A point in Fr is represented with 1 public input
static constexpr size_t FR_PUBLIC_INPUTS_SIZE = 1;

class Bn254FrParams {
// There is a helper script in ecc/fields/parameter_helper.py that can be used to extract these parameters from the
public:
Expand Down Expand Up @@ -168,15 +166,15 @@ class Bn254FrParams {
// This is a BN254 scalar, so it represents one BN254 scalar
static constexpr size_t NUM_BN254_SCALARS = 1;
static constexpr size_t MAX_BITS_PER_ENDOMORPHISM_SCALAR = 128;

// A point in Fr is represented with 1 public input
static constexpr size_t PUBLIC_INPUTS_SIZE = FR_PUBLIC_INPUTS_SIZE;
};

using fr = field<Bn254FrParams>;

template <> template <> inline fr fr::reconstruct_from_public(const std::span<const fr>& limbs)
template <> template <> inline fr fr::reconstruct_from_public(const std::span<const fr, PUBLIC_INPUTS_SIZE>& limbs)
{

BB_ASSERT_EQ(limbs.size(), FR_PUBLIC_INPUTS_SIZE, "Incorrect number of limbs");

return fr(limbs[0]);
}

Expand Down
21 changes: 0 additions & 21 deletions barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,3 @@ inline std::string msgpack_schema_name(bb::g1::affine_element const& /*unused*/)
{
return "G1AffineElement";
}

// Specialize the reconstruct from public method
template <>
inline bb::g1::affine_element bb::g1::affine_element::reconstruct_from_public(const std::span<const bb::fr>& limbs)
{
BB_ASSERT_EQ(limbs.size(), 2 * FQ_PUBLIC_INPUT_SIZE, "Incorrect number of limbs");

auto x_limbs = limbs.subspan(0, FQ_PUBLIC_INPUT_SIZE);
auto y_limbs = limbs.subspan(FQ_PUBLIC_INPUT_SIZE, FQ_PUBLIC_INPUT_SIZE);

affine_element result;
result.x = Fq::reconstruct_from_public(x_limbs);
result.y = Fq::reconstruct_from_public(y_limbs);

if (result.x == Fq::zero() && result.y == Fq::zero()) {
result.self_set_infinity();
}

ASSERT(result.on_curve());
return result;
}
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ struct Bn254G2Params {
};

using g2 = group<fq2, fr, Bn254G2Params>;
} // namespace bb
} // namespace bb
22 changes: 0 additions & 22 deletions barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,3 @@ class Grumpkin {
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH = 3;
};
} // namespace bb::curve

// Specialize the reconstruct from public method
template <>
inline bb::grumpkin::g1::affine_element bb::grumpkin::g1::affine_element::reconstruct_from_public(
const std::span<const bb::fr>& limbs)
{
BB_ASSERT_EQ(limbs.size(), 2 * FR_PUBLIC_INPUTS_SIZE, "Incorrect number of limbs");

auto x_limbs = limbs.subspan(0, FR_PUBLIC_INPUTS_SIZE);
auto y_limbs = limbs.subspan(FR_PUBLIC_INPUTS_SIZE, FR_PUBLIC_INPUTS_SIZE);

affine_element result;
result.x = Fq::reconstruct_from_public(x_limbs);
result.y = Fq::reconstruct_from_public(y_limbs);

if (result.x == Fq::zero() && result.y == Fq::zero()) {
result.self_set_infinity();
}

ASSERT(result.on_curve());
return result;
}
Loading
Loading