License | PublicDomain |
---|---|
Maintainer | root@haskoin.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
This module exposes crytpographic functions from Bitcoin’s secp256k1 library. Depends on secp256k1.
- data Msg
- msg :: ByteString -> Maybe Msg
- getMsg :: Msg -> ByteString
- data SecKey
- secKey :: ByteString -> Maybe SecKey
- getSecKey :: SecKey -> ByteString
- importSecKey :: ByteString -> Maybe SecKey
- exportSecKey :: Bool -> SecKey -> ByteString
- pubKey :: SecKey -> PubKey
- data PubKey
- importPubKey :: ByteString -> Maybe PubKey
- exportPubKey :: Bool -> PubKey -> ByteString
- data Sig
- importSig :: ByteString -> Maybe Sig
- exportSig :: Sig -> ByteString
- signMsg :: SecKey -> Msg -> Sig
- verifySig :: PubKey -> Sig -> Msg -> Bool
- 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
Create internal message data from 32-byte ByteString
.
getMsg :: Msg -> ByteString Source
Get 32-byte message.
Secret Keys
secKey :: ByteString -> Maybe SecKey Source
Create internal secret key data from 32-byte ByteString
.
getSecKey :: SecKey -> ByteString Source
Get 32-byte secret key.
importSecKey :: ByteString -> Maybe SecKey Source
Read BER-encoded secret key.
exportSecKey :: Bool -> SecKey -> ByteString Source
Encode secret key as BER. First argument True
for compressed output.
Public Keys
importPubKey :: ByteString -> Maybe PubKey Source
Read DER-encoded public key.
exportPubKey :: Bool -> PubKey -> ByteString Source
Encode public key as DER. First argument True
for compressed output.
Signatures
importSig :: ByteString -> Maybe Sig Source
Read DER-encoded signature.
exportSig :: Sig -> ByteString Source
Encode signature as DER.
verifySig :: PubKey -> Sig -> Msg -> Bool Source
Verify message signature. True
means that the signature is correct.
Addition & Multiplication
Internal tweak data type for addition and multiplication.
tweak :: ByteString -> Maybe Tweak Source
Create internal tweak data from 32-byte ByteString
.
getTweak :: Tweak -> ByteString Source
Get 32-byte tweak.
tweakAddSecKey :: SecKey -> Tweak -> Maybe SecKey Source
Add tweak to secret key using ECDSA addition.
tweakMulSecKey :: SecKey -> Tweak -> Maybe SecKey Source
Multiply secret key by tweak using ECDSA multiplication.
tweakAddPubKey :: PubKey -> Tweak -> Maybe PubKey Source
Perform ECDSA addition between the public key point and the point obtained by multiplying the tweak scalar by the curve generator.
tweakMulPubKey :: PubKey -> Tweak -> Maybe PubKey Source
Perform ECDSA multiplication between the public key point and the point obtained by multiplying the tweak scalar by the curve generator.
combinePubKeys :: [PubKey] -> Maybe PubKey Source
Add multiple public keys together using ECDSA addition.