Skip to content

Instantly share code, notes, and snippets.

@mikedotexe
Created October 24, 2024 05:33
Show Gist options
  • Save mikedotexe/15240d5331122168b3654573e1c47d1c to your computer and use it in GitHub Desktop.
Save mikedotexe/15240d5331122168b3654573e1c47d1c to your computer and use it in GitHub Desktop.
messing around with SubtleCrypto
const newEd25519Key = await window.crypto.subtle.generateKey('Ed25519', true, ['sign', 'verify']);
const encoder = new TextEncoder();
const messageUtf8Bytes = encoder.encode("aloha honua");
const signature = await window.crypto.subtle.sign("Ed25519", newEd25519Key.privateKey, messageUtf8Bytes);
console.log('signature', signature);
const pkcs8PrivateKey = await window.crypto.subtle.exportKey('pkcs8', newEd25519Key.privateKey);
const pkcs8PrivKeyArr = new Uint8Array(pkcs8PrivateKey)
console.log('pkcs8PrivKeyArr', pkcs8PrivKeyArr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment