Skip to content

Commit

Permalink
Fix bug by going on the slow path if g1_lincomb() is given a zero
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 committed Feb 17, 2023
1 parent 8b7ef36 commit 84c9ef9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/c_kzg_4844.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,18 @@ static C_KZG_RET g1_lincomb(
void *scratch = NULL;
blst_p1_affine *p_affine = NULL;
blst_scalar *scalars = NULL;
bool point_is_inf = false;

/* blst cannot handle batch affine with zero inputs so if an input point is
* zero we go through the slow path */
for (size_t i = 0; i < len; i++) {
if (blst_p1_is_inf(&p[i])) {
point_is_inf = true;
}
}

// Tunable parameter: must be at least 2 since Blst fails for 0 or 1
if (len < 8) {
if (point_is_inf || len < 8) {
// Direct approach
g1_t tmp;
*out = G1_IDENTITY;
Expand Down

1 comment on commit 84c9ef9

@xrchz
Copy link
Contributor

@xrchz xrchz commented on 84c9ef9 Feb 17, 2023

Choose a reason for hiding this comment

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

You can break after setting it to true

Please sign in to comment.