aboutsummaryrefslogtreecommitdiffstats
path: root/go/blscgo
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-03-15 10:12:57 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-03-15 10:12:57 +0800
commit89a8d07fdc790734b8b3d89c729d0f251b452962 (patch)
tree9297a071c8ae67f01660a702ad107dc740fd0933 /go/blscgo
parent0310c3a2274f1e48b2aa1631229d3904c5c80022 (diff)
downloaddexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar.gz
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar.bz2
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar.lz
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar.xz
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.tar.zst
dexon-bls-89a8d07fdc790734b8b3d89c729d0f251b452962.zip
ensure size of SetArray
Diffstat (limited to 'go/blscgo')
-rw-r--r--go/blscgo/bls.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/go/blscgo/bls.go b/go/blscgo/bls.go
index 3d78ee0..782e8b2 100644
--- a/go/blscgo/bls.go
+++ b/go/blscgo/bls.go
@@ -19,6 +19,14 @@ const CurveFp382_2 = 2
func Init(curve int) {
C.blsInit(C.int(curve), C.BLS_MAX_OP_UNIT_SIZE)
}
+// getMaxOpUnitSize --
+func GetMaxOpUnitSize() int {
+ return int(C.BLS_MAX_OP_UNIT_SIZE)
+}
+// getOpUnitSize --
+func GetOpUnitSize() int {
+ return int(C.blsGetOpUnitSize())
+}
// ID --
type ID struct {
@@ -54,13 +62,13 @@ func (id *ID) SetStr(s string) error {
}
// Set --
-func (id *ID) Set(v []uint64) error {
- if len(v) != 6 {
- return fmt.Errorf("bad size (%d), expected size 6", len(v))
+func (id *ID) Set(v []uint64) {
+ expect := GetOpUnitSize()
+ if len(v) != expect {
+ panic(fmt.Errorf("bad size (%d), expected size %d", len(v), expect))
}
// #nosec
C.blsIdSet(id.getPointer(), (*C.uint64_t)(unsafe.Pointer(&v[0])))
- return nil
}
// SecretKey --
@@ -97,13 +105,13 @@ func (sec *SecretKey) SetStr(s string) error {
}
// SetArray --
-func (sec *SecretKey) SetArray(v []uint64) error {
- if len(v) != 6 {
- return fmt.Errorf("bad size (%d), expected size 6", len(v))
+func (sec *SecretKey) SetArray(v []uint64) {
+ expect := GetOpUnitSize()
+ if len(v) != expect {
+ panic(fmt.Errorf("bad size (%d), expected size %d", len(v), expect))
}
// #nosec
C.blsSecretKeySetArray(sec.getPointer(), (*C.uint64_t)(unsafe.Pointer(&v[0])))
- return nil
}
// Init --