copyUnitToByteAsLE is removed

2merge^2
MITSUNARI Shigeo 4 years ago
parent 687445ca41
commit 8ff04a209a
  1. 2
      include/mcl/fp.hpp
  2. 16
      src/fp.cpp
  3. 8
      test/fp_test.cpp

@ -38,8 +38,6 @@ struct ZnTag;
namespace fp {
// copy src to dst as little endian
void copyUnitToByteAsLE(uint8_t *dst, const Unit *src, size_t byteSize);
// copy src to dst as little endian
void copyByteToUnitAsLE(Unit *dst, const uint8_t *src, size_t byteSize);

@ -632,22 +632,6 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, int _xi_a, Mode mode, size
return fp::initForMont(*this, p, mode);
}
void copyUnitToByteAsLE(uint8_t *dst, const Unit *src, size_t byteSize)
{
while (byteSize >= sizeof(Unit)) {
setUnitAsLE(dst, *src++);
dst += sizeof(Unit);
byteSize -= sizeof(Unit);
}
if (byteSize == 0) return;
Unit x = *src;
while (byteSize) {
*dst++ = static_cast<uint8_t>(x);
x >>= 8;
byteSize--;
}
}
void copyByteToUnitAsLE(Unit *dst, const uint8_t *src, size_t byteSize)
{
while (byteSize >= sizeof(Unit)) {

@ -1041,7 +1041,7 @@ CYBOZU_TEST_AUTO(main)
#endif
}
CYBOZU_TEST_AUTO(copyUnitToByteAsLE)
CYBOZU_TEST_AUTO(copyByteToUnitAsLE)
{
using namespace mcl::fp;
#if MCL_SIZEOF_UNIT == 4
@ -1050,12 +1050,6 @@ CYBOZU_TEST_AUTO(copyUnitToByteAsLE)
const Unit src[] = { uint64_t(0xaabbccdd12345678ull), uint64_t(0x87654321ffeeddcc) };
#endif
const uint8_t ok[] = { 0x78, 0x56, 0x34, 0x12, 0xdd, 0xcc, 0xbb, 0xaa, 0xcc, 0xdd, 0xee, 0xff, 0x21, 0x43, 0x65, 0x87 };
const size_t okN = CYBOZU_NUM_OF_ARRAY(ok);
for (size_t i = 0; i < okN; i++) {
uint8_t buf[okN] = {};
copyUnitToByteAsLE(buf, src, i);
CYBOZU_TEST_EQUAL_ARRAY(ok, buf, i);
}
mcl::fp::Unit dst[2];
for (size_t i = 1; i <= sizeof(dst); i++) {
memset(dst, 0xff, sizeof(dst));

Loading…
Cancel
Save