cardano-crypto-wrapper-1.5.1.3: Cryptographic primitives used in Byron era of the Cardano project
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Crypto.Hashing

Description

Hashing capabilities.

Synopsis

AbstractHash type supporting different hash algorithms

data AbstractHash algo a Source #

Hash wrapper with phantom type for more type-safety

Made abstract in order to support different algorithms

Instances

Instances details
HashAlgorithm algo ⇒ FromJSON (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

(HashAlgorithm algo, FromJSON (AbstractHash algo a)) ⇒ FromJSONKey (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

ToJSON (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

ToJSONKey (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Generic (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Associated Types

type Rep (AbstractHash algo a) ∷ TypeType Source #

Methods

fromAbstractHash algo a → Rep (AbstractHash algo a) x Source #

toRep (AbstractHash algo a) x → AbstractHash algo a Source #

HashAlgorithm algo ⇒ Read (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Show (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

showsPrecIntAbstractHash algo a → ShowS Source #

showAbstractHash algo a → String Source #

showList ∷ [AbstractHash algo a] → ShowS Source #

(Typeable algo, Typeable a, HashAlgorithm algo) ⇒ FromCBOR (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

fromCBORDecoder s (AbstractHash algo a) Source #

labelProxy (AbstractHash algo a) → Text Source #

(Typeable algo, Typeable a, HashAlgorithm algo) ⇒ ToCBOR (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

toCBORAbstractHash algo a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (AbstractHash algo a) → Size Source #

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

(Typeable algo, Typeable a, HashAlgorithm algo) ⇒ DecCBOR (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

decCBORDecoder s (AbstractHash algo a) Source #

dropCBORProxy (AbstractHash algo a) → Decoder s () Source #

labelProxy (AbstractHash algo a) → Text Source #

(Typeable algo, Typeable a, HashAlgorithm algo) ⇒ EncCBOR (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

encCBORAbstractHash algo a → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (AbstractHash algo a) → Size Source #

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

NFData (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

rnfAbstractHash algo a → () Source #

Buildable (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

buildAbstractHash algo a → Builder Source #

Eq (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

(==)AbstractHash algo a → AbstractHash algo a → Bool Source #

(/=)AbstractHash algo a → AbstractHash algo a → Bool Source #

Ord (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

compareAbstractHash algo a → AbstractHash algo a → Ordering Source #

(<)AbstractHash algo a → AbstractHash algo a → Bool Source #

(<=)AbstractHash algo a → AbstractHash algo a → Bool Source #

(>)AbstractHash algo a → AbstractHash algo a → Bool Source #

(>=)AbstractHash algo a → AbstractHash algo a → Bool Source #

maxAbstractHash algo a → AbstractHash algo a → AbstractHash algo a Source #

minAbstractHash algo a → AbstractHash algo a → AbstractHash algo a Source #

HeapWords (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

Methods

heapWordsAbstractHash algo a → Int Source #

NoThunks (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

type Rep (AbstractHash algo a) Source # 
Instance details

Defined in Cardano.Crypto.Hashing

type Rep (AbstractHash algo a) = D1 ('MetaData "AbstractHash" "Cardano.Crypto.Hashing" "cardano-crypto-wrapper-1.5.1.3-inplace" 'True) (C1 ('MetaCons "AbstractHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

class HashAlgorithm a Source #

Class representing hashing algorithms.

The interface presented here is update in place and lowlevel. the Hash module takes care of hidding the mutable interface properly.

Instances

Instances details
HashAlgorithm Blake2b_160 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_224 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_256 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_384 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_512 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2bp_512 
Instance details

Defined in Crypto.Hash.Blake2bp

HashAlgorithm Blake2s_160 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_224 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_256 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2sp_224 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Blake2sp_256 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Keccak_224 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_256 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_384 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_512 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm MD2 
Instance details

Defined in Crypto.Hash.MD2

HashAlgorithm MD4 
Instance details

Defined in Crypto.Hash.MD4

HashAlgorithm MD5 
Instance details

Defined in Crypto.Hash.MD5

HashAlgorithm RIPEMD160 
Instance details

Defined in Crypto.Hash.RIPEMD160

HashAlgorithm SHA1 
Instance details

Defined in Crypto.Hash.SHA1

HashAlgorithm SHA224 
Instance details

Defined in Crypto.Hash.SHA224

HashAlgorithm SHA256 
Instance details

Defined in Crypto.Hash.SHA256

HashAlgorithm SHA3_224 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_256 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_384 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_512 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA384 
Instance details

Defined in Crypto.Hash.SHA384

HashAlgorithm SHA512 
Instance details

Defined in Crypto.Hash.SHA512

HashAlgorithm SHA512t_224 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm SHA512t_256 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm Skein256_224 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein256_256 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein512_224 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_256 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_384 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_512 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Tiger 
Instance details

Defined in Crypto.Hash.Tiger

HashAlgorithm Whirlpool 
Instance details

Defined in Crypto.Hash.Whirlpool

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) ⇒ HashAlgorithm (Blake2b bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2b bitlen) ∷ Nat Source #

type HashDigestSize (Blake2b bitlen) ∷ Nat Source #

type HashInternalContextSize (Blake2b bitlen) ∷ Nat Source #

Methods

hashBlockSizeBlake2b bitlen → Int Source #

hashDigestSizeBlake2b bitlen → Int Source #

hashInternalContextSizeBlake2b bitlen → Int Source #

hashInternalInitPtr (Context (Blake2b bitlen)) → IO () Source #

hashInternalUpdatePtr (Context (Blake2b bitlen)) → Ptr Word8Word32IO () Source #

hashInternalFinalizePtr (Context (Blake2b bitlen)) → Ptr (Digest (Blake2b bitlen)) → IO () Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) ⇒ HashAlgorithm (Blake2bp bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2bp bitlen) ∷ Nat Source #

type HashDigestSize (Blake2bp bitlen) ∷ Nat Source #

type HashInternalContextSize (Blake2bp bitlen) ∷ Nat Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) ⇒ HashAlgorithm (Blake2s bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2s bitlen) ∷ Nat Source #

type HashDigestSize (Blake2s bitlen) ∷ Nat Source #

type HashInternalContextSize (Blake2s bitlen) ∷ Nat Source #

Methods

hashBlockSizeBlake2s bitlen → Int Source #

hashDigestSizeBlake2s bitlen → Int Source #

hashInternalContextSizeBlake2s bitlen → Int Source #

hashInternalInitPtr (Context (Blake2s bitlen)) → IO () Source #

hashInternalUpdatePtr (Context (Blake2s bitlen)) → Ptr Word8Word32IO () Source #

hashInternalFinalizePtr (Context (Blake2s bitlen)) → Ptr (Digest (Blake2s bitlen)) → IO () Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) ⇒ HashAlgorithm (Blake2sp bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2sp bitlen) ∷ Nat Source #

type HashDigestSize (Blake2sp bitlen) ∷ Nat Source #

type HashInternalContextSize (Blake2sp bitlen) ∷ Nat Source #

KnownNat bitlen ⇒ HashAlgorithm (SHAKE128 bitlen) 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE128 bitlen) ∷ Nat Source #

type HashDigestSize (SHAKE128 bitlen) ∷ Nat Source #

type HashInternalContextSize (SHAKE128 bitlen) ∷ Nat Source #

KnownNat bitlen ⇒ HashAlgorithm (SHAKE256 bitlen) 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE256 bitlen) ∷ Nat Source #

type HashDigestSize (SHAKE256 bitlen) ∷ Nat Source #

type HashInternalContextSize (SHAKE256 bitlen) ∷ Nat Source #

Hashing

abstractHash ∷ (HashAlgorithm algo, EncCBOR a) ⇒ a → AbstractHash algo a Source #

Hash the EncCBOR-serialised version of a value Once this is no longer used outside this module it should be made private.

unsafeAbstractHashHashAlgorithm algo ⇒ LByteStringAbstractHash algo a Source #

Hash a lazy LByteString

You can choose the phantom type, hence the "unsafe".

Conversion

abstractHashFromDigestDigest algo → AbstractHash algo a Source #

Make an AbstractHash from a Digest for the same HashAlgorithm.

abstractHashFromBytes ∷ ∀ algo a. HashAlgorithm algo ⇒ ByteStringMaybe (AbstractHash algo a) Source #

Make an AbstractHash from the bytes representation of the hash. It will fail if given the wrong number of bytes for the choice of HashAlgorithm.

unsafeAbstractHashFromBytesByteStringAbstractHash algo a Source #

Like abstractHashFromDigestBytes but the number of bytes provided must be correct for the choice of HashAlgorithm.

abstractHashToBytesAbstractHash algo a → ByteString Source #

The bytes representation of the hash value.

unsafeAbstractHashFromShortShortByteStringAbstractHash algo a Source #

The ShortByteString representation of the hash value.

abstractHashToShortAbstractHash algo a → ShortByteString Source #

The ShortByteString representation of the hash value.

Parsing and printing

decodeAbstractHashHashAlgorithm algo ⇒ TextEither Text (AbstractHash algo a) Source #

Parses given hash in base16 form.

Standard Hash type using Blake2b 256

type Hash = AbstractHash Blake2b_256 Source #

The type of our commonly used hash, Blake2b 256

Hashing

hashEncCBOR a ⇒ a → Hash a Source #

Deprecated: Use serializeCborHash or hash the annotation instead.

The hash of a value, serialised via EncCBOR.

hashDecodedDecoded t ⇒ t → Hash (BaseType t) Source #

The hash of a value's annotation

hashRawByteStringHash Raw Source #

Hash a bytestring

serializeCborHashEncCBOR a ⇒ a → Hash a Source #

The hash of a value, serialised via EncCBOR.

Conversion

hashFromBytesByteStringMaybe (Hash a) Source #

Make a hash from it bytes representation. It must be a 32-byte bytestring. The size is checked.

unsafeHashFromBytesByteStringHash a Source #

Make a hash from a 32-byte bytestring. It must be exactly 32 bytes.

hashToBytesAbstractHash algo a → ByteString Source #

The bytes representation of the hash value.

Parsing and printing

decodeHashTextEither Text (Hash a) Source #

Parses given hash in base16 form.

hashHexFFormat r (AbstractHash algo a → r) Source #

Specialized formatter for Hash.

mediumHashFFormat r (AbstractHash algo a → r) Source #

Smart formatter for Hash to show only first 16 characters of Hash.

shortHashFFormat r (AbstractHash algo a → r) Source #

Smart formatter for Hash to show only first 8 characters of Hash.