Skip to content

Instantly share code, notes, and snippets.

@cardoso
Last active October 17, 2022 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cardoso/d537a9afd5a14da8c3f2f2ed8dd00e7e to your computer and use it in GitHub Desktop.
Save cardoso/d537a9afd5a14da8c3f2f2ed8dd00e7e to your computer and use it in GitHub Desktop.
export default async () => {
const keyPair = await window.crypto.subtle.generateKey(
{
name: "ECDH",
namedCurve: "P-256",
},
true,
["deriveKey", "deriveBits"]
);
const publicKeyJwk = await window.crypto.subtle.exportKey(
"jwk",
keyPair.publicKey
);
const privateKeyJwk = await window.crypto.subtle.exportKey(
"jwk",
keyPair.privateKey
);
return { publicKeyJwk, privateKeyJwk };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment