From b8d322d5f2f56b5a2fb2858cd4553c26fd240029 Mon Sep 17 00:00:00 2001 From: codygunton Date: Thu, 13 Apr 2023 16:52:43 +0000 Subject: [PATCH] Everything builds. --- .../dsl/acir_proofs/acir_proofs.cpp | 11 +-- .../proofs/join_split/c_bind.cpp | 12 +-- .../join_split/compute_circuit_data.cpp | 3 +- .../proofs/join_split/join_split.cpp | 15 ++-- .../proofs/join_split/join_split.hpp | 5 +- .../proofs/join_split/join_split.test.cpp | 6 +- .../proofs/join_split/join_split_circuit.hpp | 7 +- .../proofs/join_split/join_split_tx.hpp | 4 +- .../proofs/mock/mock_circuit.test.cpp | 4 +- .../notes/circuit/account/account_note.hpp | 5 +- .../proofs/notes/circuit/account/commit.hpp | 8 +- .../proofs/notes/circuit/asset_id.cpp | 4 +- .../proofs/notes/circuit/asset_id.hpp | 4 +- .../proofs/notes/circuit/bridge_call_data.hpp | 4 +- .../proofs/notes/circuit/claim/claim_note.hpp | 5 +- .../claim/complete_partial_commitment.hpp | 5 +- .../notes/circuit/claim/compute_nullifier.hpp | 5 +- .../claim/create_partial_commitment.hpp | 4 +- .../notes/circuit/claim/witness_data.hpp | 5 +- .../value/complete_partial_commitment.hpp | 6 +- .../notes/circuit/value/compute_nullifier.cpp | 4 +- .../notes/circuit/value/compute_nullifier.hpp | 5 +- .../circuit/value/compute_nullifier.test.cpp | 7 +- .../value/create_partial_commitment.hpp | 6 +- .../proofs/notes/circuit/value/value_note.hpp | 4 +- .../notes/circuit/value/value_note.test.cpp | 8 +- .../notes/circuit/value/witness_data.hpp | 5 +- .../barretenberg/join_split_example/types.hpp | 82 +++++++++++++++++++ .../stdlib/hash/sha256/sha256.bench.cpp | 24 +++--- 29 files changed, 176 insertions(+), 91 deletions(-) create mode 100644 cpp/src/barretenberg/join_split_example/types.hpp diff --git a/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp b/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp index f379b00b16..2010c592fb 100644 --- a/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp +++ b/cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp @@ -75,8 +75,9 @@ size_t init_verification_key(void* pippenger, uint8_t const* g2x, uint8_t const* reinterpret_cast(pippenger), g2x); proving_key->reference_string = crs_factory->get_prover_crs(proving_key->circuit_size); - Composer composer(proving_key, nullptr); - auto verification_key = Composer::compute_verification_key_base(proving_key, crs_factory->get_verifier_crs()); + acir_format::Composer composer(proving_key, nullptr); + auto verification_key = + acir_format::Composer::compute_verification_key_base(proving_key, crs_factory->get_verifier_crs()); // The composer_type has not yet been set. We need to set the composer_type for when we later read in and // construct the verification key so that we have the correct polynomial manifest @@ -110,13 +111,13 @@ size_t new_proof(void* pippenger, reinterpret_cast(pippenger), g2x); proving_key->reference_string = crs_factory->get_prover_crs(proving_key->circuit_size); - Composer composer(proving_key, nullptr); + acir_format::Composer composer(proving_key, nullptr); create_circuit_with_witness(composer, constraint_system, witness); auto prover = composer.create_ultra_with_keccak_prover(); - auto heapProver = new Prover(std::move(prover)); + auto heapProver = new acir_format::Prover(std::move(prover)); auto& proof_data = heapProver->construct_proof().proof_data; *proof_data_buf = proof_data.data(); @@ -137,7 +138,7 @@ bool verify_proof( read(vk_buf, vk_data); auto verification_key = std::make_shared(std::move(vk_data), crs); - Composer composer(nullptr, verification_key); + acir_format::Composer composer(nullptr, verification_key); create_circuit(composer, constraint_system); plonk::proof pp = { std::vector(proof, proof + length) }; diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/c_bind.cpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/c_bind.cpp index cb35a19d27..705e5bbfab 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/c_bind.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/c_bind.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "c_bind.h" #include "join_split.hpp" #include "compute_signing_data.hpp" @@ -5,14 +8,13 @@ #include "barretenberg/common/streams.hpp" #include "barretenberg/common/mem.hpp" #include "barretenberg/common/container.hpp" -#include #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/srs/reference_string/pippenger_reference_string.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" -#include +#include "barretenberg/join_split_example/types.hpp" using namespace barretenberg; -using namespace proof_system::plonk::stdlib::types; +// using namespace proof_system::plonk::stdlib; using namespace join_split_example::proofs::join_split; #define WASM_EXPORT __attribute__((visibility("default"))) @@ -103,13 +105,13 @@ WASM_EXPORT void* join_split__new_prover(uint8_t const* join_split_buf, bool moc { auto tx = from_buffer(join_split_buf); auto prover = new_join_split_prover(tx, mock); - auto heapProver = new stdlib::types::Prover(std::move(prover)); + auto heapProver = new join_split_example::Prover(std::move(prover)); return heapProver; } WASM_EXPORT void join_split__delete_prover(void* prover) { - delete reinterpret_cast(prover); + delete reinterpret_cast(prover); } WASM_EXPORT bool join_split__verify_proof(uint8_t* proof, uint32_t length) diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp index 47fc4deec2..037799660b 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp @@ -3,13 +3,14 @@ #include "sign_join_split_tx.hpp" #include "../notes/native/index.hpp" #include "barretenberg/stdlib/merkle_tree/hash_path.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { namespace join_split { using namespace join_split_example::proofs::join_split; -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; using namespace join_split_example::proofs::notes::native; using namespace proof_system::plonk::stdlib::merkle_tree; diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp index bacb9868c8..235d13dcba 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp @@ -2,6 +2,7 @@ #include "join_split_circuit.hpp" #include "compute_circuit_data.hpp" #include "barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { @@ -23,7 +24,7 @@ void init_proving_key(std::shared_ptr cons join_split_tx tx = noop_tx(); if (!mock) { - stdlib::types::Composer composer(crs_factory); + Composer composer(crs_factory); join_split_circuit(composer, tx); proving_key = composer.compute_proving_key(); } else { @@ -55,8 +56,7 @@ void init_verification_key(std::unique_ptr // Patch the 'nothing' reference string fed to init_proving_key. proving_key->reference_string = crs_factory->get_prover_crs(proving_key->circuit_size + 1); - verification_key = - plonk::stdlib::types::Composer::compute_verification_key_base(proving_key, crs_factory->get_verifier_crs()); + verification_key = Composer::compute_verification_key_base(proving_key, crs_factory->get_verifier_crs()); } void init_verification_key(std::shared_ptr const& crs, @@ -65,7 +65,7 @@ void init_verification_key(std::shared_ptr(std::move(vk_data), crs); } -stdlib::types::Prover new_join_split_prover(join_split_tx const& tx, bool mock) +Prover new_join_split_prover(join_split_tx const& tx, bool mock) { Composer composer(proving_key, nullptr); join_split_circuit(composer, tx); @@ -79,19 +79,18 @@ stdlib::types::Prover new_join_split_prover(join_split_tx const& tx, bool mock) if (!mock) { info("composer gates: ", composer.get_num_gates()); - return composer.create_ultra_with_keccak_prover(); + return composer.create_prover(); } else { Composer mock_proof_composer(proving_key, nullptr); join_split_example::proofs::mock::mock_circuit(mock_proof_composer, composer.get_public_inputs()); info("mock composer gates: ", mock_proof_composer.get_num_gates()); - return mock_proof_composer.create_ultra_with_keccak_prover(); + return mock_proof_composer.create_prover(); } } bool verify_proof(plonk::proof const& proof) { - plonk::stdlib::types::Verifier verifier(verification_key, - Composer::create_manifest(verification_key->num_public_inputs)); + Verifier verifier(verification_key, Composer::create_manifest(verification_key->num_public_inputs)); #ifdef USE_TURBO std::unique_ptr> kate_commitment_scheme = diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp index 6c9b4ac5ab..a6c103a4a0 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp @@ -1,14 +1,13 @@ #pragma once #include "join_split_tx.hpp" #include "barretenberg/srs/reference_string/mem_reference_string.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { namespace join_split { using namespace proof_system::plonk::stdlib::merkle_tree; -using namespace proof_system::plonk::stdlib::types; void init_proving_key(std::shared_ptr const& crs_factory, bool mock); @@ -22,7 +21,7 @@ void init_verification_key(std::unique_ptr void init_verification_key(std::shared_ptr const& crs, plonk::verification_key_data&& vk_data); -stdlib::types::Prover new_join_split_prover(join_split_tx const& tx, bool mock); +Prover new_join_split_prover(join_split_tx const& tx, bool mock); bool verify_proof(plonk::proof const& proof); diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp index fc3e4a1426..9c1e62d3a6 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp @@ -1,3 +1,5 @@ +#include + #include "../../constants.hpp" #include "../inner_proof_data/inner_proof_data.hpp" #include "index.hpp" @@ -5,9 +7,9 @@ #include "join_split_circuit.hpp" #include "barretenberg/common/streams.hpp" #include "barretenberg/common/test.hpp" -#include #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/stdlib/merkle_tree/index.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example::proofs::join_split { @@ -122,7 +124,7 @@ constexpr bool CIRCUIT_CHANGE_EXPECTED = false; #endif using namespace barretenberg; -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; using namespace proof_system::plonk::stdlib::merkle_tree; using namespace join_split_example::proofs::notes::native; using key_pair = join_split_example::fixtures::grumpkin_key_pair; diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp index b8821989b4..263f6d6b09 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp @@ -3,15 +3,16 @@ #include "../notes/circuit/value/witness_data.hpp" #include "../notes/circuit/claim/witness_data.hpp" #include "barretenberg/crypto/schnorr/schnorr.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { namespace join_split { -using namespace proof_system::plonk::stdlib::types; +// using namespace proof_system::plonk::stdlib; struct join_split_inputs { + field_ct proof_id; suint_ct public_value; field_ct public_owner; @@ -25,7 +26,7 @@ struct join_split_inputs { notes::circuit::value::witness_data output_note2; notes::circuit::claim::partial_claim_note_witness_data partial_claim_note; point_ct signing_pub_key; - stdlib::schnorr::signature_bits signature; + schnorr::signature_bits signature; field_ct merkle_root; merkle_tree::hash_path input_path1; merkle_tree::hash_path input_path2; diff --git a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp index 4dae8f30e3..d5e1b2d56f 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp @@ -3,13 +3,13 @@ #include "../notes/native/value/value_note.hpp" #include "barretenberg/crypto/schnorr/schnorr.hpp" #include "barretenberg/stdlib/merkle_tree/hash_path.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { namespace join_split { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; struct join_split_tx { uint32_t proof_id; diff --git a/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp b/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp index 2188725010..34a1e5cb16 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp @@ -1,9 +1,9 @@ #include "mock_circuit.hpp" #include "../join_split/join_split_tx.hpp" #include "barretenberg/common/test.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; namespace rollup { namespace proofs { diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/account_note.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/account_note.hpp index 334b2edfc3..30390eb103 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/account_note.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/account_note.hpp @@ -1,6 +1,7 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "commit.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { @@ -8,8 +9,6 @@ namespace notes { namespace circuit { namespace account { -using namespace proof_system::plonk::stdlib::types; - struct account_note { field_ct account_alias_hash; point_ct account_public_key; diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp index 497644a951..7b00ef9206 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/account/commit.hpp @@ -1,6 +1,8 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/primitives/point/point.hpp" #include "../../constants.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { @@ -8,7 +10,7 @@ namespace notes { namespace circuit { namespace account { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; inline auto commit(field_ct const& account_alias_hash, point_ct const& account_public_key, @@ -20,7 +22,7 @@ inline auto commit(field_ct const& account_alias_hash, account_public_key.x, signing_pub_key.x, }, - GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); + join_split_example::proofs::notes::GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); } } // namespace account diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.cpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.cpp index 5163231bc5..6a7a559b70 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.cpp @@ -1,9 +1,9 @@ -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "../constants.hpp" namespace join_split_example::proofs::notes::circuit { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; std::pair deflag_asset_id(suint_ct const& asset_id) { diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.hpp index 3c67f16695..89e244f39b 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/asset_id.hpp @@ -1,9 +1,9 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example::proofs::notes::circuit { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; std::pair deflag_asset_id(suint_ct const& asset_id); diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp index f5b1bbd319..f8ea941167 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp @@ -1,5 +1,5 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "../native/bridge_call_data.hpp" #include "./asset_id.hpp" #include "../constants.hpp" @@ -9,7 +9,7 @@ namespace proofs { namespace notes { namespace circuit { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; constexpr uint32_t input_asset_id_a_shift = DEFI_BRIDGE_ADDRESS_ID_LEN; constexpr uint32_t input_asset_id_b_shift = input_asset_id_a_shift + DEFI_BRIDGE_INPUT_A_ASSET_ID_LEN; diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp index 8021265a43..8a23ff9f93 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp @@ -1,5 +1,6 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" + #include "../bridge_call_data.hpp" #include "witness_data.hpp" #include "../value/create_partial_commitment.hpp" @@ -12,7 +13,7 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; struct partial_claim_note { suint_ct deposit_value; diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp index 9b1010ab58..fb20d7fef9 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp @@ -1,6 +1,7 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "../../constants.hpp" +#include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" namespace join_split_example { namespace proofs { @@ -8,7 +9,7 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; inline auto complete_partial_commitment(field_ct const& partial_commitment, field_ct const& interaction_nonce, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp index 304f9f6205..2ffb181bb2 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp @@ -1,5 +1,6 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" + +#include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "../../constants.hpp" @@ -9,8 +10,6 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib::types; - inline field_ct compute_nullifier(field_ct const& note_commitment) { return pedersen_commitment::compress(std::vector{ note_commitment }, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp index 30eb7adb7a..36c37a8e78 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp @@ -1,5 +1,5 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "../../constants.hpp" @@ -9,7 +9,7 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; inline auto create_partial_commitment(field_ct const& deposit_value, field_ct const& bridge_call_data, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp index b49bddd3bb..e5fc35fb39 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp @@ -1,5 +1,6 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" + +#include "barretenberg/join_split_example/types.hpp" #include "../../native/claim/claim_note.hpp" #include "../../native/claim/claim_note_tx_data.hpp" #include "../../constants.hpp" @@ -11,7 +12,7 @@ namespace notes { namespace circuit { namespace claim { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; /** * Convert native claim note data into circuit witness data. diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp index e5bc84b994..1ec344d17a 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp @@ -1,15 +1,15 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" + +#include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" #include "../../constants.hpp" - namespace join_split_example { namespace proofs { namespace notes { namespace circuit { namespace value { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; inline auto complete_partial_commitment(field_ct const& value_note_partial_commitment, suint_ct const& value, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp index 30dafca6b6..6f73dd418f 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp @@ -1,6 +1,6 @@ #include "compute_nullifier.hpp" #include "../../constants.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { @@ -8,7 +8,7 @@ namespace notes { namespace circuit { using namespace barretenberg; -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; field_ct compute_nullifier(field_ct const& note_commitment, field_ct const& account_private_key, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp index 3271035abb..85a14dd416 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp @@ -1,14 +1,11 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { namespace notes { namespace circuit { -using namespace barretenberg; -using namespace proof_system::plonk::stdlib::types; - field_ct compute_nullifier(field_ct const& note_commitment, field_ct const& account_private_key, bool_ct const& is_note_in_use); diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp index 063ef93edd..69a801cc44 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp @@ -4,10 +4,11 @@ #include "./value_note.hpp" #include "../../native/value/compute_nullifier.hpp" #include "../../native/value/value_note.hpp" -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" +namespace join_split_example { using namespace join_split_example::proofs::notes; -using namespace proof_system::plonk::stdlib::types; +// using namespace proof_system::plonk::stdlib; TEST(compute_nullifier_circuit, native_consistency) { @@ -18,7 +19,6 @@ TEST(compute_nullifier_circuit, native_consistency) native::value::value_note{ 100, 0, 0, user.owner.public_key, user.note_secret, 0, fr::random_element() }; auto native_commitment = native_input_note.commit(); auto native_nullifier = native::compute_nullifier(native_commitment, priv_key, true); - Composer composer; auto circuit_witness_data = circuit::value::witness_data(composer, native_input_note); auto circuit_input_note = circuit::value::value_note(circuit_witness_data); @@ -27,3 +27,4 @@ TEST(compute_nullifier_circuit, native_consistency) EXPECT_EQ(circuit_nullifier.get_value(), native_nullifier); } +} // namespace join_split_example \ No newline at end of file diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp index f01324ee34..ac6104c65a 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp @@ -1,6 +1,6 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" -#include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "../../constants.hpp" namespace join_split_example { @@ -9,8 +9,6 @@ namespace notes { namespace circuit { namespace value { -using namespace proof_system::plonk::stdlib::types; - inline auto create_partial_commitment(field_ct const& secret, point_ct const& owner, bool_ct const& account_required, diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp index a4f8cc04c8..9f2d47a6c6 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp @@ -1,5 +1,5 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" +#include "barretenberg/join_split_example/types.hpp" #include "witness_data.hpp" #include "commit.hpp" @@ -9,7 +9,7 @@ namespace notes { namespace circuit { namespace value { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; struct value_note { point_ct owner; diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp index f3410308bd..637412a972 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp @@ -2,13 +2,14 @@ #include "../../../../fixtures/user_context.hpp" #include "../../native/value/value_note.hpp" #include "../../constants.hpp" +#include "barretenberg/join_split_example/types.hpp" #include +namespace join_split_example { using namespace barretenberg; -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; using namespace join_split_example::proofs::notes; using namespace join_split_example::proofs::notes::circuit::value; - TEST(value_note, commits) { auto user = join_split_example::fixtures::create_user_context(); @@ -106,4 +107,5 @@ TEST(value_note, commit_with_oversized_asset_id_fails) bool proof_result = verifier.verify_proof(proof); EXPECT_EQ(proof_result, false); -} \ No newline at end of file +} +} // namespace join_split_example \ No newline at end of file diff --git a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp index ff0cbc0cc2..367f0e704e 100644 --- a/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp +++ b/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp @@ -1,7 +1,6 @@ #pragma once -#include "barretenberg/stdlib/types/types.hpp" #include "../../native/value/value_note.hpp" -#include "../../constants.hpp" +#include "barretenberg/join_split_example/types.hpp" namespace join_split_example { namespace proofs { @@ -9,7 +8,7 @@ namespace notes { namespace circuit { namespace value { -using namespace proof_system::plonk::stdlib::types; +using namespace proof_system::plonk::stdlib; struct witness_data { point_ct owner; diff --git a/cpp/src/barretenberg/join_split_example/types.hpp b/cpp/src/barretenberg/join_split_example/types.hpp new file mode 100644 index 0000000000..a7ece3c87c --- /dev/null +++ b/cpp/src/barretenberg/join_split_example/types.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "barretenberg/plonk/composer/standard_composer.hpp" +#include "barretenberg/plonk/composer/turbo_composer.hpp" +#include "barretenberg/plonk/composer/ultra_composer.hpp" +#include "barretenberg/plonk/proof_system/prover/prover.hpp" +#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" +#include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" +#include "barretenberg/stdlib/primitives/bit_array/bit_array.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/primitives/byte_array/byte_array.hpp" +#include "barretenberg/stdlib/primitives/uint/uint.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" +#include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" +#include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/commitment/pedersen/pedersen_plookup.hpp" +#include "barretenberg/stdlib/merkle_tree/hash_path.hpp" +#include "barretenberg/stdlib/encryption/schnorr/schnorr.hpp" +#include "barretenberg/stdlib/primitives/curves/bn254.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" +#include "barretenberg/stdlib/primitives/memory/rom_table.hpp" +#include "barretenberg/stdlib/recursion/verifier/program_settings.hpp" +#include "barretenberg/stdlib/primitives/memory/ram_table.hpp" +#include "barretenberg/stdlib/primitives/memory/rom_table.hpp" +#include "barretenberg/stdlib/primitives/memory/dynamic_array.hpp" + +namespace join_split_example { + +using Composer = plonk::UltraComposer; + +using Prover = std::conditional_t< + std::same_as, + plonk::UltraProver, + std::conditional_t, plonk::TurboProver, plonk::Prover>>; + +using Verifier = std::conditional_t< + std::same_as, + plonk::UltraVerifier, + std::conditional_t, plonk::TurboVerifier, plonk::Verifier>>; + +using witness_ct = proof_system::plonk::stdlib::witness_t; +using public_witness_ct = proof_system::plonk::stdlib::public_witness_t; +using bool_ct = proof_system::plonk::stdlib::bool_t; +using byte_array_ct = proof_system::plonk::stdlib::byte_array; +using packed_byte_array_ct = proof_system::plonk::stdlib::packed_byte_array; +using field_ct = proof_system::plonk::stdlib::field_t; +using suint_ct = proof_system::plonk::stdlib::safe_uint_t; +using uint8_ct = proof_system::plonk::stdlib::uint8; +using uint16_ct = proof_system::plonk::stdlib::uint16; +using uint32_ct = proof_system::plonk::stdlib::uint32; +using uint64_ct = proof_system::plonk::stdlib::uint64; +using bit_array_ct = proof_system::plonk::stdlib::bit_array; +using fq_ct = proof_system::plonk::stdlib::bigfield; +using biggroup_ct = proof_system::plonk::stdlib::element; +using point_ct = proof_system::plonk::stdlib::point; +using pedersen_commitment = proof_system::plonk::stdlib::pedersen_commitment; +using group_ct = proof_system::plonk::stdlib::group; +using bn254 = proof_system::plonk::stdlib::bn254; +using secp256k1_ct = proof_system::plonk::stdlib::secp256k1; + +namespace merkle_tree { +using namespace proof_system::plonk::stdlib::merkle_tree; +using hash_path = proof_system::plonk::stdlib::merkle_tree::hash_path; +} // namespace merkle_tree + +namespace schnorr { +using signature_bits = proof_system::plonk::stdlib::schnorr::signature_bits; +} // namespace schnorr + +// Ultra-composer specific typesv +using rom_table_ct = proof_system::plonk::stdlib::rom_table; + +// NOTE: In ultra setting, recursive verifier settings are incompatible with the settings used by Noir. +// TODO: remove? +using recursive_inner_verifier_settings = + std::conditional_t, + proof_system::plonk::stdlib::recursion::recursive_ultra_verifier_settings, + proof_system::plonk::stdlib::recursion::recursive_turbo_verifier_settings>; + +} // namespace join_split_example \ No newline at end of file diff --git a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.bench.cpp b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.bench.cpp index 4cf8033c5d..0dd9908754 100644 --- a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.bench.cpp +++ b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.bench.cpp @@ -5,13 +5,12 @@ #include "barretenberg/plonk/proof_system/prover/prover.hpp" #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -namespace stdlib_sha256_bench { using namespace benchmark; -using namespace proof_system::plonk::stdlib; +using namespace proof_system::plonk; -using Composer = plonk::UltraComposer; -using Prover = plonk::UltraProver; -using Verifier = plonk::UltraVerifier; +using LocalComposer = UltraComposer; +using LocalProver = UltraProver; +using LocalVerifier = UltraVerifier; constexpr size_t NUM_HASHES = 8; constexpr size_t BYTES_PER_CHUNK = 512; @@ -23,27 +22,27 @@ char get_random_char() return static_cast(barretenberg::fr::random_element().data[0] % 8); } -void generate_test_plonk_circuit(Composer& composer, size_t num_bytes) +void generate_test_plonk_circuit(LocalComposer& composer, size_t num_bytes) { std::string in; in.resize(num_bytes); for (size_t i = 0; i < num_bytes; ++i) { in[i] = get_random_char(); } - packed_byte_array input(&composer, in); - plonk::stdlib::sha256(input); + stdlib::packed_byte_array input(&composer, in); + stdlib::sha256(input); } -Composer composers[NUM_HASHES]; -Prover provers[NUM_HASHES]; -Verifier verifiers[NUM_HASHES]; +LocalComposer composers[NUM_HASHES]; +LocalProver provers[NUM_HASHES]; +LocalVerifier verifiers[NUM_HASHES]; plonk::proof proofs[NUM_HASHES]; void construct_witnesses_bench(State& state) noexcept { for (auto _ : state) { size_t idx = (static_cast((state.range(0))) - START_BYTES) / BYTES_PER_CHUNK; - composers[idx] = Composer(); + composers[idx] = LocalComposer(); generate_test_plonk_circuit(composers[idx], static_cast(state.range(0))); } } @@ -91,4 +90,3 @@ void verify_proofs_bench(State& state) noexcept BENCHMARK(verify_proofs_bench)->DenseRange(START_BYTES, MAX_BYTES, BYTES_PER_CHUNK); BENCHMARK_MAIN(); -} // namespace stdlib_sha256_bench \ No newline at end of file