cryptonite-0.23: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | Good
Safe Haskell | None
Language | Haskell2010

Crypto.Random.Types

Description

Synopsis

- class (Functor m, Monad m) => MonadRandom m where
- data MonadPseudoRandom gen a
- class DRG gen where
- withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen)

# Documentation

class (Functor m, Monad m) => MonadRandom m where #

A monad constraint that allows to generate random bytes

Minimal complete definition

getRandomBytes

Methods

getRandomBytes :: ByteArray byteArray => Int -> m byteArray #

Instances

MonadRandom IO # |
Methods getRandomBytes :: ByteArray byteArray => Int -> IO byteArray #
DRG gen => MonadRandom (MonadPseudoRandom gen) # |
Methods getRandomBytes :: ByteArray byteArray => Int -> MonadPseudoRandom gen byteArray #

data MonadPseudoRandom gen a #

A simple Monad class very similar to a State Monad with the state being a DRG.

Instances

DRG gen => Monad (MonadPseudoRandom gen) # |
Methods (>>=) :: MonadPseudoRandom gen a -> (a -> MonadPseudoRandom gen b) -> MonadPseudoRandom gen b # (>>) :: MonadPseudoRandom gen a -> MonadPseudoRandom gen b -> MonadPseudoRandom gen b # return :: a -> MonadPseudoRandom gen a # fail :: String -> MonadPseudoRandom gen a #
DRG gen => Functor (MonadPseudoRandom gen) # |
Methods fmap :: (a -> b) -> MonadPseudoRandom gen a -> MonadPseudoRandom gen b # (<$) :: a -> MonadPseudoRandom gen b -> MonadPseudoRandom gen a #
DRG gen => Applicative (MonadPseudoRandom gen) # |
Methods pure :: a -> MonadPseudoRandom gen a # (<*>) :: MonadPseudoRandom gen (a -> b) -> MonadPseudoRandom gen a -> MonadPseudoRandom gen b # (*>) :: MonadPseudoRandom gen a -> MonadPseudoRandom gen b -> MonadPseudoRandom gen b # (<*) :: MonadPseudoRandom gen a -> MonadPseudoRandom gen b -> MonadPseudoRandom gen a #
DRG gen => MonadRandom (MonadPseudoRandom gen) # |
Methods getRandomBytes :: ByteArray byteArray => Int -> MonadPseudoRandom gen byteArray #

class DRG gen where #

A Deterministic Random Generator (DRG) class

Minimal complete definition

randomBytesGenerate

Methods

randomBytesGenerate :: ByteArray byteArray => Int -> gen -> (byteArray, gen) #

Generate N bytes of randomness from a DRG

Instances

DRG SystemDRG # |
Methods randomBytesGenerate :: ByteArray byteArray => Int -> SystemDRG -> (byteArray, SystemDRG) #
DRG ChaChaDRG # |
Methods randomBytesGenerate :: ByteArray byteArray => Int -> ChaChaDRG -> (byteArray, ChaChaDRG) #

withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen) #

Run a pure computation with a Deterministic Random Generator in the `MonadPseudoRandom`