secp256k1-0.1.7: 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 Key

data SecKey Source

Internal secret key data type.

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.

pubKey :: SecKey -> PubKey Source

Obtain public key from secret key.

Raw Secret Key

secKey :: ByteString -> Maybe SecKey Source

Create internal secret key data from 32-byte ByteString.

getSecKey :: SecKey -> ByteString Source

Get 32-byte secret key.

Public Key

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.

Raw Public Key

unsafePubKey :: ByteString -> Maybe PubKey Source

Create internal public key from raw 64-byte ByteString. Unsafe!

getPubKey :: PubKey -> ByteString Source

Get 64-byte internal public key representation.

Signature

data Sig Source

Internal signature data type.

importSig :: ByteString -> Maybe Sig Source

Read DER-encoded signature.

exportSig :: Sig -> ByteString Source

Encode signature as DER.

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.

Raw Signature

unsafeSig :: ByteString -> Maybe Sig Source

Create internal signature from raw 64-byte ByteString. Unsafe!

getSig :: Sig -> ByteString Source

Get 64-byte internal signature representation.

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.