Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
PPC ADDR GEN
node v8.17.0
version:
master
endpoint
share
tweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
const EC = require('elliptic').ec; const SHA256 = require('js-sha256').sha256; const RIPEMD160 = require('ripemd160'); const BASE58CHECK = require('base58check'); const BA = require('binascii'); const EC_INSTANCE = new EC('secp256k1'); const KEY_PAIR = EC_INSTANCE.genKeyPair(); const NETWORK = "37"; const privateKey = KEY_PAIR.getPrivate('hex'); const key = BA.unhexlify(KEY_PAIR.getPublic('hex')); const keyHash = NETWORK + new RIPEMD160().update(SHA256(key)).digest('hex'); const checksum = SHA256(SHA256(keyHash)).substr(0, 4); const address = BASE58CHECK.encode(keyHash + checksum); // Output generated address/priv. key console.log(`Address (Wallet): ${address} (length: ${address.length})`); console.log(`Private Key: ${privateKey}`);
Loading…
no comments
sign in
to comment