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

Cardano.Ledger.SafeHash

Synopsis

Documentation

data SafeHash crypto index 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.

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

Instances

Instances details
Eq ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

Methods

(==) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

(/=) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

Ord ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

Methods

compare :: SafeHash crypto index -> SafeHash crypto index -> Ordering Source #

(<) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

(<=) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

(>) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

(>=) :: SafeHash crypto index -> SafeHash crypto index -> Bool Source #

max :: SafeHash crypto index -> SafeHash crypto index -> SafeHash crypto index Source #

min :: SafeHash crypto index -> SafeHash crypto index -> SafeHash crypto index Source #

Show ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

NFData ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

Methods

rnf :: SafeHash crypto index -> () Source #

( Typeable index, Crypto c) => ToCBOR ( SafeHash c index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

( Typeable index, Crypto c) => FromCBOR ( SafeHash c index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

HeapWords ( Hash ( HASH c) i) => HeapWords ( SafeHash c i) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

NoThunks ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

HashAlgorithm ( HASH crypto) => SafeToHash ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

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 only exceptions are the legacy Shelley types: Metadata and Tx, that preserve their serialisation bytes using a different mechanism than MemoBytes. SafeToHash is a superclass requirement of the classes HashAnnotated and HashWithCrypto (below) which provide more convenient ways to construct SafeHashes than using makeHashWithExplicitProxys.

Minimal complete definition

originalBytes

Instances

Instances details
SafeToHash ByteString Source #
Instance details

Defined in Cardano.Ledger.SafeHash

SafeToHash ShortByteString Source #
Instance details

Defined in Cardano.Ledger.SafeHash

SafeToHash Safe Source #
Instance details

Defined in Cardano.Ledger.SafeHash

SafeToHash ( MemoBytes t) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

HashAlgorithm c => SafeToHash ( Hash c i) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

HashAlgorithm ( HASH crypto) => SafeToHash ( SafeHash crypto index) Source #
Instance details

Defined in Cardano.Ledger.SafeHash

castSafeHash :: forall i j c. SafeHash c i -> SafeHash c j Source #

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

class SafeToHash x => HashAnnotated x index crypto | x -> index crypto Source #

Determine the index from the type x

class SafeToHash x => HashWithCrypto x index | x -> index where Source #

When the type being hashed: x determines the index tag but not the crypto

Minimal complete definition

Nothing

Methods

hashWithCrypto :: forall crypto. HasAlgorithm crypto => Proxy crypto -> x -> SafeHash crypto index Source #

data Safe where Source #

Sometimes one wants to hash multiple things, simply by concatenating all the bytes. This abstraction allows one to do that safely.

Constructors

Safe :: SafeToHash x => x -> Safe