From 8946e743f715143531ec957691dd83d275172267 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 29 Feb 2024 14:00:09 +0900 Subject: [PATCH] add bitSize option to getMontgomeryCoeff --- include/mcl/bint.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mcl/bint.hpp b/include/mcl/bint.hpp index 4c190aca..339265cb 100644 --- a/include/mcl/bint.hpp +++ b/include/mcl/bint.hpp @@ -460,12 +460,12 @@ MCL_DLL_API void sqr_SECP256K1(Unit *y, const Unit *x, const Unit *p); MCL_DLL_API void maskN(Unit *x, size_t n, size_t bitSize); // ppLow = Unit(p) -inline Unit getMontgomeryCoeff(Unit pLow) +inline Unit getMontgomeryCoeff(Unit pLow, size_t bitSize = sizeof(Unit) * 8) { Unit pp = 0; Unit t = 0; Unit x = 1; - for (size_t i = 0; i < sizeof(Unit) * 8; i++) { + for (size_t i = 0; i < bitSize; i++) { if ((t & 1) == 0) { t += pLow; pp += x;