packages feed

secp256k1-haskell 0.1.2 → 0.1.3

raw patch · 3 files changed

+29/−3 lines, 3 filesdep +hashable

Dependencies added: hashable

Files

CHANGELOG.md view
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.1.3+### Added+- Hashable instances for various types.+ ## 0.1.2 ### Changed - Separate dependencies between library and tests.
secp256k1-haskell.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 35281985c74755de3210c0eb2137cc35489e18fbda0247acde105df6e17e7626+-- hash: b7bef3084b490638feba2c057d48b0e54085eca04ef7792e228bbba4f1f65d27  name:           secp256k1-haskell-version:        0.1.2+version:        0.1.3 synopsis:       Bindings for secp256k1 library from Bitcoin Core description:    Sign and verify signatures using the very fast C secp256k1 library from Pieter Wuille. Has Haskell types and abstractions for keys and signatures. category:       Crypto@@ -43,6 +43,7 @@     , bytestring     , cereal     , entropy+    , hashable     , string-conversions   default-language: Haskell2010 @@ -63,6 +64,7 @@     , bytestring     , cereal     , entropy+    , hashable     , hspec     , mtl     , secp256k1-haskell
src/Crypto/Secp256k1.hs view
@@ -60,15 +60,17 @@  import           Control.Monad import           Crypto.Secp256k1.Internal-import           Data.Serialize import           Data.ByteString           (ByteString) import qualified Data.ByteString           as BS import qualified Data.ByteString.Base16    as B16 import           Data.ByteString.Short     (fromShort, toShort)+import           Data.Hashable import           Data.Maybe+import           Data.Serialize import           Data.String import           Data.String.Conversions import           Foreign+import           GHC.Generics import           System.IO.Unsafe import           Test.QuickCheck import           Text.Read@@ -89,6 +91,9 @@         String str <- lexP         maybe pfail return $ importPubKey =<< decodeHex str +instance Hashable PubKey where+    i `hashWithSalt` k = i `hashWithSalt` exportPubKey True k+ instance IsString PubKey where     fromString = fromMaybe e . (importPubKey <=< decodeHex) where         e = error "Could not decode public key from hex string"@@ -101,6 +106,9 @@         String str <- lexP         maybe pfail return $ msg =<< decodeHex str +instance Hashable Msg where+    i `hashWithSalt` m = i `hashWithSalt` getMsg m+ instance IsString Msg where     fromString = fromMaybe e . (msg <=< decodeHex)  where         e = error "Could not decode message from hex string"@@ -117,6 +125,9 @@     fromString = fromMaybe e . (importSig <=< decodeHex) where         e = error "Could not decode signature from hex string" +instance Hashable Sig where+    i `hashWithSalt` s = i `hashWithSalt` exportSig s+ instance Show Sig where     showsPrec _ = shows . B16.encode . exportSig @@ -126,6 +137,9 @@     rs <- either (const Nothing) Just $ decode bs     importCompactRecSig rs +instance Hashable RecSig where+    i `hashWithSalt` s = i `hashWithSalt` encode (exportCompactRecSig s)+ instance Read RecSig where     readPrec = parens $ do         String str <- lexP@@ -144,12 +158,18 @@         String str <- lexP         maybe pfail return $ secKey =<< decodeHex str +instance Hashable SecKey where+    i `hashWithSalt` k = i `hashWithSalt` getSecKey k+ instance IsString SecKey where     fromString = fromMaybe e . (secKey <=< decodeHex) where         e = error "Colud not decode secret key from hex string"  instance Show SecKey where     showsPrec _ = shows . B16.encode . getSecKey++instance Hashable Tweak where+    i `hashWithSalt` t = i `hashWithSalt` getTweak t  instance Read Tweak where     readPrec = parens $ do