Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Crypto.Signing
Contents
Synopsis
- data SignTag
- signTag :: ProtocolMagicId -> SignTag -> ByteString
- signTagDecoded :: Annotated ProtocolMagicId ByteString -> SignTag -> ByteString
- newtype Signature a = Signature XSignature
- toCBORXSignature :: XSignature -> Encoding
- fromCBORXSignature :: Decoder s XSignature
- fullSignatureHexF :: Format r (Signature a -> r)
- parseFullSignature :: Text -> Either SignatureParseError (Signature a)
- sign :: ToCBOR a => ProtocolMagicId -> SignTag -> SigningKey -> a -> Signature a
- signEncoded :: ProtocolMagicId -> SignTag -> SigningKey -> Encoding -> Signature a
- signRaw :: ProtocolMagicId -> Maybe SignTag -> SigningKey -> ByteString -> Signature Raw
- safeSign :: ToCBOR a => ProtocolMagicId -> SignTag -> SafeSigner -> a -> Signature a
- safeSignRaw :: ProtocolMagicId -> Maybe SignTag -> SafeSigner -> ByteString -> Signature Raw
- verifySignature :: (a -> Encoding) -> ProtocolMagicId -> SignTag -> VerificationKey -> a -> Signature a -> Bool
- verifySignatureDecoded :: Decoded t => Annotated ProtocolMagicId ByteString -> SignTag -> VerificationKey -> t -> Signature (BaseType t) -> Bool
- verifySignatureRaw :: VerificationKey -> ByteString -> Signature Raw -> Bool
- newtype SigningKey = SigningKey {
- unSigningKey :: XPrv
- toVerification :: SigningKey -> VerificationKey
- toCBORXPrv :: XPrv -> Encoding
- fromCBORXPrv :: Decoder s XPrv
- module Cardano.Crypto.Signing.Safe
- module Cardano.Crypto.Signing.Redeem
- newtype VerificationKey = VerificationKey {}
- formatFullVerificationKey :: VerificationKey -> Builder
- fullVerificationKeyF :: Format r (VerificationKey -> r)
- fullVerificationKeyHexF :: Format r (VerificationKey -> r)
- shortVerificationKeyHexF :: Format r (VerificationKey -> r)
- parseFullVerificationKey :: Text -> Either VerificationKeyParseError VerificationKey
- keyGen :: MonadRandom m => m (VerificationKey, SigningKey)
- deterministicKeyGen :: ByteString -> (VerificationKey, SigningKey)
Documentation
To protect against replay attacks (i.e. when an attacker intercepts a signed piece of data and later sends it again), we add a tag to all data that we sign. This ensures that even if some bytestring can be deserialized into two different types of messages (A and B), the attacker can't take message A and send it as message B.
We also automatically add the network tag (protocolMagic
) whenever it
makes sense, to ensure that things intended for testnet won't work for
mainnet.
Constructors
SignForTestingOnly | Anything (to be used for testing only) |
SignTx | Tx: |
SignRedeemTx | Redeem tx: |
SignVssCert | Vss certificate: |
SignUSProposal | Update proposal: |
SignCommitment | Commitment: |
SignUSVote | US proposal vote: |
SignBlock VerificationKey | Block header: This constructor takes the |
SignCertificate | Certificate: |
Instances
signTag :: ProtocolMagicId -> SignTag -> ByteString Source #
Get magic bytes corresponding to a SignTag
. Guaranteed to be different
(and begin with a different byte) for different tags.
signTagDecoded :: Annotated ProtocolMagicId ByteString -> SignTag -> ByteString Source #
Get magic bytes corresponding to a SignTag
, taking ProtocolMagic
bytes
from the annotation
Signature
Wrapper around XSignature
Constructors
Signature XSignature |
Instances
Monad m => ToJSON m (Signature w) Source # | |
(Typeable x, MonadError SchemaError m) => FromJSON m (Signature x) Source # | |
Eq (Signature a) Source # | |
Ord (Signature a) Source # | |
Defined in Cardano.Crypto.Signing.Signature | |
Show (Signature a) Source # | |
Generic (Signature a) Source # | |
ToJSON (Signature w) Source # | |
FromJSON (Signature w) Source # | |
Typeable a => ToCBOR (Signature a) Source # | |
Typeable a => FromCBOR (Signature a) Source # | |
NFData (Signature a) Source # | |
Defined in Cardano.Crypto.Signing.Signature | |
Buildable (Signature a) Source # | |
NoThunks (Signature a) Source # | |
type Rep (Signature a) Source # | |
Defined in Cardano.Crypto.Signing.Signature type Rep (Signature a) = D1 ('MetaData "Signature" "Cardano.Crypto.Signing.Signature" "cardano-crypto-wrapper-1.3.0-6xpOK9u3M8m70P8UdE8hNf" 'True) (C1 ('MetaCons "Signature" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 XSignature))) |
parseFullSignature :: Text -> Either SignatureParseError (Signature a) Source #
Parse Signature
from base16 encoded string.
Signing
Arguments
:: ToCBOR a | |
=> ProtocolMagicId | |
-> SignTag | See docs for |
-> SigningKey | |
-> a | |
-> Signature a |
Encode something with ToCBOR
and sign it
signEncoded :: ProtocolMagicId -> SignTag -> SigningKey -> Encoding -> Signature a Source #
Arguments
:: ProtocolMagicId | |
-> Maybe SignTag | See docs for |
-> SigningKey | |
-> ByteString | |
-> Signature Raw |
Sign a Raw
bytestring
safeSign :: ToCBOR a => ProtocolMagicId -> SignTag -> SafeSigner -> a -> Signature a Source #
safeSignRaw :: ProtocolMagicId -> Maybe SignTag -> SafeSigner -> ByteString -> Signature Raw Source #
Verification
verifySignature :: (a -> Encoding) -> ProtocolMagicId -> SignTag -> VerificationKey -> a -> Signature a -> Bool Source #
Verify a signature
verifySignatureDecoded :: Decoded t => Annotated ProtocolMagicId ByteString -> SignTag -> VerificationKey -> t -> Signature (BaseType t) -> Bool Source #
Verify a signature
verifySignatureRaw :: VerificationKey -> ByteString -> Signature Raw -> Bool Source #
Verify Raw
signature
newtype SigningKey Source #
Wrapper around XPrv
.
Constructors
SigningKey | |
Fields
|
Instances
Show SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods showsPrec :: Int -> SigningKey -> ShowS # show :: SigningKey -> String # showList :: [SigningKey] -> ShowS # | |
ToCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods toCBOR :: SigningKey -> Encoding Source # encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SigningKey -> Size Source # encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SigningKey] -> Size Source # | |
FromCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey | |
NFData SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods rnf :: SigningKey -> () # | |
Buildable SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods build :: SigningKey -> Builder Source # | |
NoThunks SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey |
toVerification :: SigningKey -> VerificationKey Source #
Generate a verification key from a signing key. Fast (it just drops some bytes off the signing key).
toCBORXPrv :: XPrv -> Encoding Source #
fromCBORXPrv :: Decoder s XPrv Source #
module Cardano.Crypto.Signing.Safe
newtype VerificationKey Source #
Wrapper around XPub
.
Constructors
VerificationKey | |
Fields |
Instances
formatFullVerificationKey :: VerificationKey -> Builder Source #
Builder
for VerificationKey
to show it in base64 encoded form.
fullVerificationKeyF :: Format r (VerificationKey -> r) Source #
Formatter for VerificationKey
to show it in base64.
fullVerificationKeyHexF :: Format r (VerificationKey -> r) Source #
Formatter for VerificationKey
to show it in hex.
shortVerificationKeyHexF :: Format r (VerificationKey -> r) Source #
Formatter for VerificationKey
to show it in hex, but only first 8 chars.
parseFullVerificationKey :: Text -> Either VerificationKeyParseError VerificationKey Source #
Parse VerificationKey
from base64 encoded string
keyGen :: MonadRandom m => m (VerificationKey, SigningKey) Source #
Generate a key pair. It's recommended to run it with runSecureRandom
from Cardano.Crypto.Random because the OpenSSL generator is probably safer
than the default IO generator.
deterministicKeyGen :: ByteString -> (VerificationKey, SigningKey) Source #
Create key pair deterministically from 32 bytes.