Skip to content

Commit

Permalink
Everything builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Apr 13, 2023
1 parent e6e049c commit b8d322d
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 91 deletions.
11 changes: 6 additions & 5 deletions cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ size_t init_verification_key(void* pippenger, uint8_t const* g2x, uint8_t const*
reinterpret_cast<scalar_multiplication::Pippenger*>(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
Expand Down Expand Up @@ -110,13 +111,13 @@ size_t new_proof(void* pippenger,
reinterpret_cast<scalar_multiplication::Pippenger*>(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();

Expand All @@ -137,7 +138,7 @@ bool verify_proof(
read(vk_buf, vk_data);
auto verification_key = std::make_shared<proof_system::plonk::verification_key>(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<uint8_t>(proof, proof + length) };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#include <cstdint>
#include <sstream>

#include "c_bind.h"
#include "join_split.hpp"
#include "compute_signing_data.hpp"
#include "../mock/mock_circuit.hpp"
#include "barretenberg/common/streams.hpp"
#include "barretenberg/common/mem.hpp"
#include "barretenberg/common/container.hpp"
#include <cstdint>
#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 <sstream>
#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")))
Expand Down Expand Up @@ -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_tx>(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<plonk::stdlib::types::Prover*>(prover);
delete reinterpret_cast<join_split_example::Prover*>(prover);
}

WASM_EXPORT bool join_split__verify_proof(uint8_t* proof, uint32_t length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -23,7 +24,7 @@ void init_proving_key(std::shared_ptr<proof_system::ReferenceStringFactory> 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 {
Expand Down Expand Up @@ -55,8 +56,7 @@ void init_verification_key(std::unique_ptr<proof_system::ReferenceStringFactory>
// 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<proof_system::VerifierMemReferenceString> const& crs,
Expand All @@ -65,7 +65,7 @@ void init_verification_key(std::shared_ptr<proof_system::VerifierMemReferenceStr
verification_key = std::make_shared<plonk::verification_key>(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);
Expand All @@ -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<plonk::KateCommitmentScheme<plonk::turbo_settings>> kate_commitment_scheme =
Expand Down
Original file line number Diff line number Diff line change
@@ -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<proof_system::ReferenceStringFactory> const& crs_factory, bool mock);

Expand All @@ -22,7 +21,7 @@ void init_verification_key(std::unique_ptr<proof_system::ReferenceStringFactory>
void init_verification_key(std::shared_ptr<proof_system::VerifierMemReferenceString> 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);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include <gtest/gtest.h>

#include "../../constants.hpp"
#include "../inner_proof_data/inner_proof_data.hpp"
#include "index.hpp"
#include "../notes/native/index.hpp"
#include "join_split_circuit.hpp"
#include "barretenberg/common/streams.hpp"
#include "barretenberg/common/test.hpp"
#include <gtest/gtest.h>
#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 {

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Composer> signature;
schnorr::signature_bits signature;
field_ct merkle_root;
merkle_tree::hash_path input_path1;
merkle_tree::hash_path input_path2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#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 {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#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 {
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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<bool_ct, suint_ct> deflag_asset_id(suint_ct const& asset_id)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<bool_ct, suint_ct> deflag_asset_id(suint_ct const& asset_id);

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#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 {
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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<field_ct>{ note_commitment },
Expand Down
Loading

0 comments on commit b8d322d

Please sign in to comment.