I have a long list of 1million+ permutations of a 12 word BIP39 seed. How can I try them all on a bitcoin address?
edit: I know the address and the 12 words but i don't know the order of the words
I have a long list of 1million+ permutations of a 12 word BIP39 seed. How can I try them all on a bitcoin address?
edit: I know the address and the 12 words but i don't know the order of the words
Doing this requires three things:
In this specific case, the address is the one this puzzle on reddit leads to, so we will assume the derivation path is m/49'/0'/0'/0/0
This is a simple nodejs script using bitcoinjs-lib to read seeds from a file, validate them, and then try the first address against the one you are searching for. You can parallelize it by splitting the input file into pieces and running it once per file.
Do note that 12 words means roughly half a billion combinations. While this is doable with today's computing power, it is still going to take you a very long time. Some quick tests show it would take about 4 days on my laptop, although you may be able to speed it up by using a faster language, or parallelization.
var bip39 = require('bip39');
var bitcoin = require('bitcoinjs-lib')
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('addresses.txt')
});
var ctr = 1;
lineReader.on('line', function (line) {
if (ctr%100 == 0) {
console.log("Processing #" + ctr);
}
if (bip39.validateMnemonic(line)) {
var roothex = bip39.mnemonicToSeedHex(line);
var rootnode = bitcoin.HDNode.fromSeedHex(roothex);
var basechild = rootnode.deriveHardened(49)
.deriveHardened(0)
.deriveHardened(0)
.derive(0);
for (var i = 0; i < 3; i++) {
var child = basechild.derive(i);
var keyhash = bitcoin.crypto.hash160(child.getPublicKeyBuffer())
var scriptSig = bitcoin.script.witnessPubKeyHash.output.encode(keyhash)
var addressBytes = bitcoin.crypto.hash160(scriptSig)
var outputScript = bitcoin.script.scriptHash.output.encode(addressBytes)
var address = bitcoin.address.fromOutputScript(outputScript)
if (address == "3CcxyPhyvyc3S9UuPfu42GNZLvVVV11Uk8") {
console.log("Found seed! " + line)
}
}
}
ctr++;
});
You will need to install nodejs, and bitcoinjs-lib for this.
proof know able order problem end just zero run air agree next
– code511788465541441
May 19 '18 at 19:22
m/44'/0'/0'/0/i
, where i is increasing for every new address). Unless you know which path and index the address is at, it is impossible to check if a seed contains it. Which wallet is the address from? Most wallets publish their derivation path, so you should be able to find it. Then you just need the index (or an approximate) – Raghav Sood May 19 '18 at 17:59m/49'/0'/0'/0/0
, which is the first segwit address (I'm assuming the creator sent it to the first address on the seed), this is technically feasible. I'll post a script as an answer – Raghav Sood May 19 '18 at 18:04