diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-12-05 10:59:06 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-12-05 10:59:06 +0800 |
commit | f63e122a2cff8d0e20288b897c449a42cdf84897 (patch) | |
tree | bed5a15333c3d04fbf23f583a56bbc64c8c9d271 | |
parent | afbcbeaaf3b5f9962af382d668ae5bcad337f661 (diff) | |
download | dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar.gz dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar.bz2 dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar.lz dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar.xz dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.tar.zst dexon-bls-f63e122a2cff8d0e20288b897c449a42cdf84897.zip |
-tags options is necessary fo cgo
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | ffi/go/bls/bls.go | 10 | ||||
-rw-r--r-- | ffi/go/bls/bls_test.go | 6 | ||||
-rw-r--r-- | ffi/go/bls/mcl.go | 15 | ||||
-rw-r--r-- | readme.md | 16 |
5 files changed, 51 insertions, 9 deletions
@@ -106,8 +106,17 @@ ifeq ($(OS),mac) MAC_GO_LDFLAGS="-ldflags=-s" endif # PATH is for mingw, LD_RUN_PATH is for linux, DYLD_LIBRARY_PATH is for mac -test_go: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS384_SLIB) - cd ffi/go/bls && env PATH=$$PATH:../../../lib LD_RUN_PATH="../../../lib" DYLD_LIBRARY_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) . +test_go256: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS256_SLIB) + cd ffi/go/bls && env PATH=$$PATH:../../../lib LD_RUN_PATH="../../../lib" DYLD_LIBRARY_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn256 . +test_go384: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS384_SLIB) + cd ffi/go/bls && env PATH=$$PATH:../../../lib LD_RUN_PATH="../../../lib" DYLD_LIBRARY_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn384 . +test_go384_256: ffi/go/bls/bls.go ffi/go/bls/bls_test.go $(BLS384_256_SLIB) + cd ffi/go/bls && env PATH=$$PATH:../../../lib LD_RUN_PATH="../../../lib" DYLD_LIBRARY_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn384_256 . + +test_go: + $(MAKE) test_go256 + $(MAKE) test_go384 + $(MAKE) test_go384_256 EMCC_OPT=-I./include -I./src -I../mcl/include -I./ -Wall -Wextra EMCC_OPT+=-O3 -DNDEBUG diff --git a/ffi/go/bls/bls.go b/ffi/go/bls/bls.go index a7bbeb3..cb7074c 100644 --- a/ffi/go/bls/bls.go +++ b/ffi/go/bls/bls.go @@ -2,9 +2,13 @@ package bls /* #cgo CFLAGS:-I../../../include -I../../../../mcl/include/ -#cgo LDFLAGS:-L../../../lib -#cgo CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -#cgo LDFLAGS:-lbls384_dy -lcrypto -lgmp -lgmpxx -lstdc++ +#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4 +#cgo bn256 LDFLAGS:-lbls256_dy +#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 +#cgo bn384 LDFLAGS:-lbls384_dy +#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4 +#cgo bn384_256 LDFLAGS:-lbls384_256_dy +#cgo LDFLAGS:-L../../../lib -lcrypto -lgmp -lgmpxx -lstdc++ #include <bls/bls.h> */ import "C" diff --git a/ffi/go/bls/bls_test.go b/ffi/go/bls/bls_test.go index adc2806..bc94703 100644 --- a/ffi/go/bls/bls_test.go +++ b/ffi/go/bls/bls_test.go @@ -380,8 +380,10 @@ func TestMain(t *testing.T) { t.Log("CurveFp254BNb") test(t, CurveFp254BNb) if GetMaxOpUnitSize() == 6 { - t.Log("CurveFp382_1") - test(t, CurveFp382_1) + if GetFrUnitSize() == 6 { + t.Log("CurveFp382_1") + test(t, CurveFp382_1) + } t.Log("BLS12_381") test(t, BLS12_381) } diff --git a/ffi/go/bls/mcl.go b/ffi/go/bls/mcl.go index 9771201..776536f 100644 --- a/ffi/go/bls/mcl.go +++ b/ffi/go/bls/mcl.go @@ -1,7 +1,9 @@ package bls /* -#cgo CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 +#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4 +#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 +#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4 #include <mcl/bn.h> */ import "C" @@ -23,6 +25,17 @@ const BLS12_381 = C.MCL_BLS12_381 // IoSerializeHexStr const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR +// GetFrUnitSize() -- +func GetFrUnitSize() int { + return int(C.MCLBN_FR_UNIT_SIZE) +} + +// GetFpUnitSize() -- +// same as GetMaxOpUnitSize() +func GetFpUnitSize() int { + return int(C.MCLBN_FP_UNIT_SIZE) +} + // GetMaxOpUnitSize -- func GetMaxOpUnitSize() int { return int(C.MCLBN_FP_UNIT_SIZE) @@ -15,7 +15,20 @@ git clone git://github.com/herumi/bls.git git clone git://github.com/herumi/cybozulib_ext ; for only Windows ``` -# **REMARK** libbls.a for C++ interface(bls/bls.hpp) is removed +# News +* -tags options is necessary for golang binding + * -tags bn256 + * -tags bn384\_256 + * -tags bn384 ; previous version +* Support swap of G1 and G2 + * `make BLS_SWAP_G=1` then G1 is assigned to PublicKey and G2 is assigned to Signature. + * golang binding does not support this feature yet. +* Build option without GMP + * `make MCL_USE_GMP=0` +* Build option to specify `mcl` directory + * `make MCL_DIR=<mcl directory>` + +* (old) libbls.a for C++ interface(bls/bls.hpp) is removed Link `lib/libbls256.a` or `lib/libbls384.a` to use `bls/bls.hpp` according to MCLBN_FP_UNIT_SIZE = 4 or 6. # Build and test for Linux @@ -47,6 +60,7 @@ bin\bls_c384_test.exe # Library * libbls256.a/libbls256_dy.so ; for BN254 compiled with MCLBN_FP_UNIT_SIZE=4 * libbls384.a/libbls384_dy.so ; for BN254/BN381_1/BLS12_381 compiled with MCLBN_FP_UNIT_SIZE=6 +* libbls384_256.a/libbls384_256_dy.so ; for BN254/BLS12_381 compiled with MCLBN_FP_UNIT_SIZE=6 and MCLBN_FR_UNIT_SIZE=4 See `mcl/include/curve_type.h` for curve parameter |