blob: 956c792e4b022d6747b695a05300e7338dc8a544 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
define test_element_order(group) {
a := random(group);
o := order(group);
b := a^o;
CHECK(b == group(0));
}
define test_group_order() {
CHECK(order(G1) == order(G2));
CHECK(order(G2) == order(GT));
a := pairing(random(G1), random(G2));
o := order(GT);
b := a^o;
CHECK(b == GT(0));
}
define test_pairing_with_zero() {
CHECK(GT(0) == GT(1));
CHECK(pairing(G1(0), random(G2)) == GT(0));
CHECK(pairing(random(G1), G2(0)) == GT(0));
CHECK(pairing(G1(0), G2(0)) == GT(0));
}
define test_bilinear() {
a1 := random(G1);
b1 := random(G2);
x := random(Zr);
y := random(Zr);
CHECK(pairing(a1^x, b1) == pairing(a1, b1^x));
CHECK(pairing(a1^x, b1) == pairing(a1, b1)^x);
CHECK(pairing(a1, b1^x) == pairing(a1, b1)^x);
CHECK(pairing(a1^x, b1^y) == pairing(a1, b1)^(x*y));
}
define test(initfn) {
initfn();
test_element_order(G1);
test_element_order(G2);
test_element_order(GT);
test_group_order();
test_pairing_with_zero();
test_bilinear();
}
test(init_pairing_a);
test(init_pairing_d);
test(init_pairing_e);
test(init_pairing_f);
test(init_pairing_g);
test(init_pairing_i);
|