Skip to content

Commit

Permalink
work work work work work
Browse files Browse the repository at this point in the history
  • Loading branch information
maramihali committed Jun 2, 2023
1 parent 4cde973 commit 910669c
Show file tree
Hide file tree
Showing 39 changed files with 55 additions and 73 deletions.
6 changes: 3 additions & 3 deletions cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/honk/proof_system/prover.hpp"
#include "barretenberg/honk/proof_system/verifier.hpp"
#include <benchmark/benchmark.h>
#include <cstddef>
#include "barretenberg/honk/composer/standard_honk_composer.hpp"

#include "barretenberg/stdlib/primitives/field/field.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"

using namespace benchmark;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/honk/proof_system/ultra_prover.hpp"
#include "barretenberg/honk/proof_system/ultra_verifier.hpp"
#include <benchmark/benchmark.h>
#include <cstddef>
#include "barretenberg/honk/composer/ultra_honk_composer.hpp"
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp"
#include "barretenberg/stdlib/hash/keccak/keccak.hpp"
#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp"
Expand Down
1 change: 1 addition & 0 deletions cpp/src/barretenberg/dsl/acir_format/acir_format.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "acir_format.hpp"
#include "barretenberg/common/log.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"

namespace acir_format {

Expand Down
1 change: 1 addition & 0 deletions cpp/src/barretenberg/dsl/acir_format/acir_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "pedersen.hpp"
#include "hash_to_field.hpp"
#include "barretenberg/dsl/types.hpp"
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"

namespace acir_format {

Expand Down
1 change: 1 addition & 0 deletions cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "barretenberg/common/streams.hpp"
#include "barretenberg/serialize/test_helper.hpp"
#include "ecdsa_secp256k1.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
TEST(acir_format, msgpack_logic_constraint)
{
auto [actual, expected] = msgpack_roundtrip(acir_format::LogicConstraint{});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ StandardProver_<Flavor> StandardHonkComposerHelper_<Flavor>::create_prover(
{
compute_proving_key(circuit_constructor);
compute_witness(circuit_constructor);
StandardProver output_state(proving_key);
StandardProver_<Flavor> output_state(proving_key);

auto pcs_commitment_key =
std::make_unique<typename PCSParams::CommitmentKey>(proving_key->circuit_size, "../srs_db/ignition");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ UltraProver_<Flavor> UltraHonkComposerHelper_<Flavor>::create_prover(CircuitCons
compute_proving_key(circuit_constructor);
compute_witness(circuit_constructor);

UltraProver output_state(proving_key);
UltraProver_<Flavor> output_state(proving_key);

auto pcs_commitment_key =
std::make_unique<PCSParams::CommitmentKey>(proving_key->circuit_size, "../srs_db/ignition");
std::make_unique<typename PCSParams::CommitmentKey>(proving_key->circuit_size, "../srs_db/ignition");

output_state.pcs_commitment_key = std::move(pcs_commitment_key);

Expand All @@ -164,7 +164,7 @@ UltraVerifier_<Flavor> UltraHonkComposerHelper_<Flavor>::create_verifier(const C
{
auto verification_key = compute_verification_key(circuit_constructor);

UltraVerifier output_state(verification_key);
UltraVerifier_<Flavor> output_state(verification_key);

auto pcs_verification_key =
std::make_unique<PCSVerificationKey>(verification_key->circuit_size, "../srs_db/ignition");
Expand Down Expand Up @@ -320,7 +320,7 @@ std::shared_ptr<typename Flavor::VerificationKey> UltraHonkComposerHelper_<Flavo
compute_proving_key(circuit_constructor);
}

verification_key = std::make_shared<UltraHonkComposerHelper_<Flavor>::VerificationKey>(
verification_key = std::make_shared<typename Flavor::VerificationKey>(
proving_key->circuit_size, proving_key->num_public_inputs, proving_key->composer_type);

auto commitment_key = PCSCommitmentKey(proving_key->circuit_size, "../srs_db/ignition");
Expand Down Expand Up @@ -361,5 +361,6 @@ std::shared_ptr<typename Flavor::VerificationKey> UltraHonkComposerHelper_<Flavo

return verification_key;
}
template class UltraHonkComposerHelper_<honk::flavor::Ultra>;

} // namespace proof_system::honk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace test_standard_honk_composer {
*/
TEST(StandardHonkComposer, SigmaIDCorrectness)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;
auto test_permutation = [](StandardHonkComposer& composer) {
auto proving_key = composer.compute_proving_key();
const auto n = proving_key->circuit_size;
Expand Down Expand Up @@ -141,7 +140,6 @@ TEST(StandardHonkComposer, SigmaIDCorrectness)
*/
TEST(StandardHonkComposer, LagrangeCorrectness)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;
// Create a composer and a dummy circuit with a few gates
StandardHonkComposer composer = StandardHonkComposer();
fr a = fr::one();
Expand Down Expand Up @@ -191,7 +189,6 @@ TEST(StandardHonkComposer, LagrangeCorrectness)
*/
TEST(StandardHonkComposer, AssertEquals)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;

/**
* @brief A function that creates a simple circuit with repeated gates, leading to large permutation cycles
Expand Down Expand Up @@ -287,7 +284,6 @@ TEST(StandardHonkComposer, AssertEquals)

TEST(StandardHonkComposer, VerificationKeyCreation)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;

// Create a composer and a dummy circuit with a few gates
StandardHonkComposer composer = StandardHonkComposer();
Expand All @@ -312,7 +308,6 @@ TEST(StandardHonkComposer, VerificationKeyCreation)

TEST(StandardHonkComposer, BaseCase)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;
auto composer = StandardHonkComposer();
fr a = 1;
composer.circuit_constructor.add_variable(a);
Expand All @@ -326,7 +321,6 @@ TEST(StandardHonkComposer, BaseCase)

TEST(StandardHonkComposer, TwoGates)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;
auto run_test = [](bool expect_verified) {
auto composer = StandardHonkComposer();

Expand Down Expand Up @@ -361,7 +355,6 @@ TEST(StandardHonkComposer, TwoGates)

TEST(StandardHonkComposer, SumcheckEvaluations)
{
using StandardHonkComposer = StandardHonkComposer_<honk::flavor::Standard>;
auto run_test = [](bool expected_result) {
auto composer = StandardHonkComposer();
fr a = fr::one();
Expand Down
11 changes: 7 additions & 4 deletions cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace proof_system::honk {
template <class Flavor> class UltraHonkComposer_ {

public:
// TODO(#426): This doesn't belong here
static constexpr merkle::HashType merkle_hash_type = merkle::HashType::LOOKUP_PEDERSEN;
static constexpr pedersen::CommitmentType commitment_type = pedersen::CommitmentType::FIXED_BASE_PEDERSEN;
// An instantiation of the circuit constructor that only depends on arithmetization, not on the proof system
UltraCircuitConstructor circuit_constructor;
// Composer helper contains all proof-related material that is separate from circuit creation such as:
Expand All @@ -22,7 +19,13 @@ template <class Flavor> class UltraHonkComposer_ {
using CircuitConstructor = UltraCircuitConstructor;
using ProvingKey = typename Flavor::ProvingKey;
using VerificationKey = typename Flavor::VerificationKey;
static constexpr ComposerType type = ComposerType::PLOOKUP; // TODO(Mara): Get rid of this.

// TODO(#426): This don't belong here
static constexpr ComposerType type = ComposerType::PLOOKUP;
static_assert(type == CircuitConstructor::type);
static constexpr merkle::HashType merkle_hash_type = CircuitConstructor::merkle_hash_type;
static constexpr pedersen::CommitmentType commitment_type = CircuitConstructor::commitment_type;
static constexpr size_t DEFAULT_PLOOKUP_RANGE_BITNUM = UltraCircuitConstructor::DEFAULT_PLOOKUP_RANGE_BITNUM;

UltraHonkComposerHelper_<Flavor> composer_helper;
size_t& num_gates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ TEST(UltraHonkComposer, XorConstraint)
const auto lookup_accumulators = plookup::get_lookup_accumulators(
plookup::MultiTableId::UINT32_XOR, left_witness_value, right_witness_value, true);
auto xor_result = lookup_accumulators[plookup::ColumnIdx::C3]
[0]; // The zeroth index in the 3rd column is the fully accumulated xor result
EXPECT_EQ(xor_result, xor_result_expected);
[0]; // The zeroth index in the 3rd column is the fully accumulated xor

composer.create_gates_from_plookup_accumulators(
plookup::MultiTableId::UINT32_XOR, lookup_accumulators, left_witness_index, right_witness_index);
Expand Down Expand Up @@ -555,7 +554,6 @@ TEST(UltraHonkComposer, range_constraint)

TEST(UltraHonkComposer, range_with_gates)
{

auto composer = UltraHonkComposer();
auto idx = add_variables(composer, { 1, 2, 3, 4, 5, 6, 7, 8 });
for (size_t i = 0; i < idx.size(); i++) {
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/barretenberg/stdlib/encryption/aes128/aes128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <array>
#include <vector>

#include "../../primitives/composers/composers_fwd.hpp"
#include "../../primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"
#include "../../primitives/field/field.hpp"
#include "../../primitives/witness/witness.hpp"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "aes128.hpp"

#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/crypto/aes128/aes128.hpp"

#include <gtest/gtest.h>
Expand Down
1 change: 0 additions & 1 deletion cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../../primitives/byte_array/byte_array.hpp"
#include "../../primitives/uint/uint.hpp"
#include "../../primitives/composers/composers_fwd.hpp"

namespace proof_system::plonk {
namespace stdlib {
namespace ecdsa {
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "../../hash/sha256/sha256.hpp"
#include "../../primitives/bit_array/bit_array.hpp"
#include "../../primitives/composers/composers.hpp"

namespace proof_system::plonk {
namespace stdlib {
namespace ecdsa {
Expand Down
6 changes: 1 addition & 5 deletions cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#pragma once
#include "barretenberg/stdlib/primitives/byte_array/byte_array.hpp"

namespace proof_system::plonk {
class TurboPlonkComposer;
class UltraPlonkComposer;
} // namespace proof_system::plonk
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"

namespace proof_system::plonk {
namespace stdlib {
Expand Down
1 change: 1 addition & 0 deletions cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "barretenberg/crypto/blake3s/blake3s.hpp"
#include "barretenberg/common/streams.hpp"
#include <gtest/gtest.h>
#include "barretenberg/stdlib/primitives/composers/composers.hpp"

using namespace barretenberg;
using namespace proof_system::plonk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "../byte_array/byte_array.hpp"
#include "../field/field.hpp"
#include "./bigfield.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/honk/composer/ultra_honk_composer.hpp"
#include "barretenberg/plonk/composer/standard_plonk_composer.hpp"

#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
#include "barretenberg/plonk/proof_system/prover/prover.hpp"
#include "barretenberg/plonk/proof_system/verifier/verifier.hpp"
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "barretenberg/ecc/curves/secp256r1/secp256r1.hpp"
#include "barretenberg/ecc/curves/bn254/g1.hpp"

#include "../composers/composers_fwd.hpp"

namespace proof_system::plonk {
namespace stdlib {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#include "../biggroup/biggroup.hpp"
#include "../bool/bool.hpp"
#include "../field/field.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/honk/composer/ultra_honk_composer.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"

#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
#include "barretenberg/stdlib/primitives/curves/secp256r1.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "../composers/composers_fwd.hpp"
#include "../uint/uint.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include <algorithm>

namespace proof_system::plonk {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "bit_array.hpp"
#include <gtest/gtest.h>
#include "barretenberg/numeric/random/engine.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/byte_array/byte_array.hpp"
#include "barretenberg/stdlib/primitives/field/field.hpp"
#include "barretenberg/stdlib/primitives/witness/witness.hpp"
Expand Down
1 change: 0 additions & 1 deletion cpp/src/barretenberg/stdlib/primitives/bool/bool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "bool.hpp"
#include "../composers/composers.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"

using namespace barretenberg;
using namespace proof_system;
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/barretenberg/stdlib/primitives/bool/bool.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once
#include "../composers/composers_fwd.hpp"
#include "../witness/witness.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"

namespace proof_system::plonk {
namespace stdlib {

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "bool.hpp"
#include "barretenberg/plonk/composer/standard_plonk_composer.hpp"
#include <gtest/gtest.h>
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/byte_array/byte_array.cpp"

#define STDLIB_TYPE_ALIASES \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @brief Contains all the headers required to adequately compile the types defined in composers_fwd.hpp and instantiate
* templates.
*
* @details This should be the ONLY file related to composer/circuit construct included in source files not part of the
* proof systems.
*/
#pragma once
#include "barretenberg/plonk/composer/standard_plonk_composer.hpp"
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* @brief Defines particular composer and circuit constructor types expected to be used for proof or circuit
construction (outside the proof_system and honk folder) and contains macros for explicit instantiation.
*
* @details This file is designed to be included in header files to instruct the compiler that these classes exist and
* their instantiation will eventually take place. Given it has no dependencies, it causes no additional compilation or
* propagation. This should be the ONLY file related to these types included in files out side the proof system.
*/
#pragma once

namespace proof_system::plonk {
Expand Down
5 changes: 1 addition & 4 deletions cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
#include "array.hpp"
#include <gtest/gtest.h>
#include <utility>
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/plonk/composer/standard_plonk_composer.hpp"
#include "barretenberg/plonk/composer/ultra_plonk_composer.hpp"
#include "barretenberg/plonk/composer/turbo_plonk_composer.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/numeric/random/engine.hpp"

namespace test_stdlib_array {
Expand Down
5 changes: 1 addition & 4 deletions cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
#include "barretenberg/plonk/proof_system/constants.hpp"
#include <gtest/gtest.h>
#include <utility>
#include "barretenberg/honk/composer/standard_honk_composer.hpp"
#include "barretenberg/plonk/composer/standard_plonk_composer.hpp"
#include "barretenberg/plonk/composer/ultra_plonk_composer.hpp"
#include "barretenberg/plonk/composer/turbo_plonk_composer.hpp"
#include "barretenberg/numeric/random/engine.hpp"
#include "barretenberg/common/streams.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"

using namespace proof_system;

Expand Down
1 change: 0 additions & 1 deletion cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "logic.hpp"

#include "../composers/composers.hpp"
#include "../plookup/plookup.hpp"
#include "barretenberg/common/assert.hpp"
Expand Down
1 change: 0 additions & 1 deletion cpp/src/barretenberg/stdlib/primitives/logic/logic.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "barretenberg/numeric/uint256/uint256.hpp"
#include "barretenberg/stdlib/primitives/composers/composers_fwd.hpp"
#include "barretenberg/stdlib/primitives/composers/composers.hpp"
#include "barretenberg/stdlib/primitives/field/field.hpp"
#include "barretenberg/stdlib/primitives/witness/witness.hpp"
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "barretenberg/numeric/uint256/uint256.hpp"
#include "barretenberg/proof_system/types/composer_type.hpp"
#include "logic.hpp"
#include "../composers/composers.hpp"
#include <gtest/gtest.h>
#include "barretenberg/numeric/random/engine.hpp"

Expand Down
Loading

0 comments on commit 910669c

Please sign in to comment.