From c6c6e49eb894fa3c46271b0c7fa03d6c590f284c Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 19 Aug 2020 10:10:58 +0900 Subject: [PATCH] remove unused old functions --- include/mcl/fp.hpp | 4 ---- include/mcl/mapto_wb19.hpp | 27 --------------------------- src/fp.cpp | 31 ------------------------------- 3 files changed, 62 deletions(-) diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index a0af747..6c5b0b0 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -73,10 +73,6 @@ bool isEnableJIT(); // 1st call is not threadsafe uint32_t sha256(void *out, uint32_t maxOutSize, const void *msg, uint32_t msgSize); uint32_t sha512(void *out, uint32_t maxOutSize, const void *msg, uint32_t msgSize); -void hkdf_extract_addZeroByte(uint8_t hmac[32], const uint8_t *salt, size_t saltSize, const uint8_t *msg, size_t msgSize); -void hkdf_extract(uint8_t hmac[32], const uint8_t *salt, size_t saltSize, const uint8_t *msg, size_t msgSize); -void hkdf_expand(uint8_t out[64], const uint8_t prk[32], char info[6]); - // draft-07 outSize = 128 or 256 void expand_message_xmd(uint8_t out[], size_t outSize, const void *msg, size_t msgSize, const void *dst, size_t dstSize); diff --git a/include/mcl/mapto_wb19.hpp b/include/mcl/mapto_wb19.hpp index a212811..814baaa 100644 --- a/include/mcl/mapto_wb19.hpp +++ b/include/mcl/mapto_wb19.hpp @@ -9,33 +9,6 @@ */ namespace mcl { -// ctr = 0 or 1 or 2 -template -inline void hashToFp2old(Fp2& out, const void *msg, size_t msgSize, uint8_t ctr, const void *dst, size_t dstSize) -{ - const bool addZeroByte = true; // append zero byte to msg - assert(ctr <= 2); - const size_t degree = 2; - uint8_t msg_prime[32]; - // add '\0' at the end of dst - // see. 5.3. Implementation of https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve - if (addZeroByte) { - fp::hkdf_extract_addZeroByte(msg_prime, reinterpret_cast(dst), dstSize, reinterpret_cast(msg), msgSize); - } else { - fp::hkdf_extract(msg_prime, reinterpret_cast(dst), dstSize, reinterpret_cast(msg), msgSize); - } - char info_pfx[] = "H2C000"; - info_pfx[3] = ctr; - for (size_t i = 0; i < degree; i++) { - info_pfx[4] = char(i + 1); - uint8_t t[64]; - fp::hkdf_expand(t, msg_prime, info_pfx); - bool b; - out.getFp0()[i].setBigEndianMod(&b, t, 64); - assert(b); (void)b; - } -} - namespace local { // y^2 = x^3 + 4(1 + i) diff --git a/src/fp.cpp b/src/fp.cpp index ab09ff1..2b20108 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -128,37 +128,6 @@ uint32_t sha512(void *out, uint32_t maxOutSize, const void *msg, uint32_t msgSiz return (uint32_t)cybozu::Sha512().digest(out, maxOutSize, msg, msgSize); } -void hkdf_extract_addZeroByte(uint8_t hmac[32], const uint8_t *salt, size_t saltSize, const uint8_t *msg, size_t msgSize) -{ - uint8_t saltZero[32]; - if (salt == 0 || saltSize == 0) { - memset(saltZero, 0, sizeof(saltZero)); - salt = saltZero; - saltSize = sizeof(saltZero); - } - cybozu::hmac256addZeroByte(hmac, salt, saltSize, msg, msgSize); -} - -void hkdf_extract(uint8_t hmac[32], const uint8_t *salt, size_t saltSize, const uint8_t *msg, size_t msgSize) -{ - uint8_t saltZero[32]; - if (salt == 0 || saltSize == 0) { - memset(saltZero, 0, sizeof(saltZero)); - salt = saltZero; - saltSize = sizeof(saltZero); - } - cybozu::hmac256(hmac, salt, saltSize, msg, msgSize); -} - -void hkdf_expand(uint8_t out[64], const uint8_t prk[32], char info[6]) -{ - info[5] = 1; - cybozu::hmac256(out, prk, 32, info, 6); - info[5] = 2; - memcpy(out + 32, info, 6); - cybozu::hmac256(out + 32, prk, 32, out, 32 + 6); -} - void expand_message_xmd(uint8_t out[], size_t outSize, const void *msg, size_t msgSize, const void *dst, size_t dstSize) { assert(outSize == 128 || outSize == 256);