aboutsummaryrefslogtreecommitdiffstats
path: root/go/main.go
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2016-09-06 14:15:11 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2016-09-06 14:15:11 +0800
commit329b7e21ea915f4579581570ee6ae821eaeaef69 (patch)
treecccbba673d9529599754a544f78fa869edab01db /go/main.go
parent5d6ecea7ad17251f90fe4fc0a1f1937d0eac47b5 (diff)
downloaddexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar.gz
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar.bz2
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar.lz
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar.xz
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.tar.zst
dexon-bls-329b7e21ea915f4579581570ee6ae821eaeaef69.zip
use defer
Diffstat (limited to 'go/main.go')
-rw-r--r--go/main.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/go/main.go b/go/main.go
index 242aa62..f4ee030 100644
--- a/go/main.go
+++ b/go/main.go
@@ -13,18 +13,27 @@ func main() {
fmt.Println("init")
C.blsInit()
+ id := C.blsIdCreate()
+ defer C.blsIdDestroy(id)
+
+ C.blsIdSet(id, (*C.uint64_t)(unsafe.Pointer(&[]uint64{1, 2, 3, 4}[0])))
+ C.blsIdPut(id)
+
fmt.Println("create secret key")
sec := C.blsSecretKeyCreate()
+ defer C.blsSecretKeyDestroy(sec)
C.blsSecretKeyInit(sec)
C.blsSecretKeyPut(sec)
fmt.Println("create public key")
pub := C.blsPublicKeyCreate()
+ defer C.blsPublicKeyDestroy(pub)
C.blsSecretKeyGetPublicKey(sec, pub)
C.blsPublicKeyPut(pub)
sign := C.blsSignCreate()
+ defer C.blsSignDestroy(sign)
msg := []byte("Hello bls")
fmt.Println("sign message")
@@ -34,6 +43,4 @@ func main() {
fmt.Println("verify:", C.blsSignVerify(sign, pub, (*C.char)(unsafe.Pointer(&msg[0])), C.size_t(len(msg))))
- C.blsPublicKeyDestroy(pub)
- C.blsSecretKeyDestroy(sec)
}