Skip to content

Commit 6bffcbd

Browse files
authored
feat: merge-train/barretenberg (#19188)
BEGIN_COMMIT_OVERRIDE chore: Goblin AVM verifier audit - part 1 (#19091) chore: (PCS audit) added readmes and documentation for each component (#19092) chore: fix the wrong vm2 recursion vk (#19189) fix the pinned vk hash chore: unified chonk verifier (#19145) chore: keccak stdlib cleanup (#19169) END_COMMIT_OVERRIDE
2 parents e844749 + 2de1fcd commit 6bffcbd

File tree

62 files changed

+1823
-929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1823
-929
lines changed

barretenberg/cpp/scripts/test_chonk_standalone_vks_havent_changed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd ..
1313
# - Generate a hash for versioning: sha256sum bb-chonk-inputs.tar.gz
1414
# - Upload the compressed results: aws s3 cp bb-chonk-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-chonk-inputs-[hash(0:8)].tar.gz
1515
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
16-
pinned_short_hash="e9e9b7b7"
16+
pinned_short_hash="c288d94d"
1717
pinned_chonk_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-chonk-inputs-${pinned_short_hash}.tar.gz"
1818

1919
function compress_and_upload {

barretenberg/cpp/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ set(BARRETENBERG_TARGET_OBJECTS
179179
$<TARGET_OBJECTS:stdlib_blake2s_objects>
180180
$<TARGET_OBJECTS:stdlib_blake3s_objects>
181181
$<TARGET_OBJECTS:stdlib_circuit_builders_objects>
182-
$<TARGET_OBJECTS:stdlib_chonk_verifier_objects>
183182
$<TARGET_OBJECTS:stdlib_eccvm_verifier_objects>
184183
$<TARGET_OBJECTS:stdlib_honk_verifier_objects>
185184
$<TARGET_OBJECTS:stdlib_keccak_objects>

barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
*/
88

99
#include "acir_loader.hpp"
10+
#include "barretenberg/chonk/chonk_verifier.hpp"
1011
#include "barretenberg/circuit_checker/circuit_checker.hpp"
1112
#include "barretenberg/common/test.hpp"
1213
#include "barretenberg/dsl/acir_format/acir_format.hpp"
1314
#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp"
1415
#include "barretenberg/smt_verification/solver/solver.hpp"
1516
#include "barretenberg/smt_verification/util/smt_util.hpp"
16-
#include "barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp"
1717
#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"
1818
#include "formal_proofs.hpp"
1919
#include "helpers.hpp"

barretenberg/cpp/src/barretenberg/api/api_chonk.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "barretenberg/api/log.hpp"
44
#include "barretenberg/bbapi/bbapi.hpp"
55
#include "barretenberg/chonk/chonk.hpp"
6+
#include "barretenberg/chonk/chonk_verifier.hpp"
67
#include "barretenberg/chonk/mock_circuit_producer.hpp"
78
#include "barretenberg/chonk/private_execution_steps.hpp"
89
#include "barretenberg/common/get_bytecode.hpp"
@@ -120,7 +121,7 @@ bool ChonkAPI::verify([[maybe_unused]] const Flags& flags,
120121
{
121122
BB_BENCH_NAME("ChonkAPI::verify");
122123
auto proof_fields = many_from_buffer<fr>(read_file(proof_path));
123-
auto proof = Chonk::Proof::from_field_elements(proof_fields);
124+
auto proof = ChonkProof::from_field_elements(proof_fields);
124125

125126
auto vk_buffer = read_file(vk_path);
126127

@@ -138,7 +139,9 @@ bool ChonkAPI::prove_and_verify(const std::filesystem::path& input_path)
138139
// Construct the hiding kernel as the final step of the IVC
139140

140141
auto proof = ivc->prove();
141-
const bool verified = Chonk::verify(proof, ivc->get_vk());
142+
auto vk_and_hash = ivc->get_hiding_kernel_vk_and_hash();
143+
ChonkNativeVerifier verifier(vk_and_hash);
144+
const bool verified = verifier.verify(proof);
142145
return verified;
143146
}
144147

barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "barretenberg/bbapi/bbapi_chonk.hpp"
2+
#include "barretenberg/chonk/chonk_verifier.hpp"
23
#include "barretenberg/chonk/mock_circuit_producer.hpp"
34
#include "barretenberg/common/log.hpp"
45
#include "barretenberg/common/serialize.hpp"
@@ -108,19 +109,19 @@ ChonkProve::Response ChonkProve::execute(BBApiRequest& request) &&
108109
info("ChonkProve - using Chonk");
109110
auto sumcheck_ivc = std::dynamic_pointer_cast<Chonk>(request.ivc_in_progress);
110111
auto proof = sumcheck_ivc->prove();
111-
auto vk = sumcheck_ivc->get_vk();
112+
auto vk_and_hash = sumcheck_ivc->get_hiding_kernel_vk_and_hash();
112113

113114
// We verify this proof. Another bb call to verify has some overhead of loading VK/proof/SRS,
114115
// and it is mysterious if this transaction fails later in the lifecycle.
115116
info("ChonkProve - verifying the generated proof as a sanity check");
116-
verification_passed = Chonk::verify(proof, vk);
117+
ChonkNativeVerifier verifier(vk_and_hash);
118+
verification_passed = verifier.verify(proof);
117119

118120
if (!verification_passed) {
119121
throw_or_abort("Failed to verify the generated proof!");
120122
}
121123

122-
response.proof =
123-
Chonk::Proof{ .mega_proof = std::move(proof.mega_proof), .goblin_proof = std::move(proof.goblin_proof) };
124+
response.proof = ChonkProof{ std::move(proof.mega_proof), std::move(proof.goblin_proof) };
124125

125126
request.ivc_in_progress.reset();
126127
request.ivc_stack_depth = 0;
@@ -131,11 +132,13 @@ ChonkProve::Response ChonkProve::execute(BBApiRequest& request) &&
131132
ChonkVerify::Response ChonkVerify::execute(const BBApiRequest& /*request*/) &&
132133
{
133134
BB_BENCH_NAME(MSGPACK_SCHEMA_NAME);
134-
// Deserialize the verification key directly from buffer
135-
Chonk::VerificationKey verification_key = from_buffer<Chonk::VerificationKey>(vk);
135+
// Deserialize the hiding kernel verification key directly from buffer
136+
auto hiding_kernel_vk = std::make_shared<Chonk::MegaVerificationKey>(from_buffer<Chonk::MegaVerificationKey>(vk));
136137

137-
// Verify the proof using Chonk's static verify method
138-
const bool verified = Chonk::verify(proof, verification_key);
138+
// Verify the proof using ChonkNativeVerifier
139+
auto vk_and_hash = std::make_shared<ChonkNativeVerifier::VKAndHash>(hiding_kernel_vk);
140+
ChonkNativeVerifier verifier(vk_and_hash);
141+
const bool verified = verifier.verify(proof);
139142

140143
return { .valid = verified };
141144
}
@@ -171,14 +174,12 @@ ChonkComputeIvcVk::Response ChonkComputeIvcVk::execute(BB_UNUSED const BBApiRequ
171174
.circuit{ .name = "standalone_circuit", .bytecode = std::move(circuit.bytecode) }
172175
}.execute();
173176

174-
auto mega_vk = from_buffer<Chonk::MegaVerificationKey>(standalone_vk_response.bytes);
175-
Chonk::VerificationKey chonk_vk{ .mega = std::make_shared<Chonk::MegaVerificationKey>(mega_vk),
176-
.eccvm = std::make_shared<Chonk::ECCVMVerificationKey>(),
177-
.translator = std::make_shared<Chonk::TranslatorVerificationKey>() };
177+
// The hiding kernel VK is just the MegaZK verification key
178+
auto hiding_kernel_vk = from_buffer<Chonk::MegaVerificationKey>(standalone_vk_response.bytes);
178179
Response response;
179-
response.bytes = to_buffer(chonk_vk);
180+
response.bytes = to_buffer(hiding_kernel_vk);
180181

181-
info("ChonkComputeIvcVk - IVC VK derived, size: ", response.bytes.size(), " bytes");
182+
info("ChonkComputeIvcVk - hiding kernel VK derived, size: ", response.bytes.size(), " bytes");
182183

183184
return response;
184185
}

barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct ChonkProve {
106106
static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkProveResponse";
107107

108108
/** @brief Complete IVC proof for all accumulated circuits */
109-
Chonk::Proof proof;
109+
ChonkProof proof;
110110
MSGPACK_FIELDS(proof);
111111
bool operator==(const Response&) const = default;
112112
};
@@ -136,7 +136,7 @@ struct ChonkVerify {
136136
};
137137

138138
/** @brief The Chonk proof to verify */
139-
Chonk::Proof proof;
139+
ChonkProof proof;
140140
/** @brief The verification key */
141141
std::vector<uint8_t> vk;
142142
Response execute(const BBApiRequest& request = {}) &&;

barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ TEST_F(BBApiChonkTest, ChonkVkSerialization)
3838
auto [bytecode, _witness] = acir_bincode_mocks::create_simple_circuit_bytecode();
3939
auto vk_response = ChonkComputeIvcVk{ .circuit = { .name = "test_circuit", .bytecode = bytecode } }.execute();
4040

41-
// Create a VK from the field elements
42-
Chonk::VerificationKey vk = from_buffer<Chonk::VerificationKey>(vk_response.bytes);
43-
EXPECT_EQ(to_buffer(vk.to_field_elements()), vk_response.bytes)
41+
// Deserialize the hiding kernel VK
42+
auto hiding_kernel_vk = from_buffer<Chonk::MegaVerificationKey>(vk_response.bytes);
43+
EXPECT_EQ(to_buffer(hiding_kernel_vk.to_field_elements()), vk_response.bytes)
4444
<< "Serialized field elements should match original field elements";
4545
}
4646

barretenberg/cpp/src/barretenberg/benchmark/chonk_bench/chonk.bench.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*/
55

66
#include <benchmark/benchmark.h>
7+
#include <chrono>
78

9+
#include "barretenberg/chonk/chonk_verifier.hpp"
810
#include "barretenberg/chonk/test_bench_shared.hpp"
911
#include "barretenberg/common/google_bb_bench.hpp"
1012

@@ -34,10 +36,11 @@ BENCHMARK_DEFINE_F(ChonkBench, VerificationOnly)(benchmark::State& state)
3436
{
3537
size_t NUM_APP_CIRCUITS = 1;
3638
auto precomputed_vks = precompute_vks(NUM_APP_CIRCUITS);
37-
auto [proof, vk] = accumulate_and_prove_with_precomputed_vks(NUM_APP_CIRCUITS, precomputed_vks);
39+
auto [proof, vk_and_hash] = accumulate_and_prove_with_precomputed_vks(NUM_APP_CIRCUITS, precomputed_vks);
3840

3941
for (auto _ : state) {
40-
benchmark::DoNotOptimize(Chonk::verify(proof, vk));
42+
ChonkNativeVerifier verifier(vk_and_hash);
43+
benchmark::DoNotOptimize(verifier.verify(proof));
4144
}
4245
}
4346

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_goblin.test.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
8888
GoblinRecursiveVerifier verifier{ transcript, stdlib_proof, recursive_merge_commitments, MergeSettings::APPEND };
8989
GoblinRecursiveVerifier::ReductionResult output = verifier.reduce_to_pairing_check_and_ipa_opening();
9090

91+
// Aggregate merge + translator pairing points
92+
output.translator_pairing_points.aggregate(output.merge_pairing_points);
93+
9194
stdlib::recursion::honk::DefaultIO<Builder> inputs;
92-
inputs.pairing_inputs = output.pairing_points;
95+
inputs.pairing_inputs = output.translator_pairing_points;
9396
inputs.set_public();
9497

9598
// Construct and verify a proof for the Goblin Recursive Verifier circuit
@@ -105,7 +108,8 @@ TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
105108

106109
ASSERT_TRUE(verified);
107110
}
108-
auto translator_pairing_points = output.pairing_points;
111+
// Use the already aggregated pairing points (merge + translator)
112+
auto translator_pairing_points = output.translator_pairing_points;
109113

110114
// The pairing points are public outputs from the recursive verifier that will be verified externally via a pairing
111115
// check. While they are computed within the circuit (via batch_mul for P0 and negation for P1), their output
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
barretenberg_module(chonk dsl libdeflate::libdeflate_static hypernova multilinear_batching)
1+
barretenberg_module(chonk goblin dsl libdeflate::libdeflate_static hypernova multilinear_batching)

0 commit comments

Comments
 (0)