diff options
author | Ruan HE <ruan.he@orange.com> | 2015-09-04 07:35:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-09-04 07:35:06 +0000 |
commit | ca6aa8198d2335f8c326c3dd4d26bf5899064214 (patch) | |
tree | 6274a2d971fc0cac0896efe8583927d0190e3d20 /moon-abe/pbc-0.5.14/pbc/bilinear.test | |
parent | 92fd2dbfb672d7b2b1cdfd5dd5cf89f7716b3e12 (diff) | |
parent | 3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (diff) |
Merge "init attribute-based encryption"
Diffstat (limited to 'moon-abe/pbc-0.5.14/pbc/bilinear.test')
-rw-r--r-- | moon-abe/pbc-0.5.14/pbc/bilinear.test | 50 |
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); |