From 3a2f09ca73e81a09bbce64af3b020083f6dfe9d5 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 4 May 2021 14:21:36 +0900 Subject: [PATCH] compatible setByCSPRNG for big-endian --- include/mcl/fp.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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