aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-03-06 04:29:02 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-03-06 04:29:02 +0800
commitca9d69fe32427bed60a48acd2eebac60a29e1a60 (patch)
tree65b26a00e8a13cb363e989d10a2022893265bfa3
parent9475f3c408de4673427e7396b87ade704aa6e889 (diff)
downloaddexon-mcl-ca9d69fe32427bed60a48acd2eebac60a29e1a60.tar.gz
dexon-mcl-ca9d69fe32427bed60a48acd2eebac60a29e1a60.tar.zst
dexon-mcl-ca9d69fe32427bed60a48acd2eebac60a29e1a60.zip
add pairing test for C#
-rw-r--r--ffi/cs/Program.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/ffi/cs/Program.cs b/ffi/cs/Program.cs
index 961388a..853f8ca 100644
--- a/ffi/cs/Program.cs
+++ b/ffi/cs/Program.cs
@@ -430,6 +430,7 @@ namespace mcl {
TestFr();
TestG1();
TestG2();
+ TestPairing();
} catch (Exception e) {
Console.WriteLine("ERR={0}", e);
}
@@ -530,5 +531,31 @@ namespace mcl {
G2.Mul(Q, P, x);
Console.WriteLine("Q == R {0}", Q.Equals(R));
}
+ static void TestPairing()
+ {
+ Console.WriteLine("TestG2");
+ G1 P = new G1();
+ P.setStr("1 -1 1");
+ G2 Q = new G2();
+ Q.HashAndMapTo("1");
+ Fr a = new Fr();
+ Fr b = new Fr();
+ a.SetStr("12345678912345673453");
+ b.SetStr("230498230982394243424");
+ G1 aP = new G1();
+ G2 bQ = new G2();
+ G1.Mul(aP, P, a);
+ G2.Mul(bQ, Q, b);
+ GT e1 = new GT();
+ GT e2 = new GT();
+ GT e3 = new GT();
+ Pairing(e1, P, Q);
+ Pairing(e2, aP, Q);
+ GT.Pow(e3, e1, a);
+ Console.WriteLine("e2.Equals(e3) {0}", e2.Equals(e3));
+ Pairing(e2, P, bQ);
+ GT.Pow(e3, e1, b);
+ Console.WriteLine("e2.Equals(e3) {0}", e2.Equals(e3));
+ }
}
}