dice-entropy-conduit-1.0.0.3: Cryptographically secure n-sided dice via rejection sampling

Copyright | Peter Robinson 2014
License | LGPL
Maintainer | Peter Robinson <peter.robinson@monoid.at>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

System.Random.Dice.Internal

Description

Synopsis

- integralToBits :: (Integral n, Integral m) => Int -> n -> [m]
- bitsToIntegral :: Integral n => [n] -> n
- extendIntegralWithBits :: Integral n => n -> [n] -> n
- upperBound :: Word64
- getDiceRolls :: Int -> Int -> IO [Int]
- getRandomRs :: (Int, Int) -> Int -> IO [Int]
- diceRolls :: Int -> Conduit Word8 IO Int
- randomRs :: (Int, Int) -> Conduit Word8 IO Int
- systemEntropy :: Producer IO Word8
- dRoll :: Word64 -> Word64 -> Word64 -> Int -> Conduit Word8 IO (Int, Int)

# Documentation

integralToBits Source #

Arguments

:: (Integral n, Integral m) |
=> Int | minimal number of bits `b`
-> n | the number `n`
-> [m] | bit representation of `n`, length >= `b`

Converts a number to its base-2 representation (as a list of bits) and prepends zeros to ensure the minimal size.

bitsToIntegral :: Integral n => [n] -> n Source #

Convert a list of bits to an integral

extendIntegralWithBits :: Integral n => n -> [n] -> n Source #

upperBound :: Word64 Source #

Upper bound on the number of sides that a random dice can have.

getDiceRolls Source #

Arguments

:: Int | `n:` number of sides
-> Int | `k:` number of rolls
-> IO [Int] |

Generates `k` rolls of an `n` sided dice.

getRandomRs Source #

Arguments

:: (Int, Int) | (inclusive) range
-> Int | number of samples
-> IO [Int] |

Generates a list of random integer values in the specified range.

diceRolls :: Int -> Conduit Word8 IO Int Source #

Produces a stream of random integer values in the range `[0,n-1]`, for a given `n <= 2^55`. This conduit needs to be attached to an entropy source such as `systemEntropy`.

randomRs Source #

Arguments

:: (Int, Int) | range (inclusive)
-> Conduit Word8 IO Int |

Produces a stream of random integer values within a range. This conduit needs to be attached to an entropy source such as `systemEntropy`.

systemEntropy :: Producer IO Word8 Source #

A source of entropy. By default, we use the `getEntropy` function from the entropy package, see `systemEntropy`.

Warning: When combining a source of entropy with other conduits, it is important that there is no "backflow" due to leftover values that are being returned to the source from the conduit. This can be done by fusing the conduit with the identity map, e.g: `myEntropySrc $$ Data.Conduit.List.map id =$= myConduit`

dRoll :: Word64 -> Word64 -> Word64 -> Int -> Conduit Word8 IO (Int, Int) Source #

Internal function. Should not be invoked directly.