Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_bilinearity.cpp File Reference
Include dependency graph for test_bilinearity.cpp:

Go to the source code of this file.

Functions

template<typename ppT >
void pairing_test ()
 
template<typename ppT >
void double_miller_loop_test ()
 
template<typename ppT >
void affine_pairing_test ()
 
int main (void)
 

Function Documentation

◆ affine_pairing_test()

template<typename ppT >
void affine_pairing_test ( )

Definition at line 78 of file test_bilinearity.cpp.

79{
80 GT<ppT> GT_one = GT<ppT>::one();
81
82 printf("Running bilinearity tests:\n");
85
86 printf("P:\n");
87 P.print();
88 printf("Q:\n");
89 Q.print();
90 printf("\n\n");
91
93 G1<ppT> sP = s * P;
94 G2<ppT> sQ = s * Q;
95
96 printf("Pairing bilinearity tests (three must match):\n");
97 GT<ppT> ans1 = ppT::affine_reduced_pairing(sP, Q);
98 GT<ppT> ans2 = ppT::affine_reduced_pairing(P, sQ);
99 GT<ppT> ans3 = ppT::affine_reduced_pairing(P, Q)^s;
100 ans1.print();
101 ans2.print();
102 ans3.print();
103 assert(ans1 == ans2);
104 assert(ans2 == ans3);
105
106 assert(ans1 != GT_one);
107 assert((ans1^Fr<ppT>::field_char()) == GT_one);
108 printf("\n\n");
109}
#define P
Definition dtoa.c:437
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
typename EC_ppT::G1_type G1
typename EC_ppT::Fp_type Fr
typename EC_ppT::GT_type GT
char * s
Here is the caller graph for this function:

◆ double_miller_loop_test()

template<typename ppT >
void double_miller_loop_test ( )

Definition at line 59 of file test_bilinearity.cpp.

60{
65
66 const G1_precomp<ppT> prec_P1 = ppT::precompute_G1(P1);
67 const G1_precomp<ppT> prec_P2 = ppT::precompute_G1(P2);
68 const G2_precomp<ppT> prec_Q1 = ppT::precompute_G2(Q1);
69 const G2_precomp<ppT> prec_Q2 = ppT::precompute_G2(Q2);
70
71 const Fqk<ppT> ans_1 = ppT::miller_loop(prec_P1, prec_Q1);
72 const Fqk<ppT> ans_2 = ppT::miller_loop(prec_P2, prec_Q2);
73 const Fqk<ppT> ans_12 = ppT::double_miller_loop(prec_P1, prec_Q1, prec_P2, prec_Q2);
74 assert(ans_1 * ans_2 == ans_12);
75}
typename EC_ppT::Fqk_type Fqk
typename EC_ppT::G1_precomp_type G1_precomp
typename EC_ppT::G2_precomp_type G2_precomp
Here is the caller graph for this function:

◆ main()

int main ( void )

Definition at line 111 of file test_bilinearity.cpp.

112{
117
122
127
131
132#ifdef CURVE_BN128 // BN128 has fancy dependencies so it may be disabled
136#endif
137}
static void init_public_params()
static void init_public_params()
Definition bn128_pp.cpp:13
static void init_public_params()
static void init_public_params()
Definition mnt4_pp.cpp:18
static void init_public_params()
Definition mnt6_pp.cpp:18
void start_profiling()
Definition profiling.cpp:56
void affine_pairing_test()
void pairing_test()
void double_miller_loop_test()
Here is the call graph for this function:

◆ pairing_test()

template<typename ppT >
void pairing_test ( )

Definition at line 20 of file test_bilinearity.cpp.

21{
22 GT<ppT> GT_one = GT<ppT>::one();
23
24 printf("Running bilinearity tests:\n");
26 //G1<ppT> P = Fr<ppT>("2") * G1<ppT>::one();
28 //G2<ppT> Q = Fr<ppT>("3") * G2<ppT>::one();
29
30 printf("P:\n");
31 P.print();
32 P.print_coordinates();
33 printf("Q:\n");
34 Q.print();
35 Q.print_coordinates();
36 printf("\n\n");
37
39 //Fr<ppT> s = Fr<ppT>("2");
40 G1<ppT> sP = s * P;
41 G2<ppT> sQ = s * Q;
42
43 printf("Pairing bilinearity tests (three must match):\n");
44 GT<ppT> ans1 = ppT::reduced_pairing(sP, Q);
45 GT<ppT> ans2 = ppT::reduced_pairing(P, sQ);
46 GT<ppT> ans3 = ppT::reduced_pairing(P, Q)^s;
47 ans1.print();
48 ans2.print();
49 ans3.print();
50 assert(ans1 == ans2);
51 assert(ans2 == ans3);
52
53 assert(ans1 != GT_one);
54 assert((ans1^Fr<ppT>::field_char()) == GT_one);
55 printf("\n\n");
56}
Here is the caller graph for this function: