secp256k1-0.3.0: secp256k1 bindings for Haskell

LicensePublicDomain
Maintainerroot@haskoin.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Crypto.Secp256k1

Contents

Description

This module exposes crytpographic functions from Bitcoin’s secp256k1 library. Depends on secp256k1.

Synopsis

Messages

data Msg Source

Internal message data type.

msg :: ByteString -> Maybe Msg Source

Create internal message data from 32-byte ByteString.

getMsg :: Msg -> ByteString Source

Get 32-byte message.

Secret Keys

data SecKey Source

Internal secret key data type.

secKey :: ByteString -> Maybe SecKey Source

Create internal secret key data from 32-byte ByteString.

getSecKey :: SecKey -> ByteString Source

Get 32-byte secret key.

derivePubKey :: SecKey -> PubKey Source

Obtain public key from secret key.

BER

importSecKey :: ByteString -> Maybe SecKey Source

Read BER-encoded secret key.

exportSecKey :: Bool -> SecKey -> ByteString Source

Encode secret key as BER. First argument True for compressed output.

Public Keys

data PubKey Source

Internal public key data type.

importPubKey :: ByteString -> Maybe PubKey Source

Read DER-encoded public key.

exportPubKey :: Bool -> PubKey -> ByteString Source

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

Signatures

data Sig Source

Internal signature data type.

signMsg :: SecKey -> Msg -> Sig Source

Sign message using secret key.

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 was normalized, False indicates that it was already normal.

DER

importSig :: ByteString -> Maybe Sig Source

Read DER-encoded signature.

laxImportSig :: ByteString -> Maybe Sig Source

Relaxed DER parsing. Allows certain DER errors and violations.

exportSig :: Sig -> ByteString Source

Encode signature as DER.

Compact

exportCompactSig :: Sig -> CompactSig Source

Get compact signature.

importCompactSig :: CompactSig -> Maybe Sig Source

Read DER-encoded signature.

Addition & Multiplication

data Tweak Source

Internal tweak data type for addition and multiplication.

tweak :: ByteString -> Maybe Tweak Source

Create internal tweak data from 32-byte ByteString.

getTweak :: Tweak -> ByteString Source

Get 32-byte tweak.

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

Add tweak to secret key using ECDSA addition.

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

Multiply secret key by tweak using ECDSA multiplication.

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

Perform ECDSA addition between the public key point and the point obtained by multiplying the tweak scalar by the curve generator.

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

Perform ECDSA multiplication between the public key point and the point obtained by multiplying the tweak scalar by the curve generator.

combinePubKeys :: [PubKey] -> Maybe PubKey Source

Add multiple public keys together using ECDSA addition.