Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c0153a5
[empty] Start merge-train. Choo choo.
Jul 15, 2025
dfdc1b5
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
3efb90e
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
f447c5a
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
0772339
feat!: Merge with degree check (#15562)
federicobarbacovi Jul 15, 2025
ff8bd12
fix: Fix the docker build action for fuzzing (#15719)
Sarkoxed Jul 15, 2025
ecaa2d5
fix: restore accidentally deleted files (#15724)
johnathan79717 Jul 15, 2025
3eb8414
fix: civc wasm memory regression (#15722)
iakovenkos Jul 15, 2025
aa0f43c
feat: mmap backed polynomials (#15531)
johnathan79717 Jul 15, 2025
3ab6d4a
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
0428551
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
917523f
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
ddfc800
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
2c3b398
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
37932f1
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
740b698
feat(bbapi): CLI uses bbapi CIVC (#15702)
ludamad Jul 15, 2025
8d0ef02
Merge branch 'next' into merge-train/barretenberg
Jul 15, 2025
fa7378d
no more explicit use of circuit size in vk
ledwards2225 Jul 15, 2025
b963604
remove circuit size from VKs altogether
ledwards2225 Jul 15, 2025
a00dcb5
fix avm build and tests
ledwards2225 Jul 15, 2025
2a0e251
cleanup and comments
ledwards2225 Jul 15, 2025
0993360
undo sol changes
ledwards2225 Jul 16, 2025
acfcbe7
simplify vk get value
ledwards2225 Jul 16, 2025
9f27abb
[empty] Start merge-train. Choo choo.
Jul 16, 2025
6893736
Merge branch 'next' into merge-train/barretenberg
Jul 16, 2025
6cd32ca
Merge branch 'next' into merge-train/barretenberg
Jul 16, 2025
8758f14
Merge branch 'merge-train/barretenberg' into lde/only_log_n
ledwards2225 Jul 16, 2025
3515641
update cached VKs
ledwards2225 Jul 16, 2025
17041de
continmue hashing vk circuit size for keccak only
ledwards2225 Jul 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd ..
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-79e2c5e0.tar.gz"
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-ff124547.tar.gz"

# For easily rerunning the inputs generation
if [[ "${1:-}" == "--update_inputs" ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ void create_dummy_vkey_and_proof(Builder& builder,
// (Flavor::NUM_FRS_COM + Flavor::NUM_FRS_FR * (Flavor::BATCHED_RELATION_PARTIAL_LENGTH + 1));
const auto log_circuit_size = CONST_PROOF_SIZE_LOG_N;

// First key field is circuit size
builder.set_variable(key_fields[0].witness_index, 1 << log_circuit_size);
// First key field is log circuit size
builder.set_variable(key_fields[0].witness_index, log_circuit_size);
// Second key field is number of public inputs
builder.set_variable(key_fields[1].witness_index, public_inputs_size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ std::shared_ptr<typename Flavor::VerificationKey> create_mock_honk_vk(const size
{
// Set relevant VK metadata and commitments
auto honk_verification_key = std::make_shared<typename Flavor::VerificationKey>();
honk_verification_key->circuit_size = dyadic_size;
honk_verification_key->log_circuit_size = bb::numeric::get_msb(dyadic_size);
honk_verification_key->num_public_inputs = num_public_inputs;
honk_verification_key->pub_inputs_offset = pub_inputs_offset; // must be set correctly

Expand Down
10 changes: 2 additions & 8 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@ class ECCVMFlavor {

VerificationKey(const std::shared_ptr<ProvingKey>& proving_key)
{
this->circuit_size = 1UL << CONST_ECCVM_LOG_N;
this->log_circuit_size = CONST_ECCVM_LOG_N;
this->num_public_inputs = 0;
this->pub_inputs_offset = 0;
Expand Down Expand Up @@ -877,13 +876,8 @@ class ECCVMFlavor {
// from MSGPACK and the verification key.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove circuit_size from the comment, please

// Don't statically check for object completeness.
using MSGPACK_NO_STATIC_CHECK = std::true_type;
MSGPACK_FIELDS(circuit_size,
log_circuit_size,
num_public_inputs,
pub_inputs_offset,
lagrange_first,
lagrange_second,
lagrange_last);
MSGPACK_FIELDS(
log_circuit_size, num_public_inputs, pub_inputs_offset, lagrange_first, lagrange_second, lagrange_last);
};

/**
Expand Down
12 changes: 4 additions & 8 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ template <typename PrecomputedCommitments, typename Transcript>
class NativeVerificationKey_ : public PrecomputedCommitments {
public:
using Commitment = typename PrecomputedCommitments::DataType;
uint64_t circuit_size = 0;
uint64_t log_circuit_size = 0;
uint64_t num_public_inputs = 0;
uint64_t pub_inputs_offset = 0;
Expand All @@ -161,7 +160,6 @@ class NativeVerificationKey_ : public PrecomputedCommitments {
NativeVerificationKey_() = default;
NativeVerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
{
this->circuit_size = circuit_size;
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
};
Expand All @@ -182,7 +180,7 @@ class NativeVerificationKey_ : public PrecomputedCommitments {

std::vector<fr> elements;

serialize_to_field_buffer(this->circuit_size, elements);
serialize_to_field_buffer(this->log_circuit_size, elements);
serialize_to_field_buffer(this->num_public_inputs, elements);
serialize_to_field_buffer(this->pub_inputs_offset, elements);

Expand Down Expand Up @@ -218,7 +216,7 @@ class NativeVerificationKey_ : public PrecomputedCommitments {
*/
virtual fr add_hash_to_transcript(const std::string& domain_separator, Transcript& transcript) const
{
transcript.add_to_independent_hash_buffer(domain_separator + "vk_circuit_size", this->circuit_size);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_log_circuit_size", this->log_circuit_size);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_num_public_inputs", this->num_public_inputs);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_pub_inputs_offset", this->pub_inputs_offset);

Expand All @@ -244,7 +242,6 @@ class StdlibVerificationKey_ : public PrecomputedCommitments {
using FF = stdlib::field_t<Builder>;
using Commitment = typename PrecomputedCommitments::DataType;
using Transcript = BaseTranscript<stdlib::recursion::honk::StdlibTranscriptParams<Builder>>;
FF circuit_size;
FF log_circuit_size;
FF num_public_inputs;
FF pub_inputs_offset = 0;
Expand All @@ -254,7 +251,6 @@ class StdlibVerificationKey_ : public PrecomputedCommitments {
StdlibVerificationKey_() = default;
StdlibVerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
{
this->circuit_size = circuit_size;
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
};
Expand All @@ -275,7 +271,7 @@ class StdlibVerificationKey_ : public PrecomputedCommitments {

std::vector<FF> elements;

serialize_to_field_buffer(this->circuit_size, elements);
serialize_to_field_buffer(this->log_circuit_size, elements);
serialize_to_field_buffer(this->num_public_inputs, elements);
serialize_to_field_buffer(this->pub_inputs_offset, elements);

Expand Down Expand Up @@ -312,7 +308,7 @@ class StdlibVerificationKey_ : public PrecomputedCommitments {
*/
virtual FF add_hash_to_transcript(const std::string& domain_separator, Transcript& transcript) const
{
transcript.add_to_independent_hash_buffer(domain_separator + "vk_circuit_size", this->circuit_size);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_log_circuit_size", this->log_circuit_size);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_num_public_inputs", this->num_public_inputs);
transcript.add_to_independent_hash_buffer(domain_separator + "vk_pub_inputs_offset", this->pub_inputs_offset);
for (const Commitment& commitment : this->get_all()) {
Expand Down
8 changes: 3 additions & 5 deletions barretenberg/cpp/src/barretenberg/flavor/mega_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class MegaFlavor {
public:
// Serialized Verification Key length in fields
static constexpr size_t VERIFICATION_KEY_LENGTH =
/* 1. Metadata (circuit_size, num_public_inputs, pub_inputs_offset) */ (3 * num_frs_fr) +
/* 1. Metadata (log_circuit_size, num_public_inputs, pub_inputs_offset) */ (3 * num_frs_fr) +
/* 2. NUM_PRECOMPUTED_ENTITIES commitments */ (NUM_PRECOMPUTED_ENTITIES * num_frs_comm);

VerificationKey() = default;
Expand All @@ -443,8 +443,7 @@ class MegaFlavor {

void set_metadata(const MetaData& metadata)
{
this->circuit_size = metadata.dyadic_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->log_circuit_size = numeric::get_msb(metadata.dyadic_size);
this->num_public_inputs = metadata.num_public_inputs;
this->pub_inputs_offset = metadata.pub_inputs_offset;
}
Expand All @@ -461,8 +460,7 @@ class MegaFlavor {

// Don't statically check for object completeness.
using MSGPACK_NO_STATIC_CHECK = std::true_type;
MSGPACK_FIELDS(circuit_size,
log_circuit_size,
MSGPACK_FIELDS(log_circuit_size,
num_public_inputs,
pub_inputs_offset,
q_m,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ template <typename BuilderType> class MegaRecursiveFlavor_ {
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->circuit_size = FF::from_witness(builder, native_key->circuit_size);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size));
this->log_circuit_size = FF::from_witness(builder, native_key->log_circuit_size);
this->num_public_inputs = FF::from_witness(builder, native_key->num_public_inputs);
this->pub_inputs_offset = FF::from_witness(builder, native_key->pub_inputs_offset);

Expand All @@ -150,9 +148,7 @@ template <typename BuilderType> class MegaRecursiveFlavor_ {

size_t num_frs_read = 0;

this->circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = numeric::get_msb(static_cast<uint32_t>(this->circuit_size.get_value()));
this->log_circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->num_public_inputs = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->pub_inputs_offset = deserialize_from_frs<FF>(builder, elements, num_frs_read);

Expand Down
8 changes: 3 additions & 5 deletions barretenberg/cpp/src/barretenberg/flavor/ultra_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class UltraFlavor {
public:
// Serialized Verification Key length in fields
static constexpr size_t VERIFICATION_KEY_LENGTH =
/* 1. Metadata (circuit_size, num_public_inputs, pub_inputs_offset) */ (3 * num_frs_fr) +
/* 1. Metadata (log_circuit_size, num_public_inputs, pub_inputs_offset) */ (3 * num_frs_fr) +
/* 2. NUM_PRECOMPUTED_ENTITIES commitments */ (NUM_PRECOMPUTED_ENTITIES * num_frs_comm);

bool operator==(const VerificationKey&) const = default;
Expand All @@ -479,8 +479,7 @@ class UltraFlavor {

VerificationKey(const PrecomputedData& precomputed)
{
this->circuit_size = precomputed.metadata.dyadic_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->log_circuit_size = numeric::get_msb(precomputed.metadata.dyadic_size);
this->num_public_inputs = precomputed.metadata.num_public_inputs;
this->pub_inputs_offset = precomputed.metadata.pub_inputs_offset;

Expand All @@ -494,8 +493,7 @@ class UltraFlavor {
using MSGPACK_NO_STATIC_CHECK = std::true_type;

// For serialising and deserialising data
MSGPACK_FIELDS(circuit_size,
log_circuit_size,
MSGPACK_FIELDS(log_circuit_size,
num_public_inputs,
pub_inputs_offset,
q_m,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class UltraKeccakFlavor : public bb::UltraFlavor {

VerificationKey(const PrecomputedData& precomputed)
{
this->circuit_size = precomputed.metadata.dyadic_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->log_circuit_size = numeric::get_msb(precomputed.metadata.dyadic_size);
this->num_public_inputs = precomputed.metadata.num_public_inputs;
this->pub_inputs_offset = precomputed.metadata.pub_inputs_offset;

Expand All @@ -81,7 +80,8 @@ class UltraKeccakFlavor : public bb::UltraFlavor {
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1427): We need to update this function to look
// like UltraFlavor's add_hash_to_transcript. Alternatively, the VerificationKey class will go away when we
// add pairing point aggregation to the solidity verifier.
transcript.add_to_hash_buffer(domain_separator + "vk_circuit_size", this->circuit_size);
uint64_t circuit_size = 1 << this->log_circuit_size;
transcript.add_to_hash_buffer(domain_separator + "vk_log_circuit_size", circuit_size);
transcript.add_to_hash_buffer(domain_separator + "vk_num_public_inputs", this->num_public_inputs);
transcript.add_to_hash_buffer(domain_separator + "vk_pub_inputs_offset", this->pub_inputs_offset);
return 0;
Expand All @@ -91,8 +91,7 @@ class UltraKeccakFlavor : public bb::UltraFlavor {
using MSGPACK_NO_STATIC_CHECK = std::true_type;

// For serialising and deserialising data
MSGPACK_FIELDS(circuit_size,
log_circuit_size,
MSGPACK_FIELDS(log_circuit_size,
num_public_inputs,
pub_inputs_offset,
q_m,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ template <typename BuilderType> class UltraRecursiveFlavor_ {
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->circuit_size = FF::from_witness(builder, native_key->circuit_size);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size));
this->log_circuit_size = FF::from_witness(builder, native_key->log_circuit_size);
this->num_public_inputs = FF::from_witness(builder, native_key->num_public_inputs);
this->pub_inputs_offset = FF::from_witness(builder, native_key->pub_inputs_offset);

Expand All @@ -151,12 +149,7 @@ template <typename BuilderType> class UltraRecursiveFlavor_ {

size_t num_frs_read = 0;

this->circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1364): Improve VKs. log_circuit_size must be a
// witness to make the Recursive Verifier circuit constant. Seems that other members also need to be turned
// into witnesses.
this->log_circuit_size =
FF::from_witness(&builder, numeric::get_msb(static_cast<uint32_t>(this->circuit_size.get_value())));
this->log_circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->num_public_inputs = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->pub_inputs_offset = deserialize_from_frs<FF>(builder, elements, num_frs_read);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class UltraRollupFlavor : public bb::UltraFlavor {

VerificationKey(const PrecomputedData& precomputed)
{
this->circuit_size = precomputed.metadata.dyadic_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->log_circuit_size = numeric::get_msb(precomputed.metadata.dyadic_size);
this->num_public_inputs = precomputed.metadata.num_public_inputs;
this->pub_inputs_offset = precomputed.metadata.pub_inputs_offset;

Expand All @@ -57,8 +56,7 @@ class UltraRollupFlavor : public bb::UltraFlavor {
using MSGPACK_NO_STATIC_CHECK = std::true_type;

// For serialising and deserialising data
MSGPACK_FIELDS(circuit_size,
log_circuit_size,
MSGPACK_FIELDS(log_circuit_size,
num_public_inputs,
pub_inputs_offset,
q_m,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ template <typename BuilderType> class UltraRollupRecursiveFlavor_ : public Ultra
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->circuit_size = FF::from_witness(builder, native_key->circuit_size);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size));
this->log_circuit_size = FF::from_witness(builder, native_key->log_circuit_size);
this->num_public_inputs = FF::from_witness(builder, native_key->num_public_inputs);
this->pub_inputs_offset = FF::from_witness(builder, native_key->pub_inputs_offset);

Expand All @@ -94,12 +92,7 @@ template <typename BuilderType> class UltraRollupRecursiveFlavor_ : public Ultra

size_t num_frs_read = 0;

this->circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1364): Improve VKs. log_circuit_size must be a
// witness to make the Recursive Verifier circuit constant. Seems that other members also need to be turned
// into witnesses.
this->log_circuit_size =
FF::from_witness(&builder, numeric::get_msb(static_cast<uint32_t>(this->circuit_size.get_value())));
this->log_circuit_size = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->num_public_inputs = deserialize_from_frs<FF>(builder, elements, num_frs_read);
this->pub_inputs_offset = deserialize_from_frs<FF>(builder, elements, num_frs_read);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ template <typename Flavor>
typename Flavor::FF compute_public_input_delta(std::span<const typename Flavor::FF> public_inputs,
const typename Flavor::FF& beta,
const typename Flavor::FF& gamma,
const auto domain_size,
size_t offset = 0)
const typename Flavor::FF& log_domain_size,
const typename Flavor::FF& offset = 0)
{
using Field = typename Flavor::FF;
Field numerator = Field(1);
Expand Down Expand Up @@ -57,15 +57,16 @@ typename Flavor::FF compute_public_input_delta(std::span<const typename Flavor::

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1158): Ensure correct construction of public input
// delta in the face of increases to virtual size caused by execution trace overflow
Field numerator_acc = gamma + (beta * Field(domain_size + offset));
Field denominator_acc = gamma - beta * Field(1 + offset);
Field domain_size = Field(2).pow(log_domain_size);
Field numerator_acc = gamma + (beta * (domain_size + offset));
Field denominator_acc = gamma - beta * (offset + 1);

for (size_t i = 0; i < public_inputs.size(); i++) {
numerator *= (numerator_acc + public_inputs[i]); // γ + xᵢ + β(n+i)
denominator *= (denominator_acc + public_inputs[i]); // γ + xᵢ - β(1+i)

// To avoid introducing extra variables in the circuit, we skip numeratoc_acc
// and denominator_acc in the final loop iteration, since their values won't be used
// To avoid introducing extra variables in the circuit, we skip numerator_acc and denominator_acc in the final
// loop iteration, since their values won't be used
if (i < public_inputs.size() - 1) {
numerator_acc += beta;
denominator_acc -= beta;
Expand All @@ -74,4 +75,4 @@ typename Flavor::FF compute_public_input_delta(std::span<const typename Flavor::
return numerator / denominator;
}

} // namespace bb
} // namespace bb
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/honk/utils/honk_key_gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ inline void output_vk_sol_ultra_honk(std::ostream& os,
"\n"
"";
print_types_import();
print_u256_const(key->circuit_size, "N");
print_u256_const(1 << key->log_circuit_size, "N");
print_u256_const(key->log_circuit_size, "LOG_N");
print_u256_const(key->num_public_inputs, "NUMBER_OF_PUBLIC_INPUTS");
os << ""
"library " << class_name << " {\n"
" function loadVerificationKey() internal pure returns (Honk.VerificationKey memory) {\n"
" Honk.VerificationKey memory vk = Honk.VerificationKey({\n";
print_u256(key->circuit_size, "circuitSize");
print_u256(1 << key->log_circuit_size, "circuitSize");
print_u256(key->log_circuit_size, "logCircuitSize");
print_u256(key->num_public_inputs, "publicInputsSize");
print_g1(key->q_l, "ql");
Expand Down
Loading
Loading