Skip to content

Commit d35ee2e

Browse files
authored
fix: Fixing 0 naf (#6950)
Creating a naf in biggroup for 0 was incorrect because of the intricasies of NAF construction. I change the uint to be equal to the modulus in case of 0 and it worked
1 parent 79a0e03 commit d35ee2e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,11 +1278,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, batch_mul_edge_case_set1)
12781278

12791279
HEAVY_TYPED_TEST(stdlib_biggroup, batch_mul_edge_case_set2)
12801280
{
1281-
if constexpr (HasGoblinBuilder<TypeParam>) {
1282-
TestFixture::test_batch_mul_edge_case_set2();
1283-
} else {
1284-
GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/1000";
1285-
};
1281+
TestFixture::test_batch_mul_edge_case_set2();
12861282
}
12871283
HEAVY_TYPED_TEST(stdlib_biggroup, chain_add)
12881284
{

barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ std::vector<bool_t<C>> element<C, Fq, Fr, G>::compute_naf(const Fr& scalar, cons
485485
C* ctx = scalar.context;
486486
uint512_t scalar_multiplier_512 = uint512_t(uint256_t(scalar.get_value()) % Fr::modulus);
487487
uint256_t scalar_multiplier = scalar_multiplier_512.lo;
488+
// NAF can't handl 0
489+
if (scalar_multiplier == 0) {
490+
scalar_multiplier = Fr::modulus;
491+
}
488492

489493
const size_t num_rounds = (max_num_bits == 0) ? Fr::modulus.get_msb() + 1 : max_num_bits;
490494
std::vector<bool_ct> naf_entries(num_rounds + 1);

0 commit comments

Comments
 (0)