Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generation of random numbers via Crypto.RNG.
Synopsis
- data RNG :: Effect where
- RandomBytes :: Int -> RNG m ByteString
- Random :: Uniform a => RNG m a
- RandomR :: UniformRange a => (a, a) -> RNG m a
- class Monad m => CryptoRNG (m :: Type -> Type) where
- randomBytes :: Int -> m ByteString
- random :: Uniform a => m a
- randomR :: UniformRange a => (a, a) -> m a
- runCryptoRNG :: IOE :> es => CryptoRNGState -> Eff (RNG ': es) a -> Eff es a
- data CryptoRNGState
- newCryptoRNGState :: MonadIO m => m CryptoRNGState
- newCryptoRNGStateSized :: MonadIO m => Int -> m CryptoRNGState
Effect
data RNG :: Effect where Source #
Provide the ability to generate random numbers.
RandomBytes :: Int -> RNG m ByteString | |
Random :: Uniform a => RNG m a | |
RandomR :: UniformRange a => (a, a) -> RNG m a |
Instances
type DispatchOf RNG Source # | |
Defined in Effectful.Crypto.RNG.Effect |
class Monad m => CryptoRNG (m :: Type -> Type) where #
Monads carrying around the RNG state.
randomBytes :: Int -> m ByteString #
Generate a given number of cryptographically secure random bytes.
Generate a cryptographically secure value uniformly distributed over all possible values of that type.
randomR :: UniformRange a => (a, a) -> m a #
Generate a cryptographically secure value in a given, closed range.
Instances
(Monad (t m), MonadTrans t, CryptoRNG m) => CryptoRNG (t m) | Generic, overlapping instance. |
Defined in Crypto.RNG.Class randomBytes :: Int -> t m ByteString # random :: Uniform a => t m a # randomR :: UniformRange a => (a, a) -> t m a # | |
MonadIO m => CryptoRNG (RNGT m) | |
Defined in Crypto.RNG.Unsafe randomBytes :: Int -> RNGT m ByteString # random :: Uniform a => RNGT m a # randomR :: UniformRange a => (a, a) -> RNGT m a # | |
MonadIO m => CryptoRNG (CryptoRNGT m) | |
Defined in Crypto.RNG randomBytes :: Int -> CryptoRNGT m ByteString # random :: Uniform a => CryptoRNGT m a # randomR :: UniformRange a => (a, a) -> CryptoRNGT m a # | |
RNG :> es => CryptoRNG (Eff es) Source # | |
Defined in Effectful.Crypto.RNG.Effect randomBytes :: Int -> Eff es ByteString # random :: Uniform a => Eff es a # randomR :: UniformRange a => (a, a) -> Eff es a # |
Handlers
runCryptoRNG :: IOE :> es => CryptoRNGState -> Eff (RNG ': es) a -> Eff es a Source #
Generate cryptographically secure random numbers.
Instantiation of the initial RNG state
data CryptoRNGState #
The random number generator state.
Instances
StatefulGen CryptoRNGState IO | |
Defined in Crypto.RNG uniformWord32R :: Word32 -> CryptoRNGState -> IO Word32 # uniformWord64R :: Word64 -> CryptoRNGState -> IO Word64 # uniformWord8 :: CryptoRNGState -> IO Word8 # uniformWord16 :: CryptoRNGState -> IO Word16 # uniformWord32 :: CryptoRNGState -> IO Word32 # uniformWord64 :: CryptoRNGState -> IO Word64 # uniformShortByteString :: Int -> CryptoRNGState -> IO ShortByteString # |
newCryptoRNGState :: MonadIO m => m CryptoRNGState #
Create a new CryptoRNGState
based on system entropy with a buffer size of
32KB.
One buffer per capability is created.
:: MonadIO m | |
=> Int | Buffer size. |
-> m CryptoRNGState |
Create a new CryptoRNGState
based on system entropy with buffers of
specified size.
One buffer per capability is created.