@@ -102,85 +102,6 @@ pub trait BnConfig: 'static + Sized {
102102 MillerLoopOutput ( f)
103103 }
104104
105- /// Optimized version that works directly with prepared references without cloning
106- fn multi_miller_loop_ref < ' a > (
107- a : impl IntoIterator < Item = impl AsRef < G1Prepared < Self > > + ' a > ,
108- b : impl IntoIterator < Item = impl AsRef < G2Prepared < Self > > + ' a > ,
109- ) -> MillerLoopOutput < Bn < Self > > {
110- // Collect into owned vectors first to ensure we have stable references
111- let a_refs: Vec < _ > = a. into_iter ( ) . collect ( ) ;
112- let b_refs: Vec < _ > = b. into_iter ( ) . collect ( ) ;
113-
114- #[ cfg( feature = "parallel" ) ]
115- let mut pairs: Vec < ( & G1Prepared < Self > , & G2Prepared < Self > , usize ) > = {
116- use rayon:: prelude:: * ;
117- a_refs
118- . par_iter ( )
119- . zip_eq ( b_refs. par_iter ( ) )
120- . filter_map ( |( p, q) | {
121- let ( p_ref, q_ref) = ( p. as_ref ( ) , q. as_ref ( ) ) ;
122- match !p_ref. is_zero ( ) && !q_ref. is_zero ( ) {
123- true => Some ( ( p_ref, q_ref, 0usize ) ) , // 0 is the index into ell_coeffs
124- false => None ,
125- }
126- } )
127- . collect ( )
128- } ;
129-
130- #[ cfg( not( feature = "parallel" ) ) ]
131- let mut pairs: Vec < ( & G1Prepared < Self > , & G2Prepared < Self > , usize ) > = a_refs
132- . iter ( )
133- . zip_eq ( b_refs. iter ( ) )
134- . filter_map ( |( p, q) | {
135- let ( p_ref, q_ref) = ( p. as_ref ( ) , q. as_ref ( ) ) ;
136- match !p_ref. is_zero ( ) && !q_ref. is_zero ( ) {
137- true => Some ( ( p_ref, q_ref, 0usize ) ) , // 0 is the index into ell_coeffs
138- false => None ,
139- }
140- } )
141- . collect ( ) ;
142-
143- let mut f = cfg_chunks_mut ! ( pairs, 4 )
144- . map ( |pairs| {
145- let mut f = <Bn < Self > as Pairing >:: TargetField :: one ( ) ;
146- for i in ( 1 ..Self :: ATE_LOOP_COUNT . len ( ) ) . rev ( ) {
147- if i != Self :: ATE_LOOP_COUNT . len ( ) - 1 {
148- f. square_in_place ( ) ;
149- }
150-
151- for ( p, q, idx) in pairs. iter_mut ( ) {
152- Bn :: < Self > :: ell ( & mut f, & q. ell_coeffs [ * idx] , & p. 0 ) ;
153- * idx += 1 ;
154- }
155-
156- let bit = Self :: ATE_LOOP_COUNT [ i - 1 ] ;
157- if bit == 1 || bit == -1 {
158- for ( p, q, idx) in pairs. iter_mut ( ) {
159- Bn :: < Self > :: ell ( & mut f, & q. ell_coeffs [ * idx] , & p. 0 ) ;
160- * idx += 1 ;
161- }
162- }
163- }
164- f
165- } )
166- . product :: < <Bn < Self > as Pairing >:: TargetField > ( ) ;
167-
168- if Self :: X_IS_NEGATIVE {
169- f. cyclotomic_inverse_in_place ( ) ;
170- }
171-
172- for ( p, q, idx) in & mut pairs {
173- Bn :: < Self > :: ell ( & mut f, & q. ell_coeffs [ * idx] , & p. 0 ) ;
174- * idx += 1 ;
175- }
176-
177- for ( p, q, idx) in & mut pairs {
178- Bn :: < Self > :: ell ( & mut f, & q. ell_coeffs [ * idx] , & p. 0 ) ;
179- }
180-
181- MillerLoopOutput ( f)
182- }
183-
184105 #[ allow( clippy:: let_and_return) ]
185106 fn final_exponentiation ( f : MillerLoopOutput < Bn < Self > > ) -> Option < PairingOutput < Bn < Self > > > {
186107 // Easy part: result = elt^((q^6-1)*(q^2+1)).
@@ -306,13 +227,6 @@ impl<P: BnConfig> Pairing for Bn<P> {
306227 P :: multi_miller_loop ( a, b)
307228 }
308229
309- fn multi_miller_loop_ref (
310- a : impl IntoIterator < Item = impl AsRef < Self :: G1Prepared > > ,
311- b : impl IntoIterator < Item = impl AsRef < Self :: G2Prepared > > ,
312- ) -> MillerLoopOutput < Self > {
313- P :: multi_miller_loop_ref ( a, b)
314- }
315-
316230 fn final_exponentiation ( f : MillerLoopOutput < Self > ) -> Option < PairingOutput < Self > > {
317231 P :: final_exponentiation ( f)
318232 }
0 commit comments