cryptocipher-0.3.0: Symmetrical Block, Stream and PubKey Ciphers

MaintainerVincent Hanquez <>
Safe HaskellNone






type Params = (Integer, Integer)

Represent Diffie Hellman parameters namely P (prime), and G (generator).

data SharedKey

Represent Diffie Hellman shared secret.

generateParams :: CryptoRandomGen g => g -> Int -> Integer -> Either GenError (Params, g)Source

generate params from a specific generator (2 or 5 are common values) we generate a safe prime (a prime number of the form 2p+1 where p is also prime)

generatePrivate :: CryptoRandomGen g => g -> Int -> Either GenError (PrivateNumber, g)Source

generate a private number with no specific property this number is usually called X in DH text.

generatePublic :: Params -> PrivateNumber -> PublicNumberSource

generate a public number that is for the other party benefits. this number is usually called Y in DH text.

getShared :: Params -> PrivateNumber -> PublicNumber -> SharedKeySource

generate a shared key using our private number and the other party public number