packages feed

secp256k1 0.5.2 → 0.5.3

raw patch · 3 files changed

+26/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Crypto.Secp256k1: exportSecKey :: Bool -> SecKey -> ByteString
+ Crypto.Secp256k1.Internal: ecSecKeyExport :: Ptr Ctx -> Ptr CUChar -> Ptr CSize -> Ptr SecKey32 -> SerFlags -> IO Ret

Files

secp256k1.cabal view
@@ -1,5 +1,5 @@ name:                secp256k1-version:             0.5.2+version:             0.5.3 synopsis:            Bindings for secp256k1 library from Bitcoin Core description:         Please see README.md homepage:            http://github.com/haskoin/secp256k1-haskell#readme@@ -113,8 +113,8 @@     default-language:    Haskell2010     ghc-options:         -Wall     cc-options:          -DHAVE_CONFIG_H-    c-sources:           secp256k1/src/secp256k1.c, secp256k1/contrib/lax_der_parsing.c-    include-dirs:        secp256k1, secp256k1/include+    c-sources:           secp256k1/src/secp256k1.c, secp256k1/contrib/lax_der_parsing.c, secp256k1/contrib/lax_der_privatekey_parsing.c+    include-dirs:        secp256k1, secp256k1/contrib, secp256k1/include  test-suite secp256k1-test     type:                exitcode-stdio-1.0
src/Crypto/Secp256k1.hs view
@@ -20,6 +20,7 @@     , secKey     , getSecKey     , derivePubKey+    , exportSecKey      -- * Public Keys     , PubKey@@ -261,6 +262,18 @@     fp <- mallocForeignPtr     ret <- withForeignPtr fp $ \p -> ecPubKeyParse ctx p b l     if isSuccess ret then return $ Just $ PubKey fp else return Nothing++-- | Encode secret key as DER.  First argument 'True' for compressed output.+exportSecKey :: Bool -> SecKey -> ByteString+exportSecKey compress (SecKey fk) = withContext $ \ctx ->+    withForeignPtr fk $ \k -> alloca $ \l -> allocaBytes 279 $ \o -> do+        poke l 279+        ret <- ecSecKeyExport ctx o l k c+        unless (isSuccess ret) $ error "could not export secret key"+        n <- peek l+        packByteString (o, n)+  where+    c = if compress then compressed else uncompressed  -- | Encode public key as DER. First argument 'True' for compressed output. exportPubKey :: Bool -> PubKey -> ByteString
src/Crypto/Secp256k1/Internal.hs view
@@ -480,3 +480,13 @@     -> Ptr RecSig65     -> Ptr Msg32     -> IO Ret++foreign import ccall+    "lax_der_privatekey_parsing.h ec_privkey_export_der"+    ecSecKeyExport+    :: Ptr Ctx+    -> Ptr CUChar -- ^ array to store DER-encoded key (allocate 279 bytes)+    -> Ptr CSize -- ^ size of previous array, will be updated+    -> Ptr SecKey32+    -> SerFlags+    -> IO Ret