cardano-crypto-wrapper-1.3.0: Cryptographic primitives used in the Cardano project
Safe Haskell None
Language Haskell2010

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
Eq ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

Ord ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

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

Generic ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

Associated Types

type Rep ( AbstractHash algo a) :: Type -> Type Source #

ToJSON ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

ToJSONKey ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

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

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

Defined in Cardano.Crypto.Hashing

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

Defined in Cardano.Crypto.Hashing

HeapWords ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

NFData ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

Methods

rnf :: AbstractHash algo a -> () Source #

Buildable ( AbstractHash algo a) Source #
Instance details

Defined in Cardano.Crypto.Hashing

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.3.0-IHV099LYIDeGXjcjOEcwKY" ' True ) ( C1 (' MetaCons "AbstractHash" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe 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 256) => HashAlgorithm ( Blake2s bitlen)
Instance details

Defined in Crypto.Hash.Blake2

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

Defined in Crypto.Hash.Blake2

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

Defined in Crypto.Hash.Blake2

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

Defined in Crypto.Hash.Blake2

KnownNat bitlen => HashAlgorithm ( SHAKE128 bitlen)
Instance details

Defined in Crypto.Hash.SHAKE

KnownNat bitlen => HashAlgorithm ( SHAKE256 bitlen)
Instance details

Defined in Crypto.Hash.SHAKE

Hashing

abstractHash :: ( HashAlgorithm algo, ToCBOR a) => a -> AbstractHash algo a Source #

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

unsafeAbstractHash :: HashAlgorithm algo => LByteString -> AbstractHash algo a Source #

Hash a lazy LByteString

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

Conversion

abstractHashFromBytes :: forall algo a. HashAlgorithm algo => ByteString -> Maybe ( 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 .

unsafeAbstractHashFromBytes :: ByteString -> AbstractHash algo a Source #

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

abstractHashToBytes :: AbstractHash algo a -> ByteString Source #

The bytes representation of the hash value.

Parsing and printing

Standard Hash type using Blake2b 256

type Hash = AbstractHash Blake2b_256 Source #

The type of our commonly used hash, Blake2b 256

Hashing

hash :: ToCBOR a => a -> Hash a Source #

Deprecated: Use serializeCborHash or hash the annotation instead.

The hash of a value, serialised via ToCBOR .

hashDecoded :: Decoded t => t -> Hash ( BaseType t) Source #

The hash of a value's annotation

serializeCborHash :: ToCBOR a => a -> Hash a Source #

The hash of a value, serialised via ToCBOR .

Conversion

hashFromBytes :: ByteString -> Maybe ( Hash a) Source #

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

unsafeHashFromBytes :: ByteString -> Hash a Source #

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

hashToBytes :: AbstractHash algo a -> ByteString Source #

The bytes representation of the hash value.

Parsing and printing

decodeHash :: Text -> Either Text ( Hash a) Source #

Parses given hash in base16 form.

hashHexF :: Format r ( AbstractHash algo a -> r) Source #

Specialized formatter for Hash .

mediumHashF :: Format r ( AbstractHash algo a -> r) Source #

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

shortHashF :: Format r ( AbstractHash algo a -> r) Source #

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