diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-09-07 06:31:11 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-09-07 06:31:11 +0800 |
commit | 9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c (patch) | |
tree | 146abcdac0deeab5b6c42736031ad1bf8ed9dd63 | |
parent | aac66669fcb761f51bf2709d28d0c5753f08db95 (diff) | |
download | dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar.gz dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar.bz2 dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar.lz dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar.xz dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.tar.zst dexon-bls-9b6af7cbc8965c2f166f0979e1d64ec7369aaf9c.zip |
add SecretKey::setArray
-rw-r--r-- | go/bls/bls.go | 8 | ||||
-rw-r--r-- | go/main.go | 5 | ||||
-rw-r--r-- | include/bls_if.h | 1 | ||||
-rw-r--r-- | src/bls_if.cpp | 4 |
4 files changed, 18 insertions, 0 deletions
diff --git a/go/bls/bls.go b/go/bls/bls.go index 0506c10..2f7e8ca 100644 --- a/go/bls/bls.go +++ b/go/bls/bls.go @@ -88,6 +88,14 @@ func (sec *SecretKey) SetStr(s string) error { return nil } +func (sec *SecretKey) SetArray(v []uint64) error { + if len(v) != 4 { + return fmt.Errorf("bad size", len(v)) + } + C.blsSecretKeySetArray(sec.self, (*C.uint64_t)(unsafe.Pointer(&v[0]))) + return nil +} + func (sec *SecretKey) Init() { C.blsSecretKeyInit(sec.self) } @@ -115,6 +115,11 @@ func main() { id2.SetStr(id.String()) fmt.Println("id2:", id2) } + { + sec := bls.NewSecretKey() + sec.SetArray([]uint64{1, 2, 3, 4}) + fmt.Println("sec=", sec) + } fmt.Println("create secret key") m := "this is a bls sample for go" diff --git a/include/bls_if.h b/include/bls_if.h index 84b5f34..9b9012d 100644 --- a/include/bls_if.h +++ b/include/bls_if.h @@ -40,6 +40,7 @@ void blsIdSet(blsId *id, const uint64_t *p); blsSecretKey* blsSecretKeyCreate(void); void blsSecretKeyDestroy(blsSecretKey *sec); void blsSecretKeyPut(const blsSecretKey *sec); +void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p); int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize); size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize); void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs); diff --git a/src/bls_if.cpp b/src/bls_if.cpp index 6021c30..9054bb4 100644 --- a/src/bls_if.cpp +++ b/src/bls_if.cpp @@ -87,6 +87,10 @@ void blsSecretKeyPut(const blsSecretKey *sec) { std::cout << *(const bls::SecretKey*)sec << std::endl; } +void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p) +{ + ((bls::SecretKey*)sec)->set(p); +} int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize) { |