packages feed

secp256k1-haskell 3.1.0 → 3.1.1

raw patch · 8 files changed

+70/−55 lines, 8 filesdep ~QuickCheckdep ~base16dep ~bytestringPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, base16, bytestring, deepseq, entropy, hashable, string-conversions

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -5,6 +5,20 @@ and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/), in which the first two numbers together are the major version. +## [3.1.1] - 2026-12-02++### Changed+- Every dependency of the library has an upper bound, below its next major+  version as the Package Versioning Policy counts it, so that a release of a+  dependency that breaks its API cannot be picked by a solver unchecked.+  Cabal's check asked for them.+- `CHANGELOG.md` and `README.md` are in `extra-doc-files`, where Cabal wants+  documentation, instead of `extra-source-files`.+- The Haddock links to `PubKey`, `Sig`, `SecKey`, `Msg`, `Tweak`,+  `CompactSig`, `SchnorrSig`, `RecSig` and `EllSwift` name the type+  (`t'PubKey'`): each type has a constructor of the same name in the+  internal modules, which made every such link ambiguous.+ ## [3.1.0] - 2026-12-02  ### Added
README.md view
@@ -167,7 +167,7 @@     ```yaml    extra-deps:-     - secp256k1-haskell-3.1.0+     - secp256k1-haskell-3.1.1      - base16-2.0    ``` 
secp256k1-haskell.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           secp256k1-haskell-version:        3.1.0+version:        3.1.1 synopsis:       Bindings for secp256k1 description:    Sign and verify signatures using the secp256k1 library. category:       Crypto@@ -17,11 +17,12 @@ license-file:   LICENSE build-type:     Simple extra-source-files:-    CHANGELOG.md-    README.md     test/data/ellswift_decode_test_vectors.csv     test/data/packet_encoding_test_vectors.csv     test/data/xswiftec_inv_test_vectors.csv+extra-doc-files:+    CHANGELOG.md+    README.md  source-repository head   type: git@@ -58,14 +59,14 @@   pkgconfig-depends:       libsecp256k1 >= 0.2.0   build-depends:-      QuickCheck >=2.9.2+      QuickCheck >=2.9.2 && <2.18     , base >=4.9 && <5-    , base16 >=2.0-    , bytestring >=0.10.8-    , deepseq >=1.4.2-    , entropy >=0.3.8-    , hashable >=1.2.6-    , string-conversions >=0.4+    , base16 ==2.0.*+    , bytestring >=0.10.8 && <0.13+    , deepseq >=1.4.2 && <1.6+    , entropy >=0.3.8 && <0.5+    , hashable >=1.2.6 && <1.6+    , string-conversions ==0.4.*   default-language: Haskell2010   if flag(recovery)     exposed-modules:@@ -111,17 +112,17 @@       libsecp256k1 >= 0.2.0   build-depends:       HUnit-    , QuickCheck >=2.9.2+    , QuickCheck >=2.9.2 && <2.18     , base >=4.9 && <5-    , base16 >=2.0-    , bytestring >=0.10.8-    , deepseq >=1.4.2-    , entropy >=0.3.8-    , hashable >=1.2.6+    , base16 ==2.0.*+    , bytestring >=0.10.8 && <0.13+    , deepseq >=1.4.2 && <1.6+    , entropy >=0.3.8 && <0.5+    , hashable >=1.2.6 && <1.6     , hspec     , monad-par     , mtl-    , string-conversions >=0.4+    , string-conversions ==0.4.*   default-language: Haskell2010   if flag(recovery)     other-modules:
src/Crypto/Secp256k1.hs view
@@ -15,7 +15,7 @@ -- == Design -- -- * __Valid by construction.__ Every value goes through a smart constructor or---   an import function that checks it. Code that holds a 'PubKey' or a 'Sig'+--   an import function that checks it. Code that holds a t'PubKey' or a t'Sig' --   never has to wonder whether it is a point on the curve or a well-formed --   signature, and invalid input is refused at the boundary where it arrives. --@@ -47,19 +47,19 @@ -- Every value is built through a smart constructor or an import function -- that validates it, so a value of one of these types is always well formed: ----- * 'SecKey': a 32-byte big-endian number in the range 1 to n−1, where n is+-- * t'SecKey': a 32-byte big-endian number in the range 1 to n−1, where n is --   the order of the curve ('secKey').--- * 'PubKey': a point on the curve ('importPubKey' for the SEC1 encoding).--- * 'Sig': a signature whose components are both in the range 1 to n−1+-- * t'PubKey': a point on the curve ('importPubKey' for the SEC1 encoding).+-- * t'Sig': a signature whose components are both in the range 1 to n−1 --   ('importSig' for DER, 'importCompactSig' for the compact encoding).--- * 'Msg': a 32-byte hash ('msg').--- * 'Tweak': a 32-byte big-endian number in the range 0 to n−1 ('tweak').--- * 'SchnorrSig': a 64-byte BIP-340 signature ('schnorrSig' checks the+-- * t'Msg': a 32-byte hash ('msg').+-- * t'Tweak': a 32-byte big-endian number in the range 0 to n−1 ('tweak').+-- * t'SchnorrSig': a 64-byte BIP-340 signature ('schnorrSig' checks the --   length, 'verifySchnorr' the values). -- -- @x.get@ gives the bytes of a value, with @OverloadedRecordDot@. For--- 'SecKey', 'Msg', 'Tweak', 'CompactSig' and 'SchnorrSig' these are the--- standard big-endian bytes. For 'PubKey' and 'Sig' they are the internal+-- t'SecKey', t'Msg', t'Tweak', t'CompactSig' and t'SchnorrSig' these are the+-- standard big-endian bytes. For t'PubKey' and t'Sig' they are the internal -- representation of libsecp256k1, which is opaque and not portable. Use -- 'exportPubKey', 'exportSig' and 'exportCompactSig' to serialize those. -- @get@ is not a field, so a record update cannot replace the bytes of a@@ -67,10 +67,10 @@ -- "Crypto.Secp256k1.Internal.Base". -- -- 'Show', 'Read' and 'Data.String.IsString' use hex of a standard encoding: compressed--- SEC1 for 'PubKey', compact for 'Sig', and the plain bytes for the others.--- The one exception is 'Show' for 'SecKey', which prints @SecKey \<redacted\>@+-- SEC1 for t'PubKey', compact for t'Sig', and the plain bytes for the others.+-- The one exception is 'Show' for t'SecKey', which prints @SecKey \<redacted\>@ -- instead of the key, so that a key never reaches a log by accident. 'Read'--- and 'Data.String.IsString' for 'SecKey' still parse hex.+-- and 'Data.String.IsString' for t'SecKey' still parse hex. -- -- The raw constructors are not exported from this module. They are in -- "Crypto.Secp256k1.Internal.Base", which has no API stability guarantee.@@ -78,7 +78,7 @@ -- == Schnorr signatures -- -- BIP-340 public keys are x-only: the 32-byte x coordinate of a point whose--- y coordinate is even. This module keeps them as 'PubKey' and converts with+-- y coordinate is even. This module keeps them as t'PubKey' and converts with -- 'importXOnlyPubKey' and 'exportXOnlyPubKey'. 'verifySchnorr' uses only the -- x coordinate, so a key and its negation verify the same signatures. -- 'tweakAddXOnlyPubKey' and 'tweakAddXOnlySecKey' apply a BIP-341 Taproot
src/Crypto/Secp256k1/Internal/Base.hs view
@@ -14,7 +14,7 @@ -- A value built with a raw constructor skips validation. Every function here -- still checks the length of its bytes before calling the C library and -- raises an 'Control.Exception.ErrorCall' when the length is wrong, but it does not check the--- content. A raw 'PubKey' or 'Sig' with invalid content makes functions+-- content. A raw t'PubKey' or t'Sig' with invalid content makes functions -- return 'Nothing', 'False' or throw, never abort or read outside a buffer. -- -- No function here takes a context. They all use the single global context@@ -136,7 +136,7 @@   deriving (Eq, Generic, Hashable, NFData)  -- | ECDSA signature in the internal representation of libsecp256k1 (64--- bytes). Both components of a valid 'Sig' are in the range 1 to n−1, where n+-- bytes). Both components of a valid t'Sig' are in the range 1 to n−1, where n -- is the order of the curve. -- -- The bytes in @get@ are opaque and not portable. Use 'exportSig' (DER) or@@ -170,7 +170,7 @@ newtype CompactSig = CompactSig ByteString   deriving (Eq, Generic, Hashable, NFData) --- | BIP-340 Schnorr signature. Unlike 'Sig', the 64 bytes in @get@ are the+-- | BIP-340 Schnorr signature. Unlike t'Sig', the 64 bytes in @get@ are the -- serialized form that BIP-340 defines, r‖s as 32-byte big-endian numbers, -- which is the same on every platform. 'schnorrSig' only checks the length. -- 'verifySchnorr' checks the values. 'Show', 'Read' and 'IsString' use hex.@@ -182,7 +182,7 @@ -- @get@ is not a field, on purpose. A field that a module exports reads the -- bytes, but it also lets a record update replace them, as in -- @key {get = bytes}@, even where the constructor is hidden, and an update--- checks nothing. A 'PubKey' that is no point of the curve would then reach+-- checks nothing. A t'PubKey' that is no point of the curve would then reach -- the functions of the package, and an address made of it could never be -- spent. These instances give the reading without the update. The one way -- around the checks left is @to@ of 'GHC.Generics.Generic', which no@@ -310,7 +310,7 @@ instance Show SchnorrSig where   showsPrec _ = showsHex . (.get) --- | Parse the 64-byte compact encoding into a 'Sig'. Used by the 'Read' and+-- | Parse the 64-byte compact encoding into a t'Sig'. Used by the 'Read' and -- 'IsString' instances. sigFromCompactBytes :: ByteString -> Maybe Sig sigFromCompactBytes = importCompactSig <=< compactSig@@ -364,7 +364,7 @@ belowCurveOrder bs = BS.length bs == 32 && bs < curveOrder  -- | Import a signature from the bytes of its internal representation, as--- found in the @get@ field of a 'Sig' on the same platform. 'Nothing' unless+-- found in the @get@ field of a t'Sig' on the same platform. 'Nothing' unless -- the bytes are the canonical representation of a signature whose components -- are both in the range 1 to n−1. Signatures from other sources go through -- 'importSig' or 'importCompactSig'.@@ -400,7 +400,7 @@   BS.take 32 compact /= zero32 && BS.drop 32 compact /= zero32  -- | Import a public key from the bytes of its internal representation, as--- found in the @get@ field of a 'PubKey' on the same platform. 'Nothing'+-- found in the @get@ field of a t'PubKey' on the same platform. 'Nothing' -- unless the bytes are the canonical representation of a point on the curve. -- Keys from other sources go through 'importPubKey'. pubKey :: ByteString -> Maybe PubKey@@ -647,7 +647,7 @@  -- | Compute the public key of a secret key. ----- It is a pure function and cannot fail, because a 'SecKey' is valid by+-- It is a pure function and cannot fail, because a t'SecKey' is valid by -- construction. derivePubKey :: SecKey -> PubKey derivePubKey (SecKey sec_key) =@@ -728,7 +728,7 @@  -- | Negate a tweak modulo the curve order: @n − tweak@, or zero for zero. -- Adding a tweak and then its negation gives the original key back.--- 'Nothing' only for a raw 'Tweak' that is not below the curve order.+-- 'Nothing' only for a raw t'Tweak' that is not below the curve order. tweakNegate :: Tweak -> Maybe Tweak tweakNegate (Tweak t)   | t == zero32 = Just (Tweak t)@@ -867,7 +867,7 @@ -- how BIP-341 derives a Taproot output key from an internal key. The result -- is a full point: its x coordinate is the tweaked x-only key, and the parity -- of its y coordinate goes into the control block of a script path spend.--- 'Nothing' if the result is the point at infinity, or for a raw 'Tweak' that+-- 'Nothing' if the result is the point at infinity, or for a raw t'Tweak' that -- is not below the curve order. tweakAddXOnlyPubKey :: PubKey -> Tweak -> Maybe PubKey tweakAddXOnlyPubKey (PubKey pub_key) (Tweak t) =@@ -881,7 +881,7 @@ -- public key: the secret key is negated first when its public key has an odd -- y coordinate, then the tweak is added. The result signs for the Taproot -- output of 'tweakAddXOnlyPubKey' in a key path spend. 'Nothing' if the--- result is zero, or for a raw 'Tweak' that is not below the curve order.+-- result is zero, or for a raw t'Tweak' that is not below the curve order. tweakAddXOnlySecKey :: SecKey -> Tweak -> Maybe SecKey tweakAddXOnlySecKey (SecKey sec_key) (Tweak t) =   unsafePerformIO $
src/Crypto/Secp256k1/Internal/EllSwift.hs view
@@ -50,7 +50,7 @@   )  -- | ElligatorSwift encoding of a public key: 64 bytes, two field elements u--- and t as 32-byte big-endian numbers. Unlike the @get@ field of a 'PubKey',+-- and t as 32-byte big-endian numbers. Unlike the @get@ field of a t'PubKey', -- these bytes are a standard encoding, the same on every platform, and they -- are what BIP 324 sends on the wire. --@@ -132,7 +132,7 @@         withAux $ \aux_ptr -> do           out <- withOutput 64 $ \ell_ptr ->             isSuccess <$> Ops.ellSwiftCreate globalContext ell_ptr sec_key_ptr aux_ptr-          -- It fails only for a secret key out of range, which a 'SecKey' is+          -- It fails only for a secret key out of range, which a t'SecKey' is           -- not.           maybe (error "could not create ElligatorSwift public key") (return . EllSwift) out   where
src/Crypto/Secp256k1/Internal/Recovery.hs view
@@ -8,15 +8,15 @@ {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE NoFieldSelectors #-} --- | Internal module. Everything is exported, including the raw 'RecSig'+-- | Internal module. Everything is exported, including the raw t'RecSig' -- constructor that "Crypto.Secp256k1.Recovery" hides, and there is no API -- stability guarantee. This module is only built when the @recovery@ flag of -- the package is on. ----- A 'RecSig' built with the raw constructor skips validation. Every function+-- A t'RecSig' built with the raw constructor skips validation. Every function -- here still checks the length of its bytes before calling the C library and -- raises an 'Control.Exception.ErrorCall' when the length is wrong, but it--- does not check the content. A raw 'RecSig' with invalid content makes+-- does not check the content. A raw t'RecSig' with invalid content makes -- functions return 'Nothing', a value that does not verify, or throw, never -- abort or read outside a buffer. --@@ -70,7 +70,7 @@   )  -- | ECDSA signature with a recovery id, in the internal representation of--- libsecp256k1 (65 bytes). A valid 'RecSig' has both components in the range+-- libsecp256k1 (65 bytes). A valid t'RecSig' has both components in the range -- 1 to n−1, where n is the order of the curve, and a recovery id of 0 to 3. -- -- The bytes in @get@ are opaque. They are not a standard encoding, and they@@ -85,7 +85,7 @@ newtype RecSig = RecSig ByteString   deriving (Eq, Generic, Hashable, NFData) --- | The bytes of a 'RecSig', read as @x.get@. @get@ is not a field, so no+-- | The bytes of a t'RecSig', read as @x.get@. @get@ is not a field, so no -- record update can replace them: see the instances of -- "Crypto.Secp256k1.Internal.Base". instance HasField "get" RecSig ByteString where@@ -119,7 +119,7 @@   importCompactRecSig (CompactSig (BS.take 64 bs)) (BS.last bs)  -- | Import a recoverable signature from the bytes of its internal--- representation, as found in the @get@ field of a 'RecSig' on the same+-- representation, as found in the @get@ field of a t'RecSig' on the same -- platform. 'Nothing' unless the bytes are the canonical representation of a -- signature whose components are both in the range 1 to n−1, with a recovery -- id of 0 to 3. Signatures from other sources go through@@ -135,7 +135,7 @@ -- that the id is 0 to 3. Comparing the bytes rejects non-canonical forms, so -- that each signature has one representation and 'Eq' is meaningful. Zero -- components are rejected too, so that 'convertRecSig' always gives a valid--- 'Sig'.+-- t'Sig'. isCanonicalRecSig :: ByteString -> Bool isCanonicalRecSig bs =   BS.length bs == 65@@ -212,7 +212,7 @@   guard (rec_id <= 3)   -- libsecp256k1 accepts a zero component here and only refuses it in   -- 'recover'. It is rejected here so that 'convertRecSig' always gives a-  -- valid 'Sig', as 'Crypto.Secp256k1.importCompactSig' does.+  -- valid t'Sig', as 'Crypto.Secp256k1.importCompactSig' does.   guard (hasNonZeroComponents compact)   unsafePerformIO $     useFixedByteString "CompactSig" 64 compact $ \(compact_ptr, _) ->
src/Crypto/Secp256k1/Recovery.hs view
@@ -12,7 +12,7 @@ -- followed by r and s, and the verifier recovers the key and compares its -- address with the one given. The header byte is 27 plus the id, plus 4 for -- a compressed key, and BIP 137 adds 8 or 12 more for a SegWit address.--- 'exportCompactRecSig' and 'importCompactRecSig' convert between a 'RecSig'+-- 'exportCompactRecSig' and 'importCompactRecSig' convert between a t'RecSig' -- and the r‖s bytes with the id; the header byte itself is left to the -- caller. --@@ -47,8 +47,8 @@ -- -- == Values ----- 'RecSig' is built through 'signRecMsg', 'importCompactRecSig' or 'recSig',--- which validate it, so a 'RecSig' always has both components in the range 1+-- t'RecSig' is built through 'signRecMsg', 'importCompactRecSig' or 'recSig',+-- which validate it, so a t'RecSig' always has both components in the range 1 -- to n−1 and an id of 0 to 3. @x.get@ gives the internal representation -- of libsecp256k1, which is opaque and not portable. 'Show', -- 'Read' and 'Data.String.IsString' use hex of r and s as 32-byte big-endian