From 9dce0600909022821d8423c891c8b062aaadefc4 Mon Sep 17 00:00:00 2001 From: Philip Le Riche <7701190+p-leriche@users.noreply.github.com> Date: Sat, 28 Feb 2026 10:52:21 +0000 Subject: [PATCH] Refactor modPow to BigIntUtils, update to use shared function --- src/core/operations/ModularExponentiation.mjs | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/core/operations/ModularExponentiation.mjs b/src/core/operations/ModularExponentiation.mjs index 64a3bf74..6a08a97d 100644 --- a/src/core/operations/ModularExponentiation.mjs +++ b/src/core/operations/ModularExponentiation.mjs @@ -6,31 +6,10 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import { parseBigInt } from "../lib/BigIntUtils.mjs"; - -/* ---------- helper functions ---------- */ - -/** - * modPow helper operation - */ -function modPow(base, exponent, modulus) { - let result = 1n; - base %= modulus; - - while (exponent > 0n) { - if (exponent & 1n) { - result = (result * base) % modulus; - } - base = (base * base) % modulus; - exponent >>= 1n; - } - - return result; -} +import { parseBigInt, modPow } from "../lib/BigIntUtils.mjs"; /* ---------- operation class ---------- */ - /** * Modular Exponentiation operation */