Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad0 committed Feb 11, 2024
1 parent 5c3783e commit 9c08a58
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ template <class Params_> struct alignas(32) field {
k1.data[0] = ret.first[0];
k1.data[1] = ret.first[1];
k2.data[0] = ret.second[0];
k2.data[1] = ret.second[0];
k2.data[1] = ret.second[1];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ TEST(AffineElement, InfinityMul)
EXPECT_TRUE(result.is_point_at_infinity());
}

TEST(AffineElement, BatchMulMatchesMul)
{
constexpr size_t num_points = 1024;
std::vector<grumpkin::g1::affine_element> affine_points;
for (size_t i = 0; i < num_points; ++i) {
affine_points.emplace_back(grumpkin::g1::affine_element::random_element());
}
grumpkin::fr exponent = grumpkin::fr::random_element();
std::vector<grumpkin::g1::affine_element> result =
grumpkin::g1::element::batch_mul_with_endomorphism(affine_points, exponent);
size_t i = 0;
for (grumpkin::g1::affine_element& el : result) {
EXPECT_EQ(el, affine_points[i] * exponent);
i++;
}
}

TEST(AffineElement, InfinityBatchMul)
{
constexpr size_t num_points = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ std::vector<affine_element<Fq, Fr, T>> element<Fq, Fr, T>::batch_mul_with_endomo
num_points,
[&](size_t start, size_t end) {
for (size_t i = start; i < end; ++i) {
work_elements[i] = points[i].is_infinity() ? work_elements[i].set_infinity() : work_elements[i];
work_elements[i] =
points[i].is_point_at_infinity() ? work_elements[i].set_infinity() : work_elements[i];
}
},
/*finite_field_additions_per_iteration=*/0,
Expand Down

0 comments on commit 9c08a58

Please sign in to comment.