aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--go/bls/bls.go9
-rw-r--r--go/main.go10
-rw-r--r--include/bls_if.h3
-rw-r--r--src/bls_if.cpp10
4 files changed, 32 insertions, 0 deletions
diff --git a/go/bls/bls.go b/go/bls/bls.go
index 2f7e8ca..976c884 100644
--- a/go/bls/bls.go
+++ b/go/bls/bls.go
@@ -166,6 +166,12 @@ func (sec *SecretKey) Recover(secVec []SecretKey, idVec []Id) {
C.blsSecretKeyRecover(sec.self, (**C.blsSecretKey)(unsafe.Pointer(&sv[0])), (**C.blsId)(unsafe.Pointer(&iv[0])), C.size_t(len(secVec)))
}
+func (sec *SecretKey) GetPop() (sign *Sign) {
+ sign = NewSign()
+ C.blsSecretKeyGetPop(sec.self, sign.self)
+ return sign
+}
+
type PublicKey struct {
self *C.blsPublicKey
}
@@ -273,3 +279,6 @@ func (sign *Sign) Verify(pub *PublicKey, m string) bool {
return C.blsSignVerify(sign.self, pub.self, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))) == 1
}
+func (sign *Sign) VerifyPop(pub *PublicKey) bool {
+ return C.blsSignVerifyPop(sign.self, pub.self) == 1;
+}
diff --git a/go/main.go b/go/main.go
index 956b8b2..1ad8cc1 100644
--- a/go/main.go
+++ b/go/main.go
@@ -104,6 +104,15 @@ func testAdd() {
verifyTrue(sign1.Verify(pub1, m))
}
+func testPop() {
+ fmt.Println("testPop")
+ sec := bls.NewSecretKey()
+ sec.Init()
+ pop := sec.GetPop()
+ verifyTrue(pop.VerifyPop(sec.GetPublicKey()))
+ sec.Init()
+ verifyTrue(!pop.VerifyPop(sec.GetPublicKey()))
+}
func main() {
fmt.Println("init")
bls.Init()
@@ -145,4 +154,5 @@ func main() {
testRecoverSecretKey()
testAdd()
testSign()
+ testPop()
}
diff --git a/include/bls_if.h b/include/bls_if.h
index 9b9012d..be4ba40 100644
--- a/include/bls_if.h
+++ b/include/bls_if.h
@@ -50,6 +50,7 @@ void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub);
void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size);
void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* const *msk, size_t k, const blsId *id);
void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey* const *secVec, const blsId *const *idVec, size_t n);
+void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign);
blsPublicKey *blsPublicKeyCreate(void);
void blsPublicKeyDestroy(blsPublicKey *pub);
@@ -70,6 +71,8 @@ void blsSignRecover(blsSign *sign, const blsSign *const *signVec, const blsId *c
int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size);
+int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/bls_if.cpp b/src/bls_if.cpp
index 9054bb4..c8fb5d3 100644
--- a/src/bls_if.cpp
+++ b/src/bls_if.cpp
@@ -129,6 +129,11 @@ void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey* const *secVec, c
((bls::SecretKey*)sec)->recover((const bls::SecretKey *const *)secVec, (const bls::Id *const *)idVec, n);
}
+void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign)
+{
+ ((const bls::SecretKey*)sec)->getPop(*(bls::Sign*)sign);
+}
+
blsPublicKey *blsPublicKeyCreate()
{
return createT<bls::PublicKey, blsPublicKey>();
@@ -200,3 +205,8 @@ int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, s
return ((const bls::Sign*)sign)->verify(*(const bls::PublicKey*)pub, std::string(m, size));
}
+int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub)
+{
+ return ((const bls::Sign*)sign)->verify(*(const bls::PublicKey*)pub);
+}
+