Skip to content

Commit 48a48b4

Browse files
author
jeanmon
committed
Merge branch 'next' into merge-train/avm
2 parents 62e2082 + af9d8be commit 48a48b4

166 files changed

Lines changed: 460 additions & 434 deletions

File tree

Some content is hidden

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

barretenberg/cpp/pil/vm2/bytecode/address_derivation.pil

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include "../scalar_mul.pil";
99
* during contract instance retrieval (contract_instance_retrieval.pil) in our execution flow.
1010
* The address is defined by the following flow, where the hash function H() is Poseidon2, and G1
1111
* is the Grumpkin curve's generator point:
12-
* 1. salted_init_hash = H(DOM_SEP__PARTIAL_ADDRESS, salt, init_hash, deployer_addr)
12+
* 1. salted_init_hash = H(DOM_SEP__SALTED_INITIALIZATION_HASH, salt, init_hash, deployer_addr)
1313
* 2. partial_address = H(DOM_SEP__PARTIAL_ADDRESS, class_id, salted_init_hash)
1414
* 3. public_keys_hash = H(DOM_SEP__PUBLIC_KEYS_HASH,
1515
* nullifier_key_x, nullifier_key_y, nullifier_key_is_infinity,
@@ -24,10 +24,6 @@ include "../scalar_mul.pil";
2424
* curve. See the 'Hash Computations', 'Elliptic Curve Operations', and 'INTERACTIONS' sections
2525
* for details on how we enforce each step. This process follows Noir's AztecAddress::compute().
2626
*
27-
* Note: DOM_SEP__PARTIAL_ADDRESS is reused for both the salted initialization hash and the partial
28-
* address computations (steps 1 and 2). This cannot lead to a collision since the preimages are of
29-
* different lengths, hence will have different IV values. Unfortunately, why this is the case is not
30-
* documented in the protocol.
3127
*
3228
* PRECONDITIONS: The correctness of the preimage members is not constrained here and must be
3329
* enforced by the calling circuits. Like class_id_derivation, this trace can be seen
@@ -121,7 +117,7 @@ namespace address_derivation;
121117
///////////////////////////////
122118
//
123119
// This trace constrains the result of four Poseidon2 hashes:
124-
// 1. salted_init_hash = H(DOM_SEP__PARTIAL_ADDRESS, salt, init_hash, deployer_addr)
120+
// 1. salted_init_hash = H(DOM_SEP__SALTED_INITIALIZATION_HASH, salt, init_hash, deployer_addr)
125121
// 2. partial_address = H(DOM_SEP__PARTIAL_ADDRESS, class_id, salted_init_hash)
126122
// 3. public_keys_hash = H(DOM_SEP__PUBLIC_KEYS_HASH,
127123
// nullifier_key_x, nullifier_key_y, 0,
@@ -140,6 +136,8 @@ namespace address_derivation;
140136
sel * (const_four - 4) = 0;
141137
pol commit const_thirteen;
142138
sel * (const_thirteen - 13) = 0;
139+
pol commit salted_init_hash_domain_separator;
140+
sel * (salted_init_hash_domain_separator - constants.DOM_SEP__SALTED_INITIALIZATION_HASH) = 0;
143141
pol commit partial_address_domain_separator;
144142
sel * (partial_address_domain_separator - constants.DOM_SEP__PARTIAL_ADDRESS) = 0;
145143
pol commit public_keys_hash_domain_separator;
@@ -151,14 +149,14 @@ namespace address_derivation;
151149
pol commit salted_init_hash;
152150

153151
// Since Poseidon2 processes inputs in chunks of 3, we need 2 permutation rounds to cover our 4 inputs:
154-
// salted_init_hash = H(DOM_SEP__PARTIAL_ADDRESS, salt, init_hash, deployer_addr)
155-
// Round 1 (start, input_len=4): (DOM_SEP__PARTIAL_ADDRESS, salt, init_hash)
152+
// salted_init_hash = H(DOM_SEP__SALTED_INITIALIZATION_HASH, salt, init_hash, deployer_addr)
153+
// Round 1 (start, input_len=4): (DOM_SEP__SALTED_INITIALIZATION_HASH, salt, init_hash)
156154
// Round 2 (end): (deployer_addr, 0, 0)
157155

158156
// Enforces the first round of salted_init_hash. Note that we must lookup poseidon2_hash.input_len == 4
159157
// here since it is constrained in the poseidon trace on the start row.
160158
#[SALTED_INITIALIZATION_HASH_POSEIDON2_0]
161-
sel { partial_address_domain_separator, salt, init_hash, salted_init_hash, const_four }
159+
sel { salted_init_hash_domain_separator, salt, init_hash, salted_init_hash, const_four }
162160
in poseidon2_hash.start { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output, poseidon2_hash.input_len };
163161

164162
// Enforces the second and final round of salted_init_hash. Note that we must enforce the padded values are zero here.

barretenberg/cpp/pil/vm2/constants_gen.pil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ namespace constants;
178178
pol DOM_SEP__RETRIEVED_BYTECODES_MERKLE = 2789215184;
179179
pol DOM_SEP__PUBLIC_BYTECODE = 260313585;
180180
pol DOM_SEP__CONTRACT_CLASS_ID = 3923495515;
181+
pol DOM_SEP__SALTED_INITIALIZATION_HASH = 2763052992;
181182
pol DOM_SEP__PUBLIC_KEYS_HASH = 777457226;
182183
pol DOM_SEP__PARTIAL_ADDRESS = 2103633018;
183184
pol DOM_SEP__CONTRACT_ADDRESS_V1 = 1788365517;

barretenberg/cpp/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ endif()
122122
if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
123123
# Fuzzing preset cannot be built with world_state as world_state cannot compile with MULTITHREADING=OFF
124124
# Mobile builds exclude these modules that require LMDB or aren't needed on mobile
125+
add_subdirectory(barretenberg/aztec)
125126
add_subdirectory(barretenberg/world_state)
126127
# NOTE: Do not conditionally base this on the AVM flag as it defines a necessary vm2_sim library.
127128
add_subdirectory(barretenberg/vm2)
@@ -132,6 +133,7 @@ endif()
132133
if(FUZZING_AVM)
133134
if(FUZZING)
134135
# Only add these if they weren't added above (when NOT FUZZING AND NOT WASM)
136+
add_subdirectory(barretenberg/aztec)
135137
add_subdirectory(barretenberg/world_state)
136138
add_subdirectory(barretenberg/vm2)
137139
endif()

barretenberg/cpp/src/barretenberg/avm_fuzzer/common/interfaces/dbs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include <vector>
55

66
#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp"
7+
#include "barretenberg/aztec/aztec_constants.hpp"
78
#include "barretenberg/common/throw_or_abort.hpp"
89
#include "barretenberg/crypto/merkle_tree/indexed_tree/indexed_leaf.hpp"
910
#include "barretenberg/crypto/poseidon2/poseidon2.hpp"
10-
#include "barretenberg/vm2/common/aztec_constants.hpp"
1111
#include "barretenberg/vm2/common/aztec_types.hpp"
1212
#include "barretenberg/vm2/simulation/lib/contract_crypto.hpp"
1313
#include "barretenberg/vm2/simulation/lib/merkle.hpp"

barretenberg/cpp/src/barretenberg/avm_fuzzer/harness/context_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp"
44
#include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp"
5-
#include "barretenberg/vm2/common/aztec_constants.hpp"
5+
#include "barretenberg/aztec/aztec_constants.hpp"
66
#include "barretenberg/vm2/common/aztec_types.hpp"
77
#include "barretenberg/vm2/simulation/events/update_check.hpp"
88
#include "barretenberg/vm2/simulation/gadgets/bytecode_manager.hpp"

barretenberg/cpp/src/barretenberg/avm_fuzzer/harness/emit_public_log.fuzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp"
66
#include "barretenberg/avm_fuzzer/harness/context_helper.hpp"
7-
#include "barretenberg/vm2/common/aztec_constants.hpp"
7+
#include "barretenberg/aztec/aztec_constants.hpp"
88
#include "barretenberg/vm2/common/field.hpp"
99
#include "barretenberg/vm2/common/memory_types.hpp"
1010
#include "barretenberg/vm2/constraining/testing/check_relation.hpp"

barretenberg/cpp/src/barretenberg/avm_fuzzer/harness/external_call.fuzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "barretenberg/vm2/generated/relations/external_call.hpp"
2-
#include "barretenberg/vm2/common/aztec_constants.hpp"
2+
#include "barretenberg/aztec/aztec_constants.hpp"
33
#include "barretenberg/vm2/common/memory_types.hpp"
44
#include "barretenberg/vm2/common/opcodes.hpp"
55
#include <array>

barretenberg/cpp/src/barretenberg/avm_fuzzer/harness/merkle_check.fuzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp"
88
#include "barretenberg/avm_fuzzer/harness/mutation_helper.hpp"
9+
#include "barretenberg/aztec/aztec_constants.hpp"
910
#include "barretenberg/common/serialize.hpp"
1011
#include "barretenberg/numeric/uint128/uint128.hpp"
11-
#include "barretenberg/vm2/common/aztec_constants.hpp"
1212
#include "barretenberg/vm2/constraining/testing/check_relation.hpp"
1313
#include "barretenberg/vm2/generated/columns.hpp"
1414
#include "barretenberg/vm2/simulation/events/event_emitter.hpp"

barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/bytecode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp"
44
#include "barretenberg/avm_fuzzer/mutations/basic_types/field.hpp"
5+
#include "barretenberg/aztec/aztec_constants.hpp"
56
#include "barretenberg/crypto/poseidon2/poseidon2.hpp"
6-
#include "barretenberg/vm2/common/aztec_constants.hpp"
77
#include "barretenberg/vm2/common/aztec_types.hpp"
88
#include "barretenberg/vm2/common/field.hpp"
99
#include "barretenberg/vm2/simulation/lib/contract_crypto.hpp"

barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/protocol_contracts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "barretenberg/avm_fuzzer/mutations/protocol_contracts.hpp"
22

3-
#include "barretenberg/vm2/common/aztec_constants.hpp"
3+
#include "barretenberg/aztec/aztec_constants.hpp"
44
#include "barretenberg/vm2/common/aztec_types.hpp"
55

66
namespace bb::avm2::fuzzer {

0 commit comments

Comments
 (0)