aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-10-23 09:09:46 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-10-23 09:09:46 +0800
commit8ec3e3025785998b38dc7d3516471951ab558550 (patch)
tree6bd3fb5a82823e52cb9a3af60e2f26082fd72de2
parentc4ba9961024a76f7357b9ab19344c5e776245d84 (diff)
downloaddexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar.gz
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar.bz2
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar.lz
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar.xz
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.tar.zst
dexon-bls-8ec3e3025785998b38dc7d3516471951ab558550.zip
add bls384_256 and test it
-rw-r--r--Makefile20
-rw-r--r--src/bls_c384_256.cpp4
-rw-r--r--test/bls_c384_256_test.cpp3
-rw-r--r--test/bls_c_test.hpp4
4 files changed, 26 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 83fd691..ba0d0e4 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,8 @@ EXE_DIR=bin
CFLAGS += -std=c++11
LDFLAGS += -lpthread
-SRC_SRC=bls_c256.cpp bls_c384.cpp
-TEST_SRC=bls256_test.cpp bls384_test.cpp bls_c256_test.cpp bls_c384_test.cpp
+SRC_SRC=bls_c256.cpp bls_c384.cpp bls_c384_256.cpp
+TEST_SRC=bls256_test.cpp bls384_test.cpp bls_c256_test.cpp bls_c384_test.cpp bls_c384_256_test.cpp
SAMPLE_SRC=bls256_smpl.cpp bls384_smpl.cpp
CFLAGS+=-I../mcl/include -I./
@@ -21,11 +21,14 @@ SHARE_BASENAME_SUF?=_dy
BLS256_LIB=$(LIB_DIR)/libbls256.a
BLS384_LIB=$(LIB_DIR)/libbls384.a
+BLS384_256_LIB=$(LIB_DIR)/libbls384_256.a
BLS256_SNAME=bls256$(SHARE_BASENAME_SUF)
BLS384_SNAME=bls384$(SHARE_BASENAME_SUF)
+BLS384_256_SNAME=bls384_256$(SHARE_BASENAME_SUF)
BLS256_SLIB=$(LIB_DIR)/lib$(BLS256_SNAME).$(LIB_SUF)
BLS384_SLIB=$(LIB_DIR)/lib$(BLS384_SNAME).$(LIB_SUF)
-all: $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB)
+BLS384_256_SLIB=$(LIB_DIR)/lib$(BLS384_256_SNAME).$(LIB_SUF)
+all: $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB) $(BLS384_256_LIB) $(BLS384_256_SLIB)
MCL_LIB=../mcl/lib/libmcl.a
@@ -36,20 +39,26 @@ $(BLS256_LIB): $(OBJ_DIR)/bls_c256.o
$(AR) $@ $<
$(BLS384_LIB): $(OBJ_DIR)/bls_c384.o
$(AR) $@ $<
+$(BLS384_256_LIB): $(OBJ_DIR)/bls_c384_256.o
+ $(AR) $@ $<
ifneq ($(findstring $(OS),mac/mingw64),)
BLS256_SLIB_LDFLAGS+=-lgmpxx -lgmp -lcrypto -lstdc++
BLS384_SLIB_LDFLAGS+=-lgmpxx -lgmp -lcrypto -lstdc++
+ BLS384_256_SLIB_LDFLAGS+=-lgmpxx -lgmp -lcrypto -lstdc++
endif
ifeq ($(OS),mingw64)
CFLAGS+=-I../mcl
BLS256_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS256_SNAME).a
BLS384_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS384_SNAME).a
+ BLS384_256_SLIB_LDFLAGS+=-Wl,--out-implib,$(LIB_DIR)/lib$(BLS384_256_SNAME).a
endif
$(BLS256_SLIB): $(OBJ_DIR)/bls_c256.o $(MCL_LIB)
$(PRE)$(CXX) -shared -o $@ $< $(MCL_LIB) $(BLS256_SLIB_LDFLAGS)
$(BLS384_SLIB): $(OBJ_DIR)/bls_c384.o $(MCL_LIB)
$(PRE)$(CXX) -shared -o $@ $< $(MCL_LIB) $(BLS384_SLIB_LDFLAGS)
+$(BLS384_256_SLIB): $(OBJ_DIR)/bls_c384_256.o $(MCL_LIB)
+ $(PRE)$(CXX) -shared -o $@ $< $(MCL_LIB) $(BLS384_256_SLIB_LDFLAGS)
VPATH=test sample src
@@ -64,6 +73,9 @@ $(EXE_DIR)/%384_test.exe: $(OBJ_DIR)/%384_test.o $(BLS384_LIB) $(MCL_LIB)
$(EXE_DIR)/%256_test.exe: $(OBJ_DIR)/%256_test.o $(BLS256_LIB) $(MCL_LIB)
$(PRE)$(CXX) $< -o $@ $(BLS256_LIB) -lmcl -L../mcl/lib $(LDFLAGS)
+$(EXE_DIR)/%384_256_test.exe: $(OBJ_DIR)/%384_256_test.o $(BLS384_256_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(BLS384_256_LIB) -lmcl -L../mcl/lib $(LDFLAGS)
+
# sample exe links libbls256.a
$(EXE_DIR)/%.exe: $(OBJ_DIR)/%.o $(BLS256_LIB) $(MCL_LIB)
$(PRE)$(CXX) $< -o $@ $(BLS256_LIB) -lmcl -L../mcl/lib $(LDFLAGS)
@@ -103,7 +115,7 @@ bls-wasm:
$(MAKE) ../bls-wasm/bls_c.js
clean:
- $(RM) $(OBJ_DIR)/*.d $(OBJ_DIR)/*.o $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_SRC) $(ASM_OBJ) $(LLVM_SRC) $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB)
+ $(RM) $(OBJ_DIR)/*.d $(OBJ_DIR)/*.o $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_SRC) $(ASM_OBJ) $(LLVM_SRC) $(BLS256_LIB) $(BLS256_SLIB) $(BLS384_LIB) $(BLS384_SLIB) $(BLS384_256_LIB) $(BLS384_256_SLIB)
ALL_SRC=$(SRC_SRC) $(TEST_SRC) $(SAMPLE_SRC)
DEPEND_FILE=$(addprefix $(OBJ_DIR)/, $(ALL_SRC:.cpp=.d))
diff --git a/src/bls_c384_256.cpp b/src/bls_c384_256.cpp
new file mode 100644
index 0000000..3dcb3e7
--- /dev/null
+++ b/src/bls_c384_256.cpp
@@ -0,0 +1,4 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#define MCLBN_FR_UNIT_SIZE 4
+#include "bls_c_impl.hpp"
+
diff --git a/test/bls_c384_256_test.cpp b/test/bls_c384_256_test.cpp
new file mode 100644
index 0000000..6f153f9
--- /dev/null
+++ b/test/bls_c384_256_test.cpp
@@ -0,0 +1,3 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#define MCLBN_FR_UNIT_SIZE 4
+#include "bls_c_test.hpp"
diff --git a/test/bls_c_test.hpp b/test/bls_c_test.hpp
index 4991d36..1e11b88 100644
--- a/test/bls_c_test.hpp
+++ b/test/bls_c_test.hpp
@@ -309,8 +309,10 @@ CYBOZU_TEST_AUTO(all)
{
const int tbl[] = {
MCL_BN254,
-#if MCLBN_FP_UNIT_SIZE == 6
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
MCL_BN381_1,
+#endif
+#if MCLBN_FR_UNIT_SIZE == 6 && MCLBN_FP_UNIT_SIZE == 4
MCL_BLS12_381,
#endif
};