Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,13 @@ function test_cmds_native {
local prefix=$hash
# A little extra resource for these tests.
# IPARecursiveTests fails with 2 threads.
if [[ "$test" =~ ^(AcirAvmRecursionConstraint|ChonkKernelCapacity|AvmRecursiveTests|IPARecursiveTests|HonkRecursionConstraintTest) ]]; then
if [[ "$test" =~ ^(AcirAvmRecursionConstraint|ChonkKernelCapacity|AvmRecursiveTests|IPARecursiveTests|HonkRecursionConstraintTest|ChonkRecursionConstraintTest) ]]; then
prefix="$prefix:CPUS=4:MEM=8g"
fi
# These tests routinely take 400-600s in debug builds; bump from the 600s default.
if [[ "$test" =~ ^(HonkRecursionConstraintTest|ChonkRecursionConstraintTest) ]]; then
prefix="$prefix:TIMEOUT=900s"
fi
echo -e "$prefix barretenberg/cpp/scripts/run_test.sh $bin_name $test"
done || (echo "Failed to list tests in $bin" && exit 1)
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ script_path="$root/barretenberg/cpp/scripts/test_chonk_standalone_vks_havent_cha
# - Generate a hash for versioning: sha256sum bb-chonk-inputs.tar.gz
# - Upload the compressed results: aws s3 cp bb-chonk-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-chonk-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_short_hash="33a01e19"
pinned_short_hash="50947760"
pinned_chonk_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-chonk-inputs-${pinned_short_hash}.tar.gz"

function update_pinned_hash_in_script {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ template <typename Curve_> class KZG {
quotient_commitment,
GroupElement::one(builder) };
std::vector<Fr> scalars = { one, claim.opening_pair.challenge, -claim.opening_pair.evaluation };
P_0 = GroupElement::batch_mul(commitments, scalars);

// Compute C + r*[W]_1 + (-v)*[1]_1 as a batch_mul, no need of edge case handling since we don't expect the
// points to be linearly dependent.
P_0 = GroupElement::batch_mul(commitments, scalars, /*max_num_bits=*/0, /*with_edgecases=*/false);

} else {
P_0 = claim.commitment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,12 @@ template <typename Curve, bool HasZK = false> class ShpleminiVerifier_ {
}

// Erase the duplicate entries (higher-index range first to preserve lower indices)
auto erase_range = [&](size_t duplicate_start, size_t original_start, size_t count) {
// Each erase shifts elements down, so duplicate_start always points to the next duplicate;
// the original at original_start + i is unaffected since we erase higher-index ranges first.
// Commitment equality (original == duplicate) is verified by per-flavor
// RepeatedCommitmentsIndicesCorrect tests rather than at runtime here.
auto erase_range = [&](size_t duplicate_start, [[maybe_unused]] size_t original_start, size_t count) {
for (size_t i = 0; i < count; ++i) {
// Verify the commitment being erased matches its original (native only).
// Each erase shifts elements down, so duplicate_start always points to the
// next duplicate; the original at original_start + i is unaffected since
// we erase higher-index ranges first.
if constexpr (!Curve::is_stdlib_type) {
if (commitments[duplicate_start] != commitments[original_start + i]) {
throw_or_abort("remove_repeated_commitments: commitment mismatch at duplicate index " +
std::to_string(duplicate_start) + " vs original index " +
std::to_string(original_start + i));
}
}
scalars.erase(scalars.begin() + static_cast<std::ptrdiff_t>(duplicate_start));
commitments.erase(commitments.begin() + static_cast<std::ptrdiff_t>(duplicate_start));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template <typename Builder> inline constexpr size_t ASSERT_EQUALITY = ZERO_GATE
// Honk Recursion Constants
// ========================================

inline constexpr size_t ROOT_ROLLUP_GATE_COUNT = 12904885;
inline constexpr size_t ROOT_ROLLUP_GATE_COUNT = 12904895;

template <typename RecursiveFlavor>
constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
Expand All @@ -67,40 +67,40 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraRecursiveFlavor_<UltraCircuitBuilder>>) {
switch (mode) {
case PredicateTestCase::ConstantTrue:
return std::make_tuple(681762, 0);
return std::make_tuple(681767, 0);
case PredicateTestCase::WitnessTrue:
case PredicateTestCase::WitnessFalse:
return std::make_tuple(682819, 0);
return std::make_tuple(682824, 0);
}
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraZKRecursiveFlavor_<UltraCircuitBuilder>>) {
switch (mode) {
case PredicateTestCase::ConstantTrue:
return std::make_tuple(703917, 0);
return std::make_tuple(703922, 0);
case PredicateTestCase::WitnessTrue:
case PredicateTestCase::WitnessFalse:
return std::make_tuple(705070, 0);
return std::make_tuple(705075, 0);
}
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraRecursiveFlavor_<MegaCircuitBuilder>>) {
switch (mode) {
case PredicateTestCase::ConstantTrue:
return std::make_tuple(20909, 73);
return std::make_tuple(20914, 73);
case PredicateTestCase::WitnessTrue:
case PredicateTestCase::WitnessFalse:
return std::make_tuple(21966, 73);
return std::make_tuple(21971, 73);
}
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraZKRecursiveFlavor_<MegaCircuitBuilder>>) {
switch (mode) {
case PredicateTestCase::ConstantTrue:
return std::make_tuple(25476, 77);
return std::make_tuple(25481, 77);
case PredicateTestCase::WitnessTrue:
case PredicateTestCase::WitnessFalse:
return std::make_tuple(26629, 77);
return std::make_tuple(26634, 77);
}
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::MegaZKRecursiveFlavor_<UltraCircuitBuilder>>) {
if (mode != PredicateTestCase::ConstantTrue) {
bb::assert_failure("Unhandled mode in MegaZKRecursiveFlavor.");
}
return std::make_tuple(781910, 0);
return std::make_tuple(781915, 0);
} else {
bb::assert_failure("Unhandled recursive flavor.");
}
Expand All @@ -113,7 +113,7 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
// ========================================

// Gate count for Chonk recursive verification (Ultra with RollupIO)
inline constexpr size_t CHONK_RECURSION_GATES = 1491408;
inline constexpr size_t CHONK_RECURSION_GATES = 1491593;

// ========================================
// Hypernova Recursion Constants
Expand All @@ -123,22 +123,22 @@ inline constexpr size_t CHONK_RECURSION_GATES = 1491408;
inline constexpr size_t MSM_ROWS_OFFSET = 2;

// Init kernel gate counts (verifies OINK proof)
inline constexpr size_t INIT_KERNEL_GATE_COUNT = 25027;
inline constexpr size_t INIT_KERNEL_GATE_COUNT = 25032;
inline constexpr size_t INIT_KERNEL_ECC_ROWS = 848 + MSM_ROWS_OFFSET;
inline constexpr size_t INIT_KERNEL_ULTRA_OPS = 89;

// Inner kernel gate counts (verifies HN proof for previous kernel + HN for app)
inline constexpr size_t INNER_KERNEL_GATE_COUNT_HN = 60487;
inline constexpr size_t INNER_KERNEL_GATE_COUNT_HN = 60497;
inline constexpr size_t INNER_KERNEL_ECC_ROWS = 1700 + MSM_ROWS_OFFSET;
inline constexpr size_t INNER_KERNEL_ULTRA_OPS = 179;

// Tail kernel gate counts (verifies HN_TAIL proof)
inline constexpr size_t TAIL_KERNEL_GATE_COUNT = 32868;
inline constexpr size_t TAIL_KERNEL_GATE_COUNT = 32873;
inline constexpr size_t TAIL_KERNEL_ECC_ROWS = 914 + MSM_ROWS_OFFSET;
inline constexpr size_t TAIL_KERNEL_ULTRA_OPS = 96;

// Hiding kernel gate counts (verifies HN_FINAL proof)
inline constexpr size_t HIDING_KERNEL_GATE_COUNT = 36265;
inline constexpr size_t HIDING_KERNEL_GATE_COUNT = 36270;
inline constexpr size_t HIDING_KERNEL_ECC_ROWS = 1407 + MSM_ROWS_OFFSET;
inline constexpr size_t HIDING_KERNEL_ULTRA_OPS = 127;

Expand All @@ -147,7 +147,7 @@ inline constexpr size_t HIDING_KERNEL_ULTRA_OPS = 127;
// ========================================

// Gate count for ECCVM recursive verifier (Ultra-arithmetized)
inline constexpr size_t ECCVM_RECURSIVE_VERIFIER_GATE_COUNT = 224162;
inline constexpr size_t ECCVM_RECURSIVE_VERIFIER_GATE_COUNT = 224336;

// ========================================
// Goblin AVM Recursive Verifier Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ void create_logic_gate(Builder& builder,
field_ct right = to_field_ct(b, builder);

field_ct computed_result = bb::stdlib::logic<Builder>::create_logic_constraint(left, right, num_bits, is_xor_gate);

// In write-VK mode the result witness holds a dummy zero. In certain cases, the computed result is non-zero so the
// assert_equal would spuriously fail. Patch the witness value so the downstream assertion sees the correct value.
// Eg. for an XOR gate, if the inputs are constants such that the result is a non-zero constant, the assert_equal
// will fail in write-VK mode since the result witness is initialized to zero.
if (builder.is_write_vk_mode()) {
builder.set_variable(result, computed_result.get_value());
}

field_ct acir_result = field_ct::from_witness_index(&builder, result);
computed_result.assert_equal(acir_result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class LogicConstraintTestingFunctions {
return WitnessOrConstant<FF>::from_index(input_index);
};

bb::fr lhs = FF(static_cast<uint256_t>(1) << num_bits - 1); // All bits from 0 to num_bits-1 are set
bb::fr rhs = FF(static_cast<uint256_t>(1) << num_bits - 1); // All bits from 0 to num_bits-1 are set
bb::fr lhs = FF((static_cast<uint256_t>(1) << num_bits) - 1); // All bits from 0 to num_bits-1 are set
bb::fr rhs = FF((static_cast<uint256_t>(1) << num_bits) - 1); // All bits from 0 to num_bits-1 are set
bb::fr result = is_xor_gate ? (static_cast<uint256_t>(lhs) ^ static_cast<uint256_t>(rhs))
: (static_cast<uint256_t>(lhs) & static_cast<uint256_t>(rhs));

Expand Down
60 changes: 33 additions & 27 deletions barretenberg/cpp/src/barretenberg/dsl/acir_proofs/honk_contract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function equal(Fr a, Fr b) pure returns (bool) {

uint256 constant CONST_PROOF_SIZE_LOG_N = 25;

uint256 constant NUMBER_OF_SUBRELATIONS = 28;
uint256 constant NUMBER_OF_SUBRELATIONS = 29;
uint256 constant BATCHED_RELATION_PARTIAL_LENGTH = 8;
uint256 constant ZK_BATCHED_RELATION_PARTIAL_LENGTH = 9;
uint256 constant NUMBER_OF_ENTITIES = 41;
Expand Down Expand Up @@ -870,6 +870,12 @@ library RelationsLib {
Fr acc = (wire(p, WIRE.LAGRANGE_LAST) * wire(p, WIRE.Z_PERM_SHIFT)) * domainSep;
evals[3] = acc;
}

// Contribution 4: z_perm initialization check (lagrange_first * z_perm = 0)
{
Fr acc = (wire(p, WIRE.LAGRANGE_FIRST) * wire(p, WIRE.Z_PERM)) * domainSep;
evals[4] = acc;
}
}

function accumulateLogDerivativeLookupRelation(
Expand Down Expand Up @@ -919,9 +925,9 @@ library RelationsLib {

Fr read_tag_boolean_relation = read_tag * read_tag - read_tag;

evals[4] = accumulatorNone;
evals[5] = accumulatorOne;
evals[6] = read_tag_boolean_relation * domainSep;
evals[5] = accumulatorNone;
evals[6] = accumulatorOne;
evals[7] = read_tag_boolean_relation * domainSep;
}

function accumulateDeltaRangeRelation(
Expand All @@ -947,7 +953,7 @@ library RelationsLib {
acc = acc * (delta_1 + minus_three);
acc = acc * wire(p, WIRE.Q_RANGE);
acc = acc * domainSep;
evals[7] = acc;
evals[8] = acc;
}

// Contribution 7
Expand All @@ -958,7 +964,7 @@ library RelationsLib {
acc = acc * (delta_2 + minus_three);
acc = acc * wire(p, WIRE.Q_RANGE);
acc = acc * domainSep;
evals[8] = acc;
evals[9] = acc;
}

// Contribution 8
Expand All @@ -969,7 +975,7 @@ library RelationsLib {
acc = acc * (delta_3 + minus_three);
acc = acc * wire(p, WIRE.Q_RANGE);
acc = acc * domainSep;
evals[9] = acc;
evals[10] = acc;
}

// Contribution 9
Expand All @@ -980,7 +986,7 @@ library RelationsLib {
acc = acc * (delta_4 + minus_three);
acc = acc * wire(p, WIRE.Q_RANGE);
acc = acc * domainSep;
evals[10] = acc;
evals[11] = acc;
}
}

Expand Down Expand Up @@ -1015,7 +1021,7 @@ library RelationsLib {
x_add_identity = x_add_identity * x_diff * x_diff;
x_add_identity = x_add_identity - y2_sqr - y1_sqr + y1y2 + y1y2;

evals[11] = x_add_identity * partialEval * wire(p, WIRE.Q_ELLIPTIC) * (ONE - q_is_double);
evals[12] = x_add_identity * partialEval * wire(p, WIRE.Q_ELLIPTIC) * (ONE - q_is_double);
}

// Contribution 11 point addition, x-coordinate check
Expand All @@ -1024,7 +1030,7 @@ library RelationsLib {
Fr y1_plus_y3 = ep.y_1 + ep.y_3;
Fr y_diff = ep.y_2 * q_sign - ep.y_1;
Fr y_add_identity = y1_plus_y3 * x_diff + (ep.x_3 - ep.x_1) * y_diff;
evals[12] = y_add_identity * domainSep * wire(p, WIRE.Q_ELLIPTIC) * (ONE - q_is_double);
evals[13] = y_add_identity * domainSep * wire(p, WIRE.Q_ELLIPTIC) * (ONE - q_is_double);
}

// Contribution 10 point doubling, x-coordinate check
Expand All @@ -1040,15 +1046,15 @@ library RelationsLib {
ep.x_double_identity = (ep.x_3 + ep.x_1 + ep.x_1) * y1_sqr_mul_4 - x1_pow_4_mul_9;

Fr acc = ep.x_double_identity * domainSep * wire(p, WIRE.Q_ELLIPTIC) * q_is_double;
evals[11] = evals[11] + acc;
evals[12] = evals[12] + acc;
}

// Contribution 11 point doubling, y-coordinate check
// (y1 + y1) (2y1) - (3 * x1 * x1)(x1 - x3) = 0
{
Fr x1_sqr_mul_3 = (ep.x_1 + ep.x_1 + ep.x_1) * ep.x_1;
Fr y_double_identity = x1_sqr_mul_3 * (ep.x_1 - ep.x_3) - (ep.y_1 + ep.y_1) * (ep.y_1 + ep.y_3);
evals[12] = evals[12] + y_double_identity * domainSep * wire(p, WIRE.Q_ELLIPTIC) * q_is_double;
evals[13] = evals[13] + y_double_identity * domainSep * wire(p, WIRE.Q_ELLIPTIC) * q_is_double;
}
}

Expand Down Expand Up @@ -1135,9 +1141,9 @@ library RelationsLib {

ap.adjacent_values_match_if_adjacent_indices_match = (ap.index_delta * MINUS_ONE + ONE) * ap.record_delta; // deg 2

evals[14] = ap.adjacent_values_match_if_adjacent_indices_match * (wire(p, WIRE.Q_L) * wire(p, WIRE.Q_R))
evals[15] = ap.adjacent_values_match_if_adjacent_indices_match * (wire(p, WIRE.Q_L) * wire(p, WIRE.Q_R))
* (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 5
evals[15] = ap.index_is_monotonically_increasing * (wire(p, WIRE.Q_L) * wire(p, WIRE.Q_R))
evals[16] = ap.index_is_monotonically_increasing * (wire(p, WIRE.Q_L) * wire(p, WIRE.Q_R))
* (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 5

ap.ROM_consistency_check_identity = ap.memory_record_check * (wire(p, WIRE.Q_L) * wire(p, WIRE.Q_R)); // deg 3 or 7
Expand Down Expand Up @@ -1184,10 +1190,10 @@ library RelationsLib {
ap.next_gate_access_type * ap.next_gate_access_type - ap.next_gate_access_type;

// Putting it all together...
evals[16] = ap.adjacent_values_match_if_adjacent_indices_match_and_next_access_is_a_read_operation
evals[17] = ap.adjacent_values_match_if_adjacent_indices_match_and_next_access_is_a_read_operation
* (wire(p, WIRE.Q_O)) * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 5 or 8
evals[17] = ap.index_is_monotonically_increasing * (wire(p, WIRE.Q_O)) * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 4
evals[18] = ap.next_gate_access_type_is_boolean * (wire(p, WIRE.Q_O)) * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 4 or 6
evals[18] = ap.index_is_monotonically_increasing * (wire(p, WIRE.Q_O)) * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 4
evals[19] = ap.next_gate_access_type_is_boolean * (wire(p, WIRE.Q_O)) * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 4 or 6

ap.RAM_consistency_check_identity = ap.access_check * (wire(p, WIRE.Q_O)); // deg 3 or 9

Expand Down Expand Up @@ -1218,7 +1224,7 @@ library RelationsLib {

// (deg 3 or 9) + (deg 4) + (deg 3)
ap.memory_identity = ap.memory_identity * (wire(p, WIRE.Q_MEMORY) * domainSep); // deg 4 or 10
evals[13] = ap.memory_identity;
evals[14] = ap.memory_identity;
}

function accumulateNnfRelation(
Expand Down Expand Up @@ -1294,7 +1300,7 @@ library RelationsLib {

ap.nnf_identity = non_native_field_identity + limb_accumulator_identity;
ap.nnf_identity = ap.nnf_identity * (wire(p, WIRE.Q_NNF) * domainSep);
evals[19] = ap.nnf_identity;
evals[20] = ap.nnf_identity;
}

function accumulatePoseidonExternalRelation(
Expand Down Expand Up @@ -1330,13 +1336,13 @@ library RelationsLib {
ep.v3 = ep.t2 + ep.v4; // u_1 + 3u_2 + 5u_3 + 7u_4

ep.q_pos_by_scaling = wire(p, WIRE.Q_POSEIDON2_EXTERNAL) * domainSep;
evals[20] = evals[20] + ep.q_pos_by_scaling * (ep.v1 - wire(p, WIRE.W_L_SHIFT));
evals[21] = evals[21] + ep.q_pos_by_scaling * (ep.v1 - wire(p, WIRE.W_L_SHIFT));

evals[21] = evals[21] + ep.q_pos_by_scaling * (ep.v2 - wire(p, WIRE.W_R_SHIFT));
evals[22] = evals[22] + ep.q_pos_by_scaling * (ep.v2 - wire(p, WIRE.W_R_SHIFT));

evals[22] = evals[22] + ep.q_pos_by_scaling * (ep.v3 - wire(p, WIRE.W_O_SHIFT));
evals[23] = evals[23] + ep.q_pos_by_scaling * (ep.v3 - wire(p, WIRE.W_O_SHIFT));

evals[23] = evals[23] + ep.q_pos_by_scaling * (ep.v4 - wire(p, WIRE.W_4_SHIFT));
evals[24] = evals[24] + ep.q_pos_by_scaling * (ep.v4 - wire(p, WIRE.W_4_SHIFT));
}

function accumulatePoseidonInternalRelation(
Expand Down Expand Up @@ -1368,16 +1374,16 @@ library RelationsLib {
ip.q_pos_by_scaling = wire(p, WIRE.Q_POSEIDON2_INTERNAL) * domainSep;

ip.v1 = ip.u1 * INTERNAL_MATRIX_DIAGONAL[0] + ip.u_sum;
evals[24] = evals[24] + ip.q_pos_by_scaling * (ip.v1 - wire(p, WIRE.W_L_SHIFT));
evals[25] = evals[25] + ip.q_pos_by_scaling * (ip.v1 - wire(p, WIRE.W_L_SHIFT));

ip.v2 = ip.u2 * INTERNAL_MATRIX_DIAGONAL[1] + ip.u_sum;
evals[25] = evals[25] + ip.q_pos_by_scaling * (ip.v2 - wire(p, WIRE.W_R_SHIFT));
evals[26] = evals[26] + ip.q_pos_by_scaling * (ip.v2 - wire(p, WIRE.W_R_SHIFT));

ip.v3 = ip.u3 * INTERNAL_MATRIX_DIAGONAL[2] + ip.u_sum;
evals[26] = evals[26] + ip.q_pos_by_scaling * (ip.v3 - wire(p, WIRE.W_O_SHIFT));
evals[27] = evals[27] + ip.q_pos_by_scaling * (ip.v3 - wire(p, WIRE.W_O_SHIFT));

ip.v4 = ip.u4 * INTERNAL_MATRIX_DIAGONAL[3] + ip.u_sum;
evals[27] = evals[27] + ip.q_pos_by_scaling * (ip.v4 - wire(p, WIRE.W_4_SHIFT));
evals[28] = evals[28] + ip.q_pos_by_scaling * (ip.v4 - wire(p, WIRE.W_4_SHIFT));
}

// Batch subrelation evaluations using precomputed powers of alpha
Expand Down
Loading
Loading