@@ -114,7 +114,19 @@ macro_rules! pippenger_mult_impl {
114
114
}
115
115
116
116
pub fn mult( & self , scalars: & [ u8 ] , nbits: usize ) -> $point {
117
- let npoints = self . points. len( ) ;
117
+ self . as_slice( ) . mult( scalars, nbits)
118
+ }
119
+
120
+ pub fn add( & self ) -> $point {
121
+ self . as_slice( ) . add( )
122
+ }
123
+ }
124
+
125
+ impl MultiScalar for [ $point_affine] {
126
+ type Output = $point;
127
+
128
+ fn mult( & self , scalars: & [ u8 ] , nbits: usize ) -> $point {
129
+ let npoints = self . len( ) ;
118
130
let nbytes = ( nbits + 7 ) / 8 ;
119
131
120
132
if scalars. len( ) < nbytes * npoints {
@@ -124,8 +136,7 @@ macro_rules! pippenger_mult_impl {
124
136
let pool = mt:: da_pool( ) ;
125
137
let ncpus = pool. max_count( ) ;
126
138
if ncpus < 2 || npoints < 32 {
127
- let p: [ * const $point_affine; 2 ] =
128
- [ & self . points[ 0 ] , ptr:: null( ) ] ;
139
+ let p: [ * const $point_affine; 2 ] = [ & self [ 0 ] , ptr:: null( ) ] ;
129
140
let s: [ * const u8 ; 2 ] = [ & scalars[ 0 ] , ptr:: null( ) ] ;
130
141
131
142
unsafe {
@@ -178,7 +189,7 @@ macro_rules! pippenger_mult_impl {
178
189
}
179
190
let grid = & grid[ ..] ;
180
191
181
- let points = & self . points [ ..] ;
192
+ let points = & self [ ..] ;
182
193
let sz = unsafe { $scratch_sizeof( 0 ) / 8 } ;
183
194
184
195
let mut row_sync: Vec <AtomicUsize > = Vec :: with_capacity( ny) ;
@@ -262,13 +273,13 @@ macro_rules! pippenger_mult_impl {
262
273
ret
263
274
}
264
275
265
- pub fn add( & self ) -> $point {
266
- let npoints = self . points . len( ) ;
276
+ fn add( & self ) -> $point {
277
+ let npoints = self . len( ) ;
267
278
268
279
let pool = mt:: da_pool( ) ;
269
280
let ncpus = pool. max_count( ) ;
270
281
if ncpus < 2 || npoints < 384 {
271
- let p: [ * const _; 2 ] = [ & self . points [ 0 ] , ptr:: null( ) ] ;
282
+ let p: [ * const _; 2 ] = [ & self [ 0 ] , ptr:: null( ) ] ;
272
283
let mut ret = <$point>:: default ( ) ;
273
284
unsafe { $add( & mut ret, & p[ 0 ] , npoints) } ;
274
285
return ret;
@@ -295,7 +306,7 @@ macro_rules! pippenger_mult_impl {
295
306
if work >= npoints {
296
307
break ;
297
308
}
298
- p[ 0 ] = & self . points [ work] ;
309
+ p[ 0 ] = & self [ work] ;
299
310
if work + chunk > npoints {
300
311
chunk = npoints - work;
301
312
}
0 commit comments