Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- 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
- data SignTag
- signTag :: ProtocolMagicId -> SignTag -> ByteString
- signTagDecoded :: Annotated ProtocolMagicId ByteString -> SignTag -> ByteString
-
newtype
SigningKey
=
SigningKey
{
- unSigningKey :: XPrv
- toVerification :: SigningKey -> VerificationKey
- toCBORXPrv :: XPrv -> Encoding
- fromCBORXPrv :: Decoder s XPrv
- 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
- module Cardano.Crypto.Signing.Safe
- module Cardano.Crypto.Signing.Redeem
- keyGen :: MonadRandom m => m ( VerificationKey , SigningKey )
- deterministicKeyGen :: ByteString -> ( VerificationKey , SigningKey )
Documentation
newtype VerificationKey Source #
Wrapper around
XPub
.
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
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.
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
Eq SignTag Source # | |
Ord SignTag Source # | |
Defined in Cardano.Crypto.Signing.Tag |
|
Show SignTag Source # | |
Generic SignTag Source # | |
Buildable 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.3.0-IHV099LYIDeGXjcjOEcwKY" '
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
newtype SigningKey Source #
Wrapper around
XPrv
.
Instances
Show SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey |
|
ToCBOR SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey 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 rnf :: SigningKey -> () Source # |
|
Buildable SigningKey Source # | |
Defined in Cardano.Crypto.Signing.SigningKey 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 #
Signature
Wrapper around
XSignature
Instances
fullSignatureHexF :: Format r ( Signature a -> r) Source #
Formatter for
Signature
to show it in hex.
parseFullSignature :: Text -> Either SignatureParseError ( Signature a) Source #
Parse
Signature
from base16 encoded string.
Signing
:: 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 #
:: 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
module Cardano.Crypto.Signing.Safe
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.