| License | UNLICENSE |
|---|---|
| Maintainer | Keagan McClelland <keagan.mcclelland@gmail.com> |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Crypto.Secp256k1
Description
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
Messages
Instances
| Arbitrary Msg Source # | |
| IsString Msg Source # | |
Defined in Crypto.Secp256k1 Methods fromString :: String -> Msg # | |
| Generic Msg Source # | |
| Read Msg Source # | |
| Show Msg Source # | |
| Serialize Msg Source # | |
Defined in Crypto.Secp256k1 | |
| NFData Msg Source # | |
Defined in Crypto.Secp256k1 | |
| Eq Msg Source # | |
| Hashable Msg Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep Msg Source # | |
Defined in Crypto.Secp256k1 type Rep Msg = D1 ('MetaData "Msg" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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
| Arbitrary SecKey Source # | |
| IsString SecKey Source # | |
Defined in Crypto.Secp256k1 Methods fromString :: String -> SecKey # | |
| Generic SecKey Source # | |
| Read SecKey Source # | |
| Show SecKey Source # | |
| Serialize SecKey Source # | |
Defined in Crypto.Secp256k1 | |
| NFData SecKey Source # | |
Defined in Crypto.Secp256k1 | |
| Eq SecKey Source # | |
| Hashable SecKey Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep SecKey Source # | |
Defined in Crypto.Secp256k1 type Rep SecKey = D1 ('MetaData "SecKey" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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
| Arbitrary PubKey Source # | |
| IsString PubKey Source # | |
Defined in Crypto.Secp256k1 Methods fromString :: String -> PubKey # | |
| Generic PubKey Source # | |
| Read PubKey Source # | |
| Show PubKey Source # | |
| Serialize PubKey Source # | |
Defined in Crypto.Secp256k1 | |
| NFData PubKey Source # | |
Defined in Crypto.Secp256k1 | |
| Eq PubKey Source # | |
| Hashable PubKey Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep PubKey Source # | |
Defined in Crypto.Secp256k1 type Rep PubKey = D1 ('MetaData "PubKey" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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
| IsString Sig Source # | |
Defined in Crypto.Secp256k1 Methods fromString :: String -> Sig # | |
| Generic Sig Source # | |
| Read Sig Source # | |
| Show Sig Source # | |
| Serialize Sig Source # | |
Defined in Crypto.Secp256k1 | |
| NFData Sig Source # | |
Defined in Crypto.Secp256k1 | |
| Eq Sig Source # | |
| Hashable Sig Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep Sig Source # | |
Defined in Crypto.Secp256k1 type Rep Sig = D1 ('MetaData "Sig" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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
| Generic CompactSig Source # | |
Defined in Crypto.Secp256k1 Associated Types type Rep CompactSig :: Type -> Type # | |
| Serialize CompactSig Source # | |
Defined in Crypto.Secp256k1 | |
| NFData CompactSig Source # | |
Defined in Crypto.Secp256k1 Methods rnf :: CompactSig -> () # | |
| Eq CompactSig Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep CompactSig Source # | |
Defined in Crypto.Secp256k1 type Rep CompactSig = D1 ('MetaData "CompactSig" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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
| IsString Tweak Source # | |
Defined in Crypto.Secp256k1 Methods fromString :: String -> Tweak # | |
| Generic Tweak Source # | |
| Read Tweak Source # | |
| Show Tweak Source # | |
| Serialize Tweak Source # | |
Defined in Crypto.Secp256k1 | |
| NFData Tweak Source # | |
Defined in Crypto.Secp256k1 | |
| Eq Tweak Source # | |
| Hashable Tweak Source # | |
Defined in Crypto.Secp256k1 | |
| type Rep Tweak Source # | |
Defined in Crypto.Secp256k1 type Rep Tweak = D1 ('MetaData "Tweak" "Crypto.Secp256k1" "libsecp256k1-0.0.1-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.