License | UNLICENSE |
---|---|
Maintainer | Jean-Pierre Rupp <jprupp@protonmail.ch> |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Crytpographic functions from Bitcoin’s secp256k1 library.
Synopsis
- newtype Ctx = Ctx {}
- withContext :: (Ctx -> IO a) -> IO a
- randomizeContext :: Ctx -> IO ()
- createContext :: IO Ctx
- cloneContext :: Ctx -> IO Ctx
- destroyContext :: Ctx -> IO ()
- newtype Msg = Msg {
- get :: ByteString
- msg :: ByteString -> Maybe Msg
- newtype SecKey = SecKey {
- get :: ByteString
- secKey :: ByteString -> Maybe SecKey
- derivePubKey :: Ctx -> SecKey -> PubKey
- newtype PubKey = PubKey {
- get :: ByteString
- pubKey :: ByteString -> Maybe PubKey
- importPubKey :: Ctx -> ByteString -> Maybe PubKey
- exportPubKey :: Ctx -> Bool -> PubKey -> ByteString
- newtype Sig = Sig {
- get :: ByteString
- sig :: ByteString -> Maybe Sig
- signMsg :: Ctx -> SecKey -> Msg -> Sig
- verifySig :: Ctx -> PubKey -> Sig -> Msg -> Bool
- normalizeSig :: Ctx -> Sig -> Maybe Sig
- importSig :: Ctx -> ByteString -> Maybe Sig
- exportSig :: Ctx -> Sig -> ByteString
- newtype CompactSig = CompactSig {
- get :: ByteString
- compactSig :: ByteString -> Maybe CompactSig
- exportCompactSig :: Ctx -> Sig -> CompactSig
- importCompactSig :: Ctx -> CompactSig -> Maybe Sig
- newtype Tweak = Tweak {
- get :: ByteString
- tweak :: ByteString -> Maybe Tweak
- tweakAddSecKey :: Ctx -> SecKey -> Tweak -> Maybe SecKey
- tweakMulSecKey :: Ctx -> SecKey -> Tweak -> Maybe SecKey
- tweakAddPubKey :: Ctx -> PubKey -> Tweak -> Maybe PubKey
- tweakMulPubKey :: Ctx -> PubKey -> Tweak -> Maybe PubKey
- combinePubKeys :: Ctx -> [PubKey] -> Maybe PubKey
- tweakNegate :: Ctx -> Tweak -> Maybe Tweak
Context
randomizeContext :: Ctx -> IO () Source #
createContext :: IO Ctx Source #
destroyContext :: Ctx -> IO () Source #
Messages
Msg | |
|
Instances
Arbitrary Msg Source # | |
IsString Msg Source # | |
Defined in Crypto.Secp256k1.Internal.Base fromString :: String -> Msg # | |
Generic Msg Source # | |
Read Msg Source # | |
Show Msg Source # | |
NFData Msg Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
Eq Msg Source # | |
Hashable Msg Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
type Rep Msg Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep Msg = D1 ('MetaData "Msg" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "Msg" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
msg :: ByteString -> Maybe Msg Source #
Import 32-byte ByteString
as Msg
.
Secret Keys
SecKey | |
|
Instances
Arbitrary SecKey Source # | |
IsString SecKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base fromString :: String -> SecKey # | |
Generic SecKey Source # | |
Read SecKey Source # | |
Show SecKey Source # | |
NFData SecKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
Eq SecKey Source # | |
Hashable SecKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
type Rep SecKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep SecKey = D1 ('MetaData "SecKey" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "SecKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
secKey :: ByteString -> Maybe SecKey Source #
Import 32-byte ByteString
as SecKey
.
Public Keys
PubKey | |
|
Instances
IsString PubKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base fromString :: String -> PubKey # | |
Generic PubKey Source # | |
Read PubKey Source # | |
Show PubKey Source # | |
NFData PubKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
Eq PubKey Source # | |
Hashable PubKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
type Rep PubKey Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep PubKey = D1 ('MetaData "PubKey" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "PubKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
pubKey :: ByteString -> Maybe PubKey Source #
Import 64-byte ByteString
as PubKey
.
importPubKey :: Ctx -> ByteString -> Maybe PubKey Source #
Import DER-encoded public key.
exportPubKey :: Ctx -> Bool -> PubKey -> ByteString Source #
Encode public key as DER. First argument True
for compressed output.
Signatures
Sig | |
|
Instances
IsString Sig Source # | |
Defined in Crypto.Secp256k1.Internal.Base fromString :: String -> Sig # | |
Generic Sig Source # | |
Read Sig Source # | |
Show Sig Source # | |
NFData Sig Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
Eq Sig Source # | |
Hashable Sig Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
type Rep Sig Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep Sig = D1 ('MetaData "Sig" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "Sig" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
sig :: ByteString -> Maybe Sig Source #
Import 64-byte ByteString
as Sig
.
verifySig :: Ctx -> PubKey -> Sig -> Msg -> Bool Source #
Verify message signature. True
means that the signature is correct.
normalizeSig :: Ctx -> Sig -> Maybe Sig Source #
Convert signature to a normalized lower-S form. Nothing
indicates that it
was already normal.
DER
Compact
newtype CompactSig Source #
Instances
Generic CompactSig Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep CompactSig :: Type -> Type # from :: CompactSig -> Rep CompactSig x # to :: Rep CompactSig x -> CompactSig # | |
NFData CompactSig Source # | |
Defined in Crypto.Secp256k1.Internal.Base rnf :: CompactSig -> () # | |
Eq CompactSig Source # | |
Defined in Crypto.Secp256k1.Internal.Base (==) :: CompactSig -> CompactSig -> Bool # (/=) :: CompactSig -> CompactSig -> Bool # | |
Hashable CompactSig Source # | |
Defined in Crypto.Secp256k1.Internal.Base hashWithSalt :: Int -> CompactSig -> Int # hash :: CompactSig -> Int # | |
type Rep CompactSig Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep CompactSig = D1 ('MetaData "CompactSig" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "CompactSig" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
compactSig :: ByteString -> Maybe CompactSig Source #
exportCompactSig :: Ctx -> Sig -> CompactSig Source #
importCompactSig :: Ctx -> CompactSig -> Maybe Sig Source #
Addition & Multiplication
Tweak | |
|
Instances
IsString Tweak Source # | |
Defined in Crypto.Secp256k1.Internal.Base fromString :: String -> Tweak # | |
Generic Tweak Source # | |
Read Tweak Source # | |
Show Tweak Source # | |
NFData Tweak Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
Eq Tweak Source # | |
Hashable Tweak Source # | |
Defined in Crypto.Secp256k1.Internal.Base | |
type Rep Tweak Source # | |
Defined in Crypto.Secp256k1.Internal.Base type Rep Tweak = D1 ('MetaData "Tweak" "Crypto.Secp256k1.Internal.Base" "secp256k1-haskell-1.0.1-inplace" 'True) (C1 ('MetaCons "Tweak" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
tweak :: ByteString -> Maybe Tweak Source #
32-Byte ByteString
as Tweak
.
tweakAddPubKey :: Ctx -> PubKey -> Tweak -> Maybe PubKey Source #
Add tweak to public key. Tweak is multiplied first by G to obtain a point.