unify curve const

dev
MITSUNARI Shigeo 8 years ago
parent b93d198797
commit 194928d9e8
  1. 6
      include/bls/bls.h
  2. 8
      include/bls/bls.hpp
  3. 8
      src/bls.cpp
  4. 6
      test/bls_c384_test.cpp
  5. 8
      test/bls_test.cpp

@ -27,12 +27,6 @@
extern "C" {
#endif
enum {
blsCurveFp254BNb = 0,
blsCurveFp382_1 = 1,
blsCurveFp382_2 = 2
};
typedef struct {
mclBnFr v;
} blsId;

@ -18,12 +18,6 @@
namespace bls {
enum {
CurveFp254BNb = 0,
CurveFp382_1 = 1,
CurveFp382_2 = 2
};
// same value with IoMode of mcl/op.hpp
enum {
IoBin = 2, // binary number
@ -59,7 +53,7 @@ struct Id;
@param maxUnitSize [in] 4 or 6 (specify same value used in compiling for validation)
@note init() is not thread safe
*/
void init(int curve = CurveFp254BNb, int maxUnitSize = MCLBN_FP_UNIT_SIZE);
void init(int curve = mclBn_CurveFp254BNb, int maxUnitSize = MCLBN_FP_UNIT_SIZE);
size_t getOpUnitSize();
void getCurveOrder(std::string& str);
void getFieldOrder(std::string& str);

@ -168,14 +168,14 @@ void init(int curve, int maxUnitSize)
if (maxUnitSize != MCLBN_FP_UNIT_SIZE) throw cybozu::Exception("bls:init:bad maxUnitSize") << maxUnitSize << MCLBN_FP_UNIT_SIZE;
mcl::bn::CurveParam cp;
switch (curve) {
case bls::CurveFp254BNb:
case mclBn_CurveFp254BNb:
cp = mcl::bn::CurveFp254BNb;
break;
#if MCLBN_FP_UNIT_SIZE == 6
case bls::CurveFp382_1:
case mclBn_CurveFp382_1:
cp = mcl::bn::CurveFp382_1;
break;
case bls::CurveFp382_2:
case mclBn_CurveFp382_2:
cp = mcl::bn::CurveFp382_2;
break;
#endif
@ -192,7 +192,7 @@ void init(int curve, int maxUnitSize)
assert(sizeof(PublicKey) == sizeof(impl::PublicKey));
assert(sizeof(Signature) == sizeof(impl::Signature));
static G2 Q;
if (curve == bls::CurveFp254BNb) {
if (curve == mclBn_CurveFp254BNb) {
Q.set(
Fp2("12723517038133731887338407189719511622662176727675373276651903807414909099441", "4168783608814932154536427934509895782246573715297911553964171371032945126671"),
Fp2("13891744915211034074451795021214165905772212241412891944830863846330766296736", "7937318970632701341203597196594272556916396164729705624521405069090520231616")

@ -65,10 +65,10 @@ void blsOrderTest(const char *curveOrder, const char *fieldOrder)
CYBOZU_TEST_AUTO(all)
{
const int tbl[] = {
blsCurveFp254BNb,
mclBn_CurveFp254BNb,
#if MCLBN_FP_UNIT_SIZE == 6
blsCurveFp382_1,
blsCurveFp382_2
mclBn_CurveFp382_1,
mclBn_CurveFp382_2
#endif
};
const char *curveOrderTbl[] = {

@ -66,7 +66,7 @@ void SecretKeyTestBN256()
CYBOZU_TEST_AUTO(bn256)
{
bls::init(bls::CurveFp254BNb);
bls::init(mclBn_CurveFp254BNb);
IdTestBN256();
SecretKeyTestBN256();
CYBOZU_TEST_EQUAL(bls::getOpUnitSize(), 4);
@ -402,10 +402,10 @@ CYBOZU_TEST_AUTO(all)
int type;
const char *name;
} tbl[] = {
{ bls::CurveFp254BNb, "Fp254" },
{ mclBn_CurveFp254BNb, "Fp254" },
#if MCLBN_FP_UNIT_SIZE == 6
{ bls::CurveFp382_1, "Fp382_1" },
{ bls::CurveFp382_2, "Fp382_2" },
{ mclBn_CurveFp382_1, "Fp382_1" },
{ mclBn_CurveFp382_2, "Fp382_2" },
#endif
};
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {

Loading…
Cancel
Save