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

feat: Constant Honk proof sizes #6954

Merged
merged 54 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
fb8ab2c
squash; prove_then_verify flow acir test passes
codygunton Jun 12, 2024
99b9b7e
Merge branch 'master' into cg/constant-honk-proof-size
codygunton Jun 12, 2024
2edb0e8
Make stdlib Zm verifier test; it fails.
codygunton Jun 23, 2024
3e6e746
Trying to debug
codygunton Jun 24, 2024
8ffeda0
It passes
codygunton Jun 24, 2024
15beef5
WIP including sumcheck (need more stuff from lx/)
codygunton Jun 24, 2024
c22a8e7
getting it to build (with hacks)
lucasxia01 Jun 24, 2024
63dd3bc
modified dummy rounds to be end of sumcheck, native ultra_honk tests …
lucasxia01 Jun 24, 2024
7afccfe
passed dummy_round to univariate_eval - recursive verifier test passes
lucasxia01 Jun 24, 2024
0dd7530
cherrypicked - Implement vk hash and check
codygunton Jun 21, 2024
d6e1efb
moved recursive verifier changes to this branch from honk-in-rollup
lucasxia01 Jun 24, 2024
fe85e03
updating acir/prover.toml of test programs - prove_then_verify flow p…
lucasxia01 Jun 24, 2024
25d0a15
don't pass the witness to the write_vk_honk flow
lucasxia01 Jun 24, 2024
ebe4115
Detect rec ver vk changes in test
codygunton Jun 24, 2024
0036183
Note bad values
codygunton Jun 25, 2024
5db6800
check outer circuit vk not inner
ledwards2225 Jun 25, 2024
302945a
Merge branch 'master' into cg/constant-honk-proof-size
ledwards2225 Jun 25, 2024
ff23a57
missed test suite updates
ledwards2225 Jun 25, 2024
ad22a00
add back in PCS round missed in merge
ledwards2225 Jun 25, 2024
3e881e3
Merge branch 'master' into cg/constant-honk-proof-size
ledwards2225 Jun 25, 2024
d138cbc
fix wrapping size_t exponent in ZM
ledwards2225 Jun 25, 2024
41e8e50
update Prover.toml and disable tube acir test for now
ledwards2225 Jun 25, 2024
6f1767a
Fix AcirHonkRecursionConstraint.TestFullRecursiveComposition
codygunton Jun 26, 2024
dcd01e3
updating proof size and prover toml
ledwards2225 Jun 26, 2024
e4c553b
moving changes to honk_recursion_constraint over from other branch
lucasxia01 Jun 26, 2024
503adcc
revert rebuild script changes
ledwards2225 Jun 26, 2024
fd378aa
vk hash agrees for verify_honk_proof thru sumcheck
ledwards2225 Jun 26, 2024
84ba6fa
infinite llopy?
ledwards2225 Jun 26, 2024
61b6744
No infinite llopy
codygunton Jun 26, 2024
4ede58a
Pow in Zm uses witness
codygunton Jun 26, 2024
6d460c0
Skip it
codygunton Jun 26, 2024
5ca1060
prove_then_verify passes!
codygunton Jun 26, 2024
5e4ea9d
Merge branch 'master' into cg/constant-honk-proof-size
ledwards2225 Jun 26, 2024
41677b7
revert rebuild changes
ledwards2225 Jun 26, 2024
ecf2cec
delete recusion kernel pinning and fix build
ledwards2225 Jun 26, 2024
137ab4e
fix gcc
ledwards2225 Jun 26, 2024
b1fbd1e
remove lookup delta, maybe fix build?
ledwards2225 Jun 27, 2024
8c48c76
Merge branch 'master' into cg/constant-honk-proof-size
lucasxia01 Jun 27, 2024
26252cf
cleanup
ledwards2225 Jun 27, 2024
ee01801
Merge branch 'cg/constant-honk-proof-size' of github.com:AztecProtoco…
ledwards2225 Jun 27, 2024
56d9c8c
more cleanup
ledwards2225 Jun 27, 2024
79ff45a
replace local MAX_LOG with global constant
ledwards2225 Jun 27, 2024
e2875b5
more clean
ledwards2225 Jun 27, 2024
b700670
clean cleann
ledwards2225 Jun 27, 2024
ef815c9
Merge branch 'master' into cg/constant-honk-proof-size
ledwards2225 Jun 27, 2024
1c09df7
cleanup and some todos
ledwards2225 Jun 27, 2024
8d3cf4f
issue for circuit size in eccvm rec verifier
ledwards2225 Jun 27, 2024
331e839
Merge branch 'master' into cg/constant-honk-proof-size
ledwards2225 Jun 28, 2024
355083b
fix avm verifier mle challenge size
ledwards2225 Jun 28, 2024
58f324a
add todo for gate challenges
ledwards2225 Jun 28, 2024
eb1e87d
todo for adding hashing constraint for ultra
ledwards2225 Jun 28, 2024
3cb9179
cleanup, todos, and avm gen updates
ledwards2225 Jun 28, 2024
3570320
comments, TODOs, cleanup in response to review
ledwards2225 Jun 28, 2024
296b16e
use older hashing issue in TODO
ledwards2225 Jun 28, 2024
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 barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ barretenberg-acir-tests-bb:
RUN FLOW=prove_and_verify_mega_honk_program ./run_acir_tests.sh
# Fold and verify an ACIR program stack using ClientIvc
RUN FLOW=fold_and_verify_program ./run_acir_tests.sh fold_basic
# Fold and verify an ACIR program stack using ClientIvc, recursively verify as part of the Tube circuit and produce and verify a Honk proof
# Fold and verify an ACIR program stack using ClientIvc, recursively verify as part of the Tube circuit and produce and verify a Honk proof
RUN FLOW=prove_then_verify_tube ./run_acir_tests.sh fold_basic
# Construct and separately verify a UltraHonk proof for a single program that recursively verifies a Honk proof
RUN FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh verify_honk_proof
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -eu
set -eux

VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_subdirectory(barretenberg/bb)
add_subdirectory(barretenberg/circuit_checker)
add_subdirectory(barretenberg/client_ivc)
add_subdirectory(barretenberg/commitment_schemes)
add_subdirectory(barretenberg/commitment_schemes_recursion)
add_subdirectory(barretenberg/common)
add_subdirectory(barretenberg/crypto)
add_subdirectory(barretenberg/dsl)
Expand Down
69 changes: 40 additions & 29 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,18 +741,15 @@ bool avm_verify(const std::filesystem::path& proof_path, const std::filesystem::
#endif

/**
* @brief Creates a proof for an ACIR circuit
*
* Communication:
* - stdout: The proof is written to stdout as a byte array
* - Filesystem: The proof is written to the path specified by outputPath
* @brief Create a Honk a prover from program bytecode and an optional witness
*
* @param bytecodePath Path to the file containing the serialized circuit
* @param witnessPath Path to the file containing the serialized witness
* @param outputPath Path to write the proof to
* @tparam Flavor
* @param bytecodePath
* @param witnessPath
* @return UltraProver_<Flavor>
*/
template <IsUltraFlavor Flavor>
void prove_honk(const std::string& bytecodePath, const std::string& witnessPath, const std::string& outputPath)
template <typename Flavor>
UltraProver_<Flavor> compute_valid_prover(const std::string& bytecodePath, const std::string& witnessPath)
{
using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;
Expand All @@ -762,16 +759,41 @@ void prove_honk(const std::string& bytecodePath, const std::string& witnessPath,
honk_recursion = true;
}
auto constraint_system = get_constraint_system(bytecodePath, honk_recursion);
auto witness = get_witness(witnessPath);
acir_format::WitnessVector witness = {};
if (!witnessPath.empty()) {
witness = get_witness(witnessPath);
}

auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, witness, honk_recursion);

auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials();
size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates);
init_bn254_crs(srs_size);

// Construct Honk proof
Prover prover{ builder };
return prover;
}

/**
* @brief Creates a proof for an ACIR circuit
*
* Communication:
* - stdout: The proof is written to stdout as a byte array
* - Filesystem: The proof is written to the path specified by outputPath
*
* @param bytecodePath Path to the file containing the serialized circuit
* @param witnessPath Path to the file containing the serialized witness
* @param outputPath Path to write the proof to
*/
template <IsUltraFlavor Flavor>
void prove_honk(const std::string& bytecodePath, const std::string& witnessPath, const std::string& outputPath)
{
// using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;

// Construct Honk proof
Prover prover = compute_valid_prover<Flavor>(bytecodePath, witnessPath);
typename Flavor::VerificationKey vk(prover.instance->proving_key);
ledwards2225 marked this conversation as resolved.
Show resolved Hide resolved
auto proof = prover.construct_proof();

if (outputPath == "-") {
Expand Down Expand Up @@ -807,10 +829,9 @@ template <IsUltraFlavor Flavor> bool verify_honk(const std::string& proof_path,
auto g2_data = get_bn254_g2_data(CRS_PATH);
srs::init_crs_factory({}, g2_data);
auto proof = from_buffer<std::vector<bb::fr>>(read_file(proof_path));
auto verification_key = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(read_file(vk_path)));
verification_key->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

Verifier verifier{ verification_key };
auto vk = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(read_file(vk_path)));
vk->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
Verifier verifier{ vk };

bool verified = verifier.verify_proof(proof);

Expand All @@ -830,22 +851,12 @@ template <IsUltraFlavor Flavor> bool verify_honk(const std::string& proof_path,
*/
template <IsUltraFlavor Flavor> void write_vk_honk(const std::string& bytecodePath, const std::string& outputPath)
{
using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;
using ProverInstance = ProverInstance_<Flavor>;
using VerificationKey = Flavor::VerificationKey;

bool honk_recursion = false;
if constexpr (IsAnyOf<Flavor, UltraFlavor>) {
honk_recursion = true;
}
auto constraint_system = get_constraint_system(bytecodePath, honk_recursion);
auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, {}, honk_recursion);

auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials();
size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates);
init_bn254_crs(srs_size);

ProverInstance prover_inst(builder);
Prover prover = compute_valid_prover<Flavor>(bytecodePath, "");
ProverInstance& prover_inst = *prover.instance;
VerificationKey vk(
prover_inst.proving_key); // uses a partial form of the proving key which only has precomputed entities

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ template <class Curve> class VerifierCommitmentKey;
* @tparam curve::BN254
*/
template <> class VerifierCommitmentKey<curve::BN254> {
public:
using Curve = curve::BN254;
using GroupElement = typename Curve::Element;
using Commitment = typename Curve::AffineElement;

public:
VerifierCommitmentKey()
{
srs::init_crs_factory("../srs_db/ignition");
Expand Down Expand Up @@ -69,11 +69,11 @@ template <> class VerifierCommitmentKey<curve::BN254> {
* @tparam curve::Grumpkin
*/
template <> class VerifierCommitmentKey<curve::Grumpkin> {
public:
using Curve = curve::Grumpkin;
using GroupElement = typename Curve::Element;
using Commitment = typename Curve::AffineElement;

public:
/**
* @brief Construct a new IPA Verification Key object from existing SRS
*
Expand Down
Loading
Loading