From 0b6b2d661c0138136cea6795bad2e254ca2236f6 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Fri, 19 Jun 2015 11:05:54 +0100 Subject: [PATCH] [Random] allow drgNew to be run in any MonadRandom directly. this allow cascading, create a DRG from another DRG --- Crypto/Random.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Crypto/Random.hs b/Crypto/Random.hs index d270b82..bd89f0d 100644 --- a/Crypto/Random.hs +++ b/Crypto/Random.hs @@ -26,8 +26,10 @@ import Data.ByteArray (ScrubbedBytes) import Crypto.Internal.Imports -- | Create a new DRG from system entropy -drgNew :: IO ChaChaDRG -drgNew = initialize <$> (getEntropy 40 :: IO ScrubbedBytes) +drgNew :: MonadRandom randomly => randomly ChaChaDRG +drgNew = do + b <- getRandomBytes 40 + return $ initialize (b :: ScrubbedBytes) -- | Create a new DRG from 5 Word64. --