From e17ebfd57bcc6b97d7012811527fbad93952f655 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 6 Dec 2018 11:49:06 +0900 Subject: [Go] use bls384 unless tags is specified --- Makefile | 4 ++++ ffi/go/bls/bls.go | 4 +++- ffi/go/bls/config.h | 6 ++++++ ffi/go/bls/mcl.go | 1 + readme.md | 4 ++-- 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 ffi/go/bls/config.h diff --git a/Makefile b/Makefile index 4847885..9c2b208 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,9 @@ 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 +# use bls384 unless tags is specified +test_go_default: 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) @@ -114,6 +117,7 @@ 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_go_default $(MAKE) test_go256 $(MAKE) test_go384 $(MAKE) test_go384_256 diff --git a/ffi/go/bls/bls.go b/ffi/go/bls/bls.go index cb7074c..90fc264 100644 --- a/ffi/go/bls/bls.go +++ b/ffi/go/bls/bls.go @@ -8,7 +8,9 @@ package bls #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++ +#cgo LDFLAGS:-L../../../lib -lbls384_dy +#cgo LDFLAGS:-lcrypto -lgmp -lgmpxx -lstdc++ +#include "config.h" #include */ import "C" diff --git a/ffi/go/bls/config.h b/ffi/go/bls/config.h new file mode 100644 index 0000000..07e1481 --- /dev/null +++ b/ffi/go/bls/config.h @@ -0,0 +1,6 @@ +#pragma +// use bn384 unless tags is specified +#ifndef MCLBN_FP_UNIT_SIZE + #define MCLBN_FP_UNIT_SIZE 6 +#endif + diff --git a/ffi/go/bls/mcl.go b/ffi/go/bls/mcl.go index 776536f..a808bad 100644 --- a/ffi/go/bls/mcl.go +++ b/ffi/go/bls/mcl.go @@ -4,6 +4,7 @@ package bls #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 "config.h" #include */ import "C" diff --git a/readme.md b/readme.md index 42860a4..217ffcd 100644 --- a/readme.md +++ b/readme.md @@ -16,10 +16,10 @@ git clone git://github.com/herumi/cybozulib_ext ; for only Windows ``` # News -* -tags options is necessary for golang binding +* -tags option for Go bindings * -tags bn256 * -tags bn384\_256 - * -tags bn384 ; previous version + * -tags bn384 ; default mode * 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. -- cgit