commit 03473e407d0150cdc7991a5db2e3bf8e6c51c4c3
parent 12902db7a9e60e004b055cf04d41e036d7834522
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 22 Nov 2025 08:01:20 +0400
lib: show instances for montgomery
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/lib/Numeric/Montgomery/Secp256k1/Curve.hs b/lib/Numeric/Montgomery/Secp256k1/Curve.hs
@@ -22,12 +22,17 @@ import Prelude hiding (div, mod, or, and, not, quot, rem, recip)
data Montgomery = Montgomery !(# Word#, Word#, Word#, Word# #)
-instance NFData Montgomery where
- rnf (Montgomery a) = case a of (# _, _, _, _ #) -> ()
+instance Show Montgomery where
+ show (Montgomery (# a, b, c, d #)) =
+ "(" <> show (W# a) <> ", " <> show (W# b) <> ", "
+ <> show (W# c) <> ", " <> show (W# d) <> ")"
instance Eq Montgomery where
Montgomery a == Montgomery b = C.decide (C.ct_eq_wider# a b)
+instance NFData Montgomery where
+ rnf (Montgomery a) = case a of (# _, _, _, _ #) -> ()
+
-- XX define constants here, current approach is fragile
-- utilities ------------------------------------------------------------------
diff --git a/lib/Numeric/Montgomery/Secp256k1/Scalar.hs b/lib/Numeric/Montgomery/Secp256k1/Scalar.hs
@@ -22,12 +22,17 @@ import Prelude hiding (div, mod, or, and, not, quot, rem, recip)
data Montgomery = Montgomery !(# Word#, Word#, Word#, Word# #)
-instance NFData Montgomery where
- rnf (Montgomery a) = case a of (# _, _, _, _ #) -> ()
+instance Show Montgomery where
+ show (Montgomery (# a, b, c, d #)) =
+ "(" <> show (W# a) <> ", " <> show (W# b) <> ", "
+ <> show (W# c) <> ", " <> show (W# d) <> ")"
instance Eq Montgomery where
Montgomery a == Montgomery b = C.decide (C.ct_eq_wider# a b)
+instance NFData Montgomery where
+ rnf (Montgomery a) = case a of (# _, _, _, _ #) -> ()
+
-- XX define constants here, current approach is fragile
-- utilities ------------------------------------------------------------------