From fee5144d0fb21d758f124d173ddd9f3fcd617b31 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sun, 26 Jan 2020 10:34:09 +0900 Subject: [PATCH] use eth* functions for c api --- include/mcl/impl/bn_c_impl.hpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/include/mcl/impl/bn_c_impl.hpp b/include/mcl/impl/bn_c_impl.hpp index 96ae2a8..f31380b 100644 --- a/include/mcl/impl/bn_c_impl.hpp +++ b/include/mcl/impl/bn_c_impl.hpp @@ -137,23 +137,17 @@ int mclBn_setMapToMode(int mode) int mclBn_ethMsgToFp2(mclBnFp2 *out, const void *msg, size_t msgSize, uint8_t ctr, const void *dst, size_t dstSize) { - if (mclBn_getCurveType() != MCL_BLS12_381) return -1; - mcl::bn::BN::local::hashToFp2(*cast(out), msg, msgSize, ctr, dst, dstSize); - return 0; + return mcl::bn::ethMsgToFp2(*cast(out), msg, msgSize, ctr, dst, dstSize) ? 0 : -1; } int mclBn_ethFp2ToG2(mclBnG2 *out, const mclBnFp2 *t1, const mclBnFp2 *t2) { - if (mclBn_getCurveType() != MCL_BLS12_381) return -1; - mcl::bn::BN::param.mapTo.mapToG2_WB19_.opt_swu2_map(*cast(out), *cast(t1), cast(t2)); - return 0; + return mcl::bn::ethFp2ToG2(*cast(out), *cast(t1), cast(t2)) ? 0 : -1; } int mclBn_ethMsgToG2(mclBnG2 *out, const void *msg, size_t msgSize, const void *dst, size_t dstSize) { - if (mclBn_getCurveType() != MCL_BLS12_381) return -1; - mcl::bn::BN::param.mapTo.mapToG2_WB19_.map2curve_osswu2(*cast(out), msg, msgSize, dst, dstSize); - return 0; + return mcl::bn::ethMsgToG2(*cast(out), msg, msgSize, dst, dstSize) ? 0 : -1; } void mclBn_setOriginalG2cofactor(int enable)