{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module Cardano.Crypto.Hash.Blake2b
( Blake2b_224
, Blake2b_256
)
where
import Cardano.Crypto.Hash.Class
import qualified "cryptonite" Crypto.Hash as H
import qualified Data.ByteArray as BA
data Blake2b_224
data Blake2b_256
instance HashAlgorithm Blake2b_224 where
type SizeHash Blake2b_224 = 28
hashAlgorithmName :: proxy Blake2b_224 -> String
hashAlgorithmName proxy Blake2b_224
_ = String
"blake2b_224"
digest :: proxy Blake2b_224 -> ByteString -> ByteString
digest proxy Blake2b_224
_ = Digest Blake2b_224 -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
BA.convert (Digest Blake2b_224 -> ByteString)
-> (ByteString -> Digest Blake2b_224) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteArrayAccess ByteString, HashAlgorithm Blake2b_224) =>
ByteString -> Digest Blake2b_224
forall ba a.
(ByteArrayAccess ba, HashAlgorithm a) =>
ba -> Digest a
H.hash @_ @H.Blake2b_224
instance HashAlgorithm Blake2b_256 where
type SizeHash Blake2b_256 = 32
hashAlgorithmName :: proxy Blake2b_256 -> String
hashAlgorithmName proxy Blake2b_256
_ = String
"blake2b_256"
digest :: proxy Blake2b_256 -> ByteString -> ByteString
digest proxy Blake2b_256
_ = Digest Blake2b_256 -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
BA.convert (Digest Blake2b_256 -> ByteString)
-> (ByteString -> Digest Blake2b_256) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteArrayAccess ByteString, HashAlgorithm Blake2b_256) =>
ByteString -> Digest Blake2b_256
forall ba a.
(ByteArrayAccess ba, HashAlgorithm a) =>
ba -> Digest a
H.hash @_ @H.Blake2b_256