cryptonite-0.30: Cryptography Primitives sink

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

Crypto.Number.Generate

Description

Synopsis

- data GenTopPolicy
  - = SetHighest
  - | SetTwoHighest
- generateParams :: MonadRandom m => Int -> Maybe GenTopPolicy -> Bool -> m Integer
- generateMax :: MonadRandom m => Integer -> m Integer
- generateBetween :: MonadRandom m => Integer -> Integer -> m Integer

# Documentation

data GenTopPolicy Source #

Top bits policy when generating a number

Constructors

SetHighest | set the highest bit
SetTwoHighest | set the two highest bit

#### Instances

Instances details

Show GenTopPolicy Source # |
Instance details Defined in Crypto.Number.Generate Methods showsPrec :: Int -> GenTopPolicy -> ShowS Source # show :: GenTopPolicy -> String Source # showList :: [GenTopPolicy] -> ShowS Source #
Eq GenTopPolicy Source # |
Instance details Defined in Crypto.Number.Generate Methods (==) :: GenTopPolicy -> GenTopPolicy -> Bool Source # (/=) :: GenTopPolicy -> GenTopPolicy -> Bool Source #

generateParams Source #

Arguments

:: MonadRandom m |
=> Int | number of bits
-> Maybe GenTopPolicy | top bit policy
-> Bool | force the number to be odd
-> m Integer |

Generate a number for a specific size of bits, and optionaly set bottom and top bits

If the top bit policy is `Nothing`, then nothing is done on the highest bit (it's whatever the random generator set).

If @generateOdd is set to `True`, then the number generated is guaranteed to be odd. Otherwise it will be whatever is generated

generateMax Source #

Arguments

:: MonadRandom m |
=> Integer | range
-> m Integer |

Generate a positive integer x, s.t. 0 <= x < range

generateBetween :: MonadRandom m => Integer -> Integer -> m Integer Source #

generate a number between the inclusive bound [low,high].