diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index dd36bcb..706d9fa 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -460,8 +460,11 @@ public: void setByCSPRNG(bool *pb, fp::RandGen rg = fp::RandGen()) { if (rg.isZero()) rg = fp::RandGen::get(); - rg.read(pb, v_, op_.N * sizeof(Unit)); // byte size + uint8_t x[sizeof(*this)]; + const size_t n = op_.N * sizeof(Unit); + rg.read(pb, x, n); // byte size if (!pb) return; + fp::convertArrayAsLE(v_, op_.N, x, n); setArrayMask(v_, op_.N); } #ifndef CYBOZU_DONT_USE_EXCEPTION