demo · v133
JWK / SPKI round-trip
Generate an X25519 keypair, export the public key as JWK and SPKI, re-import, derive bits against another freshly-generated party. The pattern interop libraries (libsodium-bridge, age, IETF MLS) need on Day 1.
X25519 isn't supported in SubtleCrypto here. Chrome 133+ required.
public key as JWK
—
public key as SPKI (base64)
—
click the button to run the round-trip.
what the demo exercises
const me = await crypto.subtle.generateKey({ name: "X25519" }, true, ["deriveBits"]);
const you = await crypto.subtle.generateKey({ name: "X25519" }, true, ["deriveBits"]);
const jwk = await crypto.subtle.exportKey("jwk", me.publicKey);
const spki = await crypto.subtle.exportKey("spki", me.publicKey);
const re = await crypto.subtle.importKey("jwk", jwk,
{ name: "X25519" }, false, []);
const bits = await crypto.subtle.deriveBits(
{ name: "X25519", public: you.publicKey }, me.privateKey, 256);