License | MIT |
---|---|
Maintainer | Jean-Pierre Rupp <root@haskoin.com> |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Crytpographic functions from Bitcoin’s secp256k1 library.
- 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 -> (Sig, Bool)
- importSig :: ByteString -> Maybe Sig
- laxImportSig :: ByteString -> Maybe Sig
- exportSig :: Sig -> ByteString
- data CompactSig = CompactSig {}
- exportCompactSig :: Sig -> CompactSig
- importCompactSig :: CompactSig -> Maybe Sig
- data RecSig
- data CompactRecSig = CompactRecSig {}
- importCompactRecSig :: CompactRecSig -> Maybe RecSig
- exportCompactRecSig :: RecSig -> CompactRecSig
- convertRecSig :: RecSig -> Sig
- signRecMsg :: SecKey -> Msg -> RecSig
- recover :: RecSig -> Msg -> Maybe PubKey
- 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
msg :: ByteString -> Maybe Msg Source #
Import 32-byte ByteString
as Msg
.
getMsg :: Msg -> ByteString Source #
Get 32-byte message.
Secret Keys
secKey :: ByteString -> Maybe SecKey Source #
Import 32-byte ByteString
as SecKey
.
getSecKey :: SecKey -> ByteString Source #
Get 32-byte secret key.
derivePubKey :: SecKey -> PubKey Source #
Public Keys
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
verifySig :: PubKey -> Sig -> Msg -> Bool Source #
Verify message signature. True
means that the signature is correct.
DER
laxImportSig :: ByteString -> Maybe Sig Source #
Relaxed DER parsing. Allows certain DER errors and violations.
exportSig :: Sig -> ByteString Source #
Encode signature as strict DER.
Compact
data CompactSig Source #
exportCompactSig :: Sig -> CompactSig Source #
importCompactSig :: CompactSig -> Maybe Sig Source #
Recoverable
importCompactRecSig :: CompactRecSig -> Maybe RecSig Source #
Parse a compact ECDSA signature (64 bytes + recovery id).
exportCompactRecSig :: RecSig -> CompactRecSig Source #
Serialize an ECDSA signature in compact format (64 bytes + recovery id).
convertRecSig :: RecSig -> Sig Source #
Convert a recoverable signature into a normal signature.
Addition & Multiplication
tweak :: ByteString -> Maybe Tweak Source #
32-Byte ByteString
as Tweak
.
getTweak :: Tweak -> ByteString Source #
Get 32-byte tweak.
tweakAddPubKey :: PubKey -> Tweak -> Maybe PubKey Source #
Add tweak to public key. Tweak is multiplied first by G to obtain a point.