diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2019-01-05 21:10:08 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2019-01-05 21:10:08 +0800 |
commit | 5c149220075b00d9193064defa6ea3a236051a68 (patch) | |
tree | aad4f830991722d8aa1083e34ed46595050f17d2 /ffi/go/bls/bls_test.go | |
parent | 3c7d378c00da0c2d9cf2691bfd363fc0c41ffe54 (diff) | |
download | dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar.gz dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar.bz2 dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar.lz dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar.xz dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.tar.zst dexon-bls-5c149220075b00d9193064defa6ea3a236051a68.zip |
add test of VerifyPairing for cgo
Diffstat (limited to 'ffi/go/bls/bls_test.go')
-rw-r--r-- | ffi/go/bls/bls_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ffi/go/bls/bls_test.go b/ffi/go/bls/bls_test.go index bc94703..7626156 100644 --- a/ffi/go/bls/bls_test.go +++ b/ffi/go/bls/bls_test.go @@ -356,6 +356,42 @@ func testDHKeyExchange(t *testing.T) { } } +func testPairing(t *testing.T) { + var sec SecretKey + sec.SetByCSPRNG() + pub := sec.GetPublicKey() + m := "abc" + sig1 := sec.Sign(m) + sig2 := HashAndMapToSignature([]byte(m)) + if !VerifyPairing(sig1, sig2, pub) { + t.Errorf("VerifyPairing") + } +} + +func testAggregate2(t *testing.T) { + var sec SecretKey + sec.SetByCSPRNG() + pub := sec.GetPublicKey() + msgTbl := []string{"abc", "def", "123"} + n := len(msgTbl) + sigVec := make([]*Sign, n) + for i := 0; i < n; i++ { + m := msgTbl[i] + sigVec[i] = sec.Sign(m) + } + aggSign := sigVec[0] + for i := 1; i < n; i++ { + aggSign.Add(sigVec[i]) + } + hashPt := HashAndMapToSignature([]byte(msgTbl[0])) + for i := 1; i < n; i++ { + hashPt.Add(HashAndMapToSignature([]byte(msgTbl[i]))) + } + if !VerifyPairing(aggSign, hashPt, pub) { + t.Errorf("aggregate2") + } +} + func test(t *testing.T, c int) { err := Init(c) if err != nil { @@ -373,6 +409,8 @@ func test(t *testing.T, c int) { testOrder(t, c) testDHKeyExchange(t) testSerializeToHexStr(t) + testPairing(t) + testAggregate2(t) } func TestMain(t *testing.T) { |