Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixing 0 naf #6950

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, batch_mul_edge_case_set1)

HEAVY_TYPED_TEST(stdlib_biggroup, batch_mul_edge_case_set2)
{
if constexpr (HasGoblinBuilder<TypeParam>) {
TestFixture::test_batch_mul_edge_case_set2();
} else {
GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/1000";
};
TestFixture::test_batch_mul_edge_case_set2();
}
HEAVY_TYPED_TEST(stdlib_biggroup, chain_add)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ std::vector<bool_t<C>> element<C, Fq, Fr, G>::compute_naf(const Fr& scalar, cons
C* ctx = scalar.context;
uint512_t scalar_multiplier_512 = uint512_t(uint256_t(scalar.get_value()) % Fr::modulus);
uint256_t scalar_multiplier = scalar_multiplier_512.lo;
// NAF can't handl 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what is the NAF form of 0. We're doing this in-circuit so we don't benefit in the usual way from using NAF form so it's not so important, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (scalar_multiplier == 0) {
scalar_multiplier = Fr::modulus;
}

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