secp256k1-0.4.5: Bindings for secp256k1 library from Bitcoin Core

LicenseMIT
MaintainerJean-Pierre Rupp <root@haskoin.com>
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Crypto.Secp256k1

Contents

Description

Crytpographic functions from Bitcoin’s secp256k1 library.

Synopsis

Messages

msg :: ByteString -> Maybe Msg Source

Import 32-byte ByteString as Msg.

getMsg :: Msg -> ByteString Source

Get 32-byte message.

Secret Keys

getSecKey :: SecKey -> ByteString Source

Get 32-byte secret key.

Public Keys

importPubKey :: ByteString -> Maybe PubKey Source

Import DER-encoded public key.

exportPubKey :: Bool -> PubKey -> ByteString Source

Encode public key as DER. First argument True for compressed output.

Signatures

verifySig :: PubKey -> Sig -> Msg -> Bool Source

Verify message signature. True means that the signature is correct.

normalizeSig :: Sig -> (Sig, Bool) Source

Convert signature to a normalized lower-S form. Boolean value True indicates that the signature changed, False indicates that it was already normal.

DER

importSig :: ByteString -> Maybe Sig Source

Import DER-encoded signature.

laxImportSig :: ByteString -> Maybe Sig Source

Relaxed DER parsing. Allows certain DER errors and violations.

exportSig :: Sig -> ByteString Source

Encode signature as strict DER.

Compact

Addition & Multiplication

getTweak :: Tweak -> ByteString Source

Get 32-byte tweak.

tweakAddSecKey :: SecKey -> Tweak -> Maybe SecKey Source

Add tweak to secret key.

tweakMulSecKey :: SecKey -> Tweak -> Maybe SecKey Source

Multiply secret key by tweak.

tweakAddPubKey :: PubKey -> Tweak -> Maybe PubKey Source

Add tweak to public key. Tweak is multiplied first by G to obtain a point.

tweakMulPubKey :: PubKey -> Tweak -> Maybe PubKey Source

Multiply public key by tweak. Tweak is multiplied first by G to obtain a point.

combinePubKeys :: [PubKey] -> Maybe PubKey Source

Add multiple public keys together.