keccak: cryptographic functions based on the sponge construction

[ crypto, library, mit, program ] [ Propose Tags ]

pure haskell implementation of keccak hash functions for use with ghc or ghcjs

[Skip to Readme]




Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.2.0
Dependencies base (>=4.7 && <5), base16-bytestring, bytestring, keccak, vector [details]
License MIT
Copyright 2018 Roy Blankman
Author Roy Blankman
Category Crypto
Home page
Source repo head: git clone
Uploaded by aupiff at 2018-07-20T14:28:07Z
Executables collision
Downloads 2592 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-07-20 [all 1 reports]

Readme for keccak-0.2.0

[back to package description]



A pure haskell implementation of the keccak family of hashes.

Documentation available on Hackage.

Example usage

In the example usage below, I encode ByteStrings in base16 so that they can be read as standard hex strings.

ghci> import Data.ByteString.Base16 as BS16

ghci> :t keccak256
keccak256 :: BS.ByteString -> BS.ByteString

ghci> BS16.encode $ keccak256 "testing"

ghci> BS16.encode $ keccak256 ""


stack test

NIST uses the Secure Hash Algorithm Validation System (SHAVS) to validate the correctness of hash implementations. For all four variants of SHA3 and Keccak and the two standard variants of SHAKE, the keccak library's implementations successfully pass the standard KATs (Known Answer Tests).


stack bench

cryptonite's C-based implementation of Keccack256 is currently 21 times faster than my Haskell.

benchmarked keccak
time                 768.3 μs   (758.7 μs .. 775.7 μs)
                     0.998 R²   (0.995 R² .. 0.999 R²)
mean                 774.2 μs   (767.5 μs .. 784.0 μs)
std dev              29.27 μs   (23.12 μs .. 36.87 μs)
variance introduced by outliers: 19% (moderately inflated)

benchmarked cryptonite-keccak
time                 36.92 μs   (35.95 μs .. 38.03 μs)
                     0.996 R²   (0.995 R² .. 0.998 R²)
mean                 36.27 μs   (35.99 μs .. 36.66 μs)
std dev              1.147 μs   (918.3 ns .. 1.471 μs)
variance introduced by outliers: 14% (moderately inflated)

Eventually, I hope the library will have very few dependencies (only base, vector & bytestring, currently) and excellent performance.


Cryptographic Sponge Functions

Official Keccak Reference

Specification summary