diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-15 04:31:43 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-15 04:31:43 +0800 |
commit | 5d4999f1e145fdfb0f5674b768fd68c0143c9cb9 (patch) | |
tree | 1ec044d5e50c3b5d6b5f26ae92f1c478a544c38f | |
parent | d798881e3bcc634afd718b8a7fc62e3060dda6f5 (diff) | |
download | dexon-mcl-5d4999f1e145fdfb0f5674b768fd68c0143c9cb9.tar.gz dexon-mcl-5d4999f1e145fdfb0f5674b768fd68c0143c9cb9.tar.zst dexon-mcl-5d4999f1e145fdfb0f5674b768fd68c0143c9cb9.zip |
fix of SetHashOf
-rw-r--r-- | ffi/go/mcl/mcl.go | 2 | ||||
-rw-r--r-- | ffi/go/mcl/mcl_test.go | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/ffi/go/mcl/mcl.go b/ffi/go/mcl/mcl.go index bce2d56..542efbb 100644 --- a/ffi/go/mcl/mcl.go +++ b/ffi/go/mcl/mcl.go @@ -147,7 +147,7 @@ func (x *Fr) SetByCSPRNG() { // SetHashOf -- func (x *Fr) SetHashOf(buf []byte) bool { // #nosec - return C.mclBnFr_setHashOf(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 1 + return C.mclBnFr_setHashOf(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 0 } // GetString -- diff --git a/ffi/go/mcl/mcl_test.go b/ffi/go/mcl/mcl_test.go index 85900be..25aecde 100644 --- a/ffi/go/mcl/mcl_test.go +++ b/ffi/go/mcl/mcl_test.go @@ -24,6 +24,15 @@ func testGT(t *testing.T) { } } +func testHash(t *testing.T) { + var x Fr + err := x.SetHashOf([]byte("abc")) + if !err { + t.Error(err) + } + fmt.Printf("x=%s\n", x.GetString(16)) +} + func testNegAdd(t *testing.T) { var x Fr var P1, P2, P3 G1 @@ -111,6 +120,7 @@ func testMcl(t *testing.T, c int) { if err != nil { t.Fatal(err) } + testHash(t) testNegAdd(t) testPairing(t) testGT(t) |