cardano-ledger-core-0.1.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe Haskell None
Language Haskell2010

Cardano.Ledger.Keys

Synopsis

Documentation

data KeyRole Source #

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 #

Minimal complete definition

Nothing

Methods

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

Instances details
HasKeyRole KeyHash Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). KeyHash r crypto -> KeyHash r' crypto Source #

HasKeyRole KeyPair Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). KeyPair r crypto -> KeyPair r' crypto Source #

HasKeyRole VKey Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). VKey r crypto -> VKey r' crypto Source #

HasKeyRole Credential Source #
Instance details

Defined in Cardano.Ledger.Credential

Methods

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.

Constructors

VKey

Instances

Instances details
HasKeyRole VKey Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). VKey r crypto -> VKey r' crypto Source #

Crypto crypto => Eq ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

(==) :: VKey kd crypto -> VKey kd crypto -> Bool Source #

(/=) :: VKey kd crypto -> VKey kd crypto -> Bool Source #

Crypto crypto => Show ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Generic ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( VKey kd crypto) :: Type -> Type Source #

Methods

from :: VKey kd crypto -> Rep ( VKey kd crypto) x Source #

to :: Rep ( VKey kd crypto) x -> VKey kd crypto Source #

( Crypto crypto, NFData ( VerKeyDSIGN ( DSIGN crypto))) => NFData ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

rnf :: VKey kd crypto -> () Source #

( Crypto crypto, Typeable kd) => ToCBOR ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

( Crypto crypto, Typeable kd) => FromCBOR ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => NoThunks ( VKey kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( VKey kd crypto) Source #
Instance details

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.

Constructors

KeyPair

Fields

Instances

Instances details
HasKeyRole KeyPair Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). KeyPair r crypto -> KeyPair r' crypto Source #

Crypto crypto => Show ( KeyPair kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Generic ( KeyPair kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( KeyPair kd crypto) :: Type -> Type Source #

Methods

from :: KeyPair kd crypto -> Rep ( KeyPair kd crypto) x Source #

to :: Rep ( KeyPair kd crypto) x -> KeyPair kd crypto Source #

( Crypto crypto, NFData ( VerKeyDSIGN ( DSIGN crypto)), NFData ( SignKeyDSIGN ( DSIGN crypto))) => NFData ( KeyPair kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

rnf :: KeyPair kd crypto -> () Source #

Crypto crypto => NoThunks ( KeyPair kd crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( KeyPair kd crypto) Source #
Instance details

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

Constructors

KeyHash ( Hash ( ADDRHASH crypto) ( VerKeyDSIGN ( DSIGN crypto)))

Instances

Instances details
HasKeyRole KeyHash Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

coerceKeyRole :: forall (r :: KeyRole ) crypto (r' :: KeyRole ). KeyHash r crypto -> KeyHash r' crypto Source #

UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr Ptr ( Credential ' Staking crypto) Source #
Instance details

Defined in Cardano.Ledger.UnifiedMap

UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr ( Credential ' Staking crypto) Coin Source #
Instance details

Defined in Cardano.Ledger.UnifiedMap

UnifiedView Coin ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Ptr ( Credential ' Staking crypto) ( KeyHash ' StakePool crypto) Source #
Instance details

Defined in Cardano.Ledger.UnifiedMap

HasExp ( PoolDistr crypto) ( Map ( KeyHash ' StakePool crypto) ( IndividualPoolStake crypto)) Source #
Instance details

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.

Instance details

Defined in Cardano.Ledger.PoolDistr

Eq ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

(==) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source #

(/=) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool Source #

Ord ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

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 #
Instance details

Defined in Cardano.Ledger.Keys

Methods

showsPrec :: Int -> KeyHash discriminator crypto -> ShowS Source #

show :: KeyHash discriminator crypto -> String Source #

showList :: [ KeyHash discriminator crypto] -> ShowS Source #

Generic ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( KeyHash discriminator crypto) :: Type -> Type Source #

Methods

from :: KeyHash discriminator crypto -> Rep ( KeyHash discriminator crypto) x Source #

to :: Rep ( KeyHash discriminator crypto) x -> KeyHash discriminator crypto Source #

NFData ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

rnf :: KeyHash discriminator crypto -> () Source #

Crypto crypto => ToJSON ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => ToJSONKey ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => FromJSON ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => FromJSONKey ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

( Crypto crypto, Typeable disc) => ToCBOR ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

( Crypto crypto, Typeable disc) => FromCBOR ( KeyHash disc crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

NoThunks ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( KeyHash discriminator crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( KeyHash discriminator crypto) = Rep ( Hash ( ADDRHASH crypto) ( VerKeyDSIGN ( DSIGN crypto)))

hashKey :: Crypto crypto => VKey kd crypto -> KeyHash kd crypto Source #

Hash a given public key

Genesis delegations

data GenDelegPair crypto Source #

Instances

Instances details
Eq ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Ord ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Show ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Generic ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( GenDelegPair crypto) :: Type -> Type Source #

NFData ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

rnf :: GenDelegPair crypto -> () Source #

Crypto crypto => ToJSON ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => FromJSON ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => ToCBOR ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => FromCBOR ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

NoThunks ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( GenDelegPair crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( GenDelegPair crypto) = D1 (' MetaData "GenDelegPair" "Cardano.Ledger.Keys" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" ' False ) ( C1 (' MetaCons "GenDelegPair" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "genDelegKeyHash") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( KeyHash ' GenesisDelegate crypto)) :*: S1 (' MetaSel (' Just "genDelegVrfHash") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Hash crypto ( VerKeyVRF crypto)))))

newtype GenDelegs crypto Source #

Instances

Instances details
Eq ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Show ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Generic ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( GenDelegs crypto) :: Type -> Type Source #

NFData ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Methods

rnf :: GenDelegs crypto -> () Source #

Crypto crypto => ToCBOR ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => FromCBOR ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

NoThunks ( GenDelegs crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( GenDelegs crypto) Source #
Instance details

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)))))

newtype GKeys crypto Source #

Constructors

GKeys

Instances

Instances details
Crypto crypto => Eq ( GKeys crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Crypto crypto => Show ( GKeys crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Generic ( GKeys crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

Associated Types

type Rep ( GKeys crypto) :: Type -> Type Source #

Methods

from :: GKeys crypto -> Rep ( GKeys crypto) x Source #

to :: Rep ( GKeys crypto) x -> GKeys crypto Source #

Crypto crypto => NoThunks ( GKeys crypto) Source #
Instance details

Defined in Cardano.Ledger.Keys

type Rep ( GKeys crypto) Source #
Instance details

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

VRF

Re-exports from cardano-crypto-class

hashWithSerialiser :: HashAlgorithm h => (a -> Encoding ) -> a -> Hash h a Source #

A variation on hashWith , but specially for CBOR encodings.

updateKES Source #

Arguments

:: 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.

verifyKES Source #

Arguments

:: ( 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.

Re-parametrised types over crypto