@nakov/

ECDSA-in-JS

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6614641687436","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"bGV0IGVsbGlwdGljID0gcmVxdWlyZSgnZWxsaXB0aWMnKTsKbGV0IHNoYTMgPSByZXF1aXJlKCdqcy1zaGEzJyk7CmxldCBlYyA9IG5ldyBlbGxpcHRpYy5lYygnc2VjcDI1NmsxJyk7CgovLyBsZXQga2V5UGFpciA9IGVjLmdlbktleVBhaXIoKTsgLy8gR2VuZXJhdGUgcmFuZG9tIGtleXMKbGV0IGtleVBhaXIgPSBlYy5rZXlGcm9tUHJpdmF0ZSgKIjk3ZGRhZTBmM2EyNWI5MjI2ODE3NTQwMDE0OWQ2NWQ2ODg3YjljZWZhZjI4ZWEyYzA3OGUwNWNkYzE1YTNjMGEiKTsKbGV0IHByaXZLZXkgPSBrZXlQYWlyLmdldFByaXZhdGUoImhleCIpOwpsZXQgcHViS2V5ID0ga2V5UGFpci5nZXRQdWJsaWMoKTsKY29uc29sZS5sb2coYFByaXZhdGUga2V5OiAke3ByaXZLZXl9YCk7CmNvbnNvbGUubG9nKCJQdWJsaWMga2V5IDoiLCBwdWJLZXkuZW5jb2RlKCJoZXgiKS5zdWJzdHIoMikpOwpjb25zb2xlLmxvZygiUHVibGljIGtleSAoY29tcHJlc3NlZCk6IiwKcHViS2V5LmVuY29kZUNvbXByZXNzZWQoImhleCIpKTs="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
let elliptic = require('elliptic');
let sha3 = require('js-sha3');
let ec = new elliptic.ec('secp256k1');

// let keyPair = ec.genKeyPair(); // Generate random keys
let keyPair = ec.keyFromPrivate(
"97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a");
let privKey = keyPair.getPrivate("hex");
let pubKey = keyPair.getPublic();
console.log(`Private key: ${privKey}`);
console.log("Public key :", pubKey.encode("hex").substr(2));
console.log("Public key (compressed):",
pubKey.encodeCompressed("hex"));
Native Browser JavaScript