aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-12-03 14:00:22 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-12-03 14:00:22 +0800
commitc2946c7a953263083fe0fd50f6c77d88a39eb877 (patch)
treea68f790a25270608ab524dc2c0635313797b6987
parent0152955132ce7575dab7196b956a2dde8ef83018 (diff)
downloaddexon-mcl-c2946c7a953263083fe0fd50f6c77d88a39eb877.tar.gz
dexon-mcl-c2946c7a953263083fe0fd50f6c77d88a39eb877.tar.zst
dexon-mcl-c2946c7a953263083fe0fd50f6c77d88a39eb877.zip
add bn384_256 tag for cgo
-rw-r--r--Makefile5
-rw-r--r--ffi/go/mcl/mcl.go13
-rw-r--r--ffi/go/mcl/mcl_test.go6
3 files changed, 21 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 7510c8a..348a6b7 100644
--- a/Makefile
+++ b/Makefile
@@ -216,12 +216,15 @@ test_go256: $(MCL_SLIB) $(BN256_SLIB)
cd ffi/go/mcl && env PATH="$$PATH:../../../lib" LD_RUN_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn256 .
test_go384: $(MCL_SLIB) $(BN384_SLIB)
-# cd ffi/go/mcl && env LD_RUN_PATH="../../../lib" CGO_CFLAGS="-I../../../include" CGO_LDFLAGS="-L../../../lib -l$(BN384_SNAME) -l$(MCL_SNAME) -lgmpxx -lgmp -lcrypto -lstdc++" go test $(MAC_GO_LDFLAGS) .
cd ffi/go/mcl && env PATH="$$PATH:../../../lib" LD_RUN_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn384 .
+test_go384_256: $(MCL_SLIB) $(BN384_256_SLIB)
+ cd ffi/go/mcl && env PATH="$$PATH:../../../lib" LD_RUN_PATH="../../../lib" go test $(MAC_GO_LDFLAGS) -tags bn384_256 .
+
test_go:
$(MAKE) test_go256
$(MAKE) test_go384
+ $(MAKE) test_go384_256
test_java:
$(MAKE) -C ffi/java test
diff --git a/ffi/go/mcl/mcl.go b/ffi/go/mcl/mcl.go
index 091c2f0..61691a3 100644
--- a/ffi/go/mcl/mcl.go
+++ b/ffi/go/mcl/mcl.go
@@ -7,6 +7,8 @@ package mcl
#cgo bn256 LDFLAGS:-lmclbn256_dy -lmcl_dy
#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
#cgo bn384 LDFLAGS:-lmclbn384_dy -lmcl_dy
+#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4
+#cgo bn384_256 LDFLAGS:-lmclbn384_256_dy -lmcl_dy
#include <mcl/bn.h>
*/
import "C"
@@ -39,6 +41,17 @@ func Init(curve int) error {
return nil
}
+// 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)
diff --git a/ffi/go/mcl/mcl_test.go b/ffi/go/mcl/mcl_test.go
index ce29a50..16bb691 100644
--- a/ffi/go/mcl/mcl_test.go
+++ b/ffi/go/mcl/mcl_test.go
@@ -147,8 +147,10 @@ func TestMclMain(t *testing.T) {
t.Log("CurveFp254BNb")
testMcl(t, CurveFp254BNb)
if GetMaxOpUnitSize() == 6 {
- t.Log("CurveFp382_1")
- testMcl(t, CurveFp382_1)
+ if GetFrUnitSize() == 6 {
+ t.Log("CurveFp382_1")
+ testMcl(t, CurveFp382_1)
+ }
t.Log("BLS12_381")
testMcl(t, BLS12_381)
}