demo · v133
X25519 key agreement
Generate two X25519 keypairs (Alice, Bob), derive a shared secret from each direction, and check they match - a real ECDH handshake using the new "X25519" SubtleCrypto algorithm.
Alice public (base64)
-
Bob public (base64)
-
checking support...
the code
const alice = await crypto.subtle.generateKey({ name: "X25519" }, true, ["deriveBits"]);
const bob = await crypto.subtle.generateKey({ name: "X25519" }, true, ["deriveBits"]);
const aShared = await crypto.subtle.deriveBits(
{ name: "X25519", public: bob.publicKey }, alice.privateKey, 256);
const bShared = await crypto.subtle.deriveBits(
{ name: "X25519", public: alice.publicKey }, bob.privateKey, 256);
// aShared === bShared
see also
- X25519 - Web Cryptography - feature index
- ChromeStatus entry
- WICG webcrypto-secure-curves