| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | experimental |
| Portability | Good |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Random.Types
Description
Synopsis
- class Monad m => MonadRandom (m :: Type -> Type) where
- getRandomBytes :: ByteArray byteArray => Int -> m byteArray
- data MonadPseudoRandom gen a
- class DRG gen where
- randomBytesGenerate :: ByteArray byteArray => Int -> gen -> (byteArray, gen)
- withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen)
Documentation
class Monad m => MonadRandom (m :: Type -> Type) where Source #
A monad constraint that allows to generate random bytes
Everything in this library that draws a key, a nonce or a signature's
randomness draws it through this class, and cannot tell a strong source
from a weak one. The two instances below are the ones to reach for:
IO reads the system entropy source, and MonadPseudoRandom runs a
DRG seeded from it.
An instance of your own is held to the same standard. A generator that another party can predict, or that repeats, yields keys and signatures that give away what they are meant to keep -- so the deliberately repeatable instance that makes a test reproducible is not one to ship with.
Methods
getRandomBytes :: ByteArray byteArray => Int -> m byteArray Source #
Instances
| MonadRandom IO Source # | Through the generator of |
Defined in Crypto.Random.Types | |
| DRG gen => MonadRandom (MonadPseudoRandom gen) Source # | |
Defined in Crypto.Random.Types Methods getRandomBytes :: ByteArray byteArray => Int -> MonadPseudoRandom gen byteArray Source # | |
data MonadPseudoRandom gen a Source #
A simple Monad class very similar to a State Monad with the state being a DRG.
Instances
A Deterministic Random Generator (DRG) class
Methods
randomBytesGenerate :: ByteArray byteArray => Int -> gen -> (byteArray, gen) Source #
Generate N bytes of randomness from a DRG
Instances
| DRG ChaChaDRG Source # | |
Defined in Crypto.Random.ChaChaDRG | |
| DRG SystemDRG Source # | |
Defined in Crypto.Random.SystemDRG | |
withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen) Source #
Run a pure computation with a Deterministic Random Generator
in the MonadPseudoRandom