{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE TypeFamilies #-}

-- | Implementation of the SHA3_256 hashing algorithm.
module Cardano.Crypto.Hash.SHA3_256
  ( SHA3_256
  )
where

import Cardano.Crypto.Hash.Class
import qualified "cryptonite" Crypto.Hash as H
import qualified Data.ByteArray as BA

data SHA3_256

instance HashAlgorithm SHA3_256 where
  type SizeHash SHA3_256 = 32
  hashAlgorithmName :: proxy SHA3_256 -> String
hashAlgorithmName proxy SHA3_256
_ = String
"sha3-256"
  digest :: proxy SHA3_256 -> ByteString -> ByteString
digest proxy SHA3_256
_ = Digest SHA3_256 -> ByteString
convert (Digest SHA3_256 -> ByteString)
-> (ByteString -> Digest SHA3_256) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Digest SHA3_256
forall ba a.
(ByteArrayAccess ba, HashAlgorithm a) =>
ba -> Digest a
H.hash

convert :: H.Digest H.SHA3_256 -> ByteString
convert :: Digest SHA3_256 -> ByteString
convert = Digest SHA3_256 -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
BA.convert