crypto-sodium: Easy-and-safe-to-use high-level cryptography based on Sodium

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

This is a collection of high-level cryptographic primitives based on Sodium, spiced up with extra type-safety of the Haskell type system.

Note: this package is experimental and WIP.


Cryptography is hard to do right and you should never try to implement it on your own, even if you have access to safe and secure cryptographic primitives. Luckily, D. J. Bernstein created NaCl.

NaCl was designed specifically to make it hard to use it incorrectly and thus save you from a disaster. It exposes high-level cryptographic algorithms with underlying implementations chosen for you, so you do not get flexibility, but you get security, which is more important.


Sodium is a reimplementation of NaCl with the goal to make it more portable across different platforms. With time, it started providing more than the same interface as NaCl. Nowadays it implements additional primitives and utility functions.


Secret-key cryptography


Some of the Sodium (and NaCl) functions (those that generate random data) are not thread-safe. All these functions are explicitly marked as such in their Haddock documentation.

Calling sodiumInit before they are used makes them thread-safe, see Crypto.Init.


Sodium contains multiple implementations of the primitives it provides. There are generic implementations, that are used by default, and multiple alternatives optimised for various platforms.

sodiumInit will quickly benchmark all available implementations and choose the bests ones for each primitive, see Crypto.Init.

[Skip to Readme]


Change log
Dependencies base (>=4.10 && <4.15), bytestring (>=0.9 && <0.11), gdp (>= && <0.1), libsodium (>=1.0.11 && <2), memory (>=0.1 && <0.16), NaCl (>= && <0.1), safe-exceptions (>=0.1 && <0.2) [details]
License MPL-2.0
Copyright 2020 Serokell
Author Kirill Elagin <>
Maintainer Kirill Elagin <>
Category Cryptography
Home page
Bug tracker
Source repo head: git clone
Uploaded by kirelagin at 2020-05-24T18:36:47Z



Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for crypto-sodium-

[back to package description]


Easy-and-safe-to-use high-level cryptography based on Sodium

Note: this package is experimental and WIP.


Get it

Add crypto-sodium to the dependencies of your package.


All documentation exists is in the form of Haddock comments, you can find them in the source code or browse on Hackage.