aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-04-30 14:17:52 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-04-30 14:17:52 +0800
commit0f16acd7e54ce18711e839766669895cbfeb666f (patch)
treecbb96a72b2154127cdaa3ed380a58b99de09611a
parent2337888c3e22896ed8bfe0b691ffa6927b58bb62 (diff)
downloaddexon-mcl-0f16acd7e54ce18711e839766669895cbfeb666f.tar.gz
dexon-mcl-0f16acd7e54ce18711e839766669895cbfeb666f.tar.zst
dexon-mcl-0f16acd7e54ce18711e839766669895cbfeb666f.zip
test of she_c384
-rw-r--r--Makefile13
-rw-r--r--src/she_c384.cpp2
-rw-r--r--test/she_c384_test.cpp2
-rw-r--r--test/she_c_test.hpp5
4 files changed, 18 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index c5965e7..539e2e8 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ OBJ_DIR=obj
EXE_DIR=bin
SRC_SRC=fp.cpp bn_c256.cpp bn_c384.cpp bn_c512.cpp she_c256.cpp
TEST_SRC=fp_test.cpp ec_test.cpp fp_util_test.cpp window_method_test.cpp elgamal_test.cpp fp_tower_test.cpp gmp_test.cpp bn_test.cpp bn384_test.cpp glv_test.cpp paillier_test.cpp she_test.cpp vint_test.cpp bn512_test.cpp
-TEST_SRC+=bn_c256_test.cpp bn_c384_test.cpp bn_c512_test.cpp she_c256_test.cpp
+TEST_SRC+=bn_c256_test.cpp bn_c384_test.cpp bn_c512_test.cpp she_c256_test.cpp she_c384_test.cpp
TEST_SRC+=aggregate_sig_test.cpp
TEST_SRC+=bls12_test.cpp
ifeq ($(CPU),x86-64)
@@ -41,7 +41,8 @@ BN384_SLIB=$(LIB_DIR)/lib$(BN384_SNAME).$(LIB_SUF)
BN512_LIB=$(LIB_DIR)/libmclbn512.a
BN512_SLIB=$(LIB_DIR)/lib$(BN512_SNAME).$(LIB_SUF)
SHE256_LIB=$(LIB_DIR)/libmclshe256.a
-all: $(MCL_LIB) $(MCL_SLIB) $(BN256_LIB) $(BN256_SLIB) $(BN384_LIB) $(BN384_SLIB) $(BN512_LIB) $(BN512_SLIB) $(SHE256_LIB)
+SHE384_LIB=$(LIB_DIR)/libmclshe384.a
+all: $(MCL_LIB) $(MCL_SLIB) $(BN256_LIB) $(BN256_SLIB) $(BN384_LIB) $(BN384_SLIB) $(BN512_LIB) $(BN512_SLIB) $(SHE256_LIB) $(SHE384_lib)
#LLVM_VER=-3.8
LLVM_LLC=llc$(LLVM_VER)
@@ -68,6 +69,7 @@ BN256_OBJ=$(OBJ_DIR)/bn_c256.o
BN384_OBJ=$(OBJ_DIR)/bn_c384.o
BN512_OBJ=$(OBJ_DIR)/bn_c512.o
SHE256_OBJ=$(OBJ_DIR)/she_c256.o
+SHE384_OBJ=$(OBJ_DIR)/she_c384.o
FUNC_LIST=src/func.list
MCL_USE_LLVM?=1
ifeq ($(MCL_USE_LLVM),1)
@@ -115,6 +117,9 @@ $(BN256_LIB): $(BN256_OBJ)
$(SHE256_LIB): $(SHE256_OBJ)
$(AR) $@ $(SHE256_OBJ)
+$(SHE384_LIB): $(SHE384_OBJ)
+ $(AR) $@ $(SHE384_OBJ)
+
ifeq ($(OS),mac)
MAC_LDFLAGS+=-l$(MCL_SNAME) -L./lib
endif
@@ -214,6 +219,9 @@ $(EXE_DIR)/pairing_c.exe: $(OBJ_DIR)/pairing_c.o $(BN256_LIB) $(MCL_LIB)
$(EXE_DIR)/she_c256_test.exe: $(OBJ_DIR)/she_c256_test.o $(SHE256_LIB) $(MCL_LIB)
$(PRE)$(CXX) $< -o $@ $(SHE256_LIB) $(MCL_LIB) $(LDFLAGS)
+$(EXE_DIR)/she_c384_test.exe: $(OBJ_DIR)/she_c384_test.o $(SHE384_LIB) $(MCL_LIB)
+ $(PRE)$(CXX) $< -o $@ $(SHE384_LIB) $(MCL_LIB) $(LDFLAGS)
+
SAMPLE_EXE=$(addprefix $(EXE_DIR)/,$(addsuffix .exe,$(basename $(SAMPLE_SRC))))
sample: $(SAMPLE_EXE) $(MCL_LIB)
@@ -233,6 +241,7 @@ ifeq ($(MCL_USE_LLVM),2)
endif
../she-wasm/she_c.js: $(JS_DEP) Makefile
emcc -o $@ src/fp.cpp src/she_c256.cpp $(EMCC_OPT) -s TOTAL_MEMORY=67108864
+# emcc -o $@ src/fp.cpp src/she_c384.cpp $(EMCC_OPT) -s TOTAL_MEMORY=67108864
../mcl-wasm/mcl_c.js: src/fp.cpp src/bn_c256.cpp include/mcl/bn.h Makefile
emcc -o $@ src/fp.cpp src/bn_c256.cpp $(EMCC_OPT) -DMCL_MAX_BIT_SIZE=256
diff --git a/src/she_c384.cpp b/src/she_c384.cpp
new file mode 100644
index 0000000..bfc456a
--- /dev/null
+++ b/src/she_c384.cpp
@@ -0,0 +1,2 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#include "she_c_impl.hpp"
diff --git a/test/she_c384_test.cpp b/test/she_c384_test.cpp
new file mode 100644
index 0000000..5c7bd98
--- /dev/null
+++ b/test/she_c384_test.cpp
@@ -0,0 +1,2 @@
+#define MCLBN_FP_UNIT_SIZE 6
+#include "she_c_test.hpp"
diff --git a/test/she_c_test.hpp b/test/she_c_test.hpp
index 91d6775..e5e8c2e 100644
--- a/test/she_c_test.hpp
+++ b/test/she_c_test.hpp
@@ -170,10 +170,11 @@ CYBOZU_TEST_AUTO(serialize)
shePublicKey pub1, pub2;
sheGetPublicKey(&pub1, &sec1);
- char buf1[2048], buf2[2048];
+ char buf1[4096], buf2[4096];
size_t n1, n2;
size_t r, size;
const size_t sizeofFr = mclBn_getOpUnitSize() * 8;
+ const size_t sizeofFp = mclBn_getG1ByteSize();
size = sizeofFr * 2;
n1 = sheSecretKeySerialize(buf1, sizeof(buf1), &sec1);
@@ -219,7 +220,7 @@ CYBOZU_TEST_AUTO(serialize)
CYBOZU_TEST_EQUAL(n2, size);
CYBOZU_TEST_EQUAL_ARRAY(buf1, buf2, n2);
- size = sizeofFr * 12 * 4;
+ size = sizeofFp * 12 * 4;
n1 = sheCipherTextGTSerialize(buf1, sizeof(buf1), &ct1);
CYBOZU_TEST_EQUAL(n1, size);
r = sheCipherTextGTDeserialize(&ct2, buf1, n1);