-
Notifications
You must be signed in to change notification settings - Fork 305
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
refactor: Move vk computation out of Honk Ultra composer #4811
Changes from all commits
27a0bdf
1194b86
33104c2
60cbf55
396b0f5
52a3815
6842b05
6525add
4cb4182
5154851
7614280
7b44905
df82024
a08733e
0948fd4
56d2d78
45b5f7a
5f50a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
barretenberg_module(ipa_bench ultra_honk) | ||
barretenberg_module(ipa_bench commitment_schemes) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,7 @@ namespace bb { | |
template <typename Curve> std::shared_ptr<CommitmentKey<Curve>> create_commitment_key(const size_t num_points) | ||
{ | ||
std::string srs_path; | ||
if constexpr (std::same_as<Curve, curve::BN254>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic was repeated |
||
srs_path = "../srs_db/ignition"; | ||
} else { | ||
static_assert(std::same_as<Curve, curve::Grumpkin>); | ||
srs_path = "../srs_db/grumpkin"; | ||
} | ||
auto crs_factory = std::make_shared<bb::srs::factories::FileCrsFactory<Curve>>(srs_path, num_points); | ||
return std::make_shared<CommitmentKey<Curve>>(num_points, crs_factory); | ||
return std::make_shared<CommitmentKey<Curve>>(num_points); | ||
} | ||
|
||
constexpr size_t MAX_LOG_NUM_POINTS = 24; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ template <class Curve> class CommitmentKey { | |
using Commitment = typename Curve::AffineElement; | ||
|
||
public: | ||
scalar_multiplication::pippenger_runtime_state<Curve> pippenger_runtime_state; | ||
std::shared_ptr<srs::factories::CrsFactory<Curve>> crs_factory; | ||
std::shared_ptr<srs::factories::ProverCrs<Curve>> srs; | ||
|
||
CommitmentKey() = delete; | ||
|
||
/** | ||
|
@@ -45,14 +49,14 @@ template <class Curve> class CommitmentKey { | |
* @param path | ||
* | ||
*/ | ||
CommitmentKey(const size_t num_points, | ||
std::shared_ptr<bb::srs::factories::CrsFactory<Curve>> crs_factory = bb::srs::get_crs_factory()) | ||
CommitmentKey(const size_t num_points) | ||
: pippenger_runtime_state(num_points) | ||
, crs_factory(srs::get_crs_factory<Curve>()) | ||
, srs(crs_factory->get_prover_crs(num_points)) | ||
{} | ||
|
||
// Note: This constructor is used only by Plonk; For Honk the srs is extracted by the CommitmentKey | ||
CommitmentKey(const size_t num_points, std::shared_ptr<bb::srs::factories::ProverCrs<Curve>> prover_crs) | ||
// Note: This constructor is to be used only by Plonk; For Honk the srs lives in the CommitmentKey | ||
CommitmentKey(const size_t num_points, std::shared_ptr<srs::factories::ProverCrs<Curve>> prover_crs) | ||
: pippenger_runtime_state(num_points) | ||
, srs(prover_crs) | ||
{} | ||
|
@@ -68,12 +72,9 @@ template <class Curve> class CommitmentKey { | |
BB_OP_COUNT_TIME(); | ||
const size_t degree = polynomial.size(); | ||
ASSERT(degree <= srs->get_monomial_size()); | ||
return bb::scalar_multiplication::pippenger_unsafe<Curve>( | ||
return scalar_multiplication::pippenger_unsafe<Curve>( | ||
const_cast<Fr*>(polynomial.data()), srs->get_monomial_points(), degree, pippenger_runtime_state); | ||
}; | ||
|
||
bb::scalar_multiplication::pippenger_runtime_state<Curve> pippenger_runtime_state; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just moved these up bc data members go at the top now. |
||
std::shared_ptr<bb::srs::factories::ProverCrs<Curve>> srs; | ||
}; | ||
|
||
} // namespace bb |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,15 +97,17 @@ class PrecomputedEntitiesBase { | |
* @tparam FF The scalar field on which we will encode our polynomial data. When instantiating, this may be extractable | ||
* from the other template paramter. | ||
*/ | ||
template <typename PrecomputedPolynomials, typename WitnessPolynomials> | ||
template <typename PrecomputedPolynomials, typename WitnessPolynomials, typename CommitmentKey_> | ||
class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { | ||
public: | ||
using Polynomial = typename PrecomputedPolynomials::DataType; | ||
using FF = typename Polynomial::FF; | ||
|
||
size_t circuit_size; | ||
bool contains_recursive_proof; | ||
std::vector<uint32_t> recursive_proof_public_input_indices; | ||
bb::EvaluationDomain<FF> evaluation_domain; | ||
std::shared_ptr<CommitmentKey_> commitment_key; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Establishing that this is where this should live. |
||
|
||
std::vector<std::string> get_labels() const | ||
{ | ||
|
@@ -119,8 +121,9 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { | |
ProvingKey_() = default; | ||
ProvingKey_(const size_t circuit_size, const size_t num_public_inputs) | ||
{ | ||
this->commitment_key = std::make_shared<CommitmentKey_>(circuit_size + 1); | ||
this->evaluation_domain = bb::EvaluationDomain<FF>(circuit_size, circuit_size); | ||
PrecomputedPolynomials::circuit_size = circuit_size; | ||
this->circuit_size = circuit_size; | ||
this->log_circuit_size = numeric::get_msb(circuit_size); | ||
this->num_public_inputs = num_public_inputs; | ||
// Allocate memory for precomputed polynomials | ||
|
@@ -148,6 +151,16 @@ template <typename PrecomputedCommitments> class VerificationKey_ : public Preco | |
this->log_circuit_size = numeric::get_msb(circuit_size); | ||
this->num_public_inputs = num_public_inputs; | ||
}; | ||
template <typename ProvingKeyPtr> VerificationKey_(const ProvingKeyPtr& proving_key) | ||
{ | ||
this->circuit_size = proving_key->circuit_size; | ||
this->log_circuit_size = numeric::get_msb(this->circuit_size); | ||
this->num_public_inputs = proving_key->num_public_inputs; | ||
|
||
for (auto [polynomial, commitment] : zip_view(proving_key->get_precomputed_polynomials(), this->get_all())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified by counting members that this is accomplishing the same as the particular flavor functions it replaces. |
||
commitment = proving_key->commitment_key->commit(polynomial); | ||
} | ||
} | ||
}; | ||
|
||
// Because of how Gemini is written, is importat to put the polynomials out in this order. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
barretenberg_module(proof_system relations crypto_pedersen_commitment crypto_pedersen_hash) | ||
barretenberg_module(proof_system relations crypto_pedersen_hash srs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crs_factory
now lives in commitment key.