aboutsummaryrefslogtreecommitdiffstats
path: root/ffi/cs/bls_test.cs
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2019-04-01 11:55:42 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2019-04-01 11:55:42 +0800
commit20cfb8c0f35f5e74fcdb3522baf80b2edf734660 (patch)
treebf4540fcd7d7de2bba669ba157dfb2e47f0df802 /ffi/cs/bls_test.cs
parent38044ada41d699d43d72d6ddd54ed2f9de2ab583 (diff)
downloaddexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar.gz
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar.bz2
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar.lz
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar.xz
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.tar.zst
dexon-bls-20cfb8c0f35f5e74fcdb3522baf80b2edf734660.zip
[cs] update doc and add Add() methods
Diffstat (limited to 'ffi/cs/bls_test.cs')
-rw-r--r--ffi/cs/bls_test.cs30
1 files changed, 27 insertions, 3 deletions
diff --git a/ffi/cs/bls_test.cs b/ffi/cs/bls_test.cs
index e021e19..af4f761 100644
--- a/ffi/cs/bls_test.cs
+++ b/ffi/cs/bls_test.cs
@@ -67,7 +67,7 @@ namespace mcl
sec.SetByCSPRNG();
PublicKey pub = sec.GetPublicKey();
string m = "abc";
- Signature sig = sec.Signature(m);
+ Signature sig = sec.Sign(m);
Console.WriteLine("sig={0}", sig.GetHexStr());
assert("verify", pub.Verify(sig, m));
assert("not verify", !pub.Verify(sig, m + "a"));
@@ -100,7 +100,7 @@ namespace mcl
}
string m = "doremi";
for (int i = 0; i < n; i++) {
- Signature Signature = secs[i].Signature(m);
+ Signature Signature = secs[i].Sign(m);
assert("Signature.Verify", pubs[i].Verify(Signature, m));
}
{
@@ -115,7 +115,7 @@ namespace mcl
subIds[i] = ids[idx];
subSecs[i] = secs[idx];
subPubs[i] = pubs[idx];
- subSigns[i] = secs[idx].Signature(m);
+ subSigns[i] = secs[idx].Sign(m);
}
SecretKey sec = RecoverSecretKey(subSecs, subIds);
PublicKey pub = RecoverPublicKey(subPubs, subIds);
@@ -124,6 +124,29 @@ namespace mcl
assert("Signature.verify", pub.Verify(Signature, m));
}
}
+ static void TestAggregate() {
+ Console.WriteLine("TestAggregate");
+ const int n = 10;
+ const string m = "abc";
+ SecretKey[] secVec = new SecretKey[n];
+ PublicKey[] pubVec = new PublicKey[n];
+ Signature[] popVec = new Signature[n];
+ Signature[] sigVec = new Signature[n];
+ for (int i = 0; i < n; i++) {
+ secVec[i].SetByCSPRNG();
+ pubVec[i] = secVec[i].GetPublicKey();
+ popVec[i] = secVec[i].GetPop();
+ sigVec[i] = secVec[i].Sign(m);
+ }
+ for (int i = 1; i < n; i++) {
+ secVec[0].Add(secVec[i]);
+ assert("verify pop", pubVec[i].VerifyPop(popVec[i]));
+ pubVec[0].Add(pubVec[i]);
+ sigVec[0].Add(sigVec[i]);
+ }
+ assert("aggregate sec", secVec[0].Sign(m).IsEqual(sigVec[0]));
+ assert("aggregate", pubVec[0].Verify(sigVec[0], m));
+ }
static void Main(string[] args) {
try {
int[] curveTypeTbl = { BN254, BLS12_381 };
@@ -135,6 +158,7 @@ namespace mcl
TestPublicKey();
TestSign();
TestSharing();
+ TestAggregate();
if (err == 0) {
Console.WriteLine("all tests succeed");
} else {