secp256k1

Pure Haskell Schnorr, ECDSA on the elliptic curve secp256k1 (docs.ppad.tech/secp256k1).
git clone git://git.ppad.tech/secp256k1.git
Log | Files | Refs | README | LICENSE

commit 52b74114ec6422743ab215027070500af3c000d3
parent 9bd7a0815f733f120bd1fa3ef40d067f713e2944
Author: Jared Tobin <jared@jtobin.io>
Date:   Sun, 28 Dec 2025 09:04:04 -0330

lib: remove some primitives use

Diffstat:
Mflake.lock | 8++++----
Mlib/Crypto/Curve/Secp256k1.hs | 12++++--------
2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/flake.lock b/flake.lock @@ -82,11 +82,11 @@ ] }, "locked": { - "lastModified": 1766845669, - "narHash": "sha256-aDfG7HX8zn0L/ZBABimeUHdvHBcYsiksAzN898QUa5I=", + "lastModified": 1766923905, + "narHash": "sha256-j1rzjclupG6ZjfRrtVsgrspInsiVJFZy194D6l0kNrY=", "ref": "master", - "rev": "0213f7350fcda1c8d28bb9dae686205cf5983f88", - "revCount": 272, + "rev": "3373284d9b0fe3bc1c02164fb828475df0392798", + "revCount": 284, "type": "git", "url": "git://git.ppad.tech/fixed.git" }, diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs @@ -137,8 +137,7 @@ pattern Z :: Limb4 pattern Z = (# Limb 0##, Limb 0##, Limb 0##, Limb 0## #) pattern P :: Limb4 -> Limb4 -> Limb4 -> Projective -pattern P x y z = - Projective (C.Montgomery x) (C.Montgomery y) (C.Montgomery z) +pattern P x y z = Projective (C.Montgomery x) (C.Montgomery y) (C.Montgomery z) {-# COMPLETE P #-} -- utilities ------------------------------------------------------------------ @@ -285,10 +284,7 @@ unroll32 (Wider (# w0, w1, w2, w3 #)) = -- modQ via conditional subtraction modQ :: Wider -> Wider -modQ x = - let !(Wider xw) = x - !(Wider qw) = _CURVE_Q - in W.select x (x - _CURVE_Q) (CT.not (W.lt# xw qw)) +modQ x = W.select x (x - _CURVE_Q) (CT.not (W.lt x _CURVE_Q)) {-# INLINABLE modQ #-} -- bytewise xor @@ -442,8 +438,8 @@ even_y_vartime p = case affine p of -- Constant-time selection of Projective points. select_proj :: Projective -> Projective -> CT.Choice -> Projective -select_proj (P ax ay az) (P bx by bz) c = - P (W.select# ax bx c) (W.select# ay by c) (W.select# az bz c) +select_proj (Projective ax ay az) (Projective bx by bz) c = + Projective (C.select ax bx c) (C.select ay by c) (C.select az bz c) {-# INLINE select_proj #-} -- unboxed internals ----------------------------------------------------------