Skip to content

Instantly share code, notes, and snippets.

@manniru
Forked from hoytech/bip39-brute.js
Created October 27, 2022 02:21
Show Gist options
  • Save manniru/60786890efc772539d197e9fb8af3ae8 to your computer and use it in GitHub Desktop.
Save manniru/60786890efc772539d197e9fb8af3ae8 to your computer and use it in GitHub Desktop.
// https://www.reddit.com/r/ethdev/comments/7jyzlw/50_in_ether_prize_for_puzzle_in_this_tweet/
// npm i bip39 ethereumjs-wallet allcombinations shuffle-array
const bip39 = require("bip39");
const hdkey = require('ethereumjs-wallet/hdkey');
const allcombinations = require('allcombinations');
const shuffle = require('shuffle-array');
let words = 'bright summer public tenant avocado chef depend romance school reason help start';
let allCombinationsGenerator = allcombinations(shuffle(words.split(' ')));
let total = 0, totalok = 0;;
for (let comb of allCombinationsGenerator) {
total++;
let joined = comb.join(' ');
let valid = bip39.validateMnemonic(joined);
if (!valid) continue;
totalok++;
if (totalok % 1000 === 0) console.log(`${totalok}/${total}`);
let hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(joined));
let wallet = hdwallet.derivePath("m/44'/60'/0'/0").getWallet();
if (wallet.getAddress().toString("hex") === '684c2a81a42e3511c9961eeb93e31c4890b07e0f') {
console.log(joined);
process.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment