From f63e122a2cff8d0e20288b897c449a42cdf84897 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 5 Dec 2018 11:59:06 +0900 Subject: -tags options is necessary fo cgo --- ffi/go/bls/bls.go | 10 +++++++--- ffi/go/bls/bls_test.go | 6 ++++-- ffi/go/bls/mcl.go | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'ffi/go') 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 */ 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 */ 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) -- cgit v1.2.3