| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Crypto.Signing
Synopsis
- module Cardano.Crypto.Signing.Redeem
- module Cardano.Crypto.Signing.Safe
- sign ∷ EncCBOR a ⇒ ProtocolMagicId → SignTag → SigningKey → a → Signature a
- newtype Signature a = Signature XSignature
- newtype SigningKey = SigningKey {}
- newtype VerificationKey = VerificationKey {}
- keyGen ∷ MonadRandom m ⇒ m (VerificationKey, SigningKey)
- deterministicKeyGen ∷ ByteString → (VerificationKey, SigningKey)
- data SignTag
- signTag ∷ ProtocolMagicId → SignTag → ByteString
- signTagDecoded ∷ Annotated ProtocolMagicId ByteString → SignTag → ByteString
- toVerification ∷ SigningKey → VerificationKey
- encCBORXSignature ∷ XSignature → Encoding
- decCBORXSignature ∷ Decoder s XSignature
- fullSignatureHexF ∷ Format r (Signature a → r)
- parseFullSignature ∷ Text → Either SignatureParseError (Signature a)
- signEncoded ∷ ProtocolMagicId → SignTag → SigningKey → Encoding → Signature a
- signRaw ∷ ProtocolMagicId → Maybe SignTag → SigningKey → ByteString → Signature Raw
- safeSign ∷ EncCBOR 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
- encCBORXPrv ∷ XPrv → Encoding
- decCBORXPrv ∷ Decoder s XPrv
- toCBORXPrv ∷ XPrv → Encoding
- fromCBORXPrv ∷ Decoder s XPrv
- shortVerificationKeyHexF ∷ Format r (VerificationKey → r)
- formatFullVerificationKey ∷ VerificationKey → Builder
- fullVerificationKeyF ∷ Format r (VerificationKey → r)
- fullVerificationKeyHexF ∷ Format r (VerificationKey → r)
- parseFullVerificationKey ∷ Text → Either VerificationKeyParseError VerificationKey
Documentation
module Cardano.Crypto.Signing.Safe
Arguments
| ∷ EncCBOR a | |
| ⇒ ProtocolMagicId | |
| → SignTag | See docs for |
| → SigningKey | |
| → a | |
| → Signature a |
Encode something with EncCBOR and sign it
Wrapper around XSignature
Constructors
| Signature XSignature |
Instances
newtype SigningKey Source #
Wrapper around XPrv.
Constructors
| SigningKey | |
Fields | |
Instances
| FromCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey | |
| ToCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods toCBOR ∷ SigningKey → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy SigningKey → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [SigningKey] → Size Source # | |
| DecCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey | |
| EncCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods encCBOR ∷ SigningKey → Encoding Source # | |
| 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 # | |
| Show SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey Methods showsPrec ∷ Int → SigningKey → ShowS # show ∷ SigningKey → String # showList ∷ [SigningKey] → ShowS # | |
| NoThunks SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey | |
newtype VerificationKey Source #
Wrapper around XPub.
Constructors
| VerificationKey | |
Fields | |
Instances
| FromJSON VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods parseJSON ∷ Value → Parser VerificationKey Source # | |||||
| ToJSON VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods toJSON ∷ VerificationKey → Value Source # toEncoding ∷ VerificationKey → Encoding Source # toJSONList ∷ [VerificationKey] → Value Source # | |||||
| FromCBOR VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey | |||||
| ToCBOR VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods toCBOR ∷ VerificationKey → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy VerificationKey → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [VerificationKey] → Size Source # | |||||
| DecCBOR VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey | |||||
| EncCBOR VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods | |||||
| NFData VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods rnf ∷ VerificationKey → () # | |||||
| Buildable VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods | |||||
| Generic VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Associated Types
Methods from ∷ VerificationKey → Rep VerificationKey x # to ∷ Rep VerificationKey x → VerificationKey # | |||||
| Show VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods showsPrec ∷ Int → VerificationKey → ShowS # show ∷ VerificationKey → String # showList ∷ [VerificationKey] → ShowS # | |||||
| Eq VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods (==) ∷ VerificationKey → VerificationKey → Bool # (/=) ∷ VerificationKey → VerificationKey → Bool # | |||||
| Ord VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods compare ∷ VerificationKey → VerificationKey → Ordering # (<) ∷ VerificationKey → VerificationKey → Bool # (<=) ∷ VerificationKey → VerificationKey → Bool # (>) ∷ VerificationKey → VerificationKey → Bool # (>=) ∷ VerificationKey → VerificationKey → Bool # | |||||
| NoThunks VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey | |||||
| MonadError SchemaError m ⇒ FromJSON m VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods fromJSON ∷ JSValue → m VerificationKey Source # | |||||
| Monad m ⇒ ToJSON m VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey Methods toJSON ∷ VerificationKey → m JSValue Source # | |||||
| type Rep VerificationKey Source # | |||||
Defined in Cardano.Crypto.Signing.VerificationKey type Rep VerificationKey = D1 ('MetaData "VerificationKey" "Cardano.Crypto.Signing.VerificationKey" "cardano-crypto-wrapper-1.7.0.0-inplace" 'True) (C1 ('MetaCons "VerificationKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unVerificationKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 XPub))) | |||||
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.
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
| Buildable SignTag Source # | |||||
| Generic SignTag Source # | |||||
Defined in Cardano.Crypto.Signing.Tag Associated Types
| |||||
| Show SignTag Source # | |||||
| Eq SignTag Source # | |||||
| Ord SignTag Source # | |||||
| type Rep SignTag Source # | |||||
Defined in Cardano.Crypto.Signing.Tag type Rep SignTag = D1 ('MetaData "SignTag" "Cardano.Crypto.Signing.Tag" "cardano-crypto-wrapper-1.7.0.0-inplace" 'False) (((C1 ('MetaCons "SignForTestingOnly" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "SignTx" 'PrefixI 'False) (U1 ∷ Type → Type)) :+: (C1 ('MetaCons "SignRedeemTx" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "SignVssCert" 'PrefixI 'False) (U1 ∷ Type → Type))) :+: ((C1 ('MetaCons "SignUSProposal" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "SignCommitment" 'PrefixI 'False) (U1 ∷ Type → Type)) :+: (C1 ('MetaCons "SignUSVote" 'PrefixI 'False) (U1 ∷ Type → Type) :+: (C1 ('MetaCons "SignBlock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VerificationKey)) :+: C1 ('MetaCons "SignCertificate" 'PrefixI 'False) (U1 ∷ Type → Type))))) | |||||
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
toVerification ∷ SigningKey → VerificationKey Source #
Generate a verification key from a signing key. Fast (it just drops some bytes off the signing key).
parseFullSignature ∷ Text → Either SignatureParseError (Signature a) Source #
Parse Signature from base16 encoded string.
signEncoded ∷ ProtocolMagicId → SignTag → SigningKey → Encoding → Signature a Source #
Arguments
| ∷ ProtocolMagicId | |
| → Maybe SignTag | See docs for |
| → SigningKey | |
| → ByteString | |
| → Signature Raw |
Sign a Raw bytestring
safeSign ∷ EncCBOR a ⇒ ProtocolMagicId → SignTag → SafeSigner → a → Signature a Source #
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
encCBORXPrv ∷ XPrv → Encoding Source #
decCBORXPrv ∷ Decoder s XPrv Source #
toCBORXPrv ∷ XPrv → Encoding Source #
fromCBORXPrv ∷ Decoder s XPrv Source #
shortVerificationKeyHexF ∷ Format r (VerificationKey → r) Source #
Formatter for VerificationKey to show it in hex, but only first 8 chars.
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.
parseFullVerificationKey ∷ Text → Either VerificationKeyParseError VerificationKey Source #
Parse VerificationKey from base64 encoded string