diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 1cfcfd8..6703daf 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -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); diff --git a/src/fp.cpp b/src/fp.cpp index 7362770..365da45 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -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(x); - x >>= 8; - byteSize--; - } -} - void copyByteToUnitAsLE(Unit *dst, const uint8_t *src, size_t byteSize) { while (byteSize >= sizeof(Unit)) { diff --git a/test/fp_test.cpp b/test/fp_test.cpp index 3f15a0d..8883e69 100644 --- a/test/fp_test.cpp +++ b/test/fp_test.cpp @@ -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));