cryptonite-0.13: Cryptography Primitives sink

LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Crypto.Number.Prime

Description

 

Synopsis

Documentation

generatePrime :: MonadRandom m => Int -> m Integer Source

generate a prime number of the required bitsize

generateSafePrime :: MonadRandom m => Int -> m Integer Source

generate a prime number of the form 2p+1 where p is also prime. it is also knowed as a Sophie Germaine prime or safe prime.

The number of safe prime is significantly smaller to the number of prime, as such it shouldn't be used if this number is supposed to be kept safe.

isProbablyPrime :: Integer -> Bool Source

returns if the number is probably prime. first a list of small primes are implicitely tested for divisibility, then a fermat primality test is used with arbitrary numbers and then the Miller Rabin algorithm is used with an accuracy of 30 recursions

findPrimeFrom :: Integer -> Integer Source

find a prime from a starting point with no specific property.

findPrimeFromWith :: (Integer -> Bool) -> Integer -> Integer Source

find a prime from a starting point where the property hold.

primalityTestMillerRabin :: Int -> Integer -> Bool Source

Miller Rabin algorithm return if the number is probably prime or composite. the tries parameter is the number of recursion, that determines the accuracy of the test.

primalityTestNaive :: Integer -> Bool Source

Test naively is integer is prime. while naive, we skip even number and stop iteration at i > sqrt(n)

primalityTestFermat Source

Arguments

:: Int

number of iterations of the algorithm

-> Integer

starting a

-> Integer

number to test for primality

-> Bool 

Probabilitic Test using Fermat primility test. Beware of Carmichael numbers that are Fermat liars, i.e. this test is useless for them. always combines with some other test.

isCoprime :: Integer -> Integer -> Bool Source

Test is two integer are coprime to each other