aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-04-03 09:48:08 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-04-03 09:48:12 +0800
commit3b815cf485e4aea6e6249549b7126dfad26978e7 (patch)
tree0beabf03e492936ab474321f746173f66c4532bc
parent1cdd69e265a21aa71968f9dee45141a87d1d59dd (diff)
downloaddexon-mcl-3b815cf485e4aea6e6249549b7126dfad26978e7.tar.gz
dexon-mcl-3b815cf485e4aea6e6249549b7126dfad26978e7.tar.zst
dexon-mcl-3b815cf485e4aea6e6249549b7126dfad26978e7.zip
rename curveParam
-rw-r--r--include/mcl/bls12.hpp4
-rw-r--r--include/mcl/bls12_381.hpp2
-rw-r--r--include/mcl/bn.h3
-rw-r--r--include/mcl/curve_type.h15
-rw-r--r--include/mcl/pairing_util.hpp43
-rw-r--r--test/bls12_test.cpp2
-rw-r--r--test/bn384_test.cpp6
-rw-r--r--test/bn512_test.cpp6
-rw-r--r--test/bn_test.cpp2
9 files changed, 38 insertions, 45 deletions
diff --git a/include/mcl/bls12.hpp b/include/mcl/bls12.hpp
index f97c2f7..db08301 100644
--- a/include/mcl/bls12.hpp
+++ b/include/mcl/bls12.hpp
@@ -88,7 +88,7 @@ struct ParamT : public util::CommonParamT<Fp> {
typedef mcl::EcT<Fp2> G2;
MapToT<Fp> mapTo;
- void init(const CurveParam& cp = CurveFp381, fp::Mode mode = fp::FP_AUTO)
+ void init(const CurveParam& cp = mcl::BLS12_381, fp::Mode mode = fp::FP_AUTO)
{
Common::initCommonParam(cp, mode);
mapTo.init(this->z);
@@ -107,7 +107,7 @@ struct BLS12T : mcl::util::BasePairingT<BLS12T<Fp>, Fp, ParamT<Fp> > {
typedef util::HaveFrobenius<G2> G2withF;
typedef mcl::FpDblT<Fp> FpDbl;
typedef mcl::Fp2DblT<Fp> Fp2Dbl;
- static void init(const mcl::bls12::CurveParam& cp = CurveFp381, fp::Mode mode = fp::FP_AUTO)
+ static void init(const mcl::CurveParam& cp = mcl::BLS12_381, fp::Mode mode = fp::FP_AUTO)
{
Base::param.init(cp, mode);
G2withF::init(cp.isMtype);
diff --git a/include/mcl/bls12_381.hpp b/include/mcl/bls12_381.hpp
index e5e4906..24a2e34 100644
--- a/include/mcl/bls12_381.hpp
+++ b/include/mcl/bls12_381.hpp
@@ -27,7 +27,7 @@ typedef BLS12::Fp12 GT;
/* the order of G1 is r */
typedef mcl::FpT<local::FrTag, 256> Fr;
-static inline void initPairing(const mcl::bls12::CurveParam& cp = mcl::bls12::CurveFp381, fp::Mode mode = fp::FP_AUTO)
+static inline void initPairing(const mcl::bls12::CurveParam& cp = mcl::BLS12_381, fp::Mode mode = fp::FP_AUTO)
{
BLS12::init(cp, mode);
G1::setCompressedExpression();
diff --git a/include/mcl/bn.h b/include/mcl/bn.h
index c064a01..f4dddce 100644
--- a/include/mcl/bn.h
+++ b/include/mcl/bn.h
@@ -85,8 +85,6 @@ typedef struct {
*/
MCLBN_DLL_API int mclBn_setErrFile(const char *name);
-#ifndef MCL_CURVE_TYPE_DEFINED
-#define MCL_CURVE_TYPE_DEFINED
enum {
mclBn_CurveFp254BNb = 0,
mclBn_CurveFp382_1 = 1,
@@ -95,7 +93,6 @@ enum {
mclBn_CurveSNARK1 = 4,
mclBls12_CurveFp381 = 5
};
-#endif
/*
init library
diff --git a/include/mcl/curve_type.h b/include/mcl/curve_type.h
index 7ab3de6..b7b0118 100644
--- a/include/mcl/curve_type.h
+++ b/include/mcl/curve_type.h
@@ -7,14 +7,11 @@
http://opensource.org/licenses/BSD-3-Clause
*/
-#ifndef MCL_CURVE_TYPE_DEFINED
-#define MCL_CURVE_TYPE_DEFINED
enum {
- mclBn_CurveFp254BNb = 0,
- mclBn_CurveFp382_1 = 1,
- mclBn_CurveFp382_2 = 2,
- mclBn_CurveFp462 = 3,
- mclBn_CurveSNARK1 = 4,
- mclBls12_CurveFp381 = 5
+ MCL_BN254BNb = 0,
+ MCL_BN382_1 = 1,
+ MCL_BN382_2 = 2,
+ MCL_BN462 = 3,
+ MCL_BN_SNARK1 = 4,
+ MCL_BLS12_381 = 5
};
-#endif
diff --git a/include/mcl/pairing_util.hpp b/include/mcl/pairing_util.hpp
index 4214637..b65f41e 100644
--- a/include/mcl/pairing_util.hpp
+++ b/include/mcl/pairing_util.hpp
@@ -37,32 +37,31 @@ struct CurveParam {
bool operator!=(const CurveParam& rhs) const { return !operator==(rhs); }
};
-namespace bn {
-
-const CurveParam CurveFp254BNb = { "-0x4080000000000001", 2, 1, false, mclBn_CurveFp254BNb }; // -(2^62 + 2^55 + 1)
+const CurveParam BN254BNb = { "-0x4080000000000001", 2, 1, false, MCL_BN254BNb }; // -(2^62 + 2^55 + 1)
// provisional(experimental) param with maxBitSize = 384
-const CurveParam CurveFp382_1 = { "-0x400011000000000000000001", 2, 1, false, mclBn_CurveFp382_1 }; // -(2^94 + 2^76 + 2^72 + 1) // A Family of Implementation-Friendly BN Elliptic Curves
-const CurveParam CurveFp382_2 = { "-0x400040090001000000000001", 2, 1, false, mclBn_CurveFp382_2 }; // -(2^94 + 2^78 + 2^67 + 2^64 + 2^48 + 1) // used in relic-toolkit
-const CurveParam CurveFp462 = { "0x4001fffffffffffffffffffffbfff", 5, 2, false, mclBn_CurveFp462 }; // 2^114 + 2^101 - 2^14 - 1 // https://eprint.iacr.org/2017/334
-const CurveParam CurveSNARK1 = { "4965661367192848881", 3, 9, false, mclBn_CurveSNARK1 };
+const CurveParam BN382_1 = { "-0x400011000000000000000001", 2, 1, false, MCL_BN382_1 }; // -(2^94 + 2^76 + 2^72 + 1) // A Family of Implementation-Friendly BN Elliptic Curves
+const CurveParam BN382_2 = { "-0x400040090001000000000001", 2, 1, false, MCL_BN382_2 }; // -(2^94 + 2^78 + 2^67 + 2^64 + 2^48 + 1) // used in relic-toolkit
+const CurveParam BN462 = { "0x4001fffffffffffffffffffffbfff", 5, 2, false, MCL_BN462 }; // 2^114 + 2^101 - 2^14 - 1 // https://eprint.iacr.org/2017/334
+const CurveParam BN_SNARK1 = { "4965661367192848881", 3, 9, false, MCL_BN_SNARK1 };
+const CurveParam BLS12_381 = { "-0xd201000000010000", 4, 1, true, MCL_BLS12_381 };
+namespace bn {
+static const CurveParam& CurveFp254BNb = BN254BNb;
+static const CurveParam& CurveFp382_1 = BN382_1;
+static const CurveParam& CurveFp382_2 = BN382_2;
+static const CurveParam& CurveFp462 = BN462;
+static const CurveParam& CurveSNARK1 = BN_SNARK1;
} // mcl::bn
-namespace bls12 {
-
-const CurveParam CurveFp381 = { "-0xd201000000010000", 4, 1, true, mclBls12_CurveFp381 };
-
-} // mcl::bls12
-
inline const CurveParam& getCurveParam(int type)
{
switch (type) {
- case mclBn_CurveFp254BNb: return bn::CurveFp254BNb;
- case mclBn_CurveFp382_1: return bn::CurveFp382_1;
- case mclBn_CurveFp382_2: return bn::CurveFp382_2;
- case mclBn_CurveFp462: return bn::CurveFp462;
- case mclBn_CurveSNARK1: return bn::CurveSNARK1;
- case mclBls12_CurveFp381: return bls12::CurveFp381;
+ case MCL_BN254BNb: return mcl::BN254BNb;
+ case MCL_BN382_1: return mcl::BN382_1;
+ case MCL_BN382_2: return mcl::BN382_2;
+ case MCL_BN462: return mcl::BN462;
+ case MCL_BN_SNARK1: return mcl::BN_SNARK1;
+ case MCL_BLS12_381: return mcl::BLS12_381;
default:
throw cybozu::Exception("getCurveParam:bad type") << type;
}
@@ -135,7 +134,7 @@ struct CommonParamT {
void initCommonParam(const CurveParam& cp, fp::Mode mode)
{
this->cp = cp;
- isBLS12 = cp.curveType == mclBls12_CurveFp381;
+ isBLS12 = cp.curveType == MCL_BLS12_381;
z = mpz_class(cp.z);
isNegative = z < 0;
if (isNegative) {
@@ -421,7 +420,7 @@ struct BasePairingT {
z = 1;
return;
}
- assert(param.cp.curveType == mclBn_CurveFp254BNb);
+ assert(param.cp.curveType == MCL_BN254BNb);
Fp12 x_org = x;
Fp12 d62;
Fp2 c55nume, c55denomi, c62nume, c62denomi;
@@ -452,7 +451,7 @@ struct BasePairingT {
static void pow_z(Fp12& y, const Fp12& x)
{
#if 1
- if (param.cp.curveType == mclBn_CurveFp254BNb) {
+ if (param.cp.curveType == MCL_BN254BNb) {
Compress::fixed_power(y, x);
} else {
Fp12 orgX = x;
diff --git a/test/bls12_test.cpp b/test/bls12_test.cpp
index a115fef..133259a 100644
--- a/test/bls12_test.cpp
+++ b/test/bls12_test.cpp
@@ -34,7 +34,7 @@ const struct TestSet {
const char *e;
} g_testSetTbl[] = {
{
- mcl::bls12::CurveFp381,
+ mcl::BLS12_381,
"CurveFp381",
"0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",
"0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",
diff --git a/test/bn384_test.cpp b/test/bn384_test.cpp
index ea36284..01ab051 100644
--- a/test/bn384_test.cpp
+++ b/test/bn384_test.cpp
@@ -40,11 +40,11 @@ CYBOZU_TEST_AUTO(pairing)
{
puts("CurveFp254BNb");
// support 256-bit pairing
- testCurve(mcl::bn::CurveFp254BNb);
+ testCurve(mcl::BN254BNb);
puts("CurveFp382_1");
- testCurve(mcl::bn::CurveFp382_1);
+ testCurve(mcl::BN382_1);
puts("CurveFp382_2");
- testCurve(mcl::bn::CurveFp382_2);
+ testCurve(mcl::BN382_2);
// Q is not on EcT, but bad order
{
const char *s = "1 18d3d8c085a5a5e7553c3a4eb628e88b8465bf4de2612e35a0a4eb018fb0c82e9698896031e62fd7633ffd824a859474 1dc6edfcf33e29575d4791faed8e7203832217423bf7f7fbf1f6b36625b12e7132c15fbc15562ce93362a322fb83dd0d 65836963b1f7b6959030ddfa15ab38ce056097e91dedffd996c1808624fa7e2644a77be606290aa555cda8481cfb3cb 1b77b708d3d4f65aeedf54b58393463a42f0dc5856baadb5ce608036baeca398c5d9e6b169473a8838098fd72fd28b50";
diff --git a/test/bn512_test.cpp b/test/bn512_test.cpp
index a5bc660..bfe957a 100644
--- a/test/bn512_test.cpp
+++ b/test/bn512_test.cpp
@@ -39,11 +39,11 @@ void testCurve(const mcl::bn::CurveParam& cp)
CYBOZU_TEST_AUTO(pairing)
{
puts("CurveFp462");
- testCurve(mcl::bn::CurveFp462);
+ testCurve(mcl::BN462);
puts("CurveFp382_1");
- testCurve(mcl::bn::CurveFp382_1);
+ testCurve(mcl::BN382_1);
puts("CurveFp382_2");
- testCurve(mcl::bn::CurveFp382_2);
+ testCurve(mcl::BN382_2);
puts("CurveFp254BNb");
testCurve(mcl::bn::CurveFp254BNb);
}
diff --git a/test/bn_test.cpp b/test/bn_test.cpp
index 2c82746..2ccfba1 100644
--- a/test/bn_test.cpp
+++ b/test/bn_test.cpp
@@ -168,7 +168,7 @@ void testCyclotomic()
void testCompress(const G1& P, const G2& Q)
{
- if (BN::param.cp.curveType != mclBn_CurveFp254BNb) return;
+ if (BN::param.cp.curveType != MCL_BN254BNb) return;
Fp12 a;
BN::pairing(a, P, Q);
BN::mapToCyclotomic(a, a);