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: update namespace changes #41

Merged
merged 1 commit into from
Feb 7, 2024
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: 3 additions & 3 deletions bberg/src/circuit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl CircuitBuilder for BBFiles {
};
let check_lookup_transformation = |lookup_name: &String| {
format!(
"if (!evaluate_logderivative.template operator()<honk::sumcheck::{lookup_name}_relation<FF>>(\"{lookup_name}\")) {{
"if (!evaluate_logderivative.template operator()<honk::{lookup_name}_relation<FF>>(\"{lookup_name}\")) {{
return false;
}}"
)
Expand Down Expand Up @@ -125,7 +125,7 @@ namespace bb {{

class {name}CircuitBuilder {{
public:
using Flavor = bb::honk::flavor::{name}Flavor;
using Flavor = bb::{name}Flavor;
using FF = Flavor::FF;
using Row = {name}FullRow<FF>;

Expand Down Expand Up @@ -204,7 +204,7 @@ fn get_lookup_check_closure() -> String {
const auto evaluate_logderivative = [&]<typename LogDerivativeSettings>(const std::string& lookup_name) {

// Check the logderivative relation
bb::honk::logderivative_library::compute_logderivative_inverse<
bb::logderivative_library::compute_logderivative_inverse<
Flavor,
LogDerivativeSettings>(
polys, params, num_rows);
Expand Down
10 changes: 5 additions & 5 deletions bberg/src/composer_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ impl ComposerBuilder for BBFiles {
"
{include_str}

namespace bb::honk {{
namespace bb {{

using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
void {name}Composer::compute_witness(CircuitConstructor& circuit)
{{
if (computed_witness) {{
Expand Down Expand Up @@ -109,10 +109,10 @@ std::shared_ptr<Flavor::VerificationKey> {name}Composer::compute_verification_ke
"
{include_str}

namespace bb::honk {{
namespace bb {{
class {name}Composer {{
public:
using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
using CircuitConstructor = {name}CircuitBuilder;
using ProvingKey = Flavor::ProvingKey;
using VerificationKey = Flavor::VerificationKey;
Expand Down Expand Up @@ -170,7 +170,7 @@ class {name}Composer {{
}};
}};

}} // namespace bb::honk
}} // namespace bb
"
);

Expand Down
30 changes: 15 additions & 15 deletions bberg/src/flavor_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl FlavorBuilder for BBFiles {
"
{includes}

namespace bb::honk::flavor {{
namespace bb {{

class {name}Flavor {{
public:
Expand Down Expand Up @@ -101,7 +101,7 @@ class {name}Flavor {{
{transcript}
}};

}} // namespace bb::honk
}} // namespace bb


"
Expand Down Expand Up @@ -150,7 +150,7 @@ fn create_relations_tuple(master_name: &str, relation_file_names: &[String]) ->
fn create_permutations_tuple(permutations: &[Permutation]) -> String {
permutations
.iter()
.map(|perm| format!("sumcheck::{}_relation<FF>", perm.attribute.clone().unwrap()))
.map(|perm| format!("{}_relation<FF>", perm.attribute.clone().unwrap()))
.collect::<Vec<_>>()
.join(", ")
}
Expand All @@ -162,16 +162,16 @@ fn create_class_aliases() -> &'static str {
r#"
using Curve = curve::BN254;
using G1 = Curve::Group;
using PCS = pcs::kzg::KZG<Curve>;
using PCS = KZG<Curve>;

using FF = G1::subgroup_field;
using Polynomial = bb::Polynomial<FF>;
using PolynomialHandle = std::span<FF>;
using GroupElement = G1::element;
using Commitment = G1::affine_element;
using CommitmentHandle = G1::affine_element;
using CommitmentKey = pcs::CommitmentKey<Curve>;
using VerifierCommitmentKey = pcs::VerifierCommitmentKey<Curve>;
using CommitmentKey = bb::CommitmentKey<Curve>;
using VerifierCommitmentKey = bb::VerifierCommitmentKey<Curve>;
using RelationSeparator = FF;
"#
}
Expand Down Expand Up @@ -489,7 +489,7 @@ fn generate_transcript(witness: &[String]) -> String {
let declaration_transform = |c: &_| format!("Commitment {c};");
let deserialize_transform = |name: &_| {
format!(
"{name} = deserialize_from_buffer<Commitment>(Transcript::proof_data, num_bytes_read);",
"{name} = deserialize_from_buffer<Commitment>(Transcript::proof_data, num_frs_read);",
)
};
let serialize_transform =
Expand All @@ -515,30 +515,30 @@ fn generate_transcript(witness: &[String]) -> String {

Transcript() = default;

Transcript(const std::vector<uint8_t>& proof)
Transcript(const std::vector<FF>& proof)
: BaseTranscript(proof)
{{}}

void deserialize_full_transcript()
{{
size_t num_bytes_read = 0;
circuit_size = deserialize_from_buffer<uint32_t>(proof_data, num_bytes_read);
size_t num_frs_read = 0;
circuit_size = deserialize_from_buffer<uint32_t>(proof_data, num_frs_read);
size_t log_n = numeric::get_msb(circuit_size);

{deserialize_wires}

for (size_t i = 0; i < log_n; ++i) {{
sumcheck_univariates.emplace_back(
deserialize_from_buffer<bb::Univariate<FF, BATCHED_RELATION_PARTIAL_LENGTH>>(
Transcript::proof_data, num_bytes_read));
Transcript::proof_data, num_frs_read));
}}
sumcheck_evaluations = deserialize_from_buffer<std::array<FF, NUM_ALL_ENTITIES>>(
Transcript::proof_data, num_bytes_read);
Transcript::proof_data, num_frs_read);
for (size_t i = 0; i < log_n; ++i) {{
zm_cq_comms.push_back(deserialize_from_buffer<Commitment>(proof_data, num_bytes_read));
zm_cq_comms.push_back(deserialize_from_buffer<Commitment>(proof_data, num_frs_read));
}}
zm_cq_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
zm_pi_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
zm_cq_comm = deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
zm_pi_comm = deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
}}

void serialize_full_transcript()
Expand Down
4 changes: 2 additions & 2 deletions bberg/src/lookup_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn create_lookup_settings_file(lookup: &Lookup) -> String {
"
{lookup_settings_includes}

namespace bb::honk::sumcheck {{
namespace bb::sumcheck {{

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
Expand All @@ -215,7 +215,7 @@ fn create_lookup_settings_file(lookup: &Lookup) -> String {
* 3) Update \"DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS\" and \"DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS\" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,\"`
* using Relations = std::tuple<sumcheck::GenericLookupRelation<sumcheck::ExampleXorLookupSettings,
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
Expand Down
2 changes: 1 addition & 1 deletion bberg/src/permutation_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn create_permutation_settings_file(permutation: &Permutation) -> String {
"
{permutation_settings_includes}

namespace bb::honk::sumcheck {{
namespace bb::sumcheck {{

class {permutation_name}_permutation_settings {{
public:
Expand Down
31 changes: 16 additions & 15 deletions bberg/src/prover_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ impl ProverBuilder for BBFiles {
let include_str = includes_hpp(name);
let prover_hpp = format!("
{include_str}
namespace bb::honk {{
namespace bb {{

class {name}Prover {{

using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
using FF = Flavor::FF;
using PCS = Flavor::PCS;
using PCSCommitmentKey = Flavor::CommitmentKey;
Expand All @@ -34,8 +34,8 @@ impl ProverBuilder for BBFiles {
void execute_relation_check_rounds();
void execute_zeromorph_rounds();

plonk::proof& export_proof();
plonk::proof& construct_proof();
HonkProof& export_proof();
HonkProof& construct_proof();

std::shared_ptr<Transcript> transcript = std::make_shared<Transcript>();

Expand All @@ -52,17 +52,17 @@ impl ProverBuilder for BBFiles {

Polynomial quotient_W;

sumcheck::SumcheckOutput<Flavor> sumcheck_output;
SumcheckOutput<Flavor> sumcheck_output;

std::shared_ptr<PCSCommitmentKey> commitment_key;

using ZeroMorph = pcs::zeromorph::ZeroMorphProver_<Curve>;
using ZeroMorph = ZeroMorphProver_<Curve>;

private:
plonk::proof proof;
HonkProof proof;
}};

}} // namespace bb::honk
}} // namespace bb

");
self.write_file(&self.prover, &format!("{}_prover.hpp", name), &prover_hpp);
Expand All @@ -74,9 +74,10 @@ impl ProverBuilder for BBFiles {
let prover_cpp = format!("
{include_str}

namespace bb::honk {{
namespace bb {{

using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
using FF = Flavor::FF;

/**
* Create {name}Prover from proving key, witness and manifest.
Expand Down Expand Up @@ -136,7 +137,7 @@ impl ProverBuilder for BBFiles {
*/
void {name}Prover::execute_relation_check_rounds()
{{
using Sumcheck = sumcheck::SumcheckProver<Flavor>;
using Sumcheck = SumcheckProver<Flavor>;

auto sumcheck = Sumcheck(key->circuit_size, transcript);

Expand Down Expand Up @@ -168,13 +169,13 @@ impl ProverBuilder for BBFiles {
}}


plonk::proof& {name}Prover::export_proof()
HonkProof& {name}Prover::export_proof()
{{
proof.proof_data = transcript->proof_data;
proof = transcript->proof_data;
return proof;
}}

plonk::proof& {name}Prover::construct_proof()
HonkProof& {name}Prover::construct_proof()
{{
// Add circuit size public input size and public inputs to transcript.
execute_preamble_round();
Expand All @@ -201,7 +202,7 @@ impl ProverBuilder for BBFiles {
return export_proof();
}}

}} // namespace bb::honk
}} // namespace bb


");
Expand Down
23 changes: 10 additions & 13 deletions bberg/src/verifier_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ impl VerifierBuilder for BBFiles {
let ver_cpp = format!("
{include_str}

using namespace bb;
using namespace bb::honk::sumcheck;

namespace bb::honk {{
namespace bb {{
{name}Verifier::{name}Verifier(std::shared_ptr<Flavor::VerificationKey> verifier_key)
: key(verifier_key)
{{}}
Expand All @@ -45,19 +42,19 @@ impl VerifierBuilder for BBFiles {
* @brief This function verifies an {name} Honk proof for given program settings.
*
*/
bool {name}Verifier::verify_proof(const plonk::proof& proof)
bool {name}Verifier::verify_proof(const HonkProof& proof)
{{
using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
using FF = Flavor::FF;
using Commitment = Flavor::Commitment;
// using Curve = Flavor::Curve;
// using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_<Curve>;
// using ZeroMorph = ZeroMorphVerifier_<Curve>;
using VerifierCommitments = Flavor::VerifierCommitments;
using CommitmentLabels = Flavor::CommitmentLabels;

RelationParameters<FF> relation_parameters;

transcript = std::make_shared<Transcript>(proof.proof_data);
transcript = std::make_shared<Transcript>(proof);

VerifierCommitments commitments {{ key }};
CommitmentLabels commitment_labels;
Expand Down Expand Up @@ -106,7 +103,7 @@ impl VerifierBuilder for BBFiles {
}}


}} // namespace bb::honk
}} // namespace bb


");
Expand All @@ -120,9 +117,9 @@ impl VerifierBuilder for BBFiles {
"
{include_str}

namespace bb::honk {{
namespace bb {{
class {name}Verifier {{
using Flavor = honk::flavor::{name}Flavor;
using Flavor = {name}Flavor;
using FF = Flavor::FF;
using Commitment = Flavor::Commitment;
using VerificationKey = Flavor::VerificationKey;
Expand All @@ -137,15 +134,15 @@ impl VerifierBuilder for BBFiles {
{name}Verifier& operator=(const {name}Verifier& other) = delete;
{name}Verifier& operator=({name}Verifier&& other) noexcept;

bool verify_proof(const plonk::proof& proof);
bool verify_proof(const HonkProof& proof);

std::shared_ptr<VerificationKey> key;
std::map<std::string, Commitment> commitments;
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;
std::shared_ptr<Transcript> transcript;
}};

}} // namespace bb::honk
}} // namespace bb


"
Expand Down
Loading