License | UNLICENSE |
---|---|
Maintainer | Jean-Pierre Rupp <jprupp@protonmail.ch> |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Crytpographic functions from Bitcoin’s secp256k1 library.
Synopsis
- data Msg
- msg :: ByteString -> Maybe Msg
- getMsg :: Msg -> ByteString
- data SecKey
- secKey :: ByteString -> Maybe SecKey
- getSecKey :: SecKey -> ByteString
- derivePubKey :: SecKey -> PubKey
- data PubKey
- importPubKey :: ByteString -> Maybe PubKey
- exportPubKey :: Bool -> PubKey -> ByteString
- data Sig
- signMsg :: SecKey -> Msg -> Sig
- verifySig :: PubKey -> Sig -> Msg -> Bool
- normalizeSig :: Sig -> Maybe Sig
- importSig :: ByteString -> Maybe Sig
- exportSig :: Sig -> ByteString
- data CompactSig
- getCompactSig :: CompactSig -> ByteString
- compactSig :: ByteString -> Maybe CompactSig
- exportCompactSig :: Sig -> CompactSig
- importCompactSig :: CompactSig -> Maybe Sig
- data Tweak
- tweak :: ByteString -> Maybe Tweak
- getTweak :: Tweak -> ByteString
- tweakAddSecKey :: SecKey -> Tweak -> Maybe SecKey
- tweakMulSecKey :: SecKey -> Tweak -> Maybe SecKey
- tweakAddPubKey :: PubKey -> Tweak -> Maybe PubKey
- tweakMulPubKey :: PubKey -> Tweak -> Maybe PubKey
- combinePubKeys :: [PubKey] -> Maybe PubKey
- tweakNegate :: Tweak -> Maybe Tweak
Messages
Instances
Eq Msg Source # | |
Read Msg Source # | |
Show Msg Source # | |
IsString Msg Source # | |
Defined in Crypto.Secp256k1 fromString :: String -> Msg # | |
Generic Msg Source # | |
Arbitrary Msg Source # | |
Serialize Msg Source # | |
NFData Msg Source # | |
Defined in Crypto.Secp256k1 | |
Hashable Msg Source # | |
Defined in Crypto.Secp256k1 | |
type Rep Msg Source # | |
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
.
getMsg :: Msg -> ByteString Source #
Secret Keys
Instances
Eq SecKey Source # | |
Read SecKey Source # | |
Show SecKey Source # | |
IsString SecKey Source # | |
Defined in Crypto.Secp256k1 fromString :: String -> SecKey # | |
Generic SecKey Source # | |
Arbitrary SecKey Source # | |
Serialize SecKey Source # | |
NFData SecKey Source # | |
Defined in Crypto.Secp256k1 | |
Hashable SecKey Source # | |
Defined in Crypto.Secp256k1 | |
type Rep SecKey Source # | |
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))) |
secKey :: ByteString -> Maybe SecKey Source #
Import 32-byte ByteString
as SecKey
.
getSecKey :: SecKey -> ByteString Source #
derivePubKey :: SecKey -> PubKey Source #
Public Keys
Instances
Eq PubKey Source # | |
Read PubKey Source # | |
Show PubKey Source # | |
IsString PubKey Source # | |
Defined in Crypto.Secp256k1 fromString :: String -> PubKey # | |
Generic PubKey Source # | |
Arbitrary PubKey Source # | |
Serialize PubKey Source # | |
NFData PubKey Source # | |
Defined in Crypto.Secp256k1 | |
Hashable PubKey Source # | |
Defined in Crypto.Secp256k1 | |
type Rep PubKey Source # | |
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
Instances
Eq Sig Source # | |
Read Sig Source # | |
Show Sig Source # | |
IsString Sig Source # | |
Defined in Crypto.Secp256k1 fromString :: String -> Sig # | |
Generic Sig Source # | |
Serialize Sig Source # | |
NFData Sig Source # | |
Defined in Crypto.Secp256k1 | |
Hashable Sig Source # | |
Defined in Crypto.Secp256k1 | |
type Rep Sig Source # | |
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
exportSig :: Sig -> ByteString Source #
Encode signature as strict DER.
Compact
data CompactSig Source #
Instances
Eq CompactSig Source # | |
Defined in Crypto.Secp256k1 (==) :: CompactSig -> CompactSig -> Bool # (/=) :: CompactSig -> CompactSig -> Bool # | |
Generic CompactSig Source # | |
Defined in Crypto.Secp256k1 type Rep CompactSig :: Type -> Type # from :: CompactSig -> Rep CompactSig x # to :: Rep CompactSig x -> CompactSig # | |
Serialize CompactSig Source # | |
Defined in Crypto.Secp256k1 put :: Putter CompactSig # get :: Get CompactSig # | |
NFData CompactSig Source # | |
Defined in Crypto.Secp256k1 rnf :: CompactSig -> () # | |
type Rep CompactSig Source # | |
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))) |
getCompactSig :: CompactSig -> ByteString Source #
compactSig :: ByteString -> Maybe CompactSig Source #
exportCompactSig :: Sig -> CompactSig Source #
importCompactSig :: CompactSig -> Maybe Sig Source #
Addition & Multiplication
Instances
Eq Tweak Source # | |
Read Tweak Source # | |
Show Tweak Source # | |
IsString Tweak Source # | |
Defined in Crypto.Secp256k1 fromString :: String -> Tweak # | |
Generic Tweak Source # | |
Serialize Tweak Source # | |
NFData Tweak Source # | |
Defined in Crypto.Secp256k1 | |
Hashable Tweak Source # | |
Defined in Crypto.Secp256k1 | |
type Rep Tweak Source # | |
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))) |
tweak :: ByteString -> Maybe Tweak Source #
32-Byte ByteString
as Tweak
.
getTweak :: Tweak -> ByteString Source #
tweakAddPubKey :: PubKey -> Tweak -> Maybe PubKey Source #
Add tweak to public key. Tweak is multiplied first by G to obtain a point.