| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Ledger.Hashes
Synopsis
- data Hash h a
- class (KnownNat (SizeHash h), Typeable h) ⇒ HashAlgorithm h
- type HASH = Blake2b_256
- type ADDRHASH = Blake2b_224
- data EraIndependentTxBody
- data EraIndependentBlockHeader
- data EraIndependentBlockBody
- data EraIndependentMetadata
- data EraIndependentScript
- data EraIndependentData
- data EraIndependentScriptData
- data EraIndependentTxAuxData
- data EraIndependentPParamView
- data EraIndependentScriptIntegrity
- newtype KeyHash (r ∷ KeyRole) = KeyHash {}
- data KeyRole
- hashKey ∷ ∀ (kd ∷ KeyRole). VKey kd → KeyHash kd
- hashTxBodySignature ∷ SignedDSIGN DSIGN (Hash HASH EraIndependentTxBody) → Hash HASH (SignedDSIGN DSIGN (Hash HASH EraIndependentTxBody))
- newtype ScriptHash = ScriptHash (Hash ADDRHASH EraIndependentScript)
- type DataHash = SafeHash EraIndependentData
- newtype TxAuxDataHash = TxAuxDataHash {}
- data KeyRoleVRF
- newtype VRFVerKeyHash (r ∷ KeyRoleVRF) = VRFVerKeyHash {}
- toVRFVerKeyHash ∷ ∀ v (r ∷ KeyRoleVRF). Hash HASH (VerKeyVRF v) → VRFVerKeyHash r
- fromVRFVerKeyHash ∷ ∀ (r ∷ KeyRoleVRF) v. VRFVerKeyHash r → Hash HASH (VerKeyVRF v)
- data GenDelegPair = GenDelegPair {}
- newtype GenDelegs = GenDelegs {}
- data SafeHash i
- class SafeToHash t where
- originalBytes ∷ t → ByteString
- originalBytesSize ∷ t → Int
- makeHashWithExplicitProxys ∷ Proxy i → t → SafeHash i
- newtype HashHeader = HashHeader {}
- class SafeToHash x ⇒ HashAnnotated x i | x → i
- hashAnnotated ∷ HashAnnotated x i ⇒ x → SafeHash i
- unsafeMakeSafeHash ∷ Hash HASH i → SafeHash i
- castSafeHash ∷ SafeHash i → SafeHash j
- extractHash ∷ SafeHash i → Hash HASH i
- standardHashSize ∷ Int
- standardAddrHashSize ∷ Int
Hashing algorithms
Instances
| HashAlgorithm h ⇒ IsString (Q (TExp (Hash h a))) | This instance is meant to be used with
| ||||
Defined in Cardano.Crypto.Hash.Class | |||||
| HashAlgorithm h ⇒ FromJSON (Hash h a) | |||||
| HashAlgorithm h ⇒ FromJSONKey (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class Methods fromJSONKey ∷ FromJSONKeyFunction (Hash h a) Source # fromJSONKeyList ∷ FromJSONKeyFunction [Hash h a] Source # | |||||
| HashAlgorithm h ⇒ ToJSON (Hash h a) | |||||
| HashAlgorithm h ⇒ ToJSONKey (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class Methods toJSONKey ∷ ToJSONKeyFunction (Hash h a) Source # toJSONKeyList ∷ ToJSONKeyFunction [Hash h a] Source # | |||||
| (HashAlgorithm h, Typeable a) ⇒ FromCBOR (Hash h a) | |||||
| (HashAlgorithm h, Typeable a) ⇒ ToCBOR (Hash h a) | |||||
| SignableRepresentation (Hash a b) Source # | |||||
Defined in Cardano.Ledger.Orphans Methods getSignableRepresentation ∷ Hash a b → ByteString Source # | |||||
| (HashAlgorithm h, Typeable a) ⇒ DecCBOR (Hash h a) | |||||
| HashAlgorithm h ⇒ EncCBOR (Hash h a) | |||||
| HashAlgorithm h ⇒ SafeToHash (Hash h i) Source # | Hash of a hash. Hash is always safe to hash. Do you even hash? | ||||
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ Hash h i → ByteString Source # originalBytesSize ∷ Hash h i → Int Source # makeHashWithExplicitProxys ∷ Proxy i0 → Hash h i → SafeHash i0 Source # | |||||
| HashAlgorithm h ⇒ Default (Hash h b) Source # | |||||
Defined in Cardano.Ledger.Orphans | |||||
| NFData (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class | |||||
| HashAlgorithm h ⇒ IsString (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class Methods fromString ∷ String → Hash h a # | |||||
| Generic (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class Associated Types
| |||||
| HashAlgorithm h ⇒ Read (Hash h a) | |||||
| Show (Hash h a) | |||||
| Eq (Hash h a) | |||||
| Ord (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class | |||||
| HeapWords (Hash h a) | |||||
| HashAlgorithm h ⇒ MemPack (Hash h a) | |||||
| NoThunks (Hash h a) | |||||
| HashAlgorithm h ⇒ IsString (Code Q (Hash h a)) | |||||
Defined in Cardano.Crypto.Hash.Class | |||||
| type Rep (Hash h a) | |||||
Defined in Cardano.Crypto.Hash.Class type Rep (Hash h a) = D1 ('MetaData "Hash" "Cardano.Crypto.Hash.Class" "cardano-crypto-class-2.2.3.1-93e2c82f664404a263ce0cfe72acde6cccce29dd72e7a756ec140c9b1d091d59" 'True) (C1 ('MetaCons "UnsafeHashRep" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PackedBytes (SizeHash h))))) | |||||
class (KnownNat (SizeHash h), Typeable h) ⇒ HashAlgorithm h Source #
Minimal complete definition
Instances
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.
data EraIndependentTxBody Source #
data EraIndependentScript Source #
data EraIndependentData Source #
Instances
| HashAnnotated (BinaryData era) EraIndependentData Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods hashAnnotated ∷ BinaryData era → SafeHash EraIndependentData Source # | |
| HashAnnotated (Data era) EraIndependentData Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods hashAnnotated ∷ Data era → SafeHash EraIndependentData Source # | |
Hashes
`DSIGN Verification Key Hashes
newtype KeyHash (r ∷ KeyRole) Source #
Discriminated hash of public Key
Instances
| HasKeyRole KeyHash Source # | |
Defined in Cardano.Ledger.Hashes | |
| FromJSON (KeyHash r) Source # | |
| FromJSONKey (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes Methods | |
| ToJSON (KeyHash r) Source # | |
| ToJSONKey (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes Methods toJSONKey ∷ ToJSONKeyFunction (KeyHash r) Source # | |
| Typeable r ⇒ FromCBOR (KeyHash r) Source # | |
| Typeable r ⇒ ToCBOR (KeyHash r) Source # | |
| Typeable r ⇒ DecCBOR (KeyHash r) Source # | |
| EncCBOR (KeyHash r) Source # | |
| Default (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes | |
| NFData (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes | |
| Generic (KeyHash r) Source # | |
| Show (KeyHash r) Source # | |
| Eq (KeyHash r) Source # | |
| Ord (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes | |
| MemPack (KeyHash r) Source # | |
| NoThunks (KeyHash r) Source # | |
| type Rep (KeyHash r) Source # | |
Defined in Cardano.Ledger.Hashes | |
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.
hashTxBodySignature ∷ SignedDSIGN DSIGN (Hash HASH EraIndependentTxBody) → Hash HASH (SignedDSIGN DSIGN (Hash HASH EraIndependentTxBody)) Source #
Hash a given signature
Script Hashes
newtype ScriptHash Source #
Constructors
| ScriptHash (Hash ADDRHASH EraIndependentScript) |
Instances
| FromJSON ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods parseJSON ∷ Value → Parser ScriptHash Source # parseJSONList ∷ Value → Parser [ScriptHash] Source # | |||||
| FromJSONKey ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| ToJSON ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toJSON ∷ ScriptHash → Value Source # toEncoding ∷ ScriptHash → Encoding Source # toJSONList ∷ [ScriptHash] → Value Source # toEncodingList ∷ [ScriptHash] → Encoding Source # omitField ∷ ScriptHash → Bool Source # | |||||
| ToJSONKey ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| FromCBOR ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| ToCBOR ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toCBOR ∷ ScriptHash → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ScriptHash → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ScriptHash] → Size Source # | |||||
| DecCBOR ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| EncCBOR ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods encCBOR ∷ ScriptHash → Encoding Source # | |||||
| NFData ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods rnf ∷ ScriptHash → () # | |||||
| Generic ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
| |||||
| Show ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods showsPrec ∷ Int → ScriptHash → ShowS # show ∷ ScriptHash → String # showList ∷ [ScriptHash] → ShowS # | |||||
| Eq ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Ord ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods compare ∷ ScriptHash → ScriptHash → Ordering # (<) ∷ ScriptHash → ScriptHash → Bool # (<=) ∷ ScriptHash → ScriptHash → Bool # (>) ∷ ScriptHash → ScriptHash → Bool # (>=) ∷ ScriptHash → ScriptHash → Bool # max ∷ ScriptHash → ScriptHash → ScriptHash # min ∷ ScriptHash → ScriptHash → ScriptHash # | |||||
| MemPack ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| NoThunks ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| type Rep ScriptHash Source # | |||||
Defined in Cardano.Ledger.Hashes type Rep ScriptHash = D1 ('MetaData "ScriptHash" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.19.0.0-inplace" 'True) (C1 ('MetaCons "ScriptHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash ADDRHASH EraIndependentScript)))) | |||||
type DataHash = SafeHash EraIndependentData Source #
AuxiliaryData
newtype TxAuxDataHash Source #
Constructors
| TxAuxDataHash | |
Instances
| ToJSON TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toJSON ∷ TxAuxDataHash → Value Source # toEncoding ∷ TxAuxDataHash → Encoding Source # toJSONList ∷ [TxAuxDataHash] → Value Source # | |||||
| DecCBOR TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| EncCBOR TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods | |||||
| NFData TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods rnf ∷ TxAuxDataHash → () # | |||||
| Generic TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
| |||||
| Show TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods showsPrec ∷ Int → TxAuxDataHash → ShowS # show ∷ TxAuxDataHash → String # showList ∷ [TxAuxDataHash] → ShowS # | |||||
| Eq TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Ord TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes Methods compare ∷ TxAuxDataHash → TxAuxDataHash → Ordering # (<) ∷ TxAuxDataHash → TxAuxDataHash → Bool # (<=) ∷ TxAuxDataHash → TxAuxDataHash → Bool # (>) ∷ TxAuxDataHash → TxAuxDataHash → Bool # (>=) ∷ TxAuxDataHash → TxAuxDataHash → Bool # | |||||
| NoThunks TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| type Rep TxAuxDataHash Source # | |||||
Defined in Cardano.Ledger.Hashes type Rep TxAuxDataHash = D1 ('MetaData "TxAuxDataHash" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.19.0.0-inplace" 'True) (C1 ('MetaCons "TxAuxDataHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTxAuxDataHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SafeHash EraIndependentTxAuxData)))) | |||||
VRF Verification Key Hashes
data KeyRoleVRF Source #
Constructors
| StakePoolVRF | |
| GenDelegVRF | |
| BlockIssuerVRF |
newtype VRFVerKeyHash (r ∷ KeyRoleVRF) Source #
Discriminated hash of VRF Verification Key
Constructors
| VRFVerKeyHash | |
Fields | |
Instances
| FromJSON (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods parseJSON ∷ Value → Parser (VRFVerKeyHash r) Source # parseJSONList ∷ Value → Parser [VRFVerKeyHash r] Source # omittedField ∷ Maybe (VRFVerKeyHash r) Source # | |||||
| FromJSONKey (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods fromJSONKey ∷ FromJSONKeyFunction (VRFVerKeyHash r) Source # fromJSONKeyList ∷ FromJSONKeyFunction [VRFVerKeyHash r] Source # | |||||
| ToJSON (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toJSON ∷ VRFVerKeyHash r → Value Source # toEncoding ∷ VRFVerKeyHash r → Encoding Source # toJSONList ∷ [VRFVerKeyHash r] → Value Source # toEncodingList ∷ [VRFVerKeyHash r] → Encoding Source # omitField ∷ VRFVerKeyHash r → Bool Source # | |||||
| ToJSONKey (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toJSONKey ∷ ToJSONKeyFunction (VRFVerKeyHash r) Source # toJSONKeyList ∷ ToJSONKeyFunction [VRFVerKeyHash r] Source # | |||||
| Typeable r ⇒ FromCBOR (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Typeable r ⇒ ToCBOR (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toCBOR ∷ VRFVerKeyHash 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 # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| EncCBOR (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods encCBOR ∷ VRFVerKeyHash r → Encoding Source # | |||||
| Default (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods def ∷ VRFVerKeyHash r Source # | |||||
| NFData (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods rnf ∷ VRFVerKeyHash r → () # | |||||
| Generic (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
Methods from ∷ VRFVerKeyHash r → Rep (VRFVerKeyHash r) x # to ∷ Rep (VRFVerKeyHash r) x → VRFVerKeyHash r # | |||||
| Show (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods showsPrec ∷ Int → VRFVerKeyHash r → ShowS # show ∷ VRFVerKeyHash r → String # showList ∷ [VRFVerKeyHash r] → ShowS # | |||||
| Eq (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods (==) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # (/=) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # | |||||
| Ord (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes Methods compare ∷ VRFVerKeyHash r → VRFVerKeyHash r → Ordering # (<) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # (<=) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # (>) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # (>=) ∷ VRFVerKeyHash r → VRFVerKeyHash r → Bool # max ∷ VRFVerKeyHash r → VRFVerKeyHash r → VRFVerKeyHash r # min ∷ VRFVerKeyHash r → VRFVerKeyHash r → VRFVerKeyHash r # | |||||
| NoThunks (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| type Rep (VRFVerKeyHash r) Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
toVRFVerKeyHash ∷ ∀ v (r ∷ KeyRoleVRF). Hash HASH (VerKeyVRF v) → VRFVerKeyHash r Source #
fromVRFVerKeyHash ∷ ∀ (r ∷ KeyRoleVRF) v. VRFVerKeyHash r → Hash HASH (VerKeyVRF v) Source #
Genesis DSIGN and VRF Verification Key Hashes
data GenDelegPair Source #
Constructors
| GenDelegPair | |
Fields | |
Instances
| FromJSON GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods parseJSON ∷ Value → Parser GenDelegPair Source # parseJSONList ∷ Value → Parser [GenDelegPair] Source # | |||||
| ToJSON GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods toJSON ∷ GenDelegPair → Value Source # toEncoding ∷ GenDelegPair → Encoding Source # toJSONList ∷ [GenDelegPair] → Value Source # toEncodingList ∷ [GenDelegPair] → Encoding Source # omitField ∷ GenDelegPair → Bool Source # | |||||
| DecCBOR GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| EncCBOR GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods | |||||
| NFData GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods rnf ∷ GenDelegPair → () # | |||||
| Generic GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
| |||||
| Show GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods showsPrec ∷ Int → GenDelegPair → ShowS # show ∷ GenDelegPair → String # showList ∷ [GenDelegPair] → ShowS # | |||||
| Eq GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Ord GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes Methods compare ∷ GenDelegPair → GenDelegPair → Ordering # (<) ∷ GenDelegPair → GenDelegPair → Bool # (<=) ∷ GenDelegPair → GenDelegPair → Bool # (>) ∷ GenDelegPair → GenDelegPair → Bool # (>=) ∷ GenDelegPair → GenDelegPair → Bool # max ∷ GenDelegPair → GenDelegPair → GenDelegPair # min ∷ GenDelegPair → GenDelegPair → GenDelegPair # | |||||
| NoThunks GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| type Rep GenDelegPair Source # | |||||
Defined in Cardano.Ledger.Hashes type Rep GenDelegPair = D1 ('MetaData "GenDelegPair" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.19.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)))) | |||||
Constructors
| GenDelegs | |
Fields | |
Instances
| FromJSON GenDelegs Source # | |||||
| ToJSON GenDelegs Source # | |||||
| DecCBOR GenDelegs Source # | |||||
| EncCBOR GenDelegs Source # | |||||
| NFData GenDelegs Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Generic GenDelegs Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
| |||||
| Show GenDelegs Source # | |||||
| Eq GenDelegs Source # | |||||
| NoThunks GenDelegs Source # | |||||
| type Rep GenDelegs Source # | |||||
Defined in Cardano.Ledger.Hashes type Rep GenDelegs = D1 ('MetaData "GenDelegs" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.19.0.0-inplace" 'True) (C1 ('MetaCons "GenDelegs" 'PrefixI 'True) (S1 ('MetaSel ('Just "unGenDelegs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (KeyHash 'GenesisRole) 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.
A SafeHash is a hash of something that is safe to hash. Such types store their own
serialisation bytes. The prime example is (, 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.MemoBytes t)
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
| FromJSON (SafeHash i) Source # | |
| ToJSON (SafeHash i) Source # | |
| Typeable i ⇒ FromCBOR (SafeHash i) Source # | |
| Typeable i ⇒ ToCBOR (SafeHash i) Source # | |
| Typeable i ⇒ DecCBOR (SafeHash i) Source # | |
| EncCBOR (SafeHash i) Source # | |
| SafeToHash (SafeHash i) Source # | |
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ SafeHash i → ByteString Source # originalBytesSize ∷ SafeHash i → Int Source # makeHashWithExplicitProxys ∷ Proxy i0 → SafeHash i → SafeHash i0 Source # | |
| Default (SafeHash i) Source # | |
Defined in Cardano.Ledger.Hashes | |
| NFData (SafeHash i) Source # | |
Defined in Cardano.Ledger.Hashes | |
| Show (SafeHash i) Source # | |
| Eq (SafeHash i) Source # | |
| Ord (SafeHash i) Source # | |
Defined in Cardano.Ledger.Hashes | |
| MemPack (SafeHash i) Source # | |
| NoThunks (SafeHash i) Source # | |
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
Methods
originalBytes ∷ t → ByteString Source #
Extract the original bytes from t
originalBytesSize ∷ t → Int Source #
makeHashWithExplicitProxys ∷ Proxy i → t → SafeHash i Source #
Instances
| SafeToHash ByteString Source # | |
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ ByteString → ByteString Source # originalBytesSize ∷ ByteString → Int Source # makeHashWithExplicitProxys ∷ Proxy i → ByteString → SafeHash i Source # | |
| SafeToHash ShortByteString Source # | |
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ ShortByteString → ByteString Source # originalBytesSize ∷ ShortByteString → Int Source # makeHashWithExplicitProxys ∷ Proxy i → ShortByteString → SafeHash i Source # | |
| SafeToHash AnchorData Source # | |
Defined in Cardano.Ledger.BaseTypes Methods originalBytes ∷ AnchorData → ByteString Source # originalBytesSize ∷ AnchorData → Int Source # makeHashWithExplicitProxys ∷ Proxy i → AnchorData → SafeHash i Source # | |
| SafeToHash PlutusBinary Source # | |
Defined in Cardano.Ledger.Plutus.Language Methods originalBytes ∷ PlutusBinary → ByteString Source # originalBytesSize ∷ PlutusBinary → Int Source # makeHashWithExplicitProxys ∷ Proxy i → PlutusBinary → SafeHash i Source # | |
| SafeToHash (SafeHash i) Source # | |
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ SafeHash i → ByteString Source # originalBytesSize ∷ SafeHash i → Int Source # makeHashWithExplicitProxys ∷ Proxy i0 → SafeHash i → SafeHash i0 Source # | |
| SafeToHash (MemoBytes t) Source # | |
Defined in Cardano.Ledger.MemoBytes.Internal Methods originalBytes ∷ MemoBytes t → ByteString Source # originalBytesSize ∷ MemoBytes t → Int Source # makeHashWithExplicitProxys ∷ Proxy i → MemoBytes t → SafeHash i Source # | |
| SafeToHash (BinaryData era) Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods originalBytes ∷ BinaryData era → ByteString Source # originalBytesSize ∷ BinaryData era → Int Source # makeHashWithExplicitProxys ∷ Proxy i → BinaryData era → SafeHash i Source # | |
| SafeToHash (Data era) Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods originalBytes ∷ Data era → ByteString Source # originalBytesSize ∷ Data era → Int Source # makeHashWithExplicitProxys ∷ Proxy i → Data era → SafeHash i Source # | |
| SafeToHash (Plutus l) Source # | |
Defined in Cardano.Ledger.Plutus.Language Methods originalBytes ∷ Plutus l → ByteString Source # originalBytesSize ∷ Plutus l → Int Source # makeHashWithExplicitProxys ∷ Proxy i → Plutus l → SafeHash i Source # | |
| HashAlgorithm h ⇒ SafeToHash (Hash h i) Source # | Hash of a hash. Hash is always safe to hash. Do you even hash? |
Defined in Cardano.Ledger.Hashes Methods originalBytes ∷ Hash h i → ByteString Source # originalBytesSize ∷ Hash h i → Int Source # makeHashWithExplicitProxys ∷ Proxy i0 → Hash h i → SafeHash i0 Source # | |
Header Hash
newtype HashHeader Source #
Constructors
| HashHeader | |
Instances
| DecCBOR HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| EncCBOR HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes Methods encCBOR ∷ HashHeader → Encoding Source # | |||||
| NFData HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes Methods rnf ∷ HashHeader → () # | |||||
| Generic HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes Associated Types
| |||||
| Show HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes Methods showsPrec ∷ Int → HashHeader → ShowS # show ∷ HashHeader → String # showList ∷ [HashHeader] → ShowS # | |||||
| Eq HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| Ord HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes Methods compare ∷ HashHeader → HashHeader → Ordering # (<) ∷ HashHeader → HashHeader → Bool # (<=) ∷ HashHeader → HashHeader → Bool # (>) ∷ HashHeader → HashHeader → Bool # (>=) ∷ HashHeader → HashHeader → Bool # max ∷ HashHeader → HashHeader → HashHeader # min ∷ HashHeader → HashHeader → HashHeader # | |||||
| NoThunks HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes | |||||
| type Rep HashHeader Source # | |||||
Defined in Cardano.Ledger.Hashes type Rep HashHeader = D1 ('MetaData "HashHeader" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.19.0.0-inplace" 'True) (C1 ('MetaCons "HashHeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHashHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash HASH EraIndependentBlockHeader)))) | |||||
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,
Instances
| HashAnnotated AnchorData AnchorData Source # | |
Defined in Cardano.Ledger.BaseTypes Methods | |
| HashAnnotated (BinaryData era) EraIndependentData Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods hashAnnotated ∷ BinaryData era → SafeHash EraIndependentData Source # | |
| HashAnnotated (Data era) EraIndependentData Source # | |
Defined in Cardano.Ledger.Plutus.Data Methods hashAnnotated ∷ Data era → SafeHash EraIndependentData Source # | |
hashAnnotated ∷ HashAnnotated x i ⇒ x → SafeHash i Source #
Create a (, given SafeHash i)( instance.HashAnnotated x i)
unsafeMakeSafeHash ∷ Hash 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 ∷ SafeHash i → SafeHash j Source #
To change the index parameter of SafeHash (which is a phantom type) use castSafeHash