change spec of copyAndMask

dev
MITSUNARI Shigeo 8 years ago
parent 0e5eed96e0
commit 4400b61efb
  1. 2
      include/mcl/fp.hpp
  2. 5
      src/fp.cpp
  3. 2
      test/fp_test.cpp

@ -226,7 +226,7 @@ public:
toMont();
}
/*
mask inBuf with (1 << (bitLen - 1)) - 1
mask inBuf with (1 << (bitLen - 1)) - 1 if x >= p
*/
template<class S>
void setArrayMask(const S *inBuf, size_t n)

@ -607,7 +607,10 @@ void copyAndMask(Unit *y, const void *x, size_t xByteSize, const Op& op, bool do
if (isGreaterOrEqualArray(y, op.p, op.N)) throw cybozu::Exception("fp:copyAndMask:large x");
return;
}
maskArray(y, op.N, op.bitSize - 1);
maskArray(y, op.N, op.bitSize);
if (isGreaterOrEqualArray(y, op.p, op.N)) {
maskArray(y, op.N, op.bitSize - 1);
}
assert(isLessArray(y, op.p, op.N));
}

@ -545,7 +545,7 @@ void setArrayMaskTest2(mcl::fp::Mode mode)
} tbl[] = {
{ { 0x234567a4, 0x00000001, 0x00100000}, 1, "0x234567a4" },
{ { 0x234567a4, 0x00000001, 0x00100000}, 2, "0x1234567a4" },
{ { 0x234567a4, 0x00000001, 0x00100000}, 3, "0x00000000000001234567a4" },
{ { 0x234567a4, 0x00000001, 0x00100000}, 3, "0x10000000000001234567a4" },
{ { 0x234567a5, 0xfffffff1, 0xffffffff}, 3, "0x0ffffffffffff1234567a5" },
};
Fp x;

Loading…
Cancel
Save