aboutsummaryrefslogtreecommitdiffstats
path: root/go/blscgo
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-04-09 19:26:11 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-04-09 19:26:11 +0800
commit51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91 (patch)
tree25033efe1c81b3288b7e4a5263199fc2ba6b3255 /go/blscgo
parent076cb73f57616c4ddc01db19c6c0487cd886d6a8 (diff)
downloaddexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar.gz
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar.bz2
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar.lz
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar.xz
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.tar.zst
dexon-bls-51e69f9763a8d7da268c6ebcb6e9678b0dcdfd91.zip
add SetData/GetData/IsSame to bls.cgo
Diffstat (limited to 'go/blscgo')
-rw-r--r--go/blscgo/bls.go81
1 files changed, 81 insertions, 0 deletions
diff --git a/go/blscgo/bls.go b/go/blscgo/bls.go
index 5873f38..10892f9 100644
--- a/go/blscgo/bls.go
+++ b/go/blscgo/bls.go
@@ -106,6 +106,33 @@ func (sec *SecretKey) SetStr(s string) error {
return nil
}
+// SetData --
+func (sec *SecretKey) SetData(s string) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.blsSecretKeySetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if err > 0 {
+ return fmt.Errorf("bad string:%s", s)
+ }
+ return nil
+}
+
+// GetData --
+func (sec *SecretKey) GetData() string {
+ fpSize := GetOpUnitSize() * 8
+ buf := make([]byte, fpSize)
+ n := C.blsSecretKeyGetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if n == 0 {
+ panic("implementation err. size of buf is small")
+ }
+ return string(buf[:n])
+}
+
+// IsSame --
+func (lhs *SecretKey) IsSame(rhs *SecretKey) bool {
+ return C.blsSecretKeyIsSame(lhs.getPointer(), rhs.getPointer()) == 1
+}
+
// SetArray --
func (sec *SecretKey) SetArray(v []uint64) {
expect := GetOpUnitSize()
@@ -196,6 +223,33 @@ func (pub *PublicKey) SetStr(s string) error {
return nil
}
+// SetData --
+func (sec *PublicKey) SetData(s string) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.blsPublicKeySetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if err > 0 {
+ return fmt.Errorf("bad string:%s", s)
+ }
+ return nil
+}
+
+// GetData --
+func (sec *PublicKey) GetData() string {
+ fpSize := GetOpUnitSize() * 8
+ buf := make([]byte, fpSize*2)
+ n := C.blsPublicKeyGetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if n == 0 {
+ panic("implementation err. size of buf is small")
+ }
+ return string(buf[:n])
+}
+
+// IsSame --
+func (lhs *PublicKey) IsSame(rhs *PublicKey) bool {
+ return C.blsPublicKeyIsSame(lhs.getPointer(), rhs.getPointer()) == 1
+}
+
// Add --
func (pub *PublicKey) Add(rhs *PublicKey) {
C.blsPublicKeyAdd(pub.getPointer(), rhs.getPointer())
@@ -244,6 +298,33 @@ func (sign *Sign) SetStr(s string) error {
return nil
}
+// SetData --
+func (sec *Sign) SetData(s string) error {
+ buf := []byte(s)
+ // #nosec
+ err := C.blsSignSetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if err > 0 {
+ return fmt.Errorf("bad string:%s", s)
+ }
+ return nil
+}
+
+// GetData --
+func (sec *Sign) GetData() string {
+ fpSize := GetOpUnitSize() * 8
+ buf := make([]byte, fpSize)
+ n := C.blsSignGetData(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
+ if n == 0 {
+ panic("implementation err. size of buf is small")
+ }
+ return string(buf[:n])
+}
+
+// IsSame --
+func (lhs *Sign) IsSame(rhs *Sign) bool {
+ return C.blsSignIsSame(lhs.getPointer(), rhs.getPointer()) == 1
+}
+
// GetPublicKey --
func (sec *SecretKey) GetPublicKey() (pub *PublicKey) {
pub = new(PublicKey)