Skip to content
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
8 changes: 4 additions & 4 deletions barretenberg/cpp/scripts/bench_hardware_concurrency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ for test_case in test_cases:
# Categorize metrics based on name
if "Chonk" in metric_name or "Chonk" in metric_name:
components["Main"][metric_name][cpu] = time_ms
elif "ProtogalaxyProver" in metric_name:
components["ProtogalaxyProver"][metric_name][cpu] = time_ms
elif "HypernovaProver" in metric_name or "HypernovaFoldingProver" in metric_name or "HypernovaFoldingVerifier" in metric_name:
components["HypernovaProver"][metric_name][cpu] = time_ms
elif "OinkProver" in metric_name:
components["OinkProver"][metric_name][cpu] = time_ms
elif "Decider" in metric_name:
Expand All @@ -224,7 +224,7 @@ for test_case in test_cases:
# Generate tables for each component
sections = [
("Main Components", "Main"),
("ProtogalaxyProver Components", "ProtogalaxyProver"),
("HypernovaProver Components", "HypernovaProver"),
("OinkProver", "OinkProver"),
("Decider", "Decider"),
("Goblin", "Goblin"),
Expand Down Expand Up @@ -259,7 +259,7 @@ for test_case in test_cases:
count = int(count_match.group(1)) if count_match else None

# Clean up metric name
clean_name = metric_name.replace('ProtogalaxyProver::', '').replace('OinkProver::', '')
clean_name = metric_name.replace('HypernovaFoldingProver::', '').replace('HypernovaFoldingVerifier::', '').replace('HypernovaProver::', '').replace('OinkProver::', '')

row = generate_table_row(clean_name, times, available_cpus, count)
print("| " + row + " |")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd ..
# - Generate a hash for versioning: sha256sum bb-chonk-inputs.tar.gz
# - Upload the compressed results: aws s3 cp bb-chonk-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-chonk-inputs-[hash(0:8)].tar.gz
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
pinned_short_hash="7222b532"
pinned_short_hash="6322e510"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are not hashing hardcoded zero target sum - hence vk updates

pinned_chonk_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-chonk-inputs-${pinned_short_hash}.tar.gz"

function compress_and_upload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta
bool has_chonk_recursion_constraints = !constraint_system.chonk_recursion_constraints.empty();

if constexpr (IsMegaBuilder<Builder>) {
// We shouldn't have both honk recursion constraints and pg recursion constraints.
// We shouldn't have both honk recursion constraints and HN recursion constraints.
BB_ASSERT_EQ(!has_honk_recursion_constraints || !has_hn_recursion_constraints,
true,
"Invalid circuit: both honk and ivc recursion constraints present.");
Expand Down Expand Up @@ -312,7 +312,7 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta
// we return a vinfo for the case of Chonk + AVM
BB_ASSERT_EQ(has_hn_recursion_constraints,
false,
"Invalid circuit: pg recursion constraints are present with UltraBuilder.");
"Invalid circuit: HN recursion constraints are present with UltraBuilder.");
BB_ASSERT_EQ(!(has_chonk_recursion_constraints && has_honk_recursion_constraints),
true,
"Invalid circuit: both honk and chonk recursion constraints are present.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ HypernovaFoldingProver::Accumulator HypernovaFoldingProver::sumcheck_output_to_a
const std::shared_ptr<typename HypernovaFoldingProver::ProverInstance>& instance,
const std::shared_ptr<typename HypernovaFoldingProver::VerificationKey>& honk_vk)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingProver::sumcheck_output_to_accumulator");

// Generate challenges to batch shifted and unshifted polynomials/commitments/evaluation
auto [unshifted_challenges, shifted_challenges] = get_batching_challenges();
Expand Down Expand Up @@ -91,7 +91,7 @@ Polynomial<HypernovaFoldingProver::FF> HypernovaFoldingProver::batch_polynomials
const size_t& full_batched_size,
const std::vector<FF>& challenges)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingProver::batch_polynomials");
BB_ASSERT_EQ(full_batched_size,
polynomials_to_batch[0].virtual_size(),
"The virtual size of the first polynomial is different from the full batched size.");
Expand All @@ -116,7 +116,7 @@ HypernovaFoldingProver::Accumulator HypernovaFoldingProver::instance_to_accumula
const std::shared_ptr<typename HypernovaFoldingProver::ProverInstance>& instance,
const std::shared_ptr<VerificationKey>& honk_vk)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingProver::instance_to_accumulator");

vinfo("HypernovaFoldingProver: converting instance to accumulator...");

Expand Down
15 changes: 5 additions & 10 deletions barretenberg/cpp/src/barretenberg/hypernova/hypernova_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ HypernovaFoldingVerifier<Flavor>::Accumulator HypernovaFoldingVerifier<Flavor>::
HypernovaFoldingVerifier<Flavor>::MegaSumcheckOutput& sumcheck_output,
const std::shared_ptr<HypernovaFoldingVerifier::VerifierInstance>& instance)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingVerifier::sumcheck_output_to_accumulator");

// Generate challenges to batch shifted and unshifted polynomials/commitments/evaluation
auto [unshifted_challenges, shifted_challenges] = get_batching_challenges();
Expand Down Expand Up @@ -82,27 +82,22 @@ template <typename Flavor>
SumcheckOutput<Flavor> HypernovaFoldingVerifier<Flavor>::sumcheck_on_incoming_instance(
const std::shared_ptr<typename HypernovaFoldingVerifier::VerifierInstance>& instance, const Proof& proof)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingVerifier::sumcheck_on_incoming_instance");

vinfo("HypernovaFoldingVerifier: verifying Oink proof...");
// Complete the incoming verifier instance
OinkVerifier verifier{ instance, transcript };
transcript->load_proof(proof);
verifier.verify();

if constexpr (IsRecursiveFlavor<Flavor>) {
instance->target_sum = FF::from_witness_index(instance->builder, instance->builder->zero_idx());
} else {
instance->target_sum = FF::zero();
}
instance->gate_challenges = transcript->template get_powers_of_challenge<FF>(
"HypernovaFoldingProver:gate_challenge", Flavor::VIRTUAL_LOG_N);

// Sumcheck verification
vinfo("HypernovaFoldingVerifier: verifying Sumcheck to turn instance into an accumulator...");

std::vector<FF> padding_indicator_array(Flavor::VIRTUAL_LOG_N, 1);
SumcheckVerifier sumcheck(transcript, instance->alpha, Flavor::VIRTUAL_LOG_N, instance->target_sum);
SumcheckVerifier sumcheck(transcript, instance->alpha, Flavor::VIRTUAL_LOG_N);
SumcheckOutput<Flavor> sumcheck_output =
sumcheck.verify(instance->relation_parameters, instance->gate_challenges, padding_indicator_array);

Expand All @@ -114,7 +109,7 @@ std::pair<bool, typename HypernovaFoldingVerifier<Flavor>::Accumulator> Hypernov
instance_to_accumulator(const std::shared_ptr<typename HypernovaFoldingVerifier::VerifierInstance>& instance,
const Proof& proof)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingVerifier::instance_to_accumulator");

auto sumcheck_output = sumcheck_on_incoming_instance(instance, proof);

Expand All @@ -135,7 +130,7 @@ std::tuple<bool, bool, typename HypernovaFoldingVerifier<Flavor>::Accumulator> H
Flavor>::verify_folding_proof(const std::shared_ptr<typename HypernovaFoldingVerifier::VerifierInstance>& instance,
const HypernovaFoldingVerifier::Proof& proof)
{
BB_BENCH();
BB_BENCH_NAME("HypernovaFoldingVerifier::verify_folding_proof");

vinfo("HypernovaFoldingVerifier: verifying folding proof...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DeciderRecursiveVerifier_<Flavor>::PairingPoints DeciderRecursiveVerifier_<Flavo
// DeciderRecursiveVerifier's log circuit size is fixed, hence we are using a trivial `padding_indicator_array`.
std::vector<FF> padding_indicator_array(Flavor::VIRTUAL_LOG_N, 1);

Sumcheck sumcheck(transcript, accumulator->alpha, Flavor::VIRTUAL_LOG_N, accumulator->target_sum);
Sumcheck sumcheck(transcript, accumulator->alpha, Flavor::VIRTUAL_LOG_N);
SumcheckOutput<Flavor> output =
sumcheck.verify(accumulator->relation_parameters, accumulator->gate_challenges, padding_indicator_array);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ template <IsRecursiveFlavor Flavor_> class RecursiveVerifierInstance_ {
SubrelationSeparator alpha;
RelationParameters<FF> relation_parameters;
std::vector<FF> gate_challenges;
FF target_sum{ 0 };

WitnessCommitments witness_commitments;
CommitmentLabels commitment_labels;
Expand Down Expand Up @@ -84,7 +83,6 @@ template <IsRecursiveFlavor Flavor_> class RecursiveVerifierInstance_ {
comm = Commitment::from_witness(builder, other_comms[comm_idx]);
comm_idx++;
}
target_sum = FF::from_witness(builder, verification_key->target_sum);
size_t challenge_idx = 0;
gate_challenges = std::vector<FF>(verification_key->gate_challenges.size());
for (auto& challenge : gate_challenges) {
Expand Down Expand Up @@ -129,7 +127,6 @@ template <IsRecursiveFlavor Flavor_> class RecursiveVerifierInstance_ {
zip_view(witness_commitments.get_all(), verifier_inst.witness_commitments.get_all())) {
inst_comm = comm.get_value();
}
verifier_inst.target_sum = target_sum.get_value();

verifier_inst.gate_challenges = std::vector<NativeFF>(gate_challenges.size());
for (auto [challenge, inst_challenge] : zip_view(gate_challenges, verifier_inst.gate_challenges)) {
Expand Down Expand Up @@ -174,7 +171,6 @@ template <IsRecursiveFlavor Flavor_> class RecursiveVerifierInstance_ {
this->relation_parameters.gamma);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_public_input_delta",
this->relation_parameters.public_input_delta);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_target_sum", this->target_sum);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_gate_challenges",
this->gate_challenges);

Expand Down
17 changes: 6 additions & 11 deletions barretenberg/cpp/src/barretenberg/ultra_honk/decider_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@
namespace bb {

/**
* Create DeciderProver_ from an accumulator.
*
* @param accumulator Relaxed instance (ϕ, ω, \vec{β}, e) whose proof we want to generate, produced by Protogalaxy
* folding prover
*
* @tparam a type of UltraFlavor
* */
* Create DeciderProver_ from a prover instance.
*/
template <IsUltraOrMegaHonk Flavor>
DeciderProver_<Flavor>::DeciderProver_(const std::shared_ptr<ProverInstance>& prover_instance,
const std::shared_ptr<Transcript>& transcript)
DeciderProver_<Flavor>::DeciderProver_(std::shared_ptr<ProverInstance> prover_instance,
std::shared_ptr<Transcript> transcript)
: prover_instance(std::move(prover_instance))
, transcript(transcript)
, transcript(std::move(transcript))
{}

/**
* @brief Run Sumcheck to establish that ∑_i pow(\vec{β*})f_i(ω) = e*. This results in u = (u_1,...,u_d) sumcheck round
* @brief Run Sumcheck to establish that ∑_i pow(\vec{β*})f_i(ω) = 0. This results in u = (u_1,...,u_d) sumcheck round
* challenges and all evaluations at u being calculated.
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ template <IsUltraOrMegaHonk Flavor> class DeciderProver_ {
using Proof = typename Flavor::Transcript::Proof;

public:
explicit DeciderProver_(const std::shared_ptr<ProverInstance>&,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
explicit DeciderProver_(std::shared_ptr<ProverInstance>, std::shared_ptr<Transcript> transcript);

BB_PROFILE void execute_relation_check_rounds();
BB_PROFILE void execute_pcs_rounds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ template <typename Flavor> typename DeciderVerifier_<Flavor>::Output DeciderVeri
}
}

SumcheckVerifier<Flavor> sumcheck(transcript, accumulator->alpha, virtual_log_n, accumulator->target_sum);
SumcheckVerifier<Flavor> sumcheck(transcript, accumulator->alpha, virtual_log_n);
// For MegaZKFlavor: receive commitments to Libra masking polynomials
std::array<Commitment, NUM_LIBRA_COMMITMENTS> libra_commitments = {};
if constexpr (Flavor::HasZK) {
Expand Down
42 changes: 2 additions & 40 deletions barretenberg/cpp/src/barretenberg/ultra_honk/prover_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,7 @@ namespace bb {

/**
* @brief A ProverInstance is normally constructed from a finalized circuit and it contains all the information
* required by a Mega Honk prover to create a proof. A ProverInstance is also the result of running the
* Protogalaxy prover, in which case it becomes a relaxed counterpart with the folding parameters (target sum and gate
* challenges set to non-zero values).
*
* @details A ProverInstance is the equivalent of \f$\omega\f$ in the Protogalaxy paper.
*
* Our arithmetization works as follows. The Flavor defines \f$fM\f$ (Flavor::NUM_ALL_ENTITIES) and a series of
* relations
* \f$R_1, \dots, R_n\f$ (Flavor::Relations_). Each relation is made up by a series of subrelations: \f$R_i =
* (R_{i,1}, \dots, R_{i,r_i})\f$.
*
* Write \f$p_1, \dots, p_M\f$ for the prover polynomials and \f$p_{i,k}\f$ for the \f$k\f$-th coefficient of \f$p_i\f$.
* Write \f$\theta_1, \dots, \theta_6\f$ for the relation parameters. Let \f$n\f$ be the max degree of the prover
* polynomials. A pure ProverInstance is valid if for all \f$i, j, k\f$ we have \f$R_{i,j}(p_{1,k}, \dots,
* p_{M,k}, \theta_1, \dots, \theta_6) = 0\f$.
*
* Instead of checking each equality separately, we batch them using challenges that we call `alphas`. Thus, a
* ProverInstance is valid if for each \f$k = 0, \dots, n\f$.
* \f[
* f_k(\omega) := \sum_{i, j} \alpha_{i,j} R_{i,j}(p_{1,k}, \dots, p_{M,k}, \theta_1, \dots, \theta_6) = 0
* \f]
*
* Instead of checking each equality separately, we once again batch them using challenges. These challenges are the
* \f$pow_i(\beta)\f$ in the Protogalaxy paper, and are derived using the vector `gate_challenges` as the vector
* \f$\beta\f$. Write \f$gc\f$ for the vector `gate_challenges`. Then, a ProverInstance is valid if
* \f[
* \sum_{k} pow_k(gc) f_k(\omega) = 0
* \f]
* The equation is modified for a relaxed ProverInstance to
* \f[
* \sum_{k} pow_k(gc) f_k(\omega) = ts
* \f]
* where we write \f$ts\f$ for the vector `target_sum`.
*
* Hence, the correspondence between the class below and the Protogalaxy paper is \f$\omega = (p_1, \dots, p_M, ,
* \theta_1, \dots, \theta_6, \alpha_{1,1}, \dots, \alpha_{n,r_n})\f$, \f$\beta\f$ are the `gate_challenges`, and
* \f$e\f$ is `target_sum`.
* required by a Mega Honk prover to create a proof.
*/

template <IsUltraOrMegaHonk Flavor_> class ProverInstance_ {
Expand Down Expand Up @@ -92,12 +56,10 @@ template <IsUltraOrMegaHonk Flavor_> class ProverInstance_ {
SubrelationSeparator alpha; // single challenge from which powers are computed for batching subrelations
bb::RelationParameters<FF> relation_parameters;
std::vector<FF> gate_challenges;
FF target_sum{ 0 }; // Sumcheck target sum

HonkProof ipa_proof; // utilized only for UltraRollupFlavor

bool is_relaxed_instance = false; // whether this instance is relaxed or not
bool is_complete = false; // whether this instance has been completely populated
bool is_complete = false; // whether this instance has been completely populated
std::vector<uint32_t> memory_read_records;
std::vector<uint32_t> memory_write_records;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ UltraVerifier_<Flavor>::UltraVerifierOutput UltraVerifier_<Flavor>::verify_proof
// Determine the number of rounds in the sumcheck based on whether or not padding is employed
const size_t log_n =
Flavor::USE_PADDING ? Flavor::VIRTUAL_LOG_N : static_cast<size_t>(verifier_instance->vk->log_circuit_size);
verifier_instance->target_sum = 0;
verifier_instance->gate_challenges =
transcript->template get_powers_of_challenge<FF>("Sumcheck:gate_challenge", log_n);

Expand Down
16 changes: 3 additions & 13 deletions barretenberg/cpp/src/barretenberg/ultra_honk/verifier_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@
namespace bb {
/**
* @brief The VerifierInstance encapsulates all the necessary information for a Mega Honk Verifier to verify a
* proof (sumcheck + Shplemini). In the context of folding, this is returned by the Protogalaxy verifier with non-zero
* target sum.
*
* @details This is \f$\phi\f$ in the Protogalaxy paper. It is the committed version of a ProverInstance_. With the
* notation used in ProverInstance_, a prover instance is \f$\omega = (p_1, \dots, p_M, \theta_1, \dots, \theta_6,
* \alpha_{1,1}, \dots, \alpha_{n,r_n})\f$ where the \f$p_i\f$'s are the prover polynomials, the \f$\theta_i\f$'s are
* the relation parameters, and the \f$\alpha_{i,j}\f$'s are the subrelation batching parameters. Then, \f$\phi\f$ is
* given by \f$\omega = ([p_1], \dots, [p_M], \theta_1, \dots, \theta_6, \alpha_{1,1}, \dots, \alpha_{n,r_n})\f$m where
* [p_i] denotes the commitment to the i-th prover polynomial.
* proof (sumcheck + Shplemini). In the context of folding, this is provided to the Hypernova verifier as an incoming
* instance.
*/
template <IsUltraOrMegaHonk Flavor_> class VerifierInstance_ {
public:
Expand All @@ -42,8 +35,6 @@ template <IsUltraOrMegaHonk Flavor_> class VerifierInstance_ {
SubrelationSeparator alpha; // a challenge whose powers are used to batch subrelation contributions during Sumcheck
RelationParameters<FF> relation_parameters;
std::vector<FF> gate_challenges;
// The target sum, which is typically nonzero for a ProtogalaxyProver's accumulator
FF target_sum{ 0 };

WitnessCommitments witness_commitments;
CommitmentLabels commitment_labels;
Expand Down Expand Up @@ -89,14 +80,13 @@ template <IsUltraOrMegaHonk Flavor_> class VerifierInstance_ {
this->relation_parameters.gamma);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_public_input_delta",
this->relation_parameters.public_input_delta);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_target_sum", this->target_sum);
transcript.add_to_independent_hash_buffer(domain_separator + "verifier_inst_gate_challenges",
this->gate_challenges);

return transcript.hash_independent_buffer();
}

MSGPACK_FIELDS(vk, relation_parameters, alpha, is_complete, gate_challenges, target_sum, witness_commitments);
MSGPACK_FIELDS(vk, relation_parameters, alpha, is_complete, gate_challenges, witness_commitments);
};

} // namespace bb
Loading
Loading