aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-09-09 10:01:03 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-09-09 10:01:03 +0800
commita872a1544d78e79f93c67af64ed2391a3a70302b (patch)
tree6bfae498c439ad7b540df555c9db6153b0b01b23
parent04ced9f67bab87c48a474716fd31b2dfa663db89 (diff)
downloaddexon-mcl-a872a1544d78e79f93c67af64ed2391a3a70302b.tar.gz
dexon-mcl-a872a1544d78e79f93c67af64ed2391a3a70302b.tar.zst
dexon-mcl-a872a1544d78e79f93c67af64ed2391a3a70302b.zip
update how to make QcoeffTbl
-rw-r--r--Makefile8
-rw-r--r--misc/precompute.cpp18
2 files changed, 23 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6a33dea..12658ed 100644
--- a/Makefile
+++ b/Makefile
@@ -304,6 +304,14 @@ bin/pairing_c_min.exe: sample/pairing_c.c include/mcl/vint.hpp src/fp.cpp includ
# $(CXX) -o $@ sample/pairing_c.c src/fp.cpp src/bn_c256.cpp -O2 -g -I./include -fno-exceptions -fno-rtti -fno-threadsafe-statics -DMCL_DONT_USE_XBYAK -DMCL_DONT_USE_OPENSSL -DMCL_USE_VINT -DMCL_SIZEOF_UNIT=8 -DMCL_VINT_FIXED_BUFFER -DCYBOZU_DONT_USE_EXCEPTION -DCYBOZU_DONT_USE_STRING -DMCL_DONT_USE_CSPRNG -DMCL_MAX_BIT_SIZE=256 -DMCL_VINT_64BIT_PORTABLE -DNDEBUG -pg
$(CXX) -o $@ sample/pairing_c.c src/fp.cpp src/bn_c256.cpp -O2 -g -I./include -fno-threadsafe-statics -DMCL_DONT_USE_XBYAK -DMCL_DONT_USE_OPENSSL -DMCL_USE_VINT -DMCL_SIZEOF_UNIT=8 -DMCL_VINT_FIXED_BUFFER -DMCL_DONT_USE_CSPRNG -DMCL_MAX_BIT_SIZE=256 -DMCL_VINT_64BIT_PORTABLE -DNDEBUG
+make_tbl:
+ $(MAKE) ../bls/src/qcoeff-bn254.hpp
+
+../bls/src/qcoeff-bn254.hpp: $(MCL_LIB) misc/precompute.cpp
+ $(CXX) -o misc/precompute misc/precompute.cpp $(CFLAGS) $(MCL_LIB) $(LDFLAGS)
+ ./misc/precompute > ../bls/src/qcoeff-bn254.hpp
+
+
clean:
$(RM) $(MCL_LIB) $(MCL_SLIB) $(BN256_LIB) $(BN256_SLIB) $(BN384_LIB) $(BN384_SLIB) $(BN512_LIB) $(BN512_SLIB) $(SHE256_LIB) $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_OBJ) $(LIB_OBJ) $(BN256_OBJ) $(BN384_OBJ) $(BN512_OBJ) $(LLVM_SRC) $(FUNC_LIST) src/*.ll lib/*.a
diff --git a/misc/precompute.cpp b/misc/precompute.cpp
index 5661159..63cdd66 100644
--- a/misc/precompute.cpp
+++ b/misc/precompute.cpp
@@ -1,4 +1,4 @@
-#include <mcl/bn384.hpp>
+#include <mcl/bn256.hpp>
#include <iostream>
using namespace mcl::bn;
@@ -10,9 +10,21 @@ int main()
mapToG2(Q, 1);
std::vector<Fp6> Qcoeff;
precomputeG2(Qcoeff, Q);
- printf("static const char *tbl[%d] = {\n", (int)Qcoeff.size());
+ puts("#if MCL_SIZEOF_UNIT == 8");
+ puts("static const uint64_t QcoeffTblBN254[][6][4] = {");
for (size_t i = 0; i < Qcoeff.size(); i++) {
- printf("\"%s\",\n", Qcoeff[i].getStr(16).c_str());
+ const Fp6& x6 = Qcoeff[i];
+ puts("\t{");
+ for (size_t j = 0; j < 6; j++) {
+ printf("\t\t{");
+ const Fp& x = x6.getFp0()[j];
+ for (size_t k = 0; k < 4; k++) {
+ printf("0x%016llxull,", (unsigned long long)x.getUnit()[k]);
+ }
+ puts("},");
+ }
+ puts("\t},");
}
puts("};");
+ puts("#endif");
}