Safe Haskell | None |
---|---|
Language | Haskell98 |
Diffie-Hellman key exchange
- newtype SharedSecret = SharedSecret [Word8]
- diffieHellmanPrimitive :: PrivKey -> PubKey -> Maybe SharedSecret
Documentation
diffieHellmanPrimitive :: PrivKey -> PubKey -> Maybe SharedSecret Source #
Given your private key and somebody else's public key, this compute a (256 bit) shared secret.
This is actually very simple: since pubkey = G * privkey
, the shared
secret will be simply G * privkey1 * privkey2
.
This can fail if for example an invalid pubkey is given, and in some other special circumstances.