@@ -242,11 +242,20 @@ void store(uint8_t _rx[128], const blst_fp2& _x) noexcept
242
242
return true ;
243
243
}
244
244
245
- const auto scratch_size = blst_p1s_mult_pippenger_scratch_sizeof (npoints) / sizeof (limb_t );
246
- const auto scratch_space = std::make_unique_for_overwrite<limb_t []>(scratch_size);
247
245
blst_p1 out;
248
- blst_p1s_mult_pippenger (
249
- &out, p1_affine_ptrs.data (), npoints, scalars_ptrs.data (), 256 , scratch_space.get ());
246
+ if (npoints == 1 )
247
+ {
248
+ blst_p1 p;
249
+ blst_p1_from_affine (&p, &p1_affines[0 ]);
250
+ blst_p1_mult (&out, &p, scalars[0 ].b , 256 );
251
+ }
252
+ else
253
+ {
254
+ const auto scratch_size = blst_p1s_mult_pippenger_scratch_sizeof (npoints) / sizeof (limb_t );
255
+ const auto scratch_space = std::make_unique_for_overwrite<limb_t []>(scratch_size);
256
+ blst_p1s_mult_pippenger (
257
+ &out, p1_affine_ptrs.data (), npoints, scalars_ptrs.data (), 256 , scratch_space.get ());
258
+ }
250
259
251
260
blst_p1_affine result;
252
261
blst_p1_to_affine (&result, &out);
@@ -307,11 +316,20 @@ void store(uint8_t _rx[128], const blst_fp2& _x) noexcept
307
316
return true ;
308
317
}
309
318
310
- const auto scratch_size = blst_p2s_mult_pippenger_scratch_sizeof (npoints) / sizeof (limb_t );
311
- const auto scratch_space = std::make_unique_for_overwrite<limb_t []>(scratch_size);
312
319
blst_p2 out;
313
- blst_p2s_mult_pippenger (
314
- &out, p2_affine_ptrs.data (), npoints, scalars_ptrs.data (), 256 , scratch_space.get ());
320
+ if (npoints == 1 )
321
+ {
322
+ blst_p2 p;
323
+ blst_p2_from_affine (&p, &p2_affines[0 ]);
324
+ blst_p2_mult (&out, &p, scalars[0 ].b , 256 );
325
+ }
326
+ else
327
+ {
328
+ const auto scratch_size = blst_p2s_mult_pippenger_scratch_sizeof (npoints) / sizeof (limb_t );
329
+ const auto scratch_space = std::make_unique_for_overwrite<limb_t []>(scratch_size);
330
+ blst_p2s_mult_pippenger (
331
+ &out, p2_affine_ptrs.data (), npoints, scalars_ptrs.data (), 256 , scratch_space.get ());
332
+ }
315
333
316
334
blst_p2_affine result;
317
335
blst_p2_to_affine (&result, &out);
0 commit comments