aboutsummaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-12-05 10:59:06 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-12-05 10:59:06 +0800
commitf63e122a2cff8d0e20288b897c449a42cdf84897 (patch)
treebed5a15333c3d04fbf23f583a56bbc64c8c9d271 /ffi
parentafbcbeaaf3b5f9962af382d668ae5bcad337f661 (diff)
downloaddexon-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
Diffstat (limited to 'ffi')
-rw-r--r--ffi/go/bls/bls.go10
-rw-r--r--ffi/go/bls/bls_test.go6
-rw-r--r--ffi/go/bls/mcl.go15
3 files changed, 25 insertions, 6 deletions
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)