Skip to content

Commit 3354bc3

Browse files
authored
feat: merge-train/barretenberg (#19418)
BEGIN_COMMIT_OVERRIDE chore: remove round.cpp and round.hpp in dsl/acir_format (#19412) chore: docs for translator (#19056) chore: update noir/noir-repo to match next branch chore: update avm-transpiler Cargo.lock for noir submodule fix: revert noir/noir-repo to match next and update Cargo.lock fix: add actionable error when bb verify cannot find vk file (#19398) chore: `utils.cpp` audit (#19425) chore: sha audit 1 (#19072) fix: improve no artifacts found message to include search path (#19432) chore: simplify Flavors' Transcripts + VKs deduplication (#19326) Add correct VKSerializationMode to AVM VerificationKey Classes END_COMMIT_OVERRIDE
2 parents 2dc5653 + 75db26c commit 3354bc3

File tree

65 files changed

+4622
-1911
lines changed

Some content is hidden

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

65 files changed

+4622
-1911
lines changed

barretenberg/cpp/scripts/audit/audit_scopes/dsl_audit_scope.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Commit hash: 2094fd1467dd9a94803b2c5007cf60ac357aa7d2 (22.12.2025)
1212
4. `dsl/acir_format/acir_format.cpp`
1313
5. `dsl/acir_format/arithmetic_constraints.hpp`
1414
6. `dsl/acir_format/arithmetic_constraints.cpp`
15-
7. `dsl/acir_format/round.hpp`
16-
8. `dsl/acir_format/round.cpp`
1715
9. `dsl/acir_format/utils.hpp`
1816
10. `dsl/acir_format/utils.cpp`
1917

@@ -27,15 +25,13 @@ All constraints except arithmetic constraints work as follows:
2725
1. Bytes deserialised into Barretenberg's internal representation (`acir_to_constraint_buf`)
2826
2. Iterate through all instances of the given constraint and add the constraint to the circuit (`acir_format`)
2927

30-
Arithmetic constraints work slighly differently because we leverage the UltraHonk arithmetisation to efficiently encode expressions of the following form:
28+
Arithmetic constraints work slighly differently because we leverage the UltraHonk arithmetization to efficiently encode expressions of the following form:
3129
$
3230
\sum_{i, j} c_{i,j} w_i w_j + \sum_i c_i w_i + c = 0
33-
$ where $w_i$ are witnesses, $c_{i,j}, c_i$ are the coefficients of the equation, and $c$ is the constant term. For a detailed explanation of how we leverage the UltraHonk arithmetisation to encode arithmetic constraints see the documentation for the functions `acir_to_constraint_buf::split_into_mul_quad_gates` and `arithmetic_constraints::create_big_quad_constraint`.
31+
$ where $w_i$ are witnesses, $c_{i,j}, c_i$ are the coefficients of the equation, and $c$ is the constant term. For a detailed explanation of how we leverage the UltraHonk arithmetization to encode arithmetic constraints see the documentation for the functions `acir_to_constraint_buf::split_into_mul_quad_gates` and `arithmetic_constraints::create_big_quad_constraint`.
3432

3533
The difference in how arithmetic constraints are handled is the reason why they are the only constraints that are part of this audit scope: to be sure that no bugs are present, the entire flow (from bytes to to constraints) has to be audited for arithmetic constraints.
3634

37-
38-
3935
## Test Files
4036
1. `dsl/acir_format/acir_format.test.cpp`
4137
2. `dsl/acir_format/arithmetic_constraints.test.cpp`

barretenberg/cpp/scripts/audit/audit_scopes/honk_proving_system_audit_scope.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Note: Paths relative to `aztec-packages/barretenberg/cpp/src/barretenberg`
7171
50. `dsl/acir_format/recursion_constraint.cpp`
7272
51. `dsl/acir_format/recursion_constraint_output.hpp`
7373
52. `dsl/acir_format/recursion_constraint_output.cpp`
74+
53. `dsl/acir_format/honk_recursion_constraint.hpp`
75+
54. `dsl/acir_format/honk_recursion_constraint.cpp`
7476
53. `dsl/acir_format/mock_verifier_inputs.hpp`
7577

7678
## Summary of Module
@@ -93,6 +95,7 @@ The Honk proving system is Barretenberg's core SNARK proving system implementing
9395
13. `ultra_honk/lookup.test.cpp`
9496
14. `ultra_honk/rom_ram.test.cpp`
9597
15. `ultra_honk/range_constraint.test.cpp`
98+
16. `dsl/acir_format/honk_recursion_constraint.test.cpp`
9699

97100
## Security Mechanisms
98101

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="c288d94d"
16+
pinned_short_hash="04d835ae"
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/barretenberg/api/api_chonk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool ChonkAPI::verify([[maybe_unused]] const Flags& flags,
123123
auto proof_fields = many_from_buffer<fr>(read_file(proof_path));
124124
auto proof = ChonkProof::from_field_elements(proof_fields);
125125

126-
auto vk_buffer = read_file(vk_path);
126+
auto vk_buffer = read_vk_file(vk_path);
127127

128128
auto response = bbapi::ChonkVerify{ .proof = std::move(proof), .vk = std::move(vk_buffer) }.execute();
129129
return response.valid;

barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool UltraHonkAPI::verify(const Flags& flags,
101101
// Read input files
102102
auto public_inputs = many_from_buffer<uint256_t>(read_file(public_inputs_path));
103103
auto proof = many_from_buffer<uint256_t>(read_file(proof_path));
104-
auto vk_bytes = read_file(vk_path);
104+
auto vk_bytes = read_vk_file(vk_path);
105105

106106
// Convert flags to ProofSystemSettings
107107
bbapi::ProofSystemSettings settings{ .ipa_accumulation = flags.ipa_accumulation,
@@ -209,7 +209,7 @@ void UltraHonkAPI::write_solidity_verifier(const Flags& flags,
209209
{
210210
BB_BENCH_NAME("UltraHonkAPI::write_solidity_verifier");
211211
// Read VK file
212-
auto vk_bytes = read_file(vk_path);
212+
auto vk_bytes = read_vk_file(vk_path);
213213

214214
// Convert flags to ProofSystemSettings
215215
bbapi::ProofSystemSettings settings{ .ipa_accumulation = flags.ipa_accumulation,

barretenberg/cpp/src/barretenberg/api/api_ultra_honk.test.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,35 @@ TEST_F(ApiUltraHonkTest, GatesWithOpcodesSmokeTest)
233233
// Check that output contains per-opcode information
234234
EXPECT_TRUE(output.find("gates_per_opcode") != std::string::npos);
235235
}
236+
237+
TEST_F(ApiUltraHonkTest, VerifyWithMissingVkGivesActionableError)
238+
{
239+
auto [bytecode_path, witness_path] = create_test_circuit_files(test_dir);
240+
241+
API::Flags flags;
242+
flags.oracle_hash_type = "poseidon2";
243+
flags.write_vk = true;
244+
245+
UltraHonkAPI api;
246+
247+
// Generate proof with vk
248+
auto proof_output_dir = test_dir / "proof";
249+
std::filesystem::create_directories(proof_output_dir);
250+
api.prove(flags, bytecode_path, witness_path, "", proof_output_dir);
251+
252+
// Try to verify with a non-existent vk path
253+
auto nonexistent_vk_path = test_dir / "nonexistent_vk";
254+
try {
255+
api.verify(flags, proof_output_dir / "public_inputs", proof_output_dir / "proof", nonexistent_vk_path);
256+
FAIL() << "Expected an exception to be thrown";
257+
} catch (const std::runtime_error& e) {
258+
std::string error_msg = e.what();
259+
// Check that the error message contains actionable guidance
260+
EXPECT_TRUE(error_msg.find("--write_vk") != std::string::npos)
261+
<< "Error message should mention --write_vk flag. Got: " << error_msg;
262+
EXPECT_TRUE(error_msg.find("bb write_vk") != std::string::npos)
263+
<< "Error message should mention bb write_vk command. Got: " << error_msg;
264+
EXPECT_TRUE(error_msg.find("--vk_path") != std::string::npos)
265+
<< "Error message should mention --vk_path option. Got: " << error_msg;
266+
}
267+
}

barretenberg/cpp/src/barretenberg/api/aztec_process.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ bool process_all_artifacts(const std::string& search_path, bool force)
324324
auto artifacts = find_contract_artifacts(search_path);
325325

326326
if (artifacts.empty()) {
327-
info("No contract artifacts found. Please compile your contracts first with 'nargo compile'.");
327+
info("No contract artifacts found in '", search_path, "'.");
328328
return false;
329329
}
330330

barretenberg/cpp/src/barretenberg/api/file_io.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdint>
66
#include <cstring>
77
#include <fcntl.h>
8+
#include <filesystem>
89
#include <fstream>
910
#include <ios>
1011
#include <iostream>
@@ -100,4 +101,23 @@ template <typename Fr> inline std::string field_elements_to_json(const std::vect
100101
ss << "]";
101102
return ss.str();
102103
}
104+
105+
/**
106+
* @brief Read a verification key file with an actionable error message if not found.
107+
*
108+
* @param vk_path Path to the verification key file
109+
* @return std::vector<uint8_t> The verification key bytes
110+
* @throws std::runtime_error with actionable message if vk file not found
111+
*/
112+
inline std::vector<uint8_t> read_vk_file(const std::filesystem::path& vk_path)
113+
{
114+
try {
115+
return read_file(vk_path);
116+
} catch (const std::runtime_error&) {
117+
THROW std::runtime_error("Unable to open file: " + vk_path.string() +
118+
"\nGenerate a vk during proving by running `bb prove` with an additional `--write_vk` "
119+
"flag, or run `bb write_vk` to generate a standalone vk."
120+
"\nIf you already have a vk file, specify its path with `--vk_path <path>`.");
121+
}
122+
}
103123
} // namespace bb

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,9 +1241,6 @@ inline void StaticAnalyzer_<FF, CircuitBuilder>::remove_unnecessary_sha256_plook
12411241
BasicTableId::SHA256_WITNESS_SLICE_14_ROTATE_1,
12421242
BasicTableId::SHA256_BASE16,
12431243
BasicTableId::SHA256_BASE16_ROTATE2,
1244-
BasicTableId::SHA256_BASE16_ROTATE6,
1245-
BasicTableId::SHA256_BASE16_ROTATE7,
1246-
BasicTableId::SHA256_BASE16_ROTATE8,
12471244
BasicTableId::SHA256_BASE28,
12481245
BasicTableId::SHA256_BASE28_ROTATE3,
12491246
BasicTableId::SHA256_BASE28_ROTATE6 };

barretenberg/cpp/src/barretenberg/chonk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ This chain ensures the op queue history is maintained correctly. The Merge proto
726726

727727
```cpp
728728
// In OinkVerifier::verify() (called by HypernovaFoldingVerifier for each instance)
729-
FF vk_hash = vk->hash_with_origin_tagging(domain_separator, *transcript);
729+
FF vk_hash = vk->hash_with_origin_tagging(*transcript);
730730
transcript->add_to_hash_buffer(domain_separator + "vk_hash", vk_hash);
731731
// All subsequent challenges now depend on this hash
732732
```

0 commit comments

Comments
 (0)