aboutsummaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/pbc/bilinear.test
diff options
context:
space:
mode:
Diffstat (limited to 'moon-abe/pbc-0.5.14/pbc/bilinear.test')
-rw-r--r--moon-abe/pbc-0.5.14/pbc/bilinear.test50
1 files changed, 50 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/pbc/bilinear.test b/moon-abe/pbc-0.5.14/pbc/bilinear.test
new file mode 100644
index 00000000..956c792e
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/bilinear.test
@@ -0,0 +1,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);