enable GLV for secp256k1

update-fork
MITSUNARI Shigeo 5 years ago
parent 2053b495a7
commit 3c98ac00c8
  1. 2
      include/mcl/ecdsa.hpp
  2. 5
      include/mcl/she.hpp
  3. 2
      test/ecdsa_test.cpp
  4. 5
      test/she_test.cpp

@ -99,6 +99,8 @@ inline void init(bool *pb)
p.P.set(pb, x, y); p.P.set(pb, x, y);
if (!*pb) return; if (!*pb) return;
p.Pbase.init(pb, p.P, ecParam.bitSize, local::winSize); p.Pbase.init(pb, p.P, ecParam.bitSize, local::winSize);
mcl::GLV1T<Ec>::initForSecp256k1(Zn::getOp().mp);
Ec::setMulArrayGLV(mcl::GLV1T<Ec>::mulArray);
} }
#ifndef CYBOZU_DONT_USE_EXCEPTION #ifndef CYBOZU_DONT_USE_EXCEPTION

@ -26,6 +26,7 @@
#include <mcl/window_method.hpp> #include <mcl/window_method.hpp>
#include <cybozu/endian.hpp> #include <cybozu/endian.hpp>
#include <cybozu/serializer.hpp> #include <cybozu/serializer.hpp>
#include <mcl/ecparam.hpp>
namespace mcl { namespace she { namespace mcl { namespace she {
@ -588,6 +589,10 @@ public:
useDecG2ViaGT_ = false; useDecG2ViaGT_ = false;
isG1only_ = true; isG1only_ = true;
setTryNum(tryNum); setTryNum(tryNum);
if (std::string(para.name) == mcl::ecparam::secp256k1.name) {
mcl::GLV1T<G1>::initForSecp256k1(Fr::getOp().mp);
G1::setMulArrayGLV(mcl::GLV1T<G1>::mulArray);
}
} }
/* /*
set range for G1-DLP set range for G1-DLP

@ -18,8 +18,6 @@ using namespace mcl::ecdsa;
CYBOZU_TEST_AUTO(ecdsa) CYBOZU_TEST_AUTO(ecdsa)
{ {
init(); init();
mcl::GLV1T<Fp, Ec>::initForSecp256k1(Zn::getOp().mp);
Ec::setMulArrayGLV(mcl::GLV1T<Fp, Ec>::mulArray);
SecretKey sec; SecretKey sec;
PublicKey pub; PublicKey pub;
sec.setByCSPRNG(); sec.setByCSPRNG();

@ -716,8 +716,9 @@ CYBOZU_TEST_AUTO(hashBench)
CYBOZU_TEST_AUTO(liftedElGamal) CYBOZU_TEST_AUTO(liftedElGamal)
{ {
const size_t hashSize = 1024; const size_t hashSize = 1024;
initG1only(mcl::ecparam::secp192k1, hashSize); const mcl::EcParam& param = mcl::ecparam::secp256k1;
const size_t byteSize = 192 / 8; initG1only(param, hashSize);
const size_t byteSize = (param.bitSize + 7) / 8;
SecretKey sec; SecretKey sec;
sec.setByCSPRNG(); sec.setByCSPRNG();
PublicKey pub; PublicKey pub;

Loading…
Cancel
Save