Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2dc4d77
Use circuit constructor.
codygunton Jun 20, 2023
0d186af
Undo hack to stop exposing manifest.
codygunton Jun 21, 2023
350ab82
Update Bb
codygunton Jun 21, 2023
ea69fc5
Update Bb
codygunton Jun 21, 2023
64c8ba7
Bump Bb (need Mont conversion)
codygunton Jun 21, 2023
d488fc4
Using builder and CircuitType
codygunton Jun 26, 2023
ded2a64
Fix some things break others.
codygunton Jun 26, 2023
2224d0f
Satisfy prettier?
codygunton Jun 26, 2023
aa6f850
Composer ~> Builder
codygunton Jun 26, 2023
f91ece9
composer ~> builder
codygunton Jun 26, 2023
86fa2cd
mv dummy_composer.hpp and rename class.
codygunton Jun 26, 2023
b3097e2
Clean change to settingss.
codygunton Jun 26, 2023
e3eed2f
Bump Bb.
codygunton Jun 26, 2023
019c759
Merge branch 'master' into cg/circuit-builders
codygunton Jun 27, 2023
f888db5
Note on compilation errors in tests.
codygunton Jun 27, 2023
4958f0a
Try to satisfy clang-tidy.
codygunton Jun 27, 2023
2b8e215
Fix test that didn't compile before.
codygunton Jun 27, 2023
d19e5ee
Merge branch 'master' into cg/circuit-builders
codygunton Jun 27, 2023
80d7d22
Respond to comments and clean up
codygunton Jun 27, 2023
ee71367
Fix typo and formatting.
codygunton Jun 27, 2023
27b9a0a
Merge branch 'master' into cg/circuit-builders
codygunton Jun 27, 2023
46b831f
Fix compilation post-merge
codygunton Jun 27, 2023
c10ae38
It should be a Schnorr signature?
codygunton Jun 27, 2023
d5fe0d3
Merge branch 'master' into cg/circuit-builders
codygunton Jun 27, 2023
ee3d9e0
Revert to Ecdsa
codygunton Jun 27, 2023
bef4f57
Proposed fix.
codygunton Jun 27, 2023
aaeb225
Revert "Proposed fix."
codygunton Jun 27, 2023
ec3fbf4
Test Schnorr; update snapshot.
codygunton Jun 27, 2023
5d20a8d
Rebuild WASM before making snapshot.
codygunton Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg
Submodule barretenberg updated 183 files
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/abis/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace {
// Composer
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;

// Types
using CT = aztec3::utils::types::CircuitTypes<Composer>;
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/apps/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace {
// Composer
using C = plonk::UltraPlonkComposer;
using C = UltraCircuitConstructor;

// Types
using CT = aztec3::utils::types::CircuitTypes<C>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace aztec3::circuits::apps::test_apps::basic_contract_deployment {

// Composer
using C = plonk::UltraPlonkComposer;
using C = UltraCircuitConstructor;

// Native and circuit types
using CT = aztec3::utils::types::CircuitTypes<C>;
Expand Down
18 changes: 9 additions & 9 deletions circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ TEST_F(escrow_tests, circuit_deposit)
// info("witness: ", composer.witness);
// info("constant variables: ", composer.constant_variables);
// info("variables: ", composer.variables);
info("failed?: ", composer.circuit_constructor.failed());
info("err: ", composer.circuit_constructor.err());
info("n: ", composer.circuit_constructor.num_gates);
info("failed?: ", composer.failed());
info("err: ", composer.err());
info("n: ", composer.num_gates);
}

TEST_F(escrow_tests, circuit_transfer)
Expand All @@ -81,9 +81,9 @@ TEST_F(escrow_tests, circuit_transfer)
// info("witness: ", composer.witness);
// info("constant variables: ", composer.constant_variables);
// info("variables: ", composer.variables);
info("failed?: ", composer.circuit_constructor.failed());
info("err: ", composer.circuit_constructor.err());
info("n: ", composer.circuit_constructor.num_gates);
info("failed?: ", composer.failed());
info("err: ", composer.err());
info("n: ", composer.num_gates);
}

TEST_F(escrow_tests, circuit_withdraw)
Expand All @@ -105,9 +105,9 @@ TEST_F(escrow_tests, circuit_withdraw)
// info("witness: ", composer.witness);
// info("constant variables: ", composer.constant_variables);
// info("variables: ", composer.variables);
info("failed?: ", composer.circuit_constructor.failed());
info("err: ", composer.circuit_constructor.err());
info("n: ", composer.circuit_constructor.num_gates);
info("failed?: ", composer.failed());
info("err: ", composer.err());
info("n: ", composer.num_gates);
}

} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace aztec3::circuits::apps::test_apps::escrow {

// Composer
using C = plonk::UltraPlonkComposer;
using C = UltraCircuitConstructor;

// Native and circuit types
using CT = aztec3::utils::types::CircuitTypes<C>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function
// info("witness: ", fn1_composer.witness);
// info("constant variables: ", fn1_composer.constant_variables);
// info("variables: ", fn1_composer.variables);
info("failed?: ", fn1_composer.circuit_constructor.failed());
info("err: ", fn1_composer.circuit_constructor.err());
info("n: ", fn1_composer.circuit_constructor.num_gates);
info("failed?: ", fn1_composer.failed());
info("err: ", fn1_composer.err());
info("n: ", fn1_composer.num_gates);
}

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace aztec3::circuits::apps::test_apps::private_to_private_function_call {

// Composer
using C = plonk::UltraPlonkComposer;
using C = UltraCircuitConstructor;

// Native and circuit types
using CT = aztec3::utils::types::CircuitTypes<C>;
Expand Down
6 changes: 3 additions & 3 deletions circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ TEST_F(private_kernel_tests, basic)
false, deposit, { amount, asset_id, memo }, encrypted_logs_hash, encrypted_log_preimages_length, true);

// Execute and prove the first kernel iteration
Composer private_kernel_composer("../barretenberg/cpp/srs_db/ignition");
Composer private_kernel_composer;
auto const& public_inputs = private_kernel_circuit(private_kernel_composer, private_inputs, true);

// Check the private kernel circuit
EXPECT_TRUE(private_kernel_composer.circuit_constructor.check_circuit());
EXPECT_TRUE(private_kernel_composer.check_circuit());
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ TEST_F(private_kernel_tests, circuit_cbinds)
std::vector<uint8_t> private_constructor_call_vec;
write(private_constructor_call_vec, private_inputs.private_call);

uint8_t const* proof_data_buf = nullptr;
// uint8_t const* proof_data_buf = nullptr;
uint8_t const* public_inputs_buf = nullptr;
size_t public_inputs_size = 0;
// info("Simulating to generate public inputs...");
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <barretenberg/barretenberg.hpp>

namespace {
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;
using NT = aztec3::utils::types::NativeTypes;
using DummyComposer = aztec3::utils::DummyComposer;
using aztec3::circuits::abis::PreviousKernelData;
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace aztec3::circuits::kernel::private_kernel {

using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;

using Aggregator = aztec3::circuits::recursion::Aggregator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@ using aztec3::circuits::silo_nullifier;

// TODO: NEED TO RECONCILE THE `proof`'s public inputs (which are uint8's) with the
// private_call.call_stack_item.public_inputs!
CT::AggregationObject verify_proofs(Composer& composer,
PrivateKernelInputsInner<CT> const& private_inputs,
size_t const& num_private_call_public_inputs,
size_t const& num_private_kernel_public_inputs)
CT::AggregationObject verify_proofs(Composer& composer, PrivateKernelInputsInner<CT> const& private_inputs)
{
// compute P0, P1 for private function proof
CT::AggregationObject aggregation_object = Aggregator::aggregate(
&composer, private_inputs.private_call.vk, private_inputs.private_call.proof, num_private_call_public_inputs);
CT::AggregationObject aggregation_object =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice, aggregate shouldn't have to know what the number of public inputs of the private call is.

Aggregator::aggregate(&composer, private_inputs.private_call.vk, private_inputs.private_call.proof);

// computes P0, P1 for previous kernel proof
// AND accumulates all of it in P0_agg, P1_agg
Aggregator::aggregate(&composer,
private_inputs.previous_kernel.vk,
private_inputs.previous_kernel.proof,
num_private_kernel_public_inputs,
aggregation_object);
Aggregator::aggregate(
&composer, private_inputs.previous_kernel.vk, private_inputs.previous_kernel.proof, aggregation_object);

return aggregation_object;
}
Expand Down Expand Up @@ -334,10 +328,7 @@ KernelCircuitPublicInputs<NT> private_kernel_circuit(Composer& composer,

update_end_values(private_inputs, public_inputs);

auto aggregation_object = verify_proofs(composer,
private_inputs,
_private_inputs.private_call.vk->num_public_inputs,
_private_inputs.previous_kernel.vk->num_public_inputs);
auto aggregation_object = verify_proofs(composer, private_inputs);

// TODO: kernel vk membership check!

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ PreviousKernelData<NT> dummy_previous_kernel(bool real_vk_proof = false)
PreviousKernelData<NT> const init_previous_kernel{};

auto crs_factory = barretenberg::srs::get_crs_factory();
Composer mock_kernel_composer = Composer(crs_factory);
Composer mock_kernel_composer;
auto mock_kernel_public_inputs = mock_kernel_circuit(mock_kernel_composer, init_previous_kernel.public_inputs);

NT::Proof const mock_kernel_proof =
Expand Down
12 changes: 6 additions & 6 deletions circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ PublicKernelInputs<NT> get_kernel_inputs_with_previous_kernel(NT::boolean privat
.bytecode_hash = 1234567,
};

CombinedHistoricTreeRoots<NT> const historic_tree_roots = { .private_historic_tree_roots = {
.private_data_tree_root = 1000,
.contract_tree_root = 2000,
.l1_to_l2_messages_tree_root = 3000,
.private_kernel_vk_tree_root = 4000,
} };
// CombinedHistoricTreeRoots<NT> const historic_tree_roots = { .private_historic_tree_roots = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably? I haven't looked into the history or discussed with core circuits team yet.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I didn't see it was a draft, my bad

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up making an issue to look at this and two other unused variables in the same test file, and I reference that issue in TODOs in the code.

// .private_data_tree_root = 1000,
// .contract_tree_root = 2000,
// .l1_to_l2_messages_tree_root = 3000,
// .private_kernel_vk_tree_root = 4000,
// } };

CombinedConstantData<NT> const end_constants = {
.historic_tree_roots =
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <barretenberg/barretenberg.hpp>

namespace {
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;
using NT = aztec3::utils::types::NativeTypes;
using DummyComposer = aztec3::utils::DummyComposer;
using aztec3::circuits::abis::KernelCircuitPublicInputs;
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace aztec3::circuits::kernel::public_kernel {

using Composer = plonk::UltraPlonkComposer;
using Composer = proof_system::UltraCircuitConstructor;

using Aggregator = aztec3::circuits::recursion::Aggregator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KernelCircuitPublicInputs<NT> mock_kernel_circuit(Composer& composer,
// We still add dummy witness indices in the recursive proof indices just so that we don't trigger an assertion in
// while setting recursion elements as public inputs. These dummy indices would not be used as we're setting
// contains_recursive_proof to be false.
composer.circuit_constructor.contains_recursive_proof = false;
composer.contains_recursive_proof = false;

plonk::stdlib::pedersen_commitment<Composer>::compress(fr(witness_t(&composer, 1)), fr(witness_t(&composer, 1)));
return public_inputs.template to_native_type<Composer>();
Expand Down
9 changes: 4 additions & 5 deletions circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include "init.hpp"

#include "barretenberg/plonk/flavor/flavor.hpp"

namespace aztec3::circuits::recursion {

class Aggregator {
Expand All @@ -9,13 +11,10 @@ class Aggregator {
Composer* composer,
const std::shared_ptr<CT::VK>& vk,
const NT::Proof& proof,
const size_t& num_public_inputs,
const CT::AggregationObject& previous_aggregation_output = CT::AggregationObject())
{
const Manifest recursive_manifest = Composer::create_manifest(num_public_inputs);

CT::AggregationObject result = verify_proof<CT::bn254, CT::recursive_inner_verifier_settings>(
composer, vk, recursive_manifest, proof, previous_aggregation_output);
CT::AggregationObject result =
verify_proof<plonk::flavor::Ultra>(composer, vk, proof, previous_aggregation_output);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/recursion/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace aztec3::circuits::recursion {
// Composer
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;

// Generic types:
using CT = aztec3::utils::types::CircuitTypes<Composer>;
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <barretenberg/barretenberg.hpp>

namespace {
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;
using NT = aztec3::utils::types::NativeTypes;
using DummyComposer = aztec3::utils::DummyComposer;
using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs;
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <barretenberg/barretenberg.hpp>

namespace {
using Composer = plonk::UltraPlonkComposer;
using Composer = UltraCircuitConstructor;
using NT = aztec3::utils::types::NativeTypes;
using DummyComposer = aztec3::utils::DummyComposer;
using aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit;
Expand Down
5 changes: 1 addition & 4 deletions circuits/cpp/src/aztec3/utils/types/circuit_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ template <typename Composer> struct CircuitTypes {
using ecdsa_signature = stdlib::ecdsa::signature<Composer>;

using AggregationObject = stdlib::recursion::aggregation_state<bn254>;
using recursive_inner_verifier_settings =
std::conditional_t<std::same_as<Composer, plonk::TurboPlonkComposer>,
stdlib::recursion::recursive_turbo_verifier_settings<bn254>,
stdlib::recursion::recursive_ultra_verifier_settings<bn254>>;
using recursive_inner_verifier_settings = stdlib::recursion::recursive_ultra_verifier_settings<bn254>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is his because we don't expect turbo to be used as inner circuit builder anymore? If so, makes sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, Luke's previous PR fixed the inner circuit type to Ultra (indeed, Aggregate::aggregate now uses a fixed flavor), so it wouldn't even work to toggle the inner type. In general this recursion stuff needs a rework, so I thought I'd pare it down to make it simpler for when we do that work. In fact, I see now this alias is not in use anywhere, so I think I'll remove it.

using VK = stdlib::recursion::verification_key<bn254>;
// Notice: no CircuitType for a Proof: we only ever handle native; the verify_proof() function swallows the
// 'circuit-type-ness' of the proof.
Expand Down