XDH
X25519/X448 Diffie-Hellman key agreement as defined in RFC 7748.
XDH allows two parties to establish a shared secret over an insecure channel using modern Montgomery curves. It is the recommended alternative to ECDH for new applications, offering simpler implementation and resistance to timing attacks.
val aliceKeys = provider.get(XDH).keyPairGenerator(XDH.Curve.X25519).generateKey()
val bobKeys = provider.get(XDH).keyPairGenerator(XDH.Curve.X25519).generateKey()
val sharedSecret = aliceKeys.privateKey.sharedSecretGenerator().generateSharedSecret(bobKeys.publicKey)The raw shared secret output should not be used directly as a key. Use a key derivation function like HKDF to derive actual keys from the shared secret.
For key agreement using Weierstrass curves, see ECDH.
Types
An XDH private key that provides shared secret computation via sharedSecretGenerator.
An XDH public key that provides shared secret computation via sharedSecretGenerator.
Properties
The typed identifier that uniquely distinguishes this algorithm and is used to look it up from a CryptographyProvider.
Functions
Returns a KeyGenerator that generates XDH key pairs on the given curve.
Returns a Decoder that decodes XDH private keys on the given curve from the specified PrivateKey.Format.
Returns a Decoder that decodes XDH public keys on the given curve from the specified PublicKey.Format.