fixed

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

commit f60c6583eb0eedc80701c9f22c9921c64a7276bc
parent 711fb0e5286505e5a4688cd35e95d3e49287dc7e
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat,  1 Aug 2026 14:10:27 -0230

lib: document inv of zero

Both inversion chains compute a^(m - 2), so inv zero silently
returns zero; callers that require an error on zero must check for
it themselves.

Diffstat:
Mlib/Numeric/Montgomery/Secp256k1/Curve.hs | 3+++
Mlib/Numeric/Montgomery/Secp256k1/Scalar.hs | 3+++
2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/lib/Numeric/Montgomery/Secp256k1/Curve.hs b/lib/Numeric/Montgomery/Secp256k1/Curve.hs @@ -762,6 +762,9 @@ inv# a = -- | Multiplicative inverse in the Montgomery domain. -- +-- Note that 'zero' has no multiplicative inverse; 'inv' returns +-- 'zero' when applied to it. +-- -- >> inv 2 -- 57896044618658097711785492504343953926634992332820282019728792003954417335832 -- >> inv 2 * 2 diff --git a/lib/Numeric/Montgomery/Secp256k1/Scalar.hs b/lib/Numeric/Montgomery/Secp256k1/Scalar.hs @@ -793,6 +793,9 @@ inv# a = -- | Multiplicative inverse in the Montgomery domain. -- +-- Note that 'zero' has no multiplicative inverse; 'inv' returns +-- 'zero' when applied to it. +-- -- >> inv 2 -- 57896044618658097711785492504343953926418782139537452191302581570759080747169 -- >> inv 2 * 2