fixed

Pure Haskell large fixed-width integers and Montgomery arithmetic.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit 22a632874f72b50eb68dfca99f636ec2f2a7c0b3
parent 2028df25ebed756248130625ee9138e8f2da595e
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 24 Dec 2025 10:05:48 -0330

lib: formatting changes in exp#

Diffstat:
Mlib/Numeric/Montgomery/Secp256k1/Curve.hs | 15++++++++-------
Mlib/Numeric/Montgomery/Secp256k1/Scalar.hs | 15++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/lib/Numeric/Montgomery/Secp256k1/Curve.hs b/lib/Numeric/Montgomery/Secp256k1/Curve.hs @@ -1535,13 +1535,14 @@ exp# -> (# Limb, Limb, Limb, Limb #) exp# b e = let !o = (# Limb 0x1000003D1##, Limb 0##, Limb 0##, Limb 0## #) - loop !r !_ !_ 0 = r - loop !r !m !ex !n = - let !(# ne, bit #) = WW.shr1_c# ex - !candidate = mul# r m - !nr = select# r candidate bit - !nm = sqr# m - in loop nr nm ne (n - 1) + loop !r !m !ex n = case n of + 0 -> r + _ -> + let !(# ne, bit #) = WW.shr1_c# ex + !candidate = mul# r m + !nr = select# r candidate bit + !nm = sqr# m + in loop nr nm ne (n - 1) in loop o b e (256 :: Word) {-# INLINE exp# #-} diff --git a/lib/Numeric/Montgomery/Secp256k1/Scalar.hs b/lib/Numeric/Montgomery/Secp256k1/Scalar.hs @@ -960,13 +960,14 @@ exp# exp# b e = let !o = (# Limb 0x402DA1732FC9BEBF##, Limb 0x4551231950B75FC4## , Limb 0x0000000000000001##, Limb 0x0000000000000000## #) - loop !r !_ !_ 0 = r - loop !r !m !ex !n = - let !(# ne, bit #) = WW.shr1_c# ex - !candidate = mul# r m - !nr = select# r candidate bit - !nm = sqr# m - in loop nr nm ne (n - 1) + loop !r !m !ex n = case n of + 0 -> r + _ -> + let !(# ne, bit #) = WW.shr1_c# ex + !candidate = mul# r m + !nr = select# r candidate bit + !nm = sqr# m + in loop nr nm ne (n - 1) in loop o b e (256 :: Word) {-# INLINE exp# #-}