1+ use crate :: msm:: pippenger_utils:: get_wval_limb;
12use crate :: { Fr , G1Affine , G1Fp , G1GetFp , G1Mul , G1ProjAddAffine , G1 } ;
23use alloc:: vec:: Vec ;
34use core:: marker:: PhantomData ;
@@ -297,15 +298,15 @@ where
297298 // Convert scalars to scalar limbs for bit access
298299 let scalar_values = scalars. iter ( ) . map ( TFr :: to_scalar) . collect :: < Vec < _ > > ( ) ;
299300
300- // Find the maximum bit position across all scalars (not per chunk)
301+ // Find the maximum bit position across all scalars
301302 let mut global_max_bit = 0usize ;
302303 for s in & scalar_values {
303304 for ( limb_idx, & limb) in s. data . iter ( ) . enumerate ( ) . rev ( ) {
304305 if limb != 0 {
305306 let bit_pos = 63 - limb. leading_zeros ( ) as usize ;
306- let global_bit = limb_idx * 64 + bit_pos;
307- if global_bit > global_max_bit {
308- global_max_bit = global_bit ;
307+ let scalar_bit = limb_idx * 64 + bit_pos;
308+ if scalar_bit > global_max_bit {
309+ global_max_bit = scalar_bit ;
309310 }
310311 break ;
311312 }
@@ -319,9 +320,6 @@ where
319320 // Double accumulator unconditionally
320321 accumulator. dbl_assign ( ) ;
321322
322- let limb_idx = bit / 64 ;
323- let bit_in_limb = bit % 64 ;
324-
325323 // Process each chunk at this bit position
326324 let mut pt_idx = 0usize ;
327325 for table in chunk_tables. iter ( ) {
@@ -343,10 +341,9 @@ where
343341 }
344342
345343 let s = & scalar_values[ scalar_idx] ;
346- if limb_idx < s. data . len ( ) {
347- if ( ( s. data [ limb_idx] >> bit_in_limb) & 1 ) != 0 {
348- mask |= 1 << i;
349- }
344+ // Extract single bit at position 'bit' from scalar
345+ if ( get_wval_limb ( s, bit, 1 ) & 1 ) != 0 {
346+ mask |= 1 << i;
350347 }
351348 }
352349
0 commit comments