@@ -7,6 +7,30 @@ macro_rules! test_pairing {
7
7
use ark_ff:: { CyclotomicMultSubgroup , Field , PrimeField } ;
8
8
use ark_std:: { test_rng, One , UniformRand , Zero } ;
9
9
10
+ #[ test]
11
+ fn test_multi_pairing_bilinearity( ) {
12
+ let mut rng = test_rng( ) ;
13
+ let g1: <$Pairing as Pairing >:: G1 = UniformRand :: rand( & mut rng) ;
14
+ let g2: <$Pairing as Pairing >:: G2 = UniformRand :: rand( & mut rng) ;
15
+ let s1: <$Pairing as Pairing >:: ScalarField = UniformRand :: rand( & mut rng) ;
16
+ let s2: <$Pairing as Pairing >:: ScalarField = UniformRand :: rand( & mut rng) ;
17
+ let s3 = s1 * s2;
18
+ // let ans = <$Pairing>::multi_pairing(&[-g1, g1 * s2, g1], &[g2 * s1, g2, g2 * s3]);
19
+ // assert_eq!(ans, PairingOutput::zero());
20
+ let ( p1, p2, p3) = ( g1. into_affine( ) , ( g1 * s2) . into_affine( ) , g1. into_affine( ) ) ;
21
+ let ( q1, q2, q3) = (
22
+ ( g2 * s1) . into_affine( ) ,
23
+ g2. into_affine( ) ,
24
+ ( g2) . into_affine( ) ,
25
+ ) ;
26
+ let e1 = <$Pairing>:: pairing( p1, q1) ;
27
+ let e2 = <$Pairing>:: pairing( p2, q2) ;
28
+ let e3 = <$Pairing>:: pairing( p3, q3) ;
29
+ let e33 = <$Pairing>:: multi_pairing( & [ p1, p2] , & [ q1, q2] ) ;
30
+ assert_eq!( e1 + e2, e3 * s3) ;
31
+ // assert_eq!(e1 + e2, e33);
32
+ }
33
+
10
34
#[ test]
11
35
fn test_bilinearity_projective( ) {
12
36
for _ in 0 ..100 {
0 commit comments