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

UltraHonk Composer (Split) #339

Merged
merged 4 commits into from
Apr 12, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ StandardProver StandardHonkComposerHelper<CircuitConstructor>::create_prover(
compute_witness(circuit_constructor);

size_t num_sumcheck_rounds(circuit_proving_key->log_circuit_size);
// TODO(luke): what is this manifest? Remove?
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess, yes, but it is very weird that his is not raising a warning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll just remove this, I think it was added by Cody by mistake

auto manifest = Flavor::create_manifest(circuit_constructor.public_inputs.size(), num_sumcheck_rounds);
StandardProver output_state(std::move(wire_polynomials), circuit_proving_key);

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma once

#include "barretenberg/proof_system/composer/composer_helper_lib.hpp"
#include "barretenberg/plonk/composer/splitting_tmp/composer_helper/composer_helper_lib.hpp"
#include "barretenberg/srs/reference_string/file_reference_string.hpp"
#include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp"
#include "barretenberg/honk/proof_system/ultra_prover.hpp"
// #include "barretenberg/plonk/proof_system/verifier/verifier.hpp"

#include <cstddef>
#include <memory>
#include <utility>
#include <vector>

namespace proof_system::honk {
// TODO(Kesha): change initializations to specify this parameter
// Cody: What does this mean?
template <typename CircuitConstructor> class UltraHonkComposerHelper {
public:
// TODO(#340)(luke): In the split composers, NUM_RANDOMIZED_GATES has replaced NUM_RESERVED_GATES (in some places)
// to determine the next-power-of-2 circuit size. (There are some places in this composer that still use
// NUM_RESERVED_GATES). Therefore for consistency within this composer itself, and consistency with the original
// Ultra Composer, this value must match that of NUM_RESERVED_GATES. This issue needs to be reconciled
// simultaneously here and in the other split composers.
static constexpr size_t NUM_RANDOMIZED_GATES = 4; // equal to the number of multilinear evaluations leaked
static constexpr size_t program_width = CircuitConstructor::program_width;
std::vector<barretenberg::polynomial> wire_polynomials;
std::shared_ptr<proof_system::plonk::proving_key> circuit_proving_key;
std::shared_ptr<proof_system::plonk::verification_key> circuit_verification_key;
// TODO(#218)(kesha): we need to put this into the commitment key, so that the composer doesn't have to handle srs
// at all
std::shared_ptr<ReferenceStringFactory> crs_factory_;

std::vector<uint32_t> recursive_proof_public_input_indices;
bool contains_recursive_proof = false;
bool computed_witness = false;

// This variable controls the amount with which the lookup table and witness values need to be shifted
// above to make room for adding randomness into the permutation and witness polynomials in the plookup widget.
// This must be (num_roots_cut_out_of_the_vanishing_polynomial - 1), since the variable num_roots_cut_out_of_
// vanishing_polynomial cannot be trivially fetched here, I am directly setting this to 4 - 1 = 3.
static constexpr size_t s_randomness = 3;

explicit UltraHonkComposerHelper(std::shared_ptr<ReferenceStringFactory> crs_factory)
: crs_factory_(std::move(crs_factory))
{}

UltraHonkComposerHelper(std::shared_ptr<plonk::proving_key> p_key, std::shared_ptr<plonk::verification_key> v_key)
: circuit_proving_key(std::move(p_key))
, circuit_verification_key(std::move(v_key))
{}

UltraHonkComposerHelper(UltraHonkComposerHelper&& other) noexcept = default;
UltraHonkComposerHelper(UltraHonkComposerHelper const& other) noexcept = default;
UltraHonkComposerHelper& operator=(UltraHonkComposerHelper&& other) noexcept = default;
UltraHonkComposerHelper& operator=(UltraHonkComposerHelper const& other) noexcept = default;
~UltraHonkComposerHelper() = default;

void finalize_circuit(CircuitConstructor& circuit_constructor) { circuit_constructor.finalize_circuit(); };

std::shared_ptr<plonk::proving_key> compute_proving_key(const CircuitConstructor& circuit_constructor);
// std::shared_ptr<plonk::verification_key> compute_verification_key(const CircuitConstructor& circuit_constructor);

void compute_witness(CircuitConstructor& circuit_constructor);

UltraProver create_prover(CircuitConstructor& circuit_constructor);
// UltraVerifier create_verifier(const CircuitConstructor& circuit_constructor);

void add_table_column_selector_poly_to_proving_key(polynomial& small, const std::string& tag);
};

} // namespace proof_system::honk
Loading