Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
data
KeyRole
- = Genesis
- | GenesisDelegate
- | Payment
- | Staking
- | StakePool
- | BlockIssuer
- | Witness
-
class
HasKeyRole
(a ::
KeyRole
->
Type
->
Type
)
where
- coerceKeyRole :: a r crypto -> a r' crypto
- asWitness :: HasKeyRole a => a r crypto -> a ' Witness crypto
- type DSignable c = Signable ( DSIGN c)
-
newtype
VKey
(kd ::
KeyRole
) crypto =
VKey
{
- unVKey :: VerKeyDSIGN ( DSIGN crypto)
-
data
KeyPair
(kd ::
KeyRole
) crypto =
KeyPair
{
- vKey :: !( VKey kd crypto)
- sKey :: !( SignKeyDSIGN ( DSIGN crypto))
- signedDSIGN :: ( Crypto crypto, Signable ( DSIGN crypto) a) => SignKeyDSIGN ( DSIGN crypto) -> a -> SignedDSIGN crypto a
- verifySignedDSIGN :: ( Crypto crypto, Signable ( DSIGN crypto) a) => VKey kd crypto -> a -> SignedDSIGN crypto a -> Bool
- hashSignature :: Crypto crypto => SignedDSIGN crypto ( Hash crypto h) -> Hash crypto ( SignedDSIGN crypto ( Hash crypto h))
- newtype KeyHash (discriminator :: KeyRole ) crypto = KeyHash ( Hash ( ADDRHASH crypto) ( VerKeyDSIGN ( DSIGN crypto)))
- hashKey :: Crypto crypto => VKey kd crypto -> KeyHash kd crypto
-
data
GenDelegPair
crypto =
GenDelegPair
{
- genDelegKeyHash :: !( KeyHash ' GenesisDelegate crypto)
- genDelegVrfHash :: !( Hash crypto ( VerKeyVRF crypto))
-
newtype
GenDelegs
crypto =
GenDelegs
{
- unGenDelegs :: Map ( KeyHash ' Genesis crypto) ( GenDelegPair crypto)
- newtype GKeys crypto = GKeys { }
- type KESignable c = Signable ( KES c)
- type VRFSignable c = Signable ( VRF c)
- decodeSignedDSIGN :: DSIGNAlgorithm v => Decoder s ( SignedDSIGN v a)
- encodeSignedDSIGN :: DSIGNAlgorithm v => SignedDSIGN v a -> Encoding
- hashWithSerialiser :: HashAlgorithm h => (a -> Encoding ) -> a -> Hash h a
- decodeSignedKES :: KESAlgorithm v => Decoder s ( SignedKES v a)
- decodeVerKeyKES :: KESAlgorithm v => Decoder s ( VerKeyKES v)
- encodeSignedKES :: KESAlgorithm v => SignedKES v a -> Encoding
- encodeVerKeyKES :: KESAlgorithm v => VerKeyKES v -> Encoding
- signedKES :: ( KESAlgorithm v, Signable v a) => ContextKES v -> Period -> a -> SignKeyKES v -> SignedKES v a
- updateKES :: KESAlgorithm v => ContextKES v -> SignKeyKES v -> Period -> Maybe ( SignKeyKES v)
- verifyKES :: ( KESAlgorithm v, Signable v a, HasCallStack ) => ContextKES v -> VerKeyKES v -> Period -> a -> SigKES v -> Either String ()
- verifySignedKES :: ( KESAlgorithm v, Signable v a) => ContextKES v -> VerKeyKES v -> Period -> a -> SignedKES v a -> Either String ()
- decodeVerKeyVRF :: VRFAlgorithm v => Decoder s ( VerKeyVRF v)
- encodeVerKeyVRF :: VRFAlgorithm v => VerKeyVRF v -> Encoding
- hashVerKeyVRF :: ( VRFAlgorithm v, HashAlgorithm h) => VerKeyVRF v -> Hash h ( VerKeyVRF v)
- verifyVRF :: ( VRFAlgorithm v, HasCallStack , Signable v a) => ContextVRF v -> VerKeyVRF v -> a -> ( OutputVRF v, CertVRF v) -> Bool
- type CertifiedVRF c = CertifiedVRF ( VRF c)
- type Hash c = Hash ( HASH c)
- type SignedDSIGN c = SignedDSIGN ( DSIGN c)
- type SignKeyDSIGN c = SignKeyDSIGN ( DSIGN c)
- type SignedKES c = SignedKES ( KES c)
- type SignKeyKES c = SignKeyKES ( KES c)
- type SignKeyVRF c = SignKeyVRF ( VRF c)
- type VerKeyKES c = VerKeyKES ( KES c)
- type VerKeyVRF c = VerKeyVRF ( VRF c)
Documentation
The role of a key.
Note that a role is not _fixed_, nor is it unique. In particular, keys may
variously be used as witnesses, and so in many case we will change the role
of a key to the
Witness
role.
It is also perfectly allowable for a key to be used in many roles; there is nothing prohibiting somebody using the same underlying key as their payment and staking key, as well as the key for their stake pool. So these roles are more intended for two purposes:
- To make explicit how we are using a key in the specifications
- To provide a guide to downstream implementors, for whom the profusion of keys may be confusing.
class HasKeyRole (a :: KeyRole -> Type -> Type ) where Source #
Nothing
coerceKeyRole :: a r crypto -> a r' crypto Source #
General coercion of key roles.
The presence of this function is mostly to help the user realise where they are converting key roles.
default coerceKeyRole :: Coercible (a r crypto) (a r' crypto) => a r crypto -> a r' crypto Source #
Instances
HasKeyRole KeyHash Source # | |
Defined in Cardano.Ledger.Keys |
|
HasKeyRole KeyPair Source # | |
Defined in Cardano.Ledger.Keys |
|
HasKeyRole VKey Source # | |
Defined in Cardano.Ledger.Keys |
|
HasKeyRole Credential Source # | |
Defined in Cardano.Ledger.Credential coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). Credential r crypto -> Credential r' crypto Source # |
asWitness :: HasKeyRole a => a r crypto -> a ' Witness crypto Source #
Use a key as a witness.
This is the most common coercion between key roles, because most keys can be used as witnesses to some types of transaction. As such, we provide an explicit coercion for it.
DSIGN
newtype VKey (kd :: KeyRole ) crypto Source #
Discriminated verification key
We wrap the basic
VerKeyDSIGN
in order to add the key role.
VKey | |
|
Instances
HasKeyRole VKey Source # | |
Defined in Cardano.Ledger.Keys |
|
Crypto crypto => Eq ( VKey kd crypto) Source # | |
Crypto crypto => Show ( VKey kd crypto) Source # | |
Generic ( VKey kd crypto) Source # | |
( Crypto crypto, NFData ( VerKeyDSIGN ( DSIGN crypto))) => NFData ( VKey kd crypto) Source # | |
Defined in Cardano.Ledger.Keys |
|
( Crypto crypto, Typeable kd) => ToCBOR ( VKey kd crypto) Source # | |
( Crypto crypto, Typeable kd) => FromCBOR ( VKey kd crypto) Source # | |
Crypto crypto => NoThunks ( VKey kd crypto) Source # | |
type Rep ( VKey kd crypto) Source # | |
Defined in Cardano.Ledger.Keys
type
Rep
(
VKey
kd crypto) =
D1
('
MetaData
"VKey" "Cardano.Ledger.Keys" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" '
True
) (
C1
('
MetaCons
"VKey" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unVKey") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(
VerKeyDSIGN
(
DSIGN
crypto)))))
|
data KeyPair (kd :: KeyRole ) crypto Source #
Pair of signing key and verification key, with a usage role.
Instances
HasKeyRole KeyPair Source # | |
Defined in Cardano.Ledger.Keys |
|
Crypto crypto => Show ( KeyPair kd crypto) Source # | |
Generic ( KeyPair kd crypto) Source # | |
( Crypto crypto, NFData ( VerKeyDSIGN ( DSIGN crypto)), NFData ( SignKeyDSIGN ( DSIGN crypto))) => NFData ( KeyPair kd crypto) Source # | |
Defined in Cardano.Ledger.Keys |
|
Crypto crypto => NoThunks ( KeyPair kd crypto) Source # | |
type Rep ( KeyPair kd crypto) Source # | |
Defined in Cardano.Ledger.Keys
type
Rep
(
KeyPair
kd crypto) =
D1
('
MetaData
"KeyPair" "Cardano.Ledger.Keys" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" '
False
) (
C1
('
MetaCons
"KeyPair" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"vKey") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
VKey
kd crypto))
:*:
S1
('
MetaSel
('
Just
"sKey") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
SignKeyDSIGN
(
DSIGN
crypto)))))
|
signedDSIGN :: ( Crypto crypto, Signable ( DSIGN crypto) a) => SignKeyDSIGN ( DSIGN crypto) -> a -> SignedDSIGN crypto a Source #
Produce a digital signature
verifySignedDSIGN :: ( Crypto crypto, Signable ( DSIGN crypto) a) => VKey kd crypto -> a -> SignedDSIGN crypto a -> Bool Source #
Verify a digital signature
hashSignature :: Crypto crypto => SignedDSIGN crypto ( Hash crypto h) -> Hash crypto ( SignedDSIGN crypto ( Hash crypto h)) Source #
Hash a given signature
Key hashes
newtype KeyHash (discriminator :: KeyRole ) crypto Source #
Discriminated hash of public Key
KeyHash ( Hash ( ADDRHASH crypto) ( VerKeyDSIGN ( DSIGN crypto))) |
Instances
HasKeyRole KeyHash Source # | |
Defined in Cardano.Ledger.Keys |
|
UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr Ptr ( Credential ' Staking crypto) Source # | |
Defined in Cardano.Ledger.UnifiedMap |
|
UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr ( Credential ' Staking crypto) Coin Source # | |
Defined in Cardano.Ledger.UnifiedMap |
|
UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Source # | |
Defined in Cardano.Ledger.UnifiedMap |
|
HasExp ( PoolDistr crypto) ( Map ( KeyHash ' StakePool crypto) ( IndividualPoolStake crypto)) Source # | |
Defined in Cardano.Ledger.PoolDistr |
|
Embed ( PoolDistr crypto) ( Map ( KeyHash ' StakePool crypto) ( IndividualPoolStake crypto)) Source # |
We can Embed a Newtype around a Map (or other Iterable type) and then use it in a set expression. |
Eq ( KeyHash discriminator crypto) Source # | |
Ord ( KeyHash discriminator crypto) Source # | |
Defined in Cardano.Ledger.Keys compare :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Ordering Source # (<) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source # (<=) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source # (>) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source # (>=) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source # max :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> KeyHash discriminator crypto Source # min :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> KeyHash discriminator crypto Source # |
|
Show ( KeyHash discriminator crypto) Source # | |
Generic ( KeyHash discriminator crypto) Source # | |
NFData ( KeyHash discriminator crypto) Source # | |
Defined in Cardano.Ledger.Keys |
|
Crypto crypto => ToJSON ( KeyHash disc crypto) Source # | |
Crypto crypto => ToJSONKey ( KeyHash disc crypto) Source # | |
Defined in Cardano.Ledger.Keys toJSONKey :: ToJSONKeyFunction ( KeyHash disc crypto) Source # toJSONKeyList :: ToJSONKeyFunction [ KeyHash disc crypto] Source # |
|
Crypto crypto => FromJSON ( KeyHash disc crypto) Source # | |
Crypto crypto => FromJSONKey ( KeyHash disc crypto) Source # | |
Defined in Cardano.Ledger.Keys fromJSONKey :: FromJSONKeyFunction ( KeyHash disc crypto) Source # fromJSONKeyList :: FromJSONKeyFunction [ KeyHash disc crypto] Source # |
|
( Crypto crypto, Typeable disc) => ToCBOR ( KeyHash disc crypto) Source # | |
Defined in Cardano.Ledger.Keys |
|
( Crypto crypto, Typeable disc) => FromCBOR ( KeyHash disc crypto) Source # | |
NoThunks ( KeyHash discriminator crypto) Source # | |
type Rep ( KeyHash discriminator crypto) Source # | |
Defined in Cardano.Ledger.Keys |
Genesis delegations
data GenDelegPair crypto Source #
GenDelegPair | |
|
Instances
newtype GenDelegs crypto Source #
GenDelegs | |
|
Instances
Eq ( GenDelegs crypto) Source # | |
Show ( GenDelegs crypto) Source # | |
Generic ( GenDelegs crypto) Source # | |
NFData ( GenDelegs crypto) Source # | |
Defined in Cardano.Ledger.Keys |
|
Crypto crypto => ToCBOR ( GenDelegs crypto) Source # | |
Crypto crypto => FromCBOR ( GenDelegs crypto) Source # | |
NoThunks ( GenDelegs crypto) Source # | |
type Rep ( GenDelegs crypto) Source # | |
Defined in Cardano.Ledger.Keys
type
Rep
(
GenDelegs
crypto) =
D1
('
MetaData
"GenDelegs" "Cardano.Ledger.Keys" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" '
True
) (
C1
('
MetaCons
"GenDelegs" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unGenDelegs") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(
Map
(
KeyHash
'
Genesis
crypto) (
GenDelegPair
crypto)))))
|
Instances
Crypto crypto => Eq ( GKeys crypto) Source # | |
Crypto crypto => Show ( GKeys crypto) Source # | |
Generic ( GKeys crypto) Source # | |
Crypto crypto => NoThunks ( GKeys crypto) Source # | |
type Rep ( GKeys crypto) Source # | |
Defined in Cardano.Ledger.Keys
type
Rep
(
GKeys
crypto) =
D1
('
MetaData
"GKeys" "Cardano.Ledger.Keys" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" '
True
) (
C1
('
MetaCons
"GKeys" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unGKeys") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(
Set
(
VKey
'
Genesis
crypto)))))
|
KES
type KESignable c = Signable ( KES c) Source #
VRF
type VRFSignable c = Signable ( VRF c) Source #
Re-exports from cardano-crypto-class
decodeSignedDSIGN :: DSIGNAlgorithm v => Decoder s ( SignedDSIGN v a) Source #
encodeSignedDSIGN :: DSIGNAlgorithm v => SignedDSIGN v a -> Encoding Source #
hashWithSerialiser :: HashAlgorithm h => (a -> Encoding ) -> a -> Hash h a Source #
A variation on
hashWith
, but specially for CBOR encodings.
decodeSignedKES :: KESAlgorithm v => Decoder s ( SignedKES v a) Source #
decodeVerKeyKES :: KESAlgorithm v => Decoder s ( VerKeyKES v) Source #
encodeSignedKES :: KESAlgorithm v => SignedKES v a -> Encoding Source #
encodeVerKeyKES :: KESAlgorithm v => VerKeyKES v -> Encoding Source #
signedKES :: ( KESAlgorithm v, Signable v a) => ContextKES v -> Period -> a -> SignKeyKES v -> SignedKES v a Source #
:: KESAlgorithm v | |
=> ContextKES v | |
-> SignKeyKES v | |
-> Period |
The current period for the key, not the target period. |
-> Maybe ( SignKeyKES v) |
Update the KES signature key to the next period, given the current period.
It returns
Nothing
if the cannot be evolved any further.
The precondition (to get a
Just
result) is that the current KES period
of the input key is not the last period. The given period must be the
current KES period of the input key (not the next or target).
The postcondition is that in case a key is returned, its current KES period is incremented by one compared to before.
Note that you must track the current period separately, and to skip to a later period requires repeated use of this function, since it only increments one period at once.
:: ( KESAlgorithm v, Signable v a, HasCallStack ) | |
=> ContextKES v | |
-> VerKeyKES v | |
-> Period |
The current period for the key |
-> a | |
-> SigKES v | |
-> Either String () |
Full KES verification. This method checks that the signature itself
checks out (as per
verifySigKES
), and also makes sure that it matches
the provided VerKey.
verifySignedKES :: ( KESAlgorithm v, Signable v a) => ContextKES v -> VerKeyKES v -> Period -> a -> SignedKES v a -> Either String () Source #
decodeVerKeyVRF :: VRFAlgorithm v => Decoder s ( VerKeyVRF v) Source #
encodeVerKeyVRF :: VRFAlgorithm v => VerKeyVRF v -> Encoding Source #
hashVerKeyVRF :: ( VRFAlgorithm v, HashAlgorithm h) => VerKeyVRF v -> Hash h ( VerKeyVRF v) Source #
verifyVRF :: ( VRFAlgorithm v, HasCallStack , Signable v a) => ContextVRF v -> VerKeyVRF v -> a -> ( OutputVRF v, CertVRF v) -> Bool Source #
Re-parametrised types over
crypto
type CertifiedVRF c = CertifiedVRF ( VRF c) Source #
type SignedDSIGN c = SignedDSIGN ( DSIGN c) Source #
type SignKeyDSIGN c = SignKeyDSIGN ( DSIGN c) Source #
type SignKeyKES c = SignKeyKES ( KES c) Source #
type SignKeyVRF c = SignKeyVRF ( VRF c) Source #