Skip to content

Commit abf1108

Browse files
authored
fix(avm)!: sha256 pre-audit (#22001)
Linear issue [AVM-77](https://linear.app/aztec-labs/issue/AVM-77/sha256)
1 parent 0f0c471 commit abf1108

17 files changed

Lines changed: 1014 additions & 1045 deletions

File tree

barretenberg/cpp/pil/vm2/sha256.pil

Lines changed: 148 additions & 141 deletions
Large diffs are not rendered by default.

barretenberg/cpp/pil/vm2/sha256_mem.pil

Lines changed: 182 additions & 121 deletions
Large diffs are not rendered by default.

barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bitwise.test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include "barretenberg/vm2/constraining/testing/check_relation.hpp"
1010
#include "barretenberg/vm2/generated/relations/bitwise.hpp"
1111
#include "barretenberg/vm2/generated/relations/lookups_bitwise.hpp"
12+
#include "barretenberg/vm2/simulation/gadgets/bitwise.hpp"
13+
#include "barretenberg/vm2/simulation/gadgets/field_gt.hpp"
14+
#include "barretenberg/vm2/simulation/gadgets/gt.hpp"
15+
#include "barretenberg/vm2/simulation/gadgets/range_check.hpp"
1216
#include "barretenberg/vm2/testing/fixtures.hpp"
1317
#include "barretenberg/vm2/testing/macros.hpp"
1418
#include "barretenberg/vm2/tracegen/bitwise_trace.hpp"

barretenberg/cpp/src/barretenberg/vm2/constraining/relations/sha256.test.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#include "barretenberg/vm2/generated/relations/lookups_sha256.hpp"
99
#include "barretenberg/vm2/generated/relations/sha256.hpp"
1010
#include "barretenberg/vm2/simulation/events/event_emitter.hpp"
11+
#include "barretenberg/vm2/simulation/gadgets/bitwise.hpp"
12+
#include "barretenberg/vm2/simulation/gadgets/field_gt.hpp"
13+
#include "barretenberg/vm2/simulation/gadgets/gt.hpp"
1114
#include "barretenberg/vm2/simulation/gadgets/memory.hpp"
15+
#include "barretenberg/vm2/simulation/gadgets/range_check.hpp"
1216
#include "barretenberg/vm2/simulation/lib/sha256_compression.hpp"
1317
#include "barretenberg/vm2/simulation/standalone/pure_bitwise.hpp"
1418
#include "barretenberg/vm2/simulation/standalone/pure_gt.hpp"
@@ -195,21 +199,13 @@ TEST(Sha256ConstrainingTest, Interaction)
195199
lookup_sha256_range_comp_next_a_rhs_settings,
196200
lookup_sha256_range_comp_next_e_lhs_settings,
197201
lookup_sha256_range_comp_next_e_rhs_settings,
198-
lookup_sha256_range_comp_a_lhs_settings,
199202
lookup_sha256_range_comp_a_rhs_settings,
200-
lookup_sha256_range_comp_b_lhs_settings,
201203
lookup_sha256_range_comp_b_rhs_settings,
202-
lookup_sha256_range_comp_c_lhs_settings,
203204
lookup_sha256_range_comp_c_rhs_settings,
204-
lookup_sha256_range_comp_d_lhs_settings,
205205
lookup_sha256_range_comp_d_rhs_settings,
206-
lookup_sha256_range_comp_e_lhs_settings,
207206
lookup_sha256_range_comp_e_rhs_settings,
208-
lookup_sha256_range_comp_f_lhs_settings,
209207
lookup_sha256_range_comp_f_rhs_settings,
210-
lookup_sha256_range_comp_g_lhs_settings,
211208
lookup_sha256_range_comp_g_rhs_settings,
212-
lookup_sha256_range_comp_h_lhs_settings,
213209
lookup_sha256_range_comp_h_rhs_settings>(trace);
214210

215211
check_relation<sha256>(trace);

barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ namespace bb::avm2 {
141141

142142
struct AvmFlavorVariables {
143143
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 122;
144-
static constexpr size_t NUM_WITNESS_ENTITIES = 2976;
145-
static constexpr size_t NUM_SHIFTED_ENTITIES = 363;
146-
static constexpr size_t NUM_WIRES = 2524;
147-
static constexpr size_t NUM_ALL_ENTITIES = 3461;
144+
static constexpr size_t NUM_WITNESS_ENTITIES = 2948;
145+
static constexpr size_t NUM_SHIFTED_ENTITIES = 362;
146+
static constexpr size_t NUM_WIRES = 2504;
147+
static constexpr size_t NUM_ALL_ENTITIES = 3432;
148148

149149
// Need to be templated for recursive verifier
150150
template <typename FF_>
@@ -515,21 +515,13 @@ struct AvmFlavorVariables {
515515
lookup_sha256_mem_check_input_addr_in_range_relation<FF_>,
516516
lookup_sha256_mem_check_output_addr_in_range_relation<FF_>,
517517
lookup_sha256_mem_check_state_addr_in_range_relation<FF_>,
518-
lookup_sha256_range_comp_a_lhs_relation<FF_>,
519518
lookup_sha256_range_comp_a_rhs_relation<FF_>,
520-
lookup_sha256_range_comp_b_lhs_relation<FF_>,
521519
lookup_sha256_range_comp_b_rhs_relation<FF_>,
522-
lookup_sha256_range_comp_c_lhs_relation<FF_>,
523520
lookup_sha256_range_comp_c_rhs_relation<FF_>,
524-
lookup_sha256_range_comp_d_lhs_relation<FF_>,
525521
lookup_sha256_range_comp_d_rhs_relation<FF_>,
526-
lookup_sha256_range_comp_e_lhs_relation<FF_>,
527522
lookup_sha256_range_comp_e_rhs_relation<FF_>,
528-
lookup_sha256_range_comp_f_lhs_relation<FF_>,
529523
lookup_sha256_range_comp_f_rhs_relation<FF_>,
530-
lookup_sha256_range_comp_g_lhs_relation<FF_>,
531524
lookup_sha256_range_comp_g_rhs_relation<FF_>,
532-
lookup_sha256_range_comp_h_lhs_relation<FF_>,
533525
lookup_sha256_range_comp_h_rhs_relation<FF_>,
534526
lookup_sha256_range_comp_next_a_lhs_relation<FF_>,
535527
lookup_sha256_range_comp_next_a_rhs_relation<FF_>,

barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_sha256.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,13 @@ INSTANTIATE_LOOKUP(lookup_sha256_range_comp_next_a_lhs_relation);
6060
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_next_a_rhs_relation);
6161
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_next_e_lhs_relation);
6262
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_next_e_rhs_relation);
63-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_a_lhs_relation);
6463
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_a_rhs_relation);
65-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_b_lhs_relation);
6664
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_b_rhs_relation);
67-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_c_lhs_relation);
6865
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_c_rhs_relation);
69-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_d_lhs_relation);
7066
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_d_rhs_relation);
71-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_e_lhs_relation);
7267
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_e_rhs_relation);
73-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_f_lhs_relation);
7468
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_f_rhs_relation);
75-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_g_lhs_relation);
7669
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_g_rhs_relation);
77-
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_h_lhs_relation);
7870
INSTANTIATE_LOOKUP(lookup_sha256_range_comp_h_rhs_relation);
7971

8072
} // namespace bb::avm2

0 commit comments

Comments
 (0)