aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-10-22 16:36:00 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-10-22 16:36:00 +0800
commitc4ba9961024a76f7357b9ab19344c5e776245d84 (patch)
tree42dba519a2faec63169710d777cb298309a0fd32
parentae27eb0267ff59f562bcf0cefa45db23c7374467 (diff)
downloaddexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar.gz
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar.bz2
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar.lz
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar.xz
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.tar.zst
dexon-bls-c4ba9961024a76f7357b9ab19344c5e776245d84.zip
update new api of mclBn_init
-rw-r--r--ffi/go/bls/bls.go2
-rw-r--r--include/bls/bls.h10
-rw-r--r--include/bls/bls.hpp6
-rw-r--r--src/bls_c_impl.hpp8
-rw-r--r--test/bls_c_test.hpp6
5 files changed, 17 insertions, 15 deletions
diff --git a/ffi/go/bls/bls.go b/ffi/go/bls/bls.go
index 2448c3c..a7bbeb3 100644
--- a/ffi/go/bls/bls.go
+++ b/ffi/go/bls/bls.go
@@ -15,7 +15,7 @@ import "unsafe"
// call this function before calling all the other operations
// this function is not thread safe
func Init(curve int) error {
- err := C.blsInit(C.int(curve), C.MCLBN_FP_UNIT_SIZE)
+ err := C.blsInit(C.int(curve), C.MCLBN_COMPILED_TIME_VAR)
if err != 0 {
return fmt.Errorf("ERR Init curve=%d", curve)
}
diff --git a/include/bls/bls.h b/include/bls/bls.h
index 45bd839..6b7cbdd 100644
--- a/include/bls/bls.h
+++ b/include/bls/bls.h
@@ -57,12 +57,14 @@ typedef struct {
initialize this library
call this once before using the other functions
@param curve [in] enum value defined in mcl/bn.h
- @param maxUnitSize [in] MCLBN_FP_UNIT_SIZE (fixed)
- return 0 if success
+ @param compiledTimeVar [in] specify MCLBN_COMPILED_TIME_VAR,
+ which macro is used to make sure that the values
+ are the same when the library is built and used
+ @return 0 if success
@note blsInit() is thread safe and serialized if it is called simultaneously
but don't call it while using other functions.
*/
-BLS_DLL_API int blsInit(int curve, int maxUnitSize);
+BLS_DLL_API int blsInit(int curve, int compiledTimeVar);
BLS_DLL_API void blsIdSetInt(blsId *id, int x);
@@ -147,7 +149,7 @@ BLS_DLL_API void blsPublicKeySub(blsPublicKey *pub, const blsPublicKey *rhs);
BLS_DLL_API void blsSignatureSub(blsSignature *sig, const blsSignature *rhs);
// not thread safe version (old blsInit)
-BLS_DLL_API int blsInitNotThreadSafe(int curve, int maxUnitSize);
+BLS_DLL_API int blsInitNotThreadSafe(int curve, int compiledTimeVar);
BLS_DLL_API mclSize blsGetOpUnitSize(void);
// return strlen(buf) if success else 0
diff --git a/include/bls/bls.hpp b/include/bls/bls.hpp
index 722e4e2..b32b7e1 100644
--- a/include/bls/bls.hpp
+++ b/include/bls/bls.hpp
@@ -40,12 +40,12 @@ enum {
initialize this library
call this once before using the other method
@param curve [in] type of curve
- @param maxUnitSize [in] 4 or 6 (specify same value used in compiling for validation)
+ @param compiledTimevar [in] use the default value
@note init() is not thread safe
*/
-inline void init(int curve = mclBn_CurveFp254BNb, int maxUnitSize = MCLBN_FP_UNIT_SIZE)
+inline void init(int curve = mclBn_CurveFp254BNb, int compiledTimeVar = MCLBN_COMPILED_TIME_VAR)
{
- if (blsInit(curve, maxUnitSize) != 0) throw std::invalid_argument("blsInit");
+ if (blsInit(curve, compiledTimeVar) != 0) throw std::invalid_argument("blsInit");
}
inline size_t getOpUnitSize() { return blsGetOpUnitSize(); }
diff --git a/src/bls_c_impl.hpp b/src/bls_c_impl.hpp
index c041564..16b79f9 100644
--- a/src/bls_c_impl.hpp
+++ b/src/bls_c_impl.hpp
@@ -22,9 +22,9 @@ static mcl::FixedArray<Fp6, maxQcoeffN> g_Qcoeff; // precomputed Q
inline const G2& getQ() { return g_Q; }
inline const mcl::FixedArray<Fp6, maxQcoeffN>& getQcoeff() { return g_Qcoeff; }
-int blsInitNotThreadSafe(int curve, int maxUnitSize)
+int blsInitNotThreadSafe(int curve, int compiledTimeVar)
{
- int ret = mclBn_init(curve, maxUnitSize);
+ int ret = mclBn_init(curve, compiledTimeVar);
if (ret < 0) return ret;
bool b;
@@ -80,7 +80,7 @@ extern "C" BLS_DLL_API void blsFree(void *p)
#endif
#endif
-int blsInit(int curve, int maxUnitSize)
+int blsInit(int curve, int compiledTimeVar)
{
int ret = 0;
#ifdef USE_STD_MUTEX
@@ -92,7 +92,7 @@ int blsInit(int curve, int maxUnitSize)
#endif
static int g_curve = -1;
if (g_curve != curve) {
- ret = blsInitNotThreadSafe(curve, maxUnitSize);
+ ret = blsInitNotThreadSafe(curve, compiledTimeVar);
g_curve = curve;
}
return ret;
diff --git a/test/bls_c_test.hpp b/test/bls_c_test.hpp
index 7ecf42c..4991d36 100644
--- a/test/bls_c_test.hpp
+++ b/test/bls_c_test.hpp
@@ -99,7 +99,7 @@ CYBOZU_TEST_AUTO(multipleInit)
{
std::vector<Thread> vt(n);
for (size_t i = 0; i < n; i++) {
- vt[i].run(blsInit, MCL_BN254, MCLBN_FP_UNIT_SIZE);
+ vt[i].run(blsInit, MCL_BN254, MCLBN_COMPILED_TIME_VAR);
}
}
CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 4u);
@@ -107,7 +107,7 @@ CYBOZU_TEST_AUTO(multipleInit)
{
std::vector<Thread> vt(n);
for (size_t i = 0; i < n; i++) {
- vt[i].run(blsInit, MCL_BLS12_381, MCLBN_FP_UNIT_SIZE);
+ vt[i].run(blsInit, MCL_BLS12_381, MCLBN_COMPILED_TIME_VAR);
}
}
CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 6u);
@@ -326,7 +326,7 @@ CYBOZU_TEST_AUTO(all)
};
for (size_t i = 0; i < sizeof(tbl) / sizeof(tbl[0]); i++) {
printf("i=%d\n", (int)i);
- blsInit(tbl[i], MCLBN_FP_UNIT_SIZE);
+ blsInit(tbl[i], MCLBN_COMPILED_TIME_VAR);
bls_use_stackTest();
blsDataTest();
blsOrderTest(curveOrderTbl[i], fieldOrderTbl[i]);