aboutsummaryrefslogtreecommitdiffstats
path: root/go
diff options
context:
space:
mode:
Diffstat (limited to 'go')
-rw-r--r--go/blscgo/bls.go24
-rw-r--r--go/main.go10
2 files changed, 19 insertions, 15 deletions
diff --git a/go/blscgo/bls.go b/go/blscgo/bls.go
index bd0cd2d..f75945b 100644
--- a/go/blscgo/bls.go
+++ b/go/blscgo/bls.go
@@ -9,14 +9,18 @@ import "C"
import "fmt"
import "unsafe"
+const CurveFp254BNb = 0
+const CurveFp382_1 = 1
+const CurveFp382_2 = 2
+
// Init --
-func Init() {
- C.blsInit()
+func Init(curve int) {
+ C.blsInit(C.int(curve))
}
// ID --
type ID struct {
- v [4]C.uint64_t
+ v [6]C.uint64_t
}
// getPointer --
@@ -49,8 +53,8 @@ func (id *ID) SetStr(s string) error {
// Set --
func (id *ID) Set(v []uint64) error {
- if len(v) != 4 {
- return fmt.Errorf("bad size (%d), expected size 4", len(v))
+ if len(v) != 6 {
+ return fmt.Errorf("bad size (%d), expected size 6", len(v))
}
// #nosec
C.blsIdSet(id.getPointer(), (*C.uint64_t)(unsafe.Pointer(&v[0])))
@@ -59,7 +63,7 @@ func (id *ID) Set(v []uint64) error {
// SecretKey --
type SecretKey struct {
- v [4]C.uint64_t
+ v [6]C.uint64_t
}
// getPointer --
@@ -92,8 +96,8 @@ func (sec *SecretKey) SetStr(s string) error {
// SetArray --
func (sec *SecretKey) SetArray(v []uint64) error {
- if len(v) != 4 {
- return fmt.Errorf("bad size (%d), expected size 4", len(v))
+ if len(v) != 6 {
+ return fmt.Errorf("bad size (%d), expected size 6", len(v))
}
// #nosec
C.blsSecretKeySetArray(sec.getPointer(), (*C.uint64_t)(unsafe.Pointer(&v[0])))
@@ -149,7 +153,7 @@ func (sec *SecretKey) GetPop() (sign *Sign) {
// PublicKey --
type PublicKey struct {
- v [4 * 2 * 3]C.uint64_t
+ v [6 * 2 * 3]C.uint64_t
}
// getPointer --
@@ -197,7 +201,7 @@ func (pub *PublicKey) Recover(pubVec []PublicKey, idVec []ID) {
// Sign --
type Sign struct {
- v [4 * 3]C.uint64_t
+ v [6 * 3]C.uint64_t
}
// getPointer --
diff --git a/go/main.go b/go/main.go
index 87934ad..c3da950 100644
--- a/go/main.go
+++ b/go/main.go
@@ -24,7 +24,7 @@ func testRecoverSecretKey() {
secVec := make([]blscgo.SecretKey, n)
idVec := make([]blscgo.ID, n)
for i := 0; i < n; i++ {
- idVec[i].Set([]uint64{1, 2, 3, uint64(i)})
+ idVec[i].Set([]uint64{1, 2, 3, uint64(i), 4, 5})
secVec[i].Set(msk, &idVec[i])
}
// recover sec2 from secVec and idVec
@@ -56,7 +56,7 @@ func testSign() {
idVec := make([]blscgo.ID, n)
for i := 0; i < n; i++ {
- idVec[i].Set([]uint64{idTbl[i], 0, 0, 0})
+ idVec[i].Set([]uint64{idTbl[i], 0, 0, 0, 0, 0})
fmt.Printf("idVec[%d]=%s\n", i, idVec[i].String())
secVec[i].Set(msk, &idVec[i])
@@ -112,10 +112,10 @@ func testPop() {
}
func main() {
fmt.Println("init")
- blscgo.Init()
+ blscgo.Init(blscgo.CurveFp254BNb)
{
var id blscgo.ID
- id.Set([]uint64{4, 3, 2, 1})
+ id.Set([]uint64{6, 5, 4, 3, 2, 1})
fmt.Println("id :", id)
var id2 blscgo.ID
id2.SetStr(id.String())
@@ -123,7 +123,7 @@ func main() {
}
{
var sec blscgo.SecretKey
- sec.SetArray([]uint64{1, 2, 3, 4})
+ sec.SetArray([]uint64{1, 2, 3, 4, 5, 6})
fmt.Println("sec=", sec)
}