Skip to content

Commit

Permalink
chore: SmallSubgroupIPA tests (#11106)
Browse files Browse the repository at this point in the history
This PR is a follow-up to
#10773
  • Loading branch information
iakovenkos authored Jan 10, 2025
1 parent 1775e53 commit f034e2a
Show file tree
Hide file tree
Showing 7 changed files with 628 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,54 @@ namespace bb {
constexpr size_t COMMITMENT_TEST_NUM_BN254_POINTS = 4096;
constexpr size_t COMMITMENT_TEST_NUM_GRUMPKIN_POINTS = 1 << CONST_ECCVM_LOG_N;

template <class CK> inline std::shared_ptr<CK> CreateCommitmentKey();
template <class CK> inline std::shared_ptr<CK> create_commitment_key(const size_t num_points = 0);

template <> inline std::shared_ptr<CommitmentKey<curve::BN254>> CreateCommitmentKey<CommitmentKey<curve::BN254>>()
template <>
inline std::shared_ptr<CommitmentKey<curve::BN254>> create_commitment_key<CommitmentKey<curve::BN254>>(
const size_t num_points)
{
srs::init_crs_factory(bb::srs::get_ignition_crs_path());
if (num_points != 0) {
return std::make_shared<CommitmentKey<curve::BN254>>(num_points);
};
return std::make_shared<CommitmentKey<curve::BN254>>(COMMITMENT_TEST_NUM_BN254_POINTS);
}
// For IPA
template <> inline std::shared_ptr<CommitmentKey<curve::Grumpkin>> CreateCommitmentKey<CommitmentKey<curve::Grumpkin>>()
template <>
inline std::shared_ptr<CommitmentKey<curve::Grumpkin>> create_commitment_key<CommitmentKey<curve::Grumpkin>>(
const size_t num_points)
{
srs::init_grumpkin_crs_factory(bb::srs::get_grumpkin_crs_path());
if (num_points != 0) {
return std::make_shared<CommitmentKey<curve::Grumpkin>>(num_points);
}
return std::make_shared<CommitmentKey<curve::Grumpkin>>(COMMITMENT_TEST_NUM_GRUMPKIN_POINTS);
}

template <typename CK> inline std::shared_ptr<CK> CreateCommitmentKey()
template <typename CK> inline std::shared_ptr<CK> create_commitment_key(size_t num_points)
// requires std::default_initializable<CK>
{
return std::make_shared<CK>();
return std::make_shared<CK>(num_points);
}

template <class VK> inline std::shared_ptr<VK> CreateVerifierCommitmentKey();
template <class VK> inline std::shared_ptr<VK> create_verifier_commitment_key();

template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> CreateVerifierCommitmentKey<
inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> create_verifier_commitment_key<
VerifierCommitmentKey<curve::BN254>>()
{
return std::make_shared<VerifierCommitmentKey<curve::BN254>>();
}
// For IPA
template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>> CreateVerifierCommitmentKey<
inline std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>> create_verifier_commitment_key<
VerifierCommitmentKey<curve::Grumpkin>>()
{
auto crs_factory = std::make_shared<srs::factories::FileCrsFactory<curve::Grumpkin>>(
bb::srs::get_grumpkin_crs_path(), COMMITMENT_TEST_NUM_GRUMPKIN_POINTS);
return std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(COMMITMENT_TEST_NUM_GRUMPKIN_POINTS, crs_factory);
}
template <typename VK> inline std::shared_ptr<VK> CreateVerifierCommitmentKey()
template <typename VK> inline std::shared_ptr<VK> create_verifier_commitment_key()
// requires std::default_initializable<VK>
{
return std::make_shared<VK>();
Expand Down Expand Up @@ -149,10 +159,10 @@ template <typename Curve> class CommitmentTest : public ::testing::Test {
{
// Avoid reallocating static objects if called in subclasses of FooTest.
if (commitment_key == nullptr) {
commitment_key = CreateCommitmentKey<CK>();
commitment_key = create_commitment_key<CK>();
}
if (verification_key == nullptr) {
verification_key = CreateVerifierCommitmentKey<VK>();
verification_key = create_verifier_commitment_key<VK>();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ std::vector<typename GeminiProver_<Curve>::Claim> GeminiProver_<Curve>::prove(
}
const Fr r_challenge = transcript->template get_challenge<Fr>("Gemini:r");

const bool gemini_challenge_in_small_subgroup = (has_zk) && (r_challenge.pow(Curve::SUBGROUP_SIZE) == Fr(1));

// If Gemini evaluation challenge lands in the multiplicative subgroup used by SmallSubgroupIPA protocol, the
// evaluations of prover polynomials at this challenge would leak witness data.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1194). Handle edge cases in PCS
if (gemini_challenge_in_small_subgroup) {
throw_or_abort("Gemini evaluation challenge is in the SmallSubgroup.");
}

std::vector<Claim> claims =
compute_fold_polynomial_evaluations(log_n, std::move(fold_polynomials), r_challenge, std::move(batched_group));

Expand Down
Loading

1 comment on commit f034e2a

@AztecBot
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: f034e2a Previous: 1775e53 Ratio
wasmClientIVCBench/Full/6 76677.342763 ms/iter 72659.365212 ms/iter 1.06

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Please sign in to comment.