@@ -330,6 +330,20 @@ mod pairing_helpers {
330330 ArkGT ( result. 0 )
331331 }
332332
333+ pub ( super ) fn multi_pair_g2_setup_optimized_compressed (
334+ ps : & [ ArkG1 ] ,
335+ qs : & [ ArkG2 ] ,
336+ ) -> ArkGTCompressed {
337+ let combined = if cfg ! ( feature = "parallel" ) {
338+ multi_pair_g2_setup_parallel ( ps, qs)
339+ } else {
340+ multi_pair_g2_setup_sequential ( ps, qs)
341+ } ;
342+ let result = Bn254 :: compressed_final_exponentiation ( combined)
343+ . expect ( "Final exponentiation should not fail" ) ;
344+ ArkGTCompressed ( result)
345+ }
346+
333347 /// Optimized multi-pairing dispatch for G1 from setup
334348 pub ( super ) fn multi_pair_g1_setup_optimized ( ps : & [ ArkG1 ] , qs : & [ ArkG2 ] ) -> ArkGT {
335349 let combined = if cfg ! ( feature = "parallel" ) {
@@ -341,6 +355,20 @@ mod pairing_helpers {
341355 Bn254 :: final_exponentiation ( combined) . expect ( "Final exponentiation should not fail" ) ;
342356 ArkGT ( result. 0 )
343357 }
358+
359+ pub ( super ) fn multi_pair_g1_setup_optimized_compressed (
360+ ps : & [ ArkG1 ] ,
361+ qs : & [ ArkG2 ] ,
362+ ) -> ArkGTCompressed {
363+ let combined = if cfg ! ( feature = "parallel" ) {
364+ multi_pair_g1_setup_parallel ( ps, qs)
365+ } else {
366+ multi_pair_g1_setup_sequential ( ps, qs)
367+ } ;
368+ let result = Bn254 :: compressed_final_exponentiation ( combined)
369+ . expect ( "Final exponentiation should not fail" ) ;
370+ ArkGTCompressed ( result)
371+ }
344372}
345373
346374impl CompressedPairingCurve for BN254 {
@@ -349,7 +377,7 @@ impl CompressedPairingCurve for BN254 {
349377 type GT = ArkGT ;
350378 type CompressedGT = ArkGTCompressed ;
351379
352- fn multi_pair ( ps : & [ Self :: G1 ] , qs : & [ Self :: G2 ] ) -> Self :: CompressedGT {
380+ fn multi_pair_compressed ( ps : & [ Self :: G1 ] , qs : & [ Self :: G2 ] ) -> Self :: CompressedGT {
353381 assert_eq ! (
354382 ps. len( ) ,
355383 qs. len( ) ,
@@ -361,6 +389,34 @@ impl CompressedPairingCurve for BN254 {
361389
362390 pairing_helpers:: multi_pair_optimized_compressed ( ps, qs)
363391 }
392+
393+ #[ tracing:: instrument( skip_all, name = "BN254::multi_pair_g2_setup_compressed" , fields( len = ps. len( ) ) ) ]
394+ fn multi_pair_g2_setup_compressed ( ps : & [ Self :: G1 ] , qs : & [ Self :: G2 ] ) -> Self :: CompressedGT {
395+ assert_eq ! (
396+ ps. len( ) ,
397+ qs. len( ) ,
398+ "multi_pair_g2_setup requires equal length vectors"
399+ ) ;
400+
401+ // TODO: handle empty case properly by implementing the default implementation of CompressedGT in arkworks.
402+ assert ! ( !ps. is_empty( ) ) ;
403+
404+ pairing_helpers:: multi_pair_g2_setup_optimized_compressed ( ps, qs)
405+ }
406+
407+ #[ tracing:: instrument( skip_all, name = "BN254::multi_pair_g1_setup_compressed" , fields( len = ps. len( ) ) ) ]
408+ fn multi_pair_g1_setup_compressed ( ps : & [ Self :: G1 ] , qs : & [ Self :: G2 ] ) -> Self :: CompressedGT {
409+ assert_eq ! (
410+ ps. len( ) ,
411+ qs. len( ) ,
412+ "multi_pair_g1_setup requires equal length vectors"
413+ ) ;
414+
415+ // TODO: handle empty case properly by implementing the default implementation of CompressedGT in arkworks.
416+ assert ! ( !ps. is_empty( ) ) ;
417+
418+ pairing_helpers:: multi_pair_g1_setup_optimized_compressed ( ps, qs)
419+ }
364420}
365421
366422impl PairingCurve for BN254 {
0 commit comments