Last active
February 10, 2022 15:25
-
-
Save rawinng/5570381533a50753a6a611fa27be14c5 to your computer and use it in GitHub Desktop.
POC for ED25519 on node (requires crypto and ed25519 lib)
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
var crypto = require('crypto'); | |
var ed25519 = require('ed25519'); | |
var random = crypto.randomBytes(32); | |
console.log(`seed: ${random.toString('hex')}`); | |
var keyPair = ed25519.MakeKeypair(random); | |
console.log(`privateKey: ${keyPair.privateKey.toString('hex')}`); | |
console.log(`publicKey: ${keyPair.publicKey.toString('hex')}`); | |
var message = "Hello, World"; | |
var sig = ed25519.Sign(Buffer.from(message, 'utf-8'), keyPair); | |
console.log(`SIG: ${sig.toString('hex')}`); | |
var verify = ed25519.Verify(Buffer.from(message, 'utf-8'), sig, keyPair.publicKey); | |
console.log(`verify=${verify}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment