Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Use circuit builders #501

Merged
merged 65 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2b681d2
Initial commit so tests run
codygunton Jun 2, 2023
4fe7ac2
Illustrate aux gate issue
codygunton Jun 2, 2023
ae2f094
Add notes, note last point where circuit checks
codygunton Jun 5, 2023
56ebb56
Merge branch 'master' into cg/big-split
codygunton Jun 12, 2023
a779895
composer~>circuit_constructor
codygunton Jun 12, 2023
bfd910f
StandardHonk test use CCtor
codygunton Jun 12, 2023
7b4ed77
UltraHonk tests use CCtor
codygunton Jun 12, 2023
bc4bcbe
Remove honk composer include from UH tests.
codygunton Jun 12, 2023
33f31ab
Merge branch 'master' into cg/big-split
codygunton Jun 13, 2023
83412a7
Honk doesn't depend on Plonk anymore
codygunton Jun 13, 2023
83cf7d9
Fix honk tests with Grumpkin.
codygunton Jun 13, 2023
08e2741
Honk is split.
codygunton Jun 13, 2023
dc05a2c
Plonk tests split.
codygunton Jun 13, 2023
40e4d69
Fix recursive verifier
codygunton Jun 13, 2023
ecea160
Move ensure_... to finalize_circuit.
codygunton Jun 14, 2023
4e7006d
Move _ensure_ to composer helper.
codygunton Jun 14, 2023
5b10604
Cleanup
codygunton Jun 14, 2023
e3e1d45
Re-add untested code used by circuits.
codygunton Jun 14, 2023
063250b
Split honk benchmarks.
codygunton Jun 14, 2023
624b4fa
Split ultra honk bench.
codygunton Jun 14, 2023
c32e542
Fix include.
codygunton Jun 15, 2023
8a4c34c
Split plonk bench.
codygunton Jun 15, 2023
4b9b7be
Pedersen bench
codygunton Jun 15, 2023
e95b048
Clean up includes
codygunton Jun 15, 2023
0fdd8b5
Cleanup includes (esp composers.hpp)
codygunton Jun 15, 2023
ed6131f
Split simple example
codygunton Jun 16, 2023
ae5e01f
Split acir_format.
codygunton Jun 16, 2023
27f0b68
Split acir_proofs
codygunton Jun 16, 2023
a084cb7
Remove one more composers_fwd.hpp
codygunton Jun 16, 2023
7d5d87c
Split ram_table test.
codygunton Jun 16, 2023
9eb2f1e
Split rom table test.
codygunton Jun 16, 2023
c0503b8
Fix bb.js from Charlie
codygunton Jun 16, 2023
665a54a
Revert "Fix bb.js from Charlie"
codygunton Jun 16, 2023
09baba7
Merge branch 'master' into cg/big-split
codygunton Jun 16, 2023
44851bd
Split j-s example (partial)
codygunton Jun 16, 2023
0d82d1f
Split j-s example (& delete cruft).
codygunton Jun 16, 2023
9788410
Fix little j-s tests.
codygunton Jun 16, 2023
180041f
Reference refactoring issue
codygunton Jun 16, 2023
89c9bde
Split solidity helpers.
codygunton Jun 19, 2023
a9aa020
Split external bench.
codygunton Jun 19, 2023
d0a277f
Split sha256 bench.
codygunton Jun 19, 2023
30e714e
Split transcript tests (temp hide others)
codygunton Jun 19, 2023
bd46581
Unhide vk test
codygunton Jun 19, 2023
e87617c
Split stdlib vk test
codygunton Jun 19, 2023
1fea680
Uncomment verifier tests.
codygunton Jun 19, 2023
77fbc30
Split and refactor stdlib verifier tests
codygunton Jun 19, 2023
61b2c6c
Update composers.hpp
codygunton Jun 20, 2023
3773724
Quick-and-dirty to fix(?) circuits
codygunton Jun 20, 2023
0a13946
Point to circuits feature branch
codygunton Jun 20, 2023
0493ef0
Need to use commit hash(?)
codygunton Jun 20, 2023
efb4119
Undo hack to stop exposing manifest in circuits.
codygunton Jun 21, 2023
daec1bc
Make cast more explicit.
codygunton Jun 21, 2023
b053b79
Need Montgomery conversion.
codygunton Jun 21, 2023
02f9bd4
Merge remote-tracking branch 'origin/master' into cg/big-split
codygunton Jun 21, 2023
86ed54f
WORKTODO: remove unused function
codygunton Jun 21, 2023
4a642c6
Removed hack function.
codygunton Jun 21, 2023
dc25ece
WORKTODO: remove non-circuit-focused test.
codygunton Jun 21, 2023
a33cb5b
WORKTODOs: misc
codygunton Jun 21, 2023
a6ab841
WORKTODO: mv stdlib composers files.
codygunton Jun 21, 2023
22d2ff6
Update packages commit.
codygunton Jun 21, 2023
63a814d
Run acir_format_tests in CI
codygunton Jun 21, 2023
36a8a24
Cleanup
codygunton Jun 21, 2023
e3954de
Try to use automatic workflow
codygunton Jun 21, 2023
74124ba
Whoops, I misunderstood--set packages commit.
codygunton Jun 21, 2023
77742d6
Reformat some comments.
codygunton Jun 21, 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
1 change: 1 addition & 0 deletions cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "barretenberg/common/net.hpp"

const std::string protocol_name = "BARRETENBERG_GRUMPKIN_IPA_CRS";
// WORKTODO: this is incorrect now right?
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the difference between WORKTODO and a regular TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

WORKTODO is something I search for and then resolve before putting the PR up for review.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tbh maybe I should use something shorter like HEY

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or perhaps HMM alla Zac

/* Generates a monomial basis Grumpkin SRS for testing purposes.
We only provide functionality create a single transcript file.
The SRS has the form [1]_1, [x]_1, [x^2]_1, ... where x = 2. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ class UltraCircuitConstructor : public CircuitConstructorBase<arithmetization::U
fr alpha_base,
fr alpha) const;

void update_circuit_in_the_head();
void update_circuit_in_the_head(); // WORKTODO: declared but not defined
bool check_circuit();
};
} // namespace proof_system
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ element<C, Fq, Fr, G> element<C, Fq, Fr, G>::lookup_table_plookup<length, X>::ge
accumulators.emplace_back(field_t<C>(bits[i]) * (1ULL << i));
}
field_t<C> index = field_t<C>::accumulate(accumulators);
if (bits._M_elems[0].context->circuit_constructor.num_gates == 25122) {
bits._M_elems[0].context->circuit_constructor.check_circuit();
info("Executed check of partial circuit.");
}
return read_group_element_rom_tables<table_size>(coordinates, index, limb_max);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <typename Curve> struct aggregation_state {
* independently track `proof_witness_indices` and whether object has been assigned to public inputs)
*
*/
void add_proof_outputs_as_public_inputs()
void add_proof_outputs_as_public_inputs() // WORKTODO: This is not used anywhere.
{
auto* context = P0.get_context();
context->add_recursive_proof(proof_witness_indices);
Expand Down Expand Up @@ -70,6 +70,8 @@ template <typename Curve> struct aggregation_state {

auto* context = P0.get_context();

context->check_circuit();
info("checked circuit before add_recursive_proof");
context->add_recursive_proof(proof_witness_indices);
}
};
Expand Down
38 changes: 23 additions & 15 deletions cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {
fr_ct(witness_ct(&composer, 0)));

big_a* big_b;

info("Inner circuit size: ", composer.num_gates);
};

/**
Expand Down Expand Up @@ -136,7 +138,8 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {
verification_key_pt::from_witness(&outer_composer, verification_key_native);

info("Constructing the ultra (inner) proof ...");
plonk::proof recursive_proof = prover.construct_proof();
plonk::proof recursive_proof =
prover.construct_proof(); // WORKTODO: this is the proof that the outer circuit verifies

{
// Native check is mainly for comparison vs circuit version of the verifier.
Expand All @@ -150,7 +153,7 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {
}

info("Verifying the ultra (inner) proof natively...");
auto native_result = native_verifier.verify_proof(recursive_proof);
auto native_result = native_verifier.verify_proof(recursive_proof); // WORKTODO
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the TODO referring to here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

recursive_proof is a bad name... misleading shorthand for proof_to_be_recursively_verified. Plan to rename to something easier to parse.


info("Native result: ", native_result);
}
Expand Down Expand Up @@ -289,6 +292,9 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {

auto circuit_output = create_outer_circuit(inner_composer, outer_composer);

outer_composer.circuit_constructor.check_circuit();
info("Checked circuit after creating outer circuit");

g1::affine_element P[2];
P[0].x = barretenberg::fq(circuit_output.aggregation_state.P0.x.get_value().lo);
P[0].y = barretenberg::fq(circuit_output.aggregation_state.P0.y.get_value().lo);
Expand All @@ -307,21 +313,23 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {

EXPECT_EQ(outer_composer.failed(), false);

info("creating prover for outer circuit");
info("composer gates = ", outer_composer.get_num_gates());
auto prover = outer_composer.create_prover();
info("created prover for outer circuit");
info("Executing check of full circuit:");
bool result = outer_composer.circuit_constructor.check_circuit();
// info("creating prover for outer circuit");
// info("composer gates = ", outer_composer.get_num_gates());
// auto prover = outer_composer.create_prover();
// info("created prover for outer circuit");

info("creating verifier for outer proof");
auto verifier = outer_composer.create_verifier();
// info("creating verifier for outer proof");
// auto verifier = outer_composer.create_verifier();

info("creating outer proof for outer circuit");
plonk::proof proof = prover.construct_proof();
info("created outer proof");
// info("creating outer proof for outer circuit");
// plonk::proof proof = prover.construct_proof();
// info("created outer proof");

info("verifying the outer proof");
bool result = verifier.verify_proof(proof);
info("Outer proof verification result: ", result);
// info("verifying the outer proof");
// bool result = verifier.verify_proof(proof); // WORKTODO
// info("Outer proof verification result: ", result);

EXPECT_EQ(result, true);
}
Expand Down Expand Up @@ -365,7 +373,7 @@ template <typename OuterComposer> class stdlib_verifier : public testing::Test {
info("created outer proof");

info("verifying the outer proof");
bool result = verifier.verify_proof(proof);
bool result = verifier.verify_proof(proof); // WORKTODO
info("Outer proof verification result: ", result);

EXPECT_EQ(result, true);
Expand Down