Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: SmallSubgroupIPA tests #11106

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include "barretenberg/transcript/transcript.hpp"
#include "commitment_key.test.hpp"

namespace bb {
iakovenkos marked this conversation as resolved.
Show resolved Hide resolved
class TestBn254Flavor {
public:
using Curve = curve::BN254;
using CommitmentKey = CommitmentKey<Curve>;
using Transcript = NativeTranscript;
using FF = typename Curve::ScalarField;
static constexpr size_t SUBGROUP_SIZE = Curve::SUBGROUP_SIZE;
};

class TestGrumpkinFlavor {
public:
using Curve = curve::Grumpkin;
using CommitmentKey = CommitmentKey<Curve>;
using Transcript = NativeTranscript;
using FF = typename Curve::ScalarField;
static constexpr size_t SUBGROUP_SIZE = Curve::SUBGROUP_SIZE;
};
} // namespace bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Introduced this struct to remove redundant pattern in pcs tests where we manually generate polys, commit to them, and evaluate them


#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/transcript/transcript.hpp"
#include "commitment_key.test.hpp"

namespace bb {

template <typename Curve> struct PCSInstanceWitnessGenerator {
iakovenkos marked this conversation as resolved.
Show resolved Hide resolved
public:
using CommitmentKey = CommitmentKey<Curve>;
using Fr = typename Curve::ScalarField;
using Commitment = typename Curve::AffineElement;
using Polynomial = bb::Polynomial<Fr>;

std::shared_ptr<CommitmentKey> ck;
std::vector<Polynomial> polynomials;
iakovenkos marked this conversation as resolved.
Show resolved Hide resolved
std::vector<Polynomial> shiftable_polynomials;
std::vector<Fr> const_size_mle_opening_point;
std::vector<Commitment> unshifted_commitments;
std::vector<Commitment> shifted_commitments;
std::vector<Fr> unshifted_evals;
std::vector<Fr> shifted_evals;

PCSInstanceWitnessGenerator(const size_t n,
const size_t num_polynomials,
const size_t num_shiftable,
const std::vector<Fr>& mle_opening_point,
std::shared_ptr<CommitmentKey>& commitment_key)
: ck(commitment_key) // Initialize the commitment key
, polynomials(num_polynomials)
, shiftable_polynomials(num_shiftable)

{
construct_instance_and_witnesses(n, mle_opening_point);
}

void construct_instance_and_witnesses(size_t n, const std::vector<Fr>& mle_opening_point)
{

const size_t num_unshifted = polynomials.size() - shiftable_polynomials.size();

for (size_t idx = 0; idx < num_unshifted; idx++) {
polynomials[idx] = Polynomial::random(n);
unshifted_commitments.push_back(ck->commit(polynomials[idx]));
unshifted_evals.push_back(polynomials[idx].evaluate_mle(mle_opening_point));
}

size_t idx = num_unshifted;
for (auto& poly : shiftable_polynomials) {
poly = Polynomial::random(n, /*shiftable*/ 1);
polynomials[idx] = poly;
auto comm = this->ck->commit(poly);
iakovenkos marked this conversation as resolved.
Show resolved Hide resolved
unshifted_commitments.push_back(comm);
shifted_commitments.push_back(comm);
iakovenkos marked this conversation as resolved.
Show resolved Hide resolved
unshifted_evals.push_back(poly.evaluate_mle(mle_opening_point));
shifted_evals.push_back(poly.evaluate_mle(mle_opening_point, true));
idx++;
}
}
};

} // namespace bb
Loading
Loading