secp256k1-0.5.2: 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

data Sig Source #

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

Recoverable

importCompactRecSig :: CompactRecSig -> Maybe RecSig Source #

Parse a compact ECDSA signature (64 bytes + recovery id).

exportCompactRecSig :: RecSig -> CompactRecSig Source #

Serialize an ECDSA signature in compact format (64 bytes + recovery id).

convertRecSig :: RecSig -> Sig Source #

Convert a recoverable signature into a normal signature.

signRecMsg :: SecKey -> Msg -> RecSig Source #

Create a recoverable ECDSA signature.

recover :: RecSig -> Msg -> Maybe PubKey Source #

Recover an ECDSA public key from a signature.

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.