Created
October 8, 2021 18:30
-
-
Save Dan-Nolan/629054de172fe3ea5141740697379ffd to your computer and use it in GitHub Desktop.
Elliptic Key Utils
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 EC = require('elliptic').ec; | |
const ec = new EC('secp256k1'); | |
// private/public key pair generation | |
const key = ec.genKeyPair(); | |
// to public key hex string (04...) | |
const hexPublicKey = key.getPublic().encode('hex'); | |
// from hex string back to the elliptic key object (this key can verify) | |
const verifyKey = ec.keyFromPublic(hexPublicKey, 'hex'); | |
// to private key hex string | |
const hexPrivateKey = key.getPrivate().toString(16); | |
// from hex string back to elliptic key object (this key can sign) | |
const signingKey = ec.keyFromPrivate(hexPrivateKey); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment