module Crypto.Random
(
ChaChaDRG
, SystemDRG
, getSystemDRG
, drgNew
, drgNewTest
, withDRG
, withRandomBytes
, DRG(..)
, MonadRandom(..)
, MonadPseudoRandom
) where
import Crypto.Random.Types
import Crypto.Random.ChaChaDRG
import Crypto.Random.SystemDRG
import Data.ByteArray (ByteArray, ScrubbedBytes)
import Crypto.Internal.Imports
drgNew :: MonadRandom randomly => randomly ChaChaDRG
drgNew = do
b <- getRandomBytes 40
return $ initialize (b :: ScrubbedBytes)
drgNewTest :: (Word64, Word64, Word64, Word64, Word64) -> ChaChaDRG
drgNewTest = initializeWords
withRandomBytes :: (ByteArray ba, DRG g) => g -> Int -> (ba -> a) -> (a, g)
withRandomBytes rng len f = (f bs, rng')
where (bs, rng') = randomBytesGenerate len rng