Skip to content

Commit c030f9c

Browse files
committed
address PR comment and update gate count
1 parent 25dc7bb commit c030f9c

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

barretenberg/cpp/src/barretenberg/dsl/acir_format/blake2s_constraint.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ template <typename Builder> void create_blake2s_constraints(Builder& builder, co
2525
auto witness_index = witness_index_num_bits.blackbox_input;
2626
field_ct element = to_field_ct(witness_index, builder);
2727

28-
// num_bytes = ceil(witness_index_num_bits.num_bits/8). Here, num_bits is set to 8 when constructing the vector
29-
// of inputs in the Blake2s constraint. Hence, we set num_bytes = 1.
30-
uint32_t num_bytes = 1;
31-
32-
// byte_array_ct(field, num_bytes) constructor adds range constraints for each byte
33-
byte_array_ct element_bytes(element, num_bytes);
28+
// byte_array_ct(field, num_bytes) constructor adds range constraints for each byte. Note that num_bytes =
29+
// ceil(witness_index_num_bits.num_bits/8). Here, num_bits is set to 8 when constructing the vector of inputs in
30+
// the Blake2s constraint. Hence, we set num_bytes = 1.
31+
byte_array_ct element_bytes(element, 1);
3432

3533
// Safe write: both arr and element_bytes are constrained
3634
arr.write(element_bytes);

barretenberg/cpp/src/barretenberg/dsl/acir_format/blake3_constraint.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ template <typename Builder> void create_blake3_constraints(Builder& builder, con
2323
auto witness_index = witness_index_num_bits.blackbox_input;
2424
field_ct element = to_field_ct(witness_index, builder);
2525

26-
// num_bytes = ceil(witness_index_num_bits.num_bits/8). Here, num_bits is set to 8 when constructing the vector
27-
// of inputs in the Blake3 constraint. Hence, we set num_bytes = 1.
28-
uint32_t num_bytes = 1;
29-
30-
// byte_array_ct(field, num_bytes) constructor adds range constraints for each byte
31-
byte_array_ct element_bytes(element, num_bytes);
26+
// byte_array_ct(field, num_bytes) constructor adds range constraints for each byte. Note that num_bytes =
27+
// ceil(witness_index_num_bits.num_bits/8). Here, num_bits is set to 8 when constructing the vector of inputs in
28+
// the Blake3 constraint. Hence, we set num_bytes = 1.
29+
byte_array_ct element_bytes(element, 1);
3230

3331
// Safe write: both arr and element_bytes are constrained
3432
arr.write(element_bytes);

barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ template <typename Builder> inline constexpr size_t ECDSA_SECP256K1 = 41994 + ZE
3838
template <typename Builder>
3939
inline constexpr size_t ECDSA_SECP256R1 = 72209 + ZERO_GATE + (IsMegaBuilder<Builder> ? 2 : 0);
4040

41-
template <typename Builder> inline constexpr size_t BLAKE2S = 2959 + ZERO_GATE + MEGA_OFFSET<Builder>;
42-
template <typename Builder> inline constexpr size_t BLAKE3 = 2165 + ZERO_GATE + MEGA_OFFSET<Builder>;
41+
template <typename Builder> inline constexpr size_t BLAKE2S = 2952 + ZERO_GATE + MEGA_OFFSET<Builder>;
42+
template <typename Builder> inline constexpr size_t BLAKE3 = 2158 + ZERO_GATE + MEGA_OFFSET<Builder>;
4343
template <typename Builder> inline constexpr size_t KECCAK_PERMUTATION = 17387 + ZERO_GATE + MEGA_OFFSET<Builder>;
4444
template <typename Builder> inline constexpr size_t POSEIDON2_PERMUTATION = 73 + ZERO_GATE + MEGA_OFFSET<Builder>;
4545
template <typename Builder> inline constexpr size_t MULTI_SCALAR_MUL = 3550 + ZERO_GATE;

barretenberg/cpp/src/barretenberg/dsl/acir_format/opcode_gate_count.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ TYPED_TEST(OpcodeGateCountTests, Blake2s)
436436

437437
blake2s_constraint.inputs.push_back(Blake2sInput{
438438
.blackbox_input = WitnessOrConstant<bb::fr>::from_index(0),
439-
.num_bits = 32,
439+
.num_bits = 8,
440440
});
441441

442442
for (size_t i = 0; i < 32; ++i) {
@@ -466,7 +466,7 @@ TYPED_TEST(OpcodeGateCountTests, Blake3)
466466

467467
blake3_constraint.inputs.push_back(Blake3Input{
468468
.blackbox_input = WitnessOrConstant<bb::fr>::from_index(0),
469-
.num_bits = 32,
469+
.num_bits = 8,
470470
});
471471

472472
for (size_t i = 0; i < 32; ++i) {

0 commit comments

Comments
 (0)