secp256k1-haskell-0.6.0: Bindings for secp256k1
LicenseUNLICENSE
MaintainerJean-Pierre Rupp <jprupp@protonmail.ch>
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Crypto.Secp256k1

Description

Crytpographic functions from Bitcoin’s secp256k1 library.

Synopsis

Messages

data Msg Source #

Instances

Instances details
Eq Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

(==) :: Msg -> Msg -> Bool #

(/=) :: Msg -> Msg -> Bool #

Read Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Show Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

showsPrec :: Int -> Msg -> ShowS #

show :: Msg -> String #

showList :: [Msg] -> ShowS #

IsString Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

fromString :: String -> Msg #

Generic Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep Msg :: Type -> Type #

Methods

from :: Msg -> Rep Msg x #

to :: Rep Msg x -> Msg #

Arbitrary Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

arbitrary :: Gen Msg #

shrink :: Msg -> [Msg] #

Serialize Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

put :: Putter Msg #

get :: Get Msg #

NFData Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: Msg -> () #

Hashable Msg Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

hashWithSalt :: Int -> Msg -> Int #

hash :: Msg -> Int #

type Rep Msg Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep Msg = D1 ('MetaData "Msg" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "Msg" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMsg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

msg :: ByteString -> Maybe Msg Source #

Import 32-byte ByteString as Msg.

Secret Keys

data SecKey Source #

Instances

Instances details
Eq SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

(==) :: SecKey -> SecKey -> Bool #

(/=) :: SecKey -> SecKey -> Bool #

Read SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Show SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

IsString SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

fromString :: String -> SecKey #

Generic SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep SecKey :: Type -> Type #

Methods

from :: SecKey -> Rep SecKey x #

to :: Rep SecKey x -> SecKey #

Arbitrary SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Serialize SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

NFData SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: SecKey -> () #

Hashable SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

hashWithSalt :: Int -> SecKey -> Int #

hash :: SecKey -> Int #

type Rep SecKey Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep SecKey = D1 ('MetaData "SecKey" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "SecKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSecKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Public Keys

data PubKey Source #

Instances

Instances details
Eq PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

(==) :: PubKey -> PubKey -> Bool #

(/=) :: PubKey -> PubKey -> Bool #

Read PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Show PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

IsString PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

fromString :: String -> PubKey #

Generic PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep PubKey :: Type -> Type #

Methods

from :: PubKey -> Rep PubKey x #

to :: Rep PubKey x -> PubKey #

Arbitrary PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Serialize PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

NFData PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: PubKey -> () #

Hashable PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

hashWithSalt :: Int -> PubKey -> Int #

hash :: PubKey -> Int #

type Rep PubKey Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep PubKey = D1 ('MetaData "PubKey" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "PubKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPubKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

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 #

Instances

Instances details
Eq Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

(==) :: Sig -> Sig -> Bool #

(/=) :: Sig -> Sig -> Bool #

Read Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Show Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

showsPrec :: Int -> Sig -> ShowS #

show :: Sig -> String #

showList :: [Sig] -> ShowS #

IsString Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

fromString :: String -> Sig #

Generic Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep Sig :: Type -> Type #

Methods

from :: Sig -> Rep Sig x #

to :: Rep Sig x -> Sig #

Serialize Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

put :: Putter Sig #

get :: Get Sig #

NFData Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: Sig -> () #

Hashable Sig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

hashWithSalt :: Int -> Sig -> Int #

hash :: Sig -> Int #

type Rep Sig Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep Sig = D1 ('MetaData "Sig" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "Sig" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

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

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

normalizeSig :: Sig -> Maybe Sig Source #

Convert signature to a normalized lower-S form. Nothing indicates that it was already normal.

DER

importSig :: ByteString -> Maybe Sig Source #

Import DER-encoded signature.

exportSig :: Sig -> ByteString Source #

Encode signature as strict DER.

Compact

data CompactSig Source #

Instances

Instances details
Eq CompactSig Source # 
Instance details

Defined in Crypto.Secp256k1

Generic CompactSig Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep CompactSig :: Type -> Type #

Serialize CompactSig Source # 
Instance details

Defined in Crypto.Secp256k1

NFData CompactSig Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: CompactSig -> () #

type Rep CompactSig Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep CompactSig = D1 ('MetaData "CompactSig" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "CompactSig" 'PrefixI 'True) (S1 ('MetaSel ('Just "getCompactSig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Addition & Multiplication

data Tweak Source #

Instances

Instances details
Eq Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

(==) :: Tweak -> Tweak -> Bool #

(/=) :: Tweak -> Tweak -> Bool #

Read Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Show Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

showsPrec :: Int -> Tweak -> ShowS #

show :: Tweak -> String #

showList :: [Tweak] -> ShowS #

IsString Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

fromString :: String -> Tweak #

Generic Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Associated Types

type Rep Tweak :: Type -> Type #

Methods

from :: Tweak -> Rep Tweak x #

to :: Rep Tweak x -> Tweak #

Serialize Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

put :: Putter Tweak #

get :: Get Tweak #

NFData Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

rnf :: Tweak -> () #

Hashable Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

Methods

hashWithSalt :: Int -> Tweak -> Int #

hash :: Tweak -> Int #

type Rep Tweak Source # 
Instance details

Defined in Crypto.Secp256k1

type Rep Tweak = D1 ('MetaData "Tweak" "Crypto.Secp256k1" "secp256k1-haskell-0.6.0-inplace" 'True) (C1 ('MetaCons "Tweak" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTweak") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

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.