Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6ff41b8
tube failing
iakovenkos Mar 25, 2025
25c2e87
ipa verification fails in the tube
iakovenkos Mar 25, 2025
9b326b5
renaming
iakovenkos Mar 25, 2025
d0443aa
pcs tests fixed
iakovenkos Mar 25, 2025
d9b8ebe
debugging
iakovenkos Mar 25, 2025
7db86f8
client ivc fixed
iakovenkos Mar 25, 2025
5abfc56
preparing for review
iakovenkos Mar 25, 2025
802ef24
hum
iakovenkos Mar 25, 2025
acd65b4
more cleaning
iakovenkos Mar 25, 2025
b980d74
clean
iakovenkos Mar 26, 2025
06c81d1
stray
iakovenkos Mar 26, 2025
dd37060
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Mar 26, 2025
490b01d
shplemini recursion fix
iakovenkos Mar 26, 2025
3db0793
test fix
iakovenkos Mar 26, 2025
fc71919
eccvm fixed size = true by default
iakovenkos Mar 26, 2025
c4add4c
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Mar 26, 2025
11e9aca
eccvm, translator don't use circuit size, cause it's fixed. shplemini…
iakovenkos Mar 28, 2025
96cbc7a
fix
iakovenkos Mar 28, 2025
0fe86e6
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Mar 28, 2025
a204c86
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Mar 28, 2025
1793920
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Mar 28, 2025
a0f2680
reinstate removed debug statements
iakovenkos Mar 28, 2025
aa5013a
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Mar 28, 2025
af87667
fix test
iakovenkos Mar 28, 2025
9e6a4f7
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Mar 28, 2025
7cc720e
fix tests
iakovenkos Mar 31, 2025
22a6382
fix tests
iakovenkos Mar 31, 2025
4e5aca7
remove circuit sizes from Translator ECCVM vkeys
iakovenkos Mar 31, 2025
42c0a72
remove circuit size asserts from VM tests
iakovenkos Apr 1, 2025
df84f40
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Apr 2, 2025
871ede4
resolve review comments
iakovenkos Apr 2, 2025
3f9bd79
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Apr 3, 2025
f12fb6c
ensure padding logic not triggered in eccvm and translator
iakovenkos Apr 3, 2025
3d1875b
remove overlooked circuit and log circuit size from eccvm verificatio…
iakovenkos Apr 3, 2025
a9c087e
is +1 needed?
iakovenkos Apr 3, 2025
cab4caf
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Apr 3, 2025
fb8f9aa
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Apr 3, 2025
99ef9fa
prove tube fix
iakovenkos Apr 3, 2025
9540a98
undo prove tube changes, fix in flavor
iakovenkos Apr 3, 2025
7c65f6d
fix bb build + add issue
iakovenkos Apr 3, 2025
5910962
re-instate circuit_size and log_circuit_size in translator flavor, no…
iakovenkos Apr 4, 2025
d48a7ed
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Apr 4, 2025
5bb7edb
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Apr 4, 2025
a456656
fix build: circuit size -> log circuit size in avm recursive verifier
iakovenkos Apr 4, 2025
8f66df7
circuit size and log circuit sizes in eccvm and translator are fixed …
iakovenkos Apr 7, 2025
419ee09
Merge branch 'master' into si/constants-mess-clean-up
iakovenkos Apr 7, 2025
95b63bb
Merge branch 'si/constants-mess-clean-up' into si/more-consistent-fix…
iakovenkos Apr 7, 2025
14de7c9
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Apr 7, 2025
da39e15
default constructors are required by msgpack
iakovenkos Apr 7, 2025
16addf3
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Apr 7, 2025
936a368
undo noir changes o.O
iakovenkos Apr 7, 2025
282278b
Merge branches 'si/more-consistent-fixed-size-handling' and 'si/more-…
iakovenkos Apr 7, 2025
65a8031
undo noir
iakovenkos Apr 7, 2025
610c8a7
??
iakovenkos Apr 7, 2025
0c63fac
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Apr 8, 2025
ab33d8c
noir fmt fix
iakovenkos Apr 8, 2025
e65b01c
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Apr 8, 2025
eee29cb
fix verify_honk_proof + better isolation of padding logic
iakovenkos Apr 8, 2025
c920c38
remove redundant concept
iakovenkos Apr 8, 2025
bf92ab6
Merge branch 'master' into si/more-consistent-fixed-size-handling
iakovenkos Apr 10, 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
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool ClientIVCAPI::verify([[maybe_unused]] const Flags& flags,

vk.mega->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();
vk.eccvm->pcs_verification_key =
std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(vk.eccvm->circuit_size + 1);
std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>((1UL << CONST_ECCVM_LOG_N) + 1);
vk.translator->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();

const bool verified = ClientIVC::verify(proof, vk);
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/prove_tube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)
// We don't serialise and deserialise the Grumkin SRS so initialise with circuit_size + 1 to be able to recursively
// verify IPA. The + 1 is to satisfy IPA verification key requirements.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1025)
vk.eccvm->pcs_verification_key = std::make_shared<GrumpkinVk>(vk.eccvm->circuit_size + 1);
vk.eccvm->pcs_verification_key = std::make_shared<GrumpkinVk>((1UL << CONST_ECCVM_LOG_N) + 1);

auto builder = std::make_shared<Builder>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ template <typename Curve> class GeminiVerifier_ {
{
const size_t log_n = multilinear_challenge.size();
const bool has_interleaved = claim_batcher.interleaved.has_value();
// GeminiVerifier is only used in tests, so no padding required.
static constexpr bool use_padding = false;

const Fr rho = transcript->template get_challenge<Fr>("rho");

Expand Down Expand Up @@ -444,7 +446,7 @@ template <typename Curve> class GeminiVerifier_ {
}

// Compute the evaluations Aₗ(r^{2ˡ}) for l = 0, ..., m-1
std::vector<Fr> gemini_fold_pos_evaluations = compute_fold_pos_evaluations(
std::vector<Fr> gemini_fold_pos_evaluations = compute_fold_pos_evaluations<use_padding>(
log_n, batched_evaluation, multilinear_challenge, r_squares, evaluations, p_neg);
// Extract the evaluation A₀(r) = A₀₊(r) + P₊(r^s)
auto full_a_0_pos = gemini_fold_pos_evaluations[0];
Expand Down Expand Up @@ -538,6 +540,7 @@ template <typename Curve> class GeminiVerifier_ {
* @param fold_neg_evals Evaluations \f$ A_{i-1}(-r^{2^{i-1}}) \f$.
* @return Evaluation \f$ A_0(r) \f$.
*/
template <bool use_padding>
static std::vector<Fr> compute_fold_pos_evaluations(
const size_t log_n,
const Fr& batched_evaluation,
Expand All @@ -550,7 +553,7 @@ template <typename Curve> class GeminiVerifier_ {

Fr eval_pos_prev = batched_evaluation;
// Virtual size allows padding in Shplemini.
const size_t virtual_log_n = evaluation_point.size();
const size_t virtual_log_n = use_padding ? evaluation_point.size() : log_n;

Fr zero{ 0 };
if constexpr (Curve::is_stdlib_type) {
Expand All @@ -576,24 +579,28 @@ template <typename Curve> class GeminiVerifier_ {
Fr eval_pos = ((challenge_power * eval_pos_prev * 2) - eval_neg * (challenge_power * (Fr(1) - u) - u));
// Divide by the denominator
eval_pos *= (challenge_power * (Fr(1) - u) + u).invert();

if constexpr (Curve::is_stdlib_type) {
auto builder = evaluation_point[0].get_context();
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1114): insecure dummy_round derivation!
stdlib::bool_t dummy_round = stdlib::witness_t(builder, l > log_n);
// If current index is bigger than log_n, we propagate `batched_evaluation` to the next
// round. Otherwise, current `eval_pos` A₍ₗ₋₁₎(−r²⁽ˡ⁻¹⁾) becomes `eval_pos_prev` in the round l-2.
eval_pos_prev = Fr::conditional_assign(dummy_round, eval_pos_prev, eval_pos);
// If current index is bigger than log_n, we emplace 0, which is later multiplied against
// Commitment::one().
value_to_emplace = Fr::conditional_assign(dummy_round, zero, eval_pos_prev);

if constexpr (use_padding) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

avoid padding logic in Translator and ECCVM (native and recursive)

if constexpr (Curve::is_stdlib_type) {
auto builder = evaluation_point[0].get_context();
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1114): insecure dummy_round derivation!
stdlib::bool_t dummy_round = stdlib::witness_t(builder, l > log_n);
// If current index is bigger than log_n, we propagate `batched_evaluation` to the next
// round. Otherwise, current `eval_pos` A₍ₗ₋₁₎(−r²⁽ˡ⁻¹⁾) becomes `eval_pos_prev` in the round l-2.
eval_pos_prev = Fr::conditional_assign(dummy_round, eval_pos_prev, eval_pos);
// If current index is bigger than log_n, we emplace 0, which is later multiplied against
// Commitment::one().
value_to_emplace = Fr::conditional_assign(dummy_round, zero, eval_pos_prev);

} else {
// Perform the same logic natively
bool dummy_round = l > log_n;
eval_pos_prev = dummy_round ? eval_pos_prev : eval_pos;
value_to_emplace = dummy_round ? zero : eval_pos_prev;
};
} else {
// Perform the same logic natively
bool dummy_round = l > log_n;
eval_pos_prev = dummy_round ? eval_pos_prev : eval_pos;
value_to_emplace = dummy_round ? zero : eval_pos_prev;
};
eval_pos_prev = eval_pos;
value_to_emplace = eval_pos_prev;
}
fold_pos_evaluations.emplace_back(value_to_emplace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ using Curve = curve::Grumpkin;

class IPATest : public CommitmentTest<Curve> {
public:
static constexpr bool USE_PADDING = false;

using Fr = typename Curve::ScalarField;
using GroupElement = typename Curve::Element;
using CK = CommitmentKey<Curve>;
Expand All @@ -23,7 +25,7 @@ class IPATest : public CommitmentTest<Curve> {
using ShplonkVerifier = ShplonkVerifier_<Curve>;
using GeminiProver = GeminiProver_<Curve>;
using GeminiVerifier = GeminiVerifier_<Curve>;
using ShpleminiVerifier = ShpleminiVerifier_<Curve>;
using ShpleminiVerifier = ShpleminiVerifier_<Curve, USE_PADDING>;
using ClaimBatcher = ClaimBatcher_<Curve>;
using ClaimBatch = ClaimBatcher::Batch;

Expand Down Expand Up @@ -304,7 +306,7 @@ TEST_F(IPATest, ShpleminiIPAWithShift)
auto verifier_transcript = NativeTranscript::verifier_init_empty(prover_transcript);

const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(
small_n, mock_claims.claim_batcher, mle_opening_point, vk->get_g1_identity(), verifier_transcript);
small_log_n, mock_claims.claim_batcher, mle_opening_point, vk->get_g1_identity(), verifier_transcript);

auto result = PCS::reduce_verify_batch_opening_claim(batch_opening_claim, vk, verifier_transcript);
// auto result = PCS::reduce_verify(vk, shplonk_verifier_claim, verifier_transcript);
Expand Down Expand Up @@ -355,7 +357,7 @@ TEST_F(IPATest, ShpleminiIPAShiftsRemoval)
// vectors corresponding to the "shifted" commitment
auto verifier_transcript = NativeTranscript::verifier_init_empty(prover_transcript);

const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(small_n,
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(small_log_n,
mock_claims.claim_batcher,
mle_opening_point,
vk->get_g1_identity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Curve = curve::BN254;

class KZGTest : public CommitmentTest<Curve> {
public:
static constexpr bool USE_PADDING = true;
using Fr = typename Curve::ScalarField;
using Commitment = typename Curve::AffineElement;
using PCS = KZG<curve::BN254>;
Expand All @@ -18,7 +19,7 @@ class KZGTest : public CommitmentTest<Curve> {
using ShplonkVerifier = ShplonkVerifier_<Curve>;
using GeminiProver = GeminiProver_<Curve>;
using GeminiVerifier = GeminiVerifier_<Curve>;
using ShpleminiVerifier = ShpleminiVerifier_<Curve>;
using ShpleminiVerifier = ShpleminiVerifier_<Curve, USE_PADDING>;

static constexpr size_t n = 16;
static constexpr size_t log_n = 4;
Expand Down Expand Up @@ -191,7 +192,7 @@ TEST_F(KZGTest, ShpleminiKzgWithShift)
// Gemini verifier output:
// - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(
n, mock_claims.claim_batcher, mle_opening_point, vk->get_g1_identity(), verifier_transcript);
log_n, mock_claims.claim_batcher, mle_opening_point, vk->get_g1_identity(), verifier_transcript);

const auto pairing_points = PCS::reduce_verify_batch_opening_claim(batch_opening_claim, verifier_transcript);
// Final pairing check: e([Q] - [Q_z] + z[W], [1]_2) = e([W], [x]_2)
Expand Down Expand Up @@ -238,7 +239,7 @@ TEST_F(KZGTest, ShpleminiKzgWithShiftAndInterleaving)

// Gemini verifier output:
// - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(n,
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(log_n,
mock_claims.claim_batcher,
mle_opening_point,
vk->get_g1_identity(),
Expand Down Expand Up @@ -305,7 +306,7 @@ TEST_F(KZGTest, ShpleminiKzgShiftsRemoval)

// Gemini verifier output:
// - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(n,
const auto batch_opening_claim = ShpleminiVerifier::compute_batch_opening_claim(log_n,
mock_claims.claim_batcher,
mle_opening_point,
vk->get_g1_identity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ template <typename Curve> class ShpleminiProver_ {
*
*/

template <typename Curve> class ShpleminiVerifier_ {
template <typename Curve, bool use_padding> class ShpleminiVerifier_ {

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.

Maybe reconsider if this needs to be template. If it does, just FYI you can also default it
template <typename Curve, bool use_padding=true> IIRC. This may let you avoid having to change every single flavor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks! yeah, I'm leaning towards separating verifier methods into the one that uses padding and the one which does not, cause the inputs are going to be of different types + no need to mix the logic

using Fr = typename Curve::ScalarField;
using GroupElement = typename Curve::Element;
using Commitment = typename Curve::AffineElement;
Expand All @@ -192,7 +192,7 @@ template <typename Curve> class ShpleminiVerifier_ {
public:
template <typename Transcript>
static BatchOpeningClaim<Curve> compute_batch_opening_claim(
const Fr N,
const size_t log_n,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • in ECCVM and Translator, log_n is a genuine constexpr integer, so it solves the issue with insecure dummy round derivation and get_value() usage

  • in Ultra/Mega/AVM, log_n is computed many times outside of circuit, so in this PR I'm just reducing the number of occurences of this bug

ClaimBatcher& claim_batcher,
const std::vector<Fr>& multivariate_challenge,
const Commitment& g1_identity,
Expand All @@ -209,14 +209,6 @@ template <typename Curve> class ShpleminiVerifier_ {
{
const bool committed_sumcheck = !sumcheck_round_evaluations.empty();

// Extract log_n
size_t log_n{ 0 };
if constexpr (Curve::is_stdlib_type) {
log_n = numeric::get_msb(static_cast<uint32_t>(N.get_value()));
} else {
log_n = numeric::get_msb(static_cast<uint32_t>(N));
}

// When padding is enabled, the size of the multilinear challenge may be bigger than the log of `circuit_size`.
const size_t virtual_log_n = multivariate_challenge.size();

Expand Down Expand Up @@ -345,12 +337,12 @@ template <typename Curve> class ShpleminiVerifier_ {
// Reconstruct Aᵢ(r²ⁱ) for i=0, ..., d - 1 from the batched evaluation of the multilinear polynomials and
// Aᵢ(−r²ⁱ) for i = 0, ..., d - 1. In the case of interleaving, we compute A₀(r) as A₀₊(r) + P₊(r^s).
const std::vector<Fr> gemini_fold_pos_evaluations =
GeminiVerifier_<Curve>::compute_fold_pos_evaluations(log_n,
batched_evaluation,
multivariate_challenge,
gemini_eval_challenge_powers,
gemini_fold_neg_evaluations,
p_neg);
GeminiVerifier_<Curve>::template compute_fold_pos_evaluations<use_padding>(log_n,
batched_evaluation,
multivariate_challenge,
gemini_eval_challenge_powers,
gemini_fold_neg_evaluations,
p_neg);

// Place the commitments to Gemini fold polynomials Aᵢ in the vector of batch_mul commitments, compute the
// contributions from Aᵢ(−r²ⁱ) for i=1, … , d − 1 to the constant term accumulator, add corresponding scalars
Expand Down Expand Up @@ -464,7 +456,7 @@ template <typename Curve> class ShpleminiVerifier_ {
std::vector<Fr>& scalars,
Fr& constant_term_accumulator)
{
const size_t virtual_log_n = gemini_neg_evaluations.size();
const size_t virtual_log_n = use_padding ? gemini_neg_evaluations.size() : log_n;

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.

By the use in this function it doesn't look like use_padding needs to be a constexpr. it could be a defaulted param of this function.

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1159): Decouple constants from primitives.
// Start from 1, because the commitment to A_0 is reconstructed from the commitments to the multilinear
// polynomials. The corresponding evaluations are also handled separately.
Expand All @@ -484,17 +476,19 @@ template <typename Curve> class ShpleminiVerifier_ {
constant_term_accumulator +=
scaling_factor_neg * gemini_neg_evaluations[j] + scaling_factor_pos * gemini_pos_evaluations[j];

if constexpr (Curve::is_stdlib_type) {
auto builder = gemini_neg_evaluations[0].get_context();
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1114): insecure!
stdlib::bool_t dummy_round = stdlib::witness_t(builder, j >= log_n);
Fr zero = Fr(0);
scaling_factor_neg = Fr::conditional_assign(dummy_round, zero, scaling_factor_neg);
scaling_factor_pos = Fr::conditional_assign(dummy_round, zero, scaling_factor_pos);
} else {
if (j >= log_n) {
scaling_factor_neg = 0;
scaling_factor_pos = 0;
if constexpr (use_padding) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as above - avoid redundant padding

if constexpr (Curve::is_stdlib_type) {
auto builder = gemini_neg_evaluations[0].get_context();
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1114): insecure!
stdlib::bool_t dummy_round = stdlib::witness_t(builder, j >= log_n);
Fr zero = Fr(0);
scaling_factor_neg = Fr::conditional_assign(dummy_round, zero, scaling_factor_neg);
scaling_factor_pos = Fr::conditional_assign(dummy_round, zero, scaling_factor_pos);
} else {
if (j >= log_n) {
scaling_factor_neg = 0;
scaling_factor_pos = 0;
}
}
}
// Place the scaling factor to the 'scalars' vector
Expand Down
Loading