remove std::string

dev
MITSUNARI Shigeo 7 years ago
parent 95e569c6fb
commit d9b4a59df3
  1. 13
      include/mcl/bn.hpp
  2. 16
      src/bn_c_impl.hpp

@ -43,7 +43,7 @@ struct CurveParam {
int curveType; // same in curve_type.h
bool operator==(const CurveParam& rhs) const
{
return std::string(z) == rhs.z && b == rhs.b && xi_a == rhs.xi_a && isMtype == rhs.isMtype;
return strcmp(z, rhs.z) == 0 && b == rhs.b && xi_a == rhs.xi_a && isMtype == rhs.isMtype;
}
bool operator!=(const CurveParam& rhs) const { return !operator==(rhs); }
};
@ -66,7 +66,8 @@ inline const CurveParam& getCurveParam(int type)
case MCL_BN_SNARK1: return mcl::BN_SNARK1;
case MCL_BLS12_381: return mcl::BLS12_381;
default:
throw cybozu::Exception("getCurveParam:bad type") << type;
assert(0);
return mcl::BN254;
}
}
@ -446,7 +447,9 @@ struct MapTo {
*/
void initBN(const mpz_class& cofactor, const mpz_class &z)
{
if (!Fp::squareRoot(c1_, -3)) throw cybozu::Exception("MapTo:init:c1_");
bool b = Fp::squareRoot(c1_, -3);
assert(b);
(void)b;
c2_ = (c1_ - 1) / 2;
z_ = z;
cofactor_ = cofactor;
@ -506,7 +509,9 @@ struct GLV1 {
mpz_class r;
void init(const mpz_class& r, const mpz_class& z, bool isBLS12 = false)
{
if (!Fp::squareRoot(rw, -3)) throw cybozu::Exception("GLV1:init");
bool b = Fp::squareRoot(rw, -3);
assert(b);
(void)b;
rw = -(rw + 1) / 2;
this->r = r;
rBitSize = gmp::getBitSize(r);

@ -92,26 +92,14 @@ int mclBn_getFrByteSize()
return (int)Fr::getByteSize();
}
mclSize copyStrAndReturnSize(char *buf, mclSize maxBufSize, const std::string& str)
{
if (str.size() >= maxBufSize) return 0;
memcpy(buf, str.c_str(), str.size());
buf[str.size()] = '\0';
return str.size();
}
mclSize mclBn_getCurveOrder(char *buf, mclSize maxBufSize)
{
std::string str;
Fr::getModulo(str);
return copyStrAndReturnSize(buf, maxBufSize, str);
return Fr::getModulo(buf, maxBufSize);
}
mclSize mclBn_getFieldOrder(char *buf, mclSize maxBufSize)
{
std::string str;
Fp::getModulo(str);
return copyStrAndReturnSize(buf, maxBufSize, str);
return Fp::getModulo(buf, maxBufSize);
}
////////////////////////////////////////////////
// set zero

Loading…
Cancel
Save