Skip to content

Commit 037bee5

Browse files
authored
feat: merge-train/barretenberg (#16519)
BEGIN_COMMIT_OVERRIDE feat!: Introduce proof type for recursive verification of ClientIVC proofs in noir (#16400) chore!: Remove recovery byte from ecdsa signature in stdlib + add documentation (#16498) chore: redo stdlib sha256 without packed_byte_array (#16481) chore: audit ECCVM transcript relation (#16380) chore: remove databus non-issue (#16471) feat: a minimal fixed offset append merge (#16517) new civc inputs END_COMMIT_OVERRIDE
2 parents a75ac5e + cc38aca commit 037bee5

File tree

69 files changed

+1380
-1058
lines changed

Some content is hidden

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

69 files changed

+1380
-1058
lines changed

barretenberg/cpp/scripts/test_civc_standalone_vks_havent_changed.sh

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

1717
function compress_and_upload {

barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "barretenberg/common/throw_or_abort.hpp"
1111
#include "barretenberg/common/try_catch_shim.hpp"
1212
#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp"
13-
#include "barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp"
13+
#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp"
1414
#include "barretenberg/serialize/msgpack.hpp"
1515
#include "barretenberg/serialize/msgpack_check_eq.hpp"
1616
#include <algorithm>

barretenberg/cpp/src/barretenberg/api/prove_tube.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)
2727
auto proof = ClientIVC::Proof::from_file_msgpack(proof_path);
2828
auto vk = from_buffer<ClientIVC::VerificationKey>(read_file(vk_path));
2929

30-
auto builder = std::make_shared<Builder>();
30+
Builder builder;
31+
ClientIVCRecursiveVerifier verifier{ &builder, vk.mega };
3132

32-
ClientIVCRecursiveVerifier verifier{ builder, vk };
33-
34-
StdlibProof stdlib_proof(*builder, proof);
33+
StdlibProof stdlib_proof(builder, proof);
3534
ClientIVCRecursiveVerifier::Output client_ivc_rec_verifier_output = verifier.verify(stdlib_proof);
3635

3736
// The public inputs in the proof are propagated to the base rollup by making them public inputs of this circuit.
@@ -49,12 +48,12 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)
4948
inputs.set_public();
5049

5150
// The tube only calls an IPA recursive verifier once, so we can just add this IPA proof
52-
builder->ipa_proof = client_ivc_rec_verifier_output.ipa_proof.get_value();
53-
BB_ASSERT_EQ(builder->ipa_proof.size(), IPA_PROOF_LENGTH, "IPA proof should be set.");
51+
builder.ipa_proof = client_ivc_rec_verifier_output.ipa_proof.get_value();
52+
BB_ASSERT_EQ(builder.ipa_proof.size(), IPA_PROOF_LENGTH, "IPA proof should be set.");
5453

5554
using Prover = UltraProver_<UltraRollupFlavor>;
5655
using Verifier = UltraVerifier_<UltraRollupFlavor>;
57-
auto proving_key = std::make_shared<DeciderProvingKey_<UltraRollupFlavor>>(*builder);
56+
auto proving_key = std::make_shared<DeciderProvingKey_<UltraRollupFlavor>>(builder);
5857
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1201): Precompute tube vk and pass it in.
5958
info("WARNING: computing tube vk in prove_tube, but a precomputed vk should be passed in.");
6059
auto tube_verification_key = std::make_shared<UltraRollupFlavor::VerificationKey>(proving_key->get_precomputed());

barretenberg/cpp/src/barretenberg/bbapi/bbapi_client_ivc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "barretenberg/common/throw_or_abort.hpp"
66
#include "barretenberg/dsl/acir_format/acir_format.hpp"
77
#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp"
8-
#include "barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp"
8+
#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp"
99
#include "barretenberg/dsl/acir_format/serde/witness_stack.hpp"
1010
#include "barretenberg/honk/execution_trace/execution_trace_usage_tracker.hpp"
1111
#include "barretenberg/serialize/msgpack_check_eq.hpp"
@@ -181,7 +181,7 @@ ClientIvcStats::Response ClientIvcStats::execute(BBApiRequest& request) &&
181181
acir_format::AcirProgram program{ constraint_system };
182182

183183
// Get IVC constraints if any
184-
const auto& ivc_constraints = constraint_system.ivc_recursion_constraints;
184+
const auto& ivc_constraints = constraint_system.pg_recursion_constraints;
185185

186186
// Create metadata with appropriate IVC context
187187
acir_format::ProgramMetadata metadata{

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_sha256.test.cpp

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "barretenberg/crypto/sha256/sha256.hpp"
55
#include "barretenberg/stdlib/hash/sha256/sha256.hpp"
66
#include "barretenberg/stdlib/primitives/byte_array/byte_array.hpp"
7-
#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp"
87
#include "barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp"
98
#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"
109

@@ -17,28 +16,46 @@ using namespace bb::stdlib;
1716
using namespace cdg;
1817

1918
using Builder = UltraCircuitBuilder;
20-
using byte_array_pt = byte_array<Builder>;
21-
using packed_byte_array_pt = packed_byte_array<Builder>;
22-
using field_pt = field_t<Builder>;
19+
using byte_array_ct = byte_array<Builder>;
20+
using field_ct = field_t<Builder>;
21+
22+
/**
23+
* @brief Given a `byte_array` object, slice it into chunks of size `num_bytes_in_chunk` and compute field elements
24+
* reconstructed from these chunks.
25+
*/
26+
27+
std::vector<field_ct> pack_bytes_into_field_elements(const byte_array_ct& input, size_t num_bytes_in_chunk = 4)
28+
{
29+
std::vector<field_t<Builder>> result;
30+
const size_t byte_len = input.size();
31+
32+
for (size_t i = 0; i < byte_len; i += num_bytes_in_chunk) {
33+
byte_array_ct chunk = input.slice(i, std::min(num_bytes_in_chunk, byte_len - i));
34+
result.emplace_back(static_cast<field_ct>(chunk));
35+
}
36+
37+
return result;
38+
}
2339

2440
/**
2541
static analyzer usually prints input and output variables as variables in one gate. In tests these variables
2642
are not dangerous and usually we can filter them by adding gate for fixing witness. Then these variables will be
2743
in 2 gates, and static analyzer won't print them. functions fix_vector and fix_byte_array do it
28-
for vector of variables and packed_byte_array respectively
44+
for vector of variables and byte_array respectively
2945
*/
3046

31-
void fix_vector(std::vector<field_pt>& vector)
47+
void fix_vector(std::vector<field_ct>& vector)
3248
{
3349
for (auto& elem : vector) {
3450
elem.fix_witness();
3551
}
3652
}
3753

38-
void fix_byte_array(packed_byte_array_pt& input)
54+
void fix_byte_array(byte_array_ct& input)
3955
{
40-
std::vector<field_pt> limbs = input.get_limbs();
41-
fix_vector(limbs);
56+
for (size_t idx = 0; idx < input.size(); idx++) {
57+
input[idx].fix_witness();
58+
}
4259
}
4360

4461
/**
@@ -55,12 +72,12 @@ TEST(boomerang_stdlib_sha256, test_graph_for_sha256_55_bytes)
5572
// 55 bytes is the largest number of bytes that can be hashed in a single block,
5673
// accounting for the single padding bit, and the 64 size bits required by the SHA-256 standard.
5774
auto builder = Builder();
58-
packed_byte_array_pt input(&builder, "An 8 character password? Snow White and the 7 Dwarves..");
75+
byte_array_ct input(&builder, "An 8 character password? Snow White and the 7 Dwarves..");
5976
fix_byte_array(input);
6077

61-
packed_byte_array_pt output_bits = stdlib::SHA256<Builder>::hash(input);
78+
byte_array_ct output_bytes = stdlib::SHA256<Builder>::hash(input);
6279

63-
std::vector<field_pt> output = output_bits.to_unverified_byte_slices(4);
80+
std::vector<field_ct> output = pack_bytes_into_field_elements(output_bytes);
6481
fix_vector(output);
6582

6683
StaticAnalyzer graph = StaticAnalyzer(builder);
@@ -87,7 +104,7 @@ HEAVY_TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_five)
87104
{
88105
auto builder = Builder();
89106

90-
packed_byte_array_pt input(
107+
byte_array_ct input(
91108
&builder,
92109
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
93110
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
@@ -101,9 +118,9 @@ HEAVY_TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_five)
101118
"AAAAAAAAAA");
102119

103120
fix_byte_array(input);
104-
packed_byte_array_pt output_bits = stdlib::SHA256<bb::UltraCircuitBuilder>::hash(input);
121+
byte_array_ct output_bytes = stdlib::SHA256<bb::UltraCircuitBuilder>::hash(input);
105122

106-
std::vector<field_pt> output = output_bits.to_unverified_byte_slices(4);
123+
std::vector<field_ct> output = pack_bytes_into_field_elements(output_bytes);
107124
fix_vector(output);
108125

109126
StaticAnalyzer graph = StaticAnalyzer(builder);
@@ -126,10 +143,10 @@ HEAVY_TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_five)
126143
TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_one)
127144
{
128145
auto builder = Builder();
129-
packed_byte_array_pt input(&builder, "abc");
146+
byte_array_ct input(&builder, "abc");
130147
fix_byte_array(input);
131-
packed_byte_array_pt output_bits = stdlib::SHA256<Builder>::hash(input);
132-
fix_byte_array(output_bits);
148+
byte_array_ct output_bytes = stdlib::SHA256<Builder>::hash(input);
149+
fix_byte_array(output_bytes);
133150
StaticAnalyzer graph = StaticAnalyzer(builder);
134151
auto connected_components = graph.find_connected_components();
135152
EXPECT_EQ(connected_components.size(), 1);
@@ -146,10 +163,10 @@ TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_one)
146163
TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_two)
147164
{
148165
auto builder = Builder();
149-
packed_byte_array_pt input(&builder, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
166+
byte_array_ct input(&builder, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
150167
fix_byte_array(input);
151-
packed_byte_array_pt output_bits = stdlib::SHA256<Builder>::hash(input);
152-
fix_byte_array(output_bits);
168+
byte_array_ct output_bytes = stdlib::SHA256<Builder>::hash(input);
169+
fix_byte_array(output_bytes);
153170
StaticAnalyzer graph = StaticAnalyzer(builder);
154171
auto connected_components = graph.find_connected_components();
155172
EXPECT_EQ(connected_components.size(), 1);
@@ -168,10 +185,10 @@ TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_three)
168185
auto builder = Builder();
169186

170187
// one byte, 0xbd
171-
packed_byte_array_pt input(&builder, std::vector<uint8_t>{ 0xbd });
188+
byte_array_ct input(&builder, std::vector<uint8_t>{ 0xbd });
172189
fix_byte_array(input);
173-
packed_byte_array_pt output_bits = stdlib::SHA256<Builder>::hash(input);
174-
fix_byte_array(output_bits);
190+
byte_array_ct output_bytes = stdlib::SHA256<Builder>::hash(input);
191+
fix_byte_array(output_bytes);
175192
StaticAnalyzer graph = StaticAnalyzer(builder);
176193
auto connected_components = graph.find_connected_components();
177194
EXPECT_EQ(connected_components.size(), 1);
@@ -190,10 +207,10 @@ TEST(boomerang_stdlib_sha256, test_graph_for_sha256_NIST_vector_four)
190207
auto builder = Builder();
191208

192209
// 4 bytes, 0xc98c8e55
193-
packed_byte_array_pt input(&builder, std::vector<uint8_t>{ 0xc9, 0x8c, 0x8e, 0x55 });
210+
byte_array_ct input(&builder, std::vector<uint8_t>{ 0xc9, 0x8c, 0x8e, 0x55 });
194211
fix_byte_array(input);
195-
packed_byte_array_pt output_bits = stdlib::SHA256<Builder>::hash(input);
196-
fix_byte_array(output_bits);
212+
byte_array_ct output_bytes = stdlib::SHA256<Builder>::hash(input);
213+
fix_byte_array(output_bytes);
197214
StaticAnalyzer graph = StaticAnalyzer(builder);
198215
auto connected_components = graph.find_connected_components();
199216
EXPECT_EQ(connected_components.size(), 1);

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,20 @@ size_t ClientIVC::Proof::size() const
611611
return mega_proof.size() + goblin_proof.size();
612612
}
613613

614+
std::vector<ClientIVC::FF> ClientIVC::Proof::to_field_elements() const
615+
{
616+
HonkProof proof;
617+
618+
proof.insert(proof.end(), mega_proof.begin(), mega_proof.end());
619+
proof.insert(proof.end(), goblin_proof.merge_proof.begin(), goblin_proof.merge_proof.end());
620+
proof.insert(
621+
proof.end(), goblin_proof.eccvm_proof.pre_ipa_proof.begin(), goblin_proof.eccvm_proof.pre_ipa_proof.end());
622+
proof.insert(proof.end(), goblin_proof.eccvm_proof.ipa_proof.begin(), goblin_proof.eccvm_proof.ipa_proof.end());
623+
proof.insert(proof.end(), goblin_proof.translator_proof.begin(), goblin_proof.translator_proof.end());
624+
625+
return proof;
626+
};
627+
614628
msgpack::sbuffer ClientIVC::Proof::to_msgpack_buffer() const
615629
{
616630
msgpack::sbuffer buffer;

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,42 @@ class ClientIVC {
9797
HonkProof mega_proof;
9898
GoblinProof goblin_proof;
9999

100+
/**
101+
* @brief The size of a ClientIVC proof without backend-added public inputs
102+
*
103+
* @param virtual_log_n
104+
* @return constexpr size_t
105+
*/
106+
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n = MegaZKFlavor::VIRTUAL_LOG_N)
107+
{
108+
return /*mega_proof*/ MegaZKFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n) +
109+
/*merge_proof*/ MERGE_PROOF_SIZE +
110+
/*eccvm pre-ipa proof*/ (ECCVMFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS - IPA_PROOF_LENGTH) +
111+
/*eccvm ipa proof*/ IPA_PROOF_LENGTH +
112+
/*translator*/ TranslatorFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS;
113+
}
114+
115+
/**
116+
* @brief The size of a ClientIVC proof with backend-added public inputs: HidingKernelIO
117+
*
118+
* @param virtual_log_n
119+
* @return constexpr size_t
120+
*/
121+
static constexpr size_t PROOF_LENGTH(size_t virtual_log_n = MegaZKFlavor::VIRTUAL_LOG_N)
122+
{
123+
return PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n) +
124+
/*public_inputs*/ bb::HidingKernelIO::PUBLIC_INPUTS_SIZE;
125+
}
126+
100127
size_t size() const;
101128

129+
/**
130+
* @brief Serialize proof to field elements
131+
*
132+
* @return std::vector<FF>
133+
*/
134+
std::vector<FF> to_field_elements() const;
135+
102136
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1299): The following msgpack methods are generic
103137
// and should leverage some kind of shared msgpack utility.
104138
msgpack::sbuffer to_msgpack_buffer() const;

barretenberg/cpp/src/barretenberg/dsl/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ set(DSL_DEPENDENCIES
66
stdlib_keccak
77
stdlib_poseidon2
88
stdlib_schnorr
9-
stdlib_honk_verifier)
9+
stdlib_honk_verifier
10+
stdlib_client_ivc_verifier)
1011

1112
if (NOT DISABLE_AZTEC_VM)
1213
list(APPEND DSL_DEPENDENCIES vm2)

0 commit comments

Comments
 (0)