Portability | Good |
---|---|

Stability | experimental |

Maintainer | Vincent Hanquez <vincent@snarc.org> |

Safe Haskell | None |

Deprecated: Use crypto-pubkey Crypto.PubKey.DH

- type Params = (Integer, Integer)
- data PublicNumber
- data PrivateNumber
- data SharedKey
- generateParams :: CryptoRandomGen g => g -> Int -> Integer -> Either GenError (Params, g)
- generatePrivate :: CryptoRandomGen g => g -> Int -> Either GenError (PrivateNumber, g)
- generatePublic :: Params -> PrivateNumber -> PublicNumber
- getShared :: Params -> PrivateNumber -> PublicNumber -> SharedKey

# Documentation

type Params = (Integer, Integer)

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

data PublicNumber

Represent Diffie Hellman public number Y.

data PrivateNumber

Represent Diffie Hellman private number X.

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