cardano-ledger-core-1.17.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Hashes

Synopsis

Hashing algorithms

data Hash h a Source #

Instances

Instances details
HashAlgorithm h ⇒ IsString (Q (TExp (Hash h a)))

This instance is meant to be used with TemplateHaskell

>>> import Cardano.Crypto.Hash.Class (Hash)
>>> import Cardano.Crypto.Hash.Short (ShortHash)
>>> :set -XTemplateHaskell
>>> :set -XOverloadedStrings
>>> let hash = $$("0xBADC0FFEE0DDF00D") :: Hash ShortHash ()
>>> print hash
"badc0ffee0ddf00d"
>>> let hash = $$("0123456789abcdef") :: Hash ShortHash ()
>>> print hash
"0123456789abcdef"
>>> let hash = $$("deadbeef") :: Hash ShortHash ()
<interactive>:5:15: error:
    • <Hash blake2b_prefix_8>: Expected in decoded form to be: 8 bytes, but got: 4
    • In the Template Haskell splice $$("deadbeef")
      In the expression: $$("deadbeef") :: Hash ShortHash ()
      In an equation for ‘hash’:
          hash = $$("deadbeef") :: Hash ShortHash ()
>>> let hash = $$("123") :: Hash ShortHash ()
<interactive>:6:15: error:
    • <Hash blake2b_prefix_8>: Malformed hex: invalid bytestring size
    • In the Template Haskell splice $$("123")
      In the expression: $$("123") :: Hash ShortHash ()
      In an equation for ‘hash’: hash = $$("123") :: Hash ShortHash ()
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

fromStringStringQ (TExp (Hash h a)) Source #

HashAlgorithm h ⇒ FromJSON (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

HashAlgorithm h ⇒ FromJSONKey (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

HashAlgorithm h ⇒ ToJSON (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

toJSONHash h a → Value Source #

toEncodingHash h a → Encoding Source #

toJSONList ∷ [Hash h a] → Value Source #

toEncodingList ∷ [Hash h a] → Encoding Source #

omitFieldHash h a → Bool Source #

HashAlgorithm h ⇒ ToJSONKey (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

HashAlgorithm h ⇒ IsString (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

fromStringStringHash h a Source #

Generic (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Associated Types

type Rep (Hash h a) ∷ TypeType Source #

Methods

fromHash h a → Rep (Hash h a) x Source #

toRep (Hash h a) x → Hash h a Source #

HashAlgorithm h ⇒ Read (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Show (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

showsPrecIntHash h a → ShowS Source #

showHash h a → String Source #

showList ∷ [Hash h a] → ShowS Source #

(HashAlgorithm h, Typeable a) ⇒ FromCBOR (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

fromCBORDecoder s (Hash h a) Source #

labelProxy (Hash h a) → Text Source #

(HashAlgorithm h, Typeable a) ⇒ ToCBOR (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

toCBORHash h a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Hash h a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Hash h a] → Size Source #

SignableRepresentation (Hash a b) Source # 
Instance details

Defined in Cardano.Ledger.Orphans

(HashAlgorithm h, Typeable a) ⇒ DecCBOR (Hash h a) 
Instance details

Defined in Cardano.Ledger.Binary.Decoding.DecCBOR

Methods

decCBORDecoder s (Hash h a) Source #

dropCBORProxy (Hash h a) → Decoder s () Source #

labelProxy (Hash h a) → Text Source #

(HashAlgorithm h, Typeable a) ⇒ EncCBOR (Hash h a) 
Instance details

Defined in Cardano.Ledger.Binary.Encoding.EncCBOR

Methods

encCBORHash h a → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (Hash h a) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Hash h a] → Size Source #

HashAlgorithm h ⇒ SafeToHash (Hash h i) Source #

Hash of a hash. Hash is always safe to hash. Do you even hash?

Instance details

Defined in Cardano.Ledger.Hashes

HashAlgorithm h ⇒ Default (Hash h b) Source # 
Instance details

Defined in Cardano.Ledger.Orphans

Methods

defHash h b Source #

NFData (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

rnfHash h a → () Source #

Eq (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

(==)Hash h a → Hash h a → Bool Source #

(/=)Hash h a → Hash h a → Bool Source #

Ord (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

compareHash h a → Hash h a → Ordering Source #

(<)Hash h a → Hash h a → Bool Source #

(<=)Hash h a → Hash h a → Bool Source #

(>)Hash h a → Hash h a → Bool Source #

(>=)Hash h a → Hash h a → Bool Source #

maxHash h a → Hash h a → Hash h a Source #

minHash h a → Hash h a → Hash h a Source #

HeapWords (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

heapWordsHash h a → Int Source #

HashAlgorithm h ⇒ MemPack (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

typeNameString Source #

packedByteCountHash h a → Int Source #

packMHash h a → Pack s () Source #

unpackMBuffer b ⇒ Unpack b (Hash h a) Source #

NoThunks (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

HashAlgorithm h ⇒ IsString (Code Q (Hash h a)) 
Instance details

Defined in Cardano.Crypto.Hash.Class

Methods

fromStringStringCode Q (Hash h a) Source #

type Rep (Hash h a) 
Instance details

Defined in Cardano.Crypto.Hash.Class

type Rep (Hash h a) = D1 ('MetaData "Hash" "Cardano.Crypto.Hash.Class" "cardano-crypto-class-2.2.0.0-26c5fd30d06a5d79fe778ccc9b3b70cb764a47cb3e1af3de4f34878e2972d13e" 'True) (C1 ('MetaCons "UnsafeHashRep" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PackedBytes (SizeHash h)))))

class (KnownNat (SizeHash h), Typeable h) ⇒ HashAlgorithm h Source #

Minimal complete definition

hashAlgorithmName, digest

Instances

Instances details
HashAlgorithm Blake2b_224 
Instance details

Defined in Cardano.Crypto.Hash.Blake2b

Associated Types

type SizeHash Blake2b_224Nat Source #

HashAlgorithm Blake2b_256 
Instance details

Defined in Cardano.Crypto.Hash.Blake2b

Associated Types

type SizeHash Blake2b_256Nat Source #

HashAlgorithm Keccak256 
Instance details

Defined in Cardano.Crypto.Hash.Keccak256

Associated Types

type SizeHash Keccak256Nat Source #

HashAlgorithm NeverHash 
Instance details

Defined in Cardano.Crypto.Hash.NeverUsed

Associated Types

type SizeHash NeverHashNat Source #

HashAlgorithm RIPEMD160 
Instance details

Defined in Cardano.Crypto.Hash.RIPEMD160

Associated Types

type SizeHash RIPEMD160Nat Source #

HashAlgorithm SHA256 
Instance details

Defined in Cardano.Crypto.Hash.SHA256

Associated Types

type SizeHash SHA256Nat Source #

HashAlgorithm SHA3_256 
Instance details

Defined in Cardano.Crypto.Hash.SHA3_256

Associated Types

type SizeHash SHA3_256Nat Source #

(KnownNat n, CmpNat n 33 ~ 'LT) ⇒ HashAlgorithm (Blake2bPrefix n) 
Instance details

Defined in Cardano.Crypto.Hash.Short

Associated Types

type SizeHash (Blake2bPrefix n) ∷ Nat Source #

type HASH = Blake2b_256 Source #

Hashing algorithm used for hashing everything, except addresses, for which ADDRHASH is used.

type ADDRHASH = Blake2b_224 Source #

Hashing algorithm used for hashing cryptographic keys and scripts. As the type synonym name alludes, this is the hashing algorithm used for addresses.

Era-independent hash type identifiers.

Various identifiers in the ledger are hashes of particular structures. While the structures may change from era to era, the hash will remain the same, and we can refer to the hash of, say, a transaction, without knowing the actual transaction type. As such, we define a number of these hashes here.

Hashes

`DSIGN Verification Key Hashes

newtype KeyHash (r ∷ KeyRole) Source #

Discriminated hash of public Key

Constructors

KeyHash 

Instances

Instances details
HasKeyRole KeyHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

coerceKeyRole ∷ ∀ (r ∷ KeyRole) (r' ∷ KeyRole). KeyHash r → KeyHash r' Source #

FromJSON (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

FromJSONKey (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSONKey (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep (KeyHash r) ∷ TypeType Source #

Methods

fromKeyHash r → Rep (KeyHash r) x Source #

toRep (KeyHash r) x → KeyHash r Source #

Show (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

showsPrecIntKeyHash r → ShowS Source #

showKeyHash r → String Source #

showList ∷ [KeyHash r] → ShowS Source #

Typeable r ⇒ FromCBOR (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

fromCBORDecoder s (KeyHash r) Source #

labelProxy (KeyHash r) → Text Source #

Typeable r ⇒ ToCBOR (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

toCBORKeyHash r → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (KeyHash r) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [KeyHash r] → Size Source #

Typeable r ⇒ DecCBOR (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

decCBORDecoder s (KeyHash r) Source #

dropCBORProxy (KeyHash r) → Decoder s () Source #

labelProxy (KeyHash r) → Text Source #

Typeable r ⇒ EncCBOR (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

encCBORKeyHash r → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (KeyHash r) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [KeyHash r] → Size Source #

Default (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

defKeyHash r Source #

NFData (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfKeyHash r → () Source #

Eq (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

(==)KeyHash r → KeyHash r → Bool Source #

(/=)KeyHash r → KeyHash r → Bool Source #

Ord (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

compareKeyHash r → KeyHash r → Ordering Source #

(<)KeyHash r → KeyHash r → Bool Source #

(<=)KeyHash r → KeyHash r → Bool Source #

(>)KeyHash r → KeyHash r → Bool Source #

(>=)KeyHash r → KeyHash r → Bool Source #

maxKeyHash r → KeyHash r → KeyHash r Source #

minKeyHash r → KeyHash r → KeyHash r Source #

NoThunks (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep (KeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

data KeyRole Source #

The role of a key.

All key roles are fixed and unique, except for the Witness role. In particular, keys can be cast to a Witness role with the help of asWitness, because same witness can be valid for many roles.

In fact, it is perfectly allowable for a key to be used in many roles by the end user; there is nothing prohibiting somebody using the same underlying key or a script as their payment and staking credential, as well as the key for their stake pool. However, in the ledger code mixing up keys with different roles could be catastrophic, that is why we have this separation.

Instances

Instances details
Show KeyRole Source # 
Instance details

Defined in Cardano.Ledger.Keys.Internal

hashKeyVKey kd → KeyHash kd Source #

Hash a given public key

Script Hashes

newtype ScriptHash Source #

Instances

Instances details
FromJSON ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

FromJSONKey ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSONKey ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep ScriptHashTypeType Source #

Show ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

FromCBOR ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToCBOR ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

toCBORScriptHashEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ScriptHashSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ScriptHash] → Size Source #

DecCBOR ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

EncCBOR ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

encCBORScriptHashEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy ScriptHashSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [ScriptHash] → Size Source #

NFData ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfScriptHash → () Source #

Eq ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Ord ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep ScriptHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep ScriptHash = D1 ('MetaData "ScriptHash" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "ScriptHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash ADDRHASH EraIndependentScript))))

AuxiliaryData

newtype TxAuxDataHash Source #

Instances

Instances details
ToJSON TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep TxAuxDataHashTypeType Source #

Show TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

DecCBOR TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

EncCBOR TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NFData TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfTxAuxDataHash → () Source #

Eq TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Ord TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep TxAuxDataHash Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep TxAuxDataHash = D1 ('MetaData "TxAuxDataHash" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "TxAuxDataHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTxAuxDataHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SafeHash EraIndependentTxAuxData))))

VRF Verification Key Hashes

newtype VRFVerKeyHash (r ∷ KeyRoleVRF) Source #

Discriminated hash of VRF Verification Key

Instances

Instances details
FromJSON (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

FromJSONKey (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSONKey (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep (VRFVerKeyHash r) ∷ TypeType Source #

Show (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable r ⇒ FromCBOR (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable r ⇒ ToCBOR (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

toCBORVRFVerKeyHash r → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (VRFVerKeyHash r) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [VRFVerKeyHash r] → Size Source #

Typeable r ⇒ DecCBOR (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable r ⇒ EncCBOR (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

encCBORVRFVerKeyHash r → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (VRFVerKeyHash r) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [VRFVerKeyHash r] → Size Source #

Default (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

defVRFVerKeyHash r Source #

NFData (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfVRFVerKeyHash r → () Source #

Eq (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Ord (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep (VRFVerKeyHash r) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Genesis DSIGN and VRF Verification Key Hashes

data GenDelegPair Source #

Instances

Instances details
FromJSON GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep GenDelegPairTypeType Source #

Show GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

DecCBOR GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

EncCBOR GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NFData GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfGenDelegPair → () Source #

Eq GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Ord GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep GenDelegPair Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep GenDelegPair = D1 ('MetaData "GenDelegPair" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "GenDelegPair" 'PrefixI 'True) (S1 ('MetaSel ('Just "genDelegKeyHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'GenesisDelegate)) :*: S1 ('MetaSel ('Just "genDelegVrfHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VRFVerKeyHash 'GenDelegVRF))))

newtype GenDelegs Source #

Constructors

GenDelegs 

Instances

Instances details
FromJSON GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Generic GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep GenDelegsTypeType Source #

Show GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

DecCBOR GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

EncCBOR GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

encCBORGenDelegsEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy GenDelegsSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [GenDelegs] → Size Source #

NFData GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfGenDelegs → () Source #

Eq GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep GenDelegs Source # 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep GenDelegs = D1 ('MetaData "GenDelegs" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "GenDelegs" 'PrefixI 'True) (S1 ('MetaSel ('Just "unGenDelegs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (KeyHash 'Genesis) GenDelegPair))))

SafeHash

In cardano-ledger, hashing a type X is based upon the serialization of X. Serialization is based upon the EncCBOR and DecCBOR type classes, and the serialization that can be handled by DecCBOR instances for a particular type, are not necessarily unique. For this reason, when an X object comes over the network in serialized form, we must preserve the original bytes that arrived over the network, otherwise when the system hashes that object, the hash in the ledger, and the hash of that object from the other side of the network may not agree. In otherwords reserialization for the purpose of hash calculation is not an option. The SafeToHash type class ensures that types with a (SafeToHash X) instance store the original bytes that arrived over the network for the value of X. The recommended way to store the original bytes is to use the type MemoBytes, although there are a few types that store their original bytes in other ways. In order to encourage the use of newtype over MemoBytes newtype defined as a MemoBytes, which would get the functionality of retaining bytes and deriving of SafeToHash instance for free.

data SafeHash i Source #

A SafeHash is a hash of something that is safe to hash. Such types store their own serialisation bytes. The prime example is (MemoBytes t), but other examples are things that consist of only ByteStrings (i.e. they are their own serialization) or for some other reason store their original bytes.

We do NOT export the constructor SafeHash, but instead export other functions such as hashAnnotated and extractHash which have constraints that limit their application to types which preserve their original serialization bytes.

Instances

Instances details
FromJSON (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

ToJSON (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Show (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable i ⇒ FromCBOR (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable i ⇒ ToCBOR (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

toCBORSafeHash i → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (SafeHash i) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [SafeHash i] → Size Source #

Typeable i ⇒ DecCBOR (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Typeable i ⇒ EncCBOR (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

encCBORSafeHash i → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (SafeHash i) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [SafeHash i] → Size Source #

SafeToHash (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Default (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

defSafeHash i Source #

NFData (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnfSafeHash i → () Source #

Eq (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

(==)SafeHash i → SafeHash i → Bool Source #

(/=)SafeHash i → SafeHash i → Bool Source #

Ord (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

compareSafeHash i → SafeHash i → Ordering Source #

(<)SafeHash i → SafeHash i → Bool Source #

(<=)SafeHash i → SafeHash i → Bool Source #

(>)SafeHash i → SafeHash i → Bool Source #

(>=)SafeHash i → SafeHash i → Bool Source #

maxSafeHash i → SafeHash i → SafeHash i Source #

minSafeHash i → SafeHash i → SafeHash i Source #

HeapWords (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

heapWordsSafeHash i → Int Source #

HeapWords (StrictMaybe DataHash) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

NoThunks (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

class SafeToHash t where Source #

Only Types that preserve their serialisation bytes are members of the class SafeToHash. There are only a limited number of primitive direct instances of SafeToHash, all but two of them are present in this file. Instead of making explicit instances, we almost always use a newtype (around a type S) where their is already an instance (SafeToHash S). In that case the newtype has its SafeToHash instance derived using newtype deriving. The prime example of s is MemoBytes. The only exceptions are the legacy Shelley types: Metadata and ShelleyTx, that preserve their serialization bytes using a different mechanism than the use of MemoBytes. SafeToHash is a superclass requirement of the classes HashAnnotated which provide more convenient ways to construct SafeHashes than using makeHashWithExplicitProxys.

Minimal complete definition

originalBytes

Methods

originalBytes ∷ t → ByteString Source #

Extract the original bytes from t

originalBytesSize ∷ t → Int Source #

makeHashWithExplicitProxysProxy i → t → SafeHash i Source #

Instances

Instances details
SafeToHash ByteString Source # 
Instance details

Defined in Cardano.Ledger.Hashes

SafeToHash ShortByteString Source # 
Instance details

Defined in Cardano.Ledger.Hashes

SafeToHash AnchorData Source # 
Instance details

Defined in Cardano.Ledger.BaseTypes

SafeToHash PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

SafeToHash (SafeHash i) Source # 
Instance details

Defined in Cardano.Ledger.Hashes

SafeToHash (BinaryData era) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

SafeToHash (Data era) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

SafeToHash (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

HashAlgorithm h ⇒ SafeToHash (Hash h i) Source #

Hash of a hash. Hash is always safe to hash. Do you even hash?

Instance details

Defined in Cardano.Ledger.Hashes

SafeToHash (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Creating SafeHash

class SafeToHash x ⇒ HashAnnotated x i | x → i Source #

Types that are SafeToHash AND have the type uniquely determines the index type tag of SafeHash index

The SafeToHash and the HashAnnotated classes are designed so that their instances can be easily derived (because their methods have default methods when the type is a newtype around a type that is SafeToHash). For example,

hashAnnotatedHashAnnotated x i ⇒ x → SafeHash i Source #

Create a (SafeHash i), given (HashAnnotated x i) instance.

unsafeMakeSafeHashHash HASH i → SafeHash i Source #

Don't use this except in Testing to make Arbitrary instances, etc. or in cases when it can be guaranteed that original bytes were used for computing the hash.

Other operations

castSafeHash ∷ ∀ i j. SafeHash i → SafeHash j Source #

To change the index parameter of SafeHash (which is a phantom type) use castSafeHash

extractHashSafeHash i → Hash HASH i Source #

Extract the hash out of a SafeHash