Skip to content

Instantly share code, notes, and snippets.

@chiro-hiro
Last active September 13, 2017 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiro-hiro/3273a057fa7e12df6bfda49184755b23 to your computer and use it in GitHub Desktop.
Save chiro-hiro/3273a057fa7e12df6bfda49184755b23 to your computer and use it in GitHub Desktop.
Bip39 triple duplicate

Our testor (Ms. Phương) talk to me about, duplication of passphrase will become invalid passphrase in our wallet.

Look at BIP39 there are no duplication check. So I give it a try.

Create bip39.js

var bip39 = require('bip39')

function scanDuplicated(value){
    let buff = value.split(' ');
    let found = false;
    let tripple = [];
    for(let i = 0; i < buff.length; i++){
        tripple[i] = (!tripple[i]) ? 0 : tripple[i];
        for(let j = 0; j < buff.length; j++){
            if(buff[i] == buff[j] && i != j){
                tripple[i]++;
            }
            if(tripple[i] >= 2){
                console.log(value);
                found = true;
                break;
            }
        }
        if(found) break;
    }
}

while(true){
    scanDuplicated(bip39.generateMnemonic());
}

Install bip39

npm install bip39

Test and take result:

chiro@moonfang:~/bip39$ node bip39.js 
cruise loan drop drop mansion regular drop length two present property caution
roast body roast roast cry fitness vendor nasty memory hollow curve duck
pretty nest electric explain wrong spread loyal fee spread eyebrow rebel spread
capable fiction hybrid fiction outdoor wing fiction jeans various monitor oblige curious
cube anchor pride dog anchor lock claim cable anchor what pull height

Let's take a look:

cube anchor pride dog anchor lock claim cable anchor what pull height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment