diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-04-06 10:46:57 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-04-06 10:46:57 +0800 |
commit | ec2fea6176b1830eb0def80db5162a3856421a6e (patch) | |
tree | fa8391aa2147ff26ba0b75953bcb563e43c58282 | |
parent | 4f0477170d6d442756f66d6e3ed187dd48edcb87 (diff) | |
download | tangerine-mcl-ec2fea6176b1830eb0def80db5162a3856421a6e.tar.gz tangerine-mcl-ec2fea6176b1830eb0def80db5162a3856421a6e.tar.zst tangerine-mcl-ec2fea6176b1830eb0def80db5162a3856421a6e.zip |
use new CurveParam name
-rw-r--r-- | include/mcl/aggregate_sig.hpp | 2 | ||||
-rw-r--r-- | include/mcl/bn.h | 24 | ||||
-rw-r--r-- | include/mcl/bn256.hpp | 7 | ||||
-rw-r--r-- | include/mcl/bn384.hpp | 7 | ||||
-rw-r--r-- | include/mcl/bn512.hpp | 2 | ||||
-rw-r--r-- | include/mcl/she.hpp | 2 | ||||
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | sample/pairing_c.c | 2 | ||||
-rw-r--r-- | test/aggregate_sig_test.cpp | 4 | ||||
-rw-r--r-- | test/bls12_test.cpp | 2 | ||||
-rw-r--r-- | test/bn512_test.cpp | 12 | ||||
-rw-r--r-- | test/bn_c_test.hpp | 14 | ||||
-rw-r--r-- | test/bn_test.cpp | 8 | ||||
-rw-r--r-- | test/glv_test.cpp | 6 | ||||
-rw-r--r-- | test/she_c_test.hpp | 6 | ||||
-rw-r--r-- | test/she_test.cpp | 12 |
16 files changed, 52 insertions, 60 deletions
diff --git a/include/mcl/aggregate_sig.hpp b/include/mcl/aggregate_sig.hpp index c2e93eb..f161f14 100644 --- a/include/mcl/aggregate_sig.hpp +++ b/include/mcl/aggregate_sig.hpp @@ -53,7 +53,7 @@ struct AGGST { static G2 Q_; static std::vector<bn_current::Fp6> Qcoeff_; public: - static void init(const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb) + static void init(const mcl::CurveParam& cp = mcl::BN254) { bn_current::initPairing(cp); BN::hashAndMapToG1(P_, "0"); diff --git a/include/mcl/bn.h b/include/mcl/bn.h index 1140c42..43df24c 100644 --- a/include/mcl/bn.h +++ b/include/mcl/bn.h @@ -100,11 +100,11 @@ enum { init library @param curve [in] type of bn curve @param maxUnitSize [in] MCLBN_FP_UNIT_SIZE - curve = MCLBN_CurveFp254BNb is allowed if maxUnitSize = 4 - curve = MCLBN_CurveFp254BNb/MCLBN_CurveFp382_1/MCLBN_CurveFp382_2 are allowed if maxUnitSize = 6 + curve = BN254/BN_SNARK1 is allowed if maxUnitSize = 4 + curve = BN381_1/BN381_2/BLS12_381 are allowed if maxUnitSize = 6 This parameter is used to detect a library compiled with different MCLBN_FP_UNIT_SIZE for safety. @note not threadsafe - @note MCLBN_init is used in libeay32 + @note BN_init is used in libeay32 */ MCLBN_DLL_API int mclBn_init(int curve, int maxUnitSize); @@ -115,25 +115,27 @@ MCLBN_DLL_API int mclBn_init(int curve, int maxUnitSize); G1 is a curve defined on Fp serialized size of elements - |Fr| = |G1| = 32 bytes (if CurveFp254BNb), 48 bytes (if CurevFp382_{1,2}), 58 bytes (if CurveFp462) + |Fr| |Fp| + BN254 32 32 + BN381 48 48 + BLS12_381 32 48 + BN462 58 58 + |G1| = |Fp| |G2| = |G1| * 2 |GT| = |G1| * 12 */ /* return the num of Unit(=uint64_t) to store Fr - 4 if curve is mclBn_CurveFp254BNb - 6 if curve is mclBn_CurveFp382_{1,2} - 8 if curve is mclBn_CurveFp462 */ MCLBN_DLL_API int mclBn_getOpUnitSize(); /* - return bytes for serialized G1 - 32 if mclBn_CurveFp254BNb - 48 if mclBn_CurveFp382_{1,2} - 58 if mclBn_CurveFpA462 + return bytes for serialized G1(=Fp) */ MCLBN_DLL_API int mclBn_getG1ByteSize(); +/* + return bytes for serialized Fr +*/ MCLBN_DLL_API int mclBn_getFrByteSize(); /* diff --git a/include/mcl/bn256.hpp b/include/mcl/bn256.hpp index ef12d2b..ac44e70 100644 --- a/include/mcl/bn256.hpp +++ b/include/mcl/bn256.hpp @@ -27,7 +27,7 @@ typedef BN::Fp12 GT; /* the order of G1 is r */ typedef mcl::FpT<local::FrTag, 256> Fr; -static inline void initPairing(const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb, fp::Mode mode = fp::FP_AUTO) +static inline void initPairing(const mcl::CurveParam& cp = mcl::BN254, fp::Mode mode = fp::FP_AUTO) { BN::init(cp, mode); G1::setCompressedExpression(); @@ -35,10 +35,5 @@ static inline void initPairing(const mcl::CurveParam& cp = mcl::bn::CurveFp254BN Fr::init(BN::param.r); } -static inline void bn256init(const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb, fp::Mode mode = fp::FP_AUTO) -{ - initPairing(cp, mode); -} - } } // mcl::bn256 diff --git a/include/mcl/bn384.hpp b/include/mcl/bn384.hpp index 20dcbcf..21800c6 100644 --- a/include/mcl/bn384.hpp +++ b/include/mcl/bn384.hpp @@ -27,7 +27,7 @@ typedef BN::Fp12 GT; /* the order of G1 is r */ typedef mcl::FpT<local::FrTag, 384> Fr; -static inline void initPairing(const mcl::CurveParam& cp = mcl::bn::CurveFp382_2, fp::Mode mode = fp::FP_AUTO) +static inline void initPairing(const mcl::CurveParam& cp = mcl::BN381_1, fp::Mode mode = fp::FP_AUTO) { BN::init(cp, mode); G1::setCompressedExpression(); @@ -35,10 +35,5 @@ static inline void initPairing(const mcl::CurveParam& cp = mcl::bn::CurveFp382_2 Fr::init(BN::param.r); } -static inline void bn384init(const mcl::CurveParam& cp = mcl::bn::CurveFp382_2, fp::Mode mode = fp::FP_AUTO) -{ - initPairing(cp, mode); -} - } } // mcl::bn384 diff --git a/include/mcl/bn512.hpp b/include/mcl/bn512.hpp index 5dc84b5..2a5d3f7 100644 --- a/include/mcl/bn512.hpp +++ b/include/mcl/bn512.hpp @@ -27,7 +27,7 @@ typedef BN::Fp12 GT; /* the order of G1 is r */ typedef mcl::FpT<local::FrTag, 512> Fr; -static inline void initPairing(const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb, fp::Mode mode = fp::FP_AUTO) +static inline void initPairing(const mcl::CurveParam& cp = mcl::BN462, fp::Mode mode = fp::FP_AUTO) { BN::init(cp, mode); G1::setCompressedExpression(); diff --git a/include/mcl/she.hpp b/include/mcl/she.hpp index 610581c..f934663 100644 --- a/include/mcl/she.hpp +++ b/include/mcl/she.hpp @@ -506,7 +506,7 @@ public: typedef CipherTextAT<G1> CipherTextG1; typedef CipherTextAT<G2> CipherTextG2; - static void init(const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb) + static void init(const mcl::CurveParam& cp = mcl::BN254) { bn_current::initPairing(cp); BN::hashAndMapToG1(P_, "0"); @@ -64,7 +64,7 @@ BN462 | 2.16| 14.73| 22.77| * Firefox : 64-bit version 58.
* iPhone7 : iOS 11.2.1.
* BN254 is by `test/bn_test.cpp`.
-* BN381\_1 and CurveFp462 are by `test/bn512_test.cpp`.
+* BN381\_1 and BN462 are by `test/bn512_test.cpp`.
* All the timings are given in ms(milliseconds).
The other benchmark results are [bench.txt](bench.txt).
diff --git a/sample/pairing_c.c b/sample/pairing_c.c index 3337afe..b9f159a 100644 --- a/sample/pairing_c.c +++ b/sample/pairing_c.c @@ -11,7 +11,7 @@ int main() char buf[1024]; const char *aStr = "123"; const char *bStr = "456"; - mclBn_init(mclBn_CurveFp254BNb, MCLBN_FP_UNIT_SIZE); + mclBn_init(MCL_BN254, MCLBN_FP_UNIT_SIZE); mclBnFr a, b, ab; mclBnG1 P, aP; mclBnG2 Q, bQ; diff --git a/test/aggregate_sig_test.cpp b/test/aggregate_sig_test.cpp index ff90507..c3a0e75 100644 --- a/test/aggregate_sig_test.cpp +++ b/test/aggregate_sig_test.cpp @@ -9,8 +9,8 @@ using namespace mcl::aggs; CYBOZU_TEST_AUTO(init) { AGGS::init(); -// AGGS::init(mcl::bn::CurveFp382_1); -// AGGS::init(mcl::bn::CurveFp462); +// AGGS::init(mcl::BN381_1); +// AGGS::init(mcl::BLS12_381); SecretKey sec; sec.init(); PublicKey pub; diff --git a/test/bls12_test.cpp b/test/bls12_test.cpp index 7a60e8d..b0344fe 100644 --- a/test/bls12_test.cpp +++ b/test/bls12_test.cpp @@ -34,7 +34,7 @@ const struct TestSet { } g_testSetTbl[] = { { mcl::BLS12_381, - "CurveFp381", + "BLS12_381", "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", "0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", { diff --git a/test/bn512_test.cpp b/test/bn512_test.cpp index dae3d0e..3f42ea5 100644 --- a/test/bn512_test.cpp +++ b/test/bn512_test.cpp @@ -38,14 +38,14 @@ void testCurve(const mcl::CurveParam& cp) CYBOZU_TEST_AUTO(pairing) { - puts("CurveFp462"); + puts("BN462"); testCurve(mcl::BN462); - puts("CurveFp382_1"); + puts("BN381_1"); testCurve(mcl::BN381_1); - puts("CurveFp382_2"); - testCurve(mcl::BN381_2); - puts("CurveFp254BNb"); - testCurve(mcl::bn::CurveFp254BNb); + puts("BLS12_381"); + testCurve(mcl::BLS12_381); + puts("BN254"); + testCurve(mcl::BN254); } int main(int argc, char *argv[]) diff --git a/test/bn_c_test.hpp b/test/bn_c_test.hpp index 305e35b..5f34d2f 100644 --- a/test/bn_c_test.hpp +++ b/test/bn_c_test.hpp @@ -28,14 +28,14 @@ CYBOZU_TEST_AUTO(init) // CYBOZU_TEST_EQUAL(ret, 0); #if MCLBN_FP_UNIT_SIZE == 4 - printf("test MCLBN_curveFp254BNb %d\n", MCLBN_FP_UNIT_SIZE); - ret = mclBn_init(mclBn_CurveFp254BNb, MCLBN_FP_UNIT_SIZE); + printf("test BN254 %d\n", MCLBN_FP_UNIT_SIZE); + ret = mclBn_init(MCL_BN254, MCLBN_FP_UNIT_SIZE); #elif MCLBN_FP_UNIT_SIZE == 6 - printf("test MCLBN_curveFp382_1 %d\n", MCLBN_FP_UNIT_SIZE); - ret = mclBn_init(mclBn_CurveFp382_1, MCLBN_FP_UNIT_SIZE); + printf("test BN381_1 %d\n", MCLBN_FP_UNIT_SIZE); + ret = mclBn_init(MCL_BN381_1, MCLBN_FP_UNIT_SIZE); #elif MCLBN_FP_UNIT_SIZE == 8 - printf("test MCLBN_curveFp462 %d\n", MCLBN_FP_UNIT_SIZE); - ret = mclBn_init(mclBn_CurveFp462, MCLBN_FP_UNIT_SIZE); + printf("test BN462 %d\n", MCLBN_FP_UNIT_SIZE); + ret = mclBn_init(MCL_BN462, MCLBN_FP_UNIT_SIZE); #else #error "bad MCLBN_FP_UNIT_SIZE" #endif @@ -421,7 +421,7 @@ CYBOZU_TEST_AUTO(serialize) CYBOZU_TEST_AUTO(badG2) { int ret; - ret = mclBn_init(mclBn_CurveFp382_1, MCLBN_FP_UNIT_SIZE); + ret = mclBn_init(MCL_BN381_1, MCLBN_FP_UNIT_SIZE); CYBOZU_TEST_EQUAL(ret, 0); const char *s = "1 18d3d8c085a5a5e7553c3a4eb628e88b8465bf4de2612e35a0a4eb018fb0c82e9698896031e62fd7633ffd824a859474 1dc6edfcf33e29575d4791faed8e7203832217423bf7f7fbf1f6b36625b12e7132c15fbc15562ce93362a322fb83dd0d 65836963b1f7b6959030ddfa15ab38ce056097e91dedffd996c1808624fa7e2644a77be606290aa555cda8481cfb3cb 1b77b708d3d4f65aeedf54b58393463a42f0dc5856baadb5ce608036baeca398c5d9e6b169473a8838098fd72fd28b50"; mclBnG2 Q; diff --git a/test/bn_test.cpp b/test/bn_test.cpp index 6fb3b7a..8e31b8a 100644 --- a/test/bn_test.cpp +++ b/test/bn_test.cpp @@ -32,8 +32,8 @@ const struct TestSet { const char *e; } g_testSetTbl[] = { { - mcl::bn::CurveFp254BNb, - "CurveFp254BNb", + mcl::BN254, + "BN254", { "12723517038133731887338407189719511622662176727675373276651903807414909099441", "4168783608814932154536427934509895782246573715297911553964171371032945126671", @@ -57,8 +57,8 @@ const struct TestSet { "10688745994254573144943003027511098295097561129365638275727908595677791826005" }, { - mcl::bn::CurveSNARK1, - "CurveSNARK1", + mcl::BN_SNARK1, + "BN_SNARK1", { "15267802884793550383558706039165621050290089775961208824303765753922461897946", "9034493566019742339402378670461897774509967669562610788113215988055021632533", diff --git a/test/glv_test.cpp b/test/glv_test.cpp index a3a44b9..d6a8401 100644 --- a/test/glv_test.cpp +++ b/test/glv_test.cpp @@ -188,9 +188,9 @@ void testGLV2() CYBOZU_TEST_AUTO(glv) { const mcl::CurveParam tbl[] = { - mcl::bn::CurveFp254BNb, - mcl::bn::CurveFp382_1, - mcl::bn::CurveFp382_2, + mcl::BN254, + mcl::BN381_1, + mcl::BN381_2, }; for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) { const mcl::CurveParam& cp = tbl[i]; diff --git a/test/she_c_test.hpp b/test/she_c_test.hpp index 77bf893..6e30e29 100644 --- a/test/she_c_test.hpp +++ b/test/she_c_test.hpp @@ -11,11 +11,11 @@ CYBOZU_TEST_AUTO(init) { int curve; #if MCLBN_FP_UNIT_SIZE == 4 - curve = mclBn_CurveFp254BNb; + curve = MCL_BN254; #elif MCLBN_FP_UNIT_SIZE == 6 - curve = mclBn_CurveFp382_1; + curve = MCL_BN381_1; #elif MCLBN_FP_UNIT_SIZE == 8 - curve = mclBn_CurveFp462; + curve = MCL_BN462; #endif int ret; ret = sheInit(curve, MCLBN_FP_UNIT_SIZE); diff --git a/test/she_test.cpp b/test/she_test.cpp index c07038e..d07eac5 100644 --- a/test/she_test.cpp +++ b/test/she_test.cpp @@ -14,14 +14,14 @@ SecretKey g_sec; CYBOZU_TEST_AUTO(log) { #if MCLBN_FP_UNIT_SIZE == 4 - const mcl::CurveParam& cp = mcl::bn::CurveFp254BNb; - puts("CurveFp254BNb"); + const mcl::CurveParam& cp = mcl::BN254; + puts("BN254"); #elif MCLBN_FP_UNIT_SIZE == 6 - const mcl::CurveParam& cp = mcl::bn::CurveFp382_1; - puts("CurveFp382_1"); + const mcl::CurveParam& cp = mcl::BN381_1; + puts("BN381_1"); #elif MCLBN_FP_UNIT_SIZE == 8 - const mcl::CurveParam& cp = mcl::bn::CurveFp462; - puts("CurveFp462"); + const mcl::CurveParam& cp = mcl::BN462; + puts("BN462"); #endif SHE::init(cp); G1 P; |