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

Cardano.Ledger.SafeHash

Description

Deprecated: Use Hashes instead

Synopsis

SafeHash and SafeToHash

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

indexProxy ∷ ∀ x i. HashAnnotated x i ⇒ x → Proxy i Source #