Skip to content

Commit

Permalink
Moved members from proof_system into the UltraCircuitConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rumata888 committed Apr 25, 2023
1 parent 3d8c393 commit a1b6748
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void UltraHonkComposerHelper<CircuitConstructor>::compute_witness(CircuitConstru
const size_t filled_gates = circuit_constructor.num_gates + circuit_constructor.public_inputs.size();
const size_t total_num_gates = std::max(filled_gates, tables_size + lookups_size);

const size_t subgroup_size = circuit_constructor.get_circuit_subgroup_size(total_num_gates + NUM_RESERVED_GATES);
const size_t subgroup_size = circuit_constructor.get_circuit_subgroup_size(total_num_gates + NUM_RANDOMIZED_GATES);

// Pad the wires (pointers to `witness_indices` of the `variables` vector).
// Note: the remaining NUM_RESERVED_GATES indices are padded with zeros within `compute_witness_base` (called
Expand Down
14 changes: 8 additions & 6 deletions cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class UltraHonkComposer {
std::vector<uint32_t> decompose_into_default_range(
const uint32_t variable_index,
const uint64_t num_bits,
const uint64_t target_range_bitnum = DEFAULT_PLOOKUP_RANGE_BITNUM,
const uint64_t target_range_bitnum = UltraCircuitConstructor::DEFAULT_PLOOKUP_RANGE_BITNUM,
std::string const& msg = "decompose_into_default_range")
{
return circuit_constructor.decompose_into_default_range(variable_index, num_bits, target_range_bitnum, msg);
Expand Down Expand Up @@ -348,17 +348,19 @@ class UltraHonkComposer {
// /**
// * Non Native Field Arithmetic
// **/
void range_constrain_two_limbs(const uint32_t lo_idx,
const uint32_t hi_idx,
const size_t lo_limb_bits = DEFAULT_NON_NATIVE_FIELD_LIMB_BITS,
const size_t hi_limb_bits = DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)
void range_constrain_two_limbs(
const uint32_t lo_idx,
const uint32_t hi_idx,
const size_t lo_limb_bits = UltraCircuitConstructor::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS,
const size_t hi_limb_bits = UltraCircuitConstructor::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)
{
circuit_constructor.range_constrain_two_limbs(lo_idx, hi_idx, lo_limb_bits, hi_limb_bits);
};
// std::array<uint32_t, 2> decompose_non_native_field_double_width_limb(
// const uint32_t limb_idx, const size_t num_limb_bits = (2 * DEFAULT_NON_NATIVE_FIELD_LIMB_BITS));
std::array<uint32_t, 2> evaluate_non_native_field_multiplication(
const non_native_field_witnesses& input, const bool range_constrain_quotient_and_remainder = true)
const UltraCircuitConstructor::non_native_field_witnesses& input,
const bool range_constrain_quotient_and_remainder = true)
{
return circuit_constructor.evaluate_non_native_field_multiplication(input,
range_constrain_quotient_and_remainder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ TEST(UltraHonkComposer, non_native_field_multiplication)
const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q)));
const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r)));

proof_system::non_native_field_witnesses inputs{
proof_system::UltraCircuitConstructor::non_native_field_witnesses inputs{
a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)),
};
const auto [lo_1_idx, hi_1_idx] = honk_composer.evaluate_non_native_field_multiplication(inputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void UltraPlonkComposerHelper<CircuitConstructor>::compute_witness(CircuitConstr

// TODO(luke): subgroup size was already computed above but compute_witness_base computes it again. If we pass in
// NUM_RANDOMIZED_GATES (as in the other split composers) the resulting sizes can differ. Reconcile this.
auto wire_polynomial_evaluations = compute_witness_base(circuit_constructor, total_num_gates, NUM_RANDOMIZED_GATES);
auto wire_polynomial_evaluations = compute_witness_base(circuit_constructor, total_num_gates, NUM_RESERVED_GATES);

for (size_t j = 0; j < program_width; ++j) {
std::string index = std::to_string(j + 1);
Expand Down Expand Up @@ -225,7 +225,7 @@ std::shared_ptr<proving_key> UltraPlonkComposerHelper<CircuitConstructor>::compu
}

const size_t minimum_circuit_size = tables_size + lookups_size;
const size_t num_randomized_gates = NUM_RANDOMIZED_GATES;
const size_t num_randomized_gates = NUM_RESERVED_GATES;
// Initialize circuit_proving_key
// TODO(#229)(Kesha): replace composer types.
circuit_proving_key = initialize_proving_key(
Expand Down Expand Up @@ -359,7 +359,7 @@ std::shared_ptr<plonk::verification_key> UltraPlonkComposerHelper<CircuitConstru
}
circuit_verification_key = compute_verification_key_common(circuit_proving_key, crs_factory_->get_verifier_crs());

circuit_verification_key->composer_type = type; // Invariably plookup for this class.
circuit_verification_key->composer_type = ComposerType::PLOOKUP; // Invariably plookup for this class.

// See `add_recusrive_proof()` for how this recursive data is assigned.
circuit_verification_key->recursive_proof_public_input_indices =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ template <typename CircuitConstructor> class UltraPlonkComposerHelper {
// 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 NUM_RESERVED_GATES = 4; // equal to the number of multilinear evaluations leaked
static constexpr size_t program_width = CircuitConstructor::program_width;
std::shared_ptr<plonk::proving_key> circuit_proving_key;
std::shared_ptr<plonk::verification_key> circuit_verification_key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class UltraPlonkComposer {
std::vector<uint32_t> decompose_into_default_range(
const uint32_t variable_index,
const uint64_t num_bits,
const uint64_t target_range_bitnum = DEFAULT_PLOOKUP_RANGE_BITNUM,
const uint64_t target_range_bitnum = UltraCircuitConstructor::DEFAULT_PLOOKUP_RANGE_BITNUM,
std::string const& msg = "decompose_into_default_range")
{
return circuit_constructor.decompose_into_default_range(variable_index, num_bits, target_range_bitnum, msg);
Expand Down Expand Up @@ -358,17 +358,19 @@ class UltraPlonkComposer {
// /**
// * Non Native Field Arithmetic
// **/
void range_constrain_two_limbs(const uint32_t lo_idx,
const uint32_t hi_idx,
const size_t lo_limb_bits = DEFAULT_NON_NATIVE_FIELD_LIMB_BITS,
const size_t hi_limb_bits = DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)
void range_constrain_two_limbs(
const uint32_t lo_idx,
const uint32_t hi_idx,
const size_t lo_limb_bits = UltraCircuitConstructor::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS,
const size_t hi_limb_bits = UltraCircuitConstructor::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)
{
circuit_constructor.range_constrain_two_limbs(lo_idx, hi_idx, lo_limb_bits, hi_limb_bits);
};
// std::array<uint32_t, 2> decompose_non_native_field_double_width_limb(
// const uint32_t limb_idx, const size_t num_limb_bits = (2 * DEFAULT_NON_NATIVE_FIELD_LIMB_BITS));
std::array<uint32_t, 2> evaluate_non_native_field_multiplication(
const non_native_field_witnesses& input, const bool range_constrain_quotient_and_remainder = true)
const UltraCircuitConstructor::non_native_field_witnesses& input,
const bool range_constrain_quotient_and_remainder = true)
{
return circuit_constructor.evaluate_non_native_field_multiplication(input,
range_constrain_quotient_and_remainder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ TEST(ultra_plonk_composer_splitting_tmp, non_native_field_multiplication)
const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q)));
const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r)));

non_native_field_witnesses inputs{
UltraCircuitConstructor::non_native_field_witnesses inputs{
a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)),
};
const auto [lo_1_idx, hi_1_idx] = composer.evaluate_non_native_field_multiplication(inputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ plookup::ReadData<uint32_t> UltraCircuitConstructor::create_gates_from_plookup_a
* Generalized Permutation Methods
**/

RangeList UltraCircuitConstructor::create_range_list(const uint64_t target_range)
UltraCircuitConstructor::RangeList UltraCircuitConstructor::create_range_list(const uint64_t target_range)
{
RangeList result;
const auto range_tag = get_new_tag(); // current_tag + 1;
Expand Down
Loading

0 comments on commit a1b6748

Please sign in to comment.