libsecp256k1 0.1.2 → 0.1.3
raw patch · 2 files changed
+17/−8 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- libsecp256k1.cabal +1/−1
- src/Crypto/Secp256k1.hs +16/−7
libsecp256k1.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: libsecp256k1-version: 0.1.2+version: 0.1.3 synopsis: Bindings for secp256k1 description: Sign and verify signatures using the secp256k1 library. category: Crypto
src/Crypto/Secp256k1.hs view
@@ -159,9 +159,9 @@ pure $ "0x" <> B8.unpack (BA.convertToBase BA.Base16 bs) instance Read SecKey where readsPrec i s = case s of- ('0' : 'x' : bytes) -> case decodeBase16 $ B8.pack bytes of+ ('0' : 'x' : cs) -> case decodeBase16 $ B8.pack (Prelude.take 64 cs) of Left e -> []- Right a -> maybeToList $ (,"") <$> importSecKey a+ Right a -> maybeToList $ (,Prelude.drop 64 cs) <$> importSecKey a _ -> [] instance Eq SecKey where sk == sk' = unsafePerformIO . evalContT $ do@@ -187,10 +187,19 @@ show pk = "0x" <> B8.unpack (BA.convertToBase BA.Base16 (exportPubKeyXY True pk)) instance Read PubKeyXY where readsPrec i s = case s of- ('0' : 'x' : bytes) -> case decodeBase16 $ B8.pack bytes of- Left e -> []- Right a -> maybeToList $ (,"") <$> importPubKeyXY a+ ('0' : 'x' : cs) -> maybeToList $ case cs of+ ('0' : '2' : _) -> parseNextN 66 cs+ ('0' : '3' : _) -> parseNextN 66 cs+ ('0' : '4' : _) -> parseNextN 130 cs+ _ -> Nothing _ -> []+ where+ hush x = case x of+ Left _ -> Nothing+ Right a -> Just a+ parseNextN n cs =+ let (key, rest) = Prelude.splitAt n cs+ in (,rest) <$> (importPubKeyXY <=< hush . decodeBase16) (B8.pack key) instance Eq PubKeyXY where pk == pk' = unsafePerformIO . evalContT $ do pkp <- ContT . withForeignPtr . pubKeyXYFPtr $ pk@@ -217,9 +226,9 @@ show pk = "0x" <> B8.unpack (BA.convertToBase BA.Base16 (exportPubKeyXO pk)) instance Read PubKeyXO where readsPrec i s = case s of- ('0' : 'x' : bytes) -> case decodeBase16 $ B8.pack bytes of+ ('0' : 'x' : bytes) -> case decodeBase16 $ B8.pack (Prelude.take 64 bytes) of Left e -> []- Right a -> maybeToList $ (,"") <$> importPubKeyXO a+ Right a -> maybeToList $ (,Prelude.drop 64 bytes) <$> importPubKeyXO a _ -> [] instance Eq PubKeyXO where pk == pk' = unsafePerformIO . evalContT $ do