Skip to content

Commit

Permalink
add split UltraHonk composer and checks for consistency with UltraPlonk
Browse files Browse the repository at this point in the history
  • Loading branch information
ledwards2225 committed Apr 11, 2023
1 parent 8fa24c9 commit 4e25f4d
Show file tree
Hide file tree
Showing 14 changed files with 2,421 additions and 15 deletions.
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?
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(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

0 comments on commit 4e25f4d

Please sign in to comment.