Last active
June 2, 2024 13:17
-
-
Save dahlia/7a182572e01a327ec25417739d6960c0 to your computer and use it in GitHub Desktop.
Ed25519 signing/verification using Web Cryptography API (tested on Node.js, Bun, and Deno)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keyPair = await crypto.subtle.generateKey( | |
"Ed25519", | |
true, | |
["sign", "verify"], | |
); | |
console.debug(keyPair); | |
const msg = new TextEncoder().encode("Hello, World!"); | |
const sig = await crypto.subtle.sign( | |
"Ed25519", | |
keyPair.privateKey, | |
msg, | |
); | |
console.debug(sig); | |
const isValid = await crypto.subtle.verify( | |
"Ed25519", | |
keyPair.publicKey, | |
sig, | |
msg, | |
); | |
console.debug(isValid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment