commit 9533b2768394cb5cddf0d08006042c869725d269
parent bd7872118b13e76833830ec3e3fee7fa2a411d71
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 19 Oct 2024 18:55:21 +0400
lib: haddock stuff
Diffstat:
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs
@@ -20,8 +20,16 @@
-- "low-S" signatures) on the elliptic curve secp256k1.
module Crypto.Curve.Secp256k1 (
+ -- * secp256k1 points
+ Pub
+ , derive_pub
+
+ -- * Parsing
+ , parse_int256
+ , parse_point
+
-- * BIP0340 Schnorr signatures
- sign_schnorr
+ , sign_schnorr
, verify_schnorr
-- * RFC6979 ECDSA
@@ -32,14 +40,6 @@ module Crypto.Curve.Secp256k1 (
, verify_ecdsa
, verify_ecdsa_unrestricted
- -- * secp256k1 points
- , Pub
- , derive_pub
-
- -- * Parsing
- , parse_int256
- , parse_point
-
-- Elliptic curve group operations
, neg
, add
@@ -602,7 +602,7 @@ derive_pub _SECRET
--
-- >>> import qualified Data.ByteString as BS
-- >>> parse_int256 (BS.replicate 32 0xFF)
--- <2 ^ 256 - 1>
+-- <2^256 - 1>
parse_int256 :: BS.ByteString -> Integer
parse_int256 bs
| BS.length bs /= 32 =
@@ -611,6 +611,15 @@ parse_int256 bs
-- | Parse compressed secp256k1 point (33 bytes), uncompressed point (65
-- bytes), or BIP0340-style point (32 bytes).
+--
+-- >>> parse_point <33-byte compressed point>
+-- Just <Pub>
+-- >>> parse_point <65-byte uncompressed point>
+-- Just <Pub>
+-- >>> parse_point <32-byte bip0340 public key>
+-- Just <Pub>
+-- >>> parse_point <anything else>
+-- Nothing
parse_point :: BS.ByteString -> Maybe Projective
parse_point bs
| len == 32 = _parse_bip0340 bs