From 378c191833be2022412cd61d99e613b56e0cbbfb Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 17 May 2017 05:56:30 +0900 Subject: change PublicKey::verify(Sign, String) --- ffi/cs/bls256.cs | 16 ++++++++-------- ffi/cs/bls256_test.cs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ffi/cs/bls256.cs b/ffi/cs/bls256.cs index b0ba6ce..f39b6f3 100644 --- a/ffi/cs/bls256.cs +++ b/ffi/cs/bls256.cs @@ -242,9 +242,13 @@ namespace mcl { { blsPublicKeyAdd(ref this, ref rhs); } - } - // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i - public static PublicKey SharePublicKey(PublicKey[] mpk, Id id) + public bool Verify(Sign sign, string m) + { + return blsSignVerify(ref sign, ref this, m, (ulong)m.Length) == 1; + } + } + // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i + public static PublicKey SharePublicKey(PublicKey[] mpk, Id id) { PublicKey pub = new PublicKey(); if (blsPublicKeySet(ref pub, ref mpk[0], (ulong)mpk.Length, ref id) != 0) { @@ -286,12 +290,8 @@ namespace mcl { { blsSignAdd(ref this, ref rhs); } - public bool Verify(PublicKey pub, string m) - { - return blsSignVerify(ref this, ref pub, m, (ulong)m.Length) == 1; - } } - public static Sign RecoverSign(Sign[] signs, Id[] ids) + public static Sign RecoverSign(Sign[] signs, Id[] ids) { Sign sign = new Sign(); if (blsSignRecover(ref sign, ref signs[0], ref ids[0], (ulong)signs.Length) != 0) { diff --git a/ffi/cs/bls256_test.cs b/ffi/cs/bls256_test.cs index aff7a44..2eace18 100644 --- a/ffi/cs/bls256_test.cs +++ b/ffi/cs/bls256_test.cs @@ -45,10 +45,10 @@ namespace mcl { SecretKey sec = new SecretKey(); sec.Init(); PublicKey pub = sec.GetPublicKey(); - String s = pub.ToString(); - Console.WriteLine("pub={0}", s); + String sign = pub.ToString(); + Console.WriteLine("pub={0}", sign); PublicKey pub2 = new PublicKey(); - pub2.SetStr(s); + pub2.SetStr(sign); assert("pub.SetStr", pub.IsSame(pub2)); } static void TestSign() @@ -58,9 +58,9 @@ namespace mcl { sec.Init(); PublicKey pub = sec.GetPublicKey(); String m = "abc"; - Sign s = sec.Sign(m); - assert("verify", s.Verify(pub, m)); - assert("not verify", !s.Verify(pub, m + "a")); + Sign sign = sec.Sign(m); + assert("verify", pub.Verify(sign, m)); + assert("not verify", !pub.Verify(sign, m + "a")); } static void TestSharing() { @@ -86,7 +86,7 @@ namespace mcl { string m = "doremi"; for (int i = 0; i < n; i++) { Sign sign = secs[i].Sign(m); - assert("sign.Verify", sign.Verify(pubs[i], m)); + assert("sign.Verify", pubs[i].Verify(sign, m)); } { int[] idxTbl = { 0, 2, 5, 8, 10 }; @@ -106,7 +106,7 @@ namespace mcl { PublicKey pub = RecoverPublicKey(subPubs, subIds); assert("check pub", pub.IsSame(sec.GetPublicKey())); Sign sign = RecoverSign(subSigns, subIds); - assert("sign.verify", sign.Verify(pub, m)); + assert("sign.verify", pub.Verify(sign, m)); } } static void Main(string[] args) -- cgit v1.2.3