add Fp::setArrayMod

update-fork
MITSUNARI Shigeo 5 years ago
parent 8877933592
commit e6bb40a838
  1. 10
      include/mcl/fp.hpp

@ -330,6 +330,7 @@ public:
} }
/* /*
mode = Mod : set x mod p if sizeof(S) * n <= 64 else error mode = Mod : set x mod p if sizeof(S) * n <= 64 else error
set array x as little endian
*/ */
template<class S> template<class S>
void setArray(bool *pb, const S *x, size_t n, mcl::fp::MaskMode mode = fp::NoMask) void setArray(bool *pb, const S *x, size_t n, mcl::fp::MaskMode mode = fp::NoMask)
@ -346,6 +347,15 @@ public:
fp::copyAndMask(v_, x, sizeof(S) * n, op_, fp::MaskAndMod); fp::copyAndMask(v_, x, sizeof(S) * n, op_, fp::MaskAndMod);
toMont(); toMont();
} }
/*
set (array mod p)
error if sizeof(S) * n > 64
*/
template<class S>
void setArrayMod(bool *pb, const S *x, size_t n)
{
setArray(pb, x, n, fp::Mod);
}
/* /*
mask x with (1 << (bitLen - 1)) - 1 if x >= p mask x with (1 << (bitLen - 1)) - 1 if x >= p

Loading…
Cancel
Save