Created
June 23, 2020 10:13
-
-
Save nnkken/2d8416ca5dab9ed8019e3b5e4afa87d9 to your computer and use it in GitHub Desktop.
create 200000 Cosmos addresses test
This file contains hidden or 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 crypto = require('crypto'); | |
const secp256k1 = require('secp256k1'); | |
const bech32 = require('bech32'); | |
const createHash = require('create-hash'); | |
function createSigner(privateKey) { | |
const publicKeyArr = secp256k1.publicKeyCreate(privateKey, true); | |
const publicKey = Buffer.from(publicKeyArr); | |
const sha256 = createHash('sha256'); | |
const ripemd = createHash('ripemd160'); | |
sha256.update(publicKey); | |
ripemd.update(sha256.digest()); | |
const rawAddr = ripemd.digest(); | |
const cosmosAddress = bech32.encode('cosmos', bech32.toWords(rawAddr)); | |
console.log(`address: ${cosmosAddress}`); | |
} | |
for (let i = 0; i < 200000; i += 1) { | |
const privKey = crypto.randomBytes(32); | |
createSigner(privKey); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment