Browse Source

modify dice to mnemonic algorithm

dev
ZhangJun 5 years ago
parent
commit
3baf41d443
  1. 7
      app/src/main/java/com/cobo/cold/viewmodel/SetupVaultViewModel.java

7
app/src/main/java/com/cobo/cold/viewmodel/SetupVaultViewModel.java

@ -191,7 +191,12 @@ public class SetupVaultViewModel extends AndroidViewModel {
}
public void generateMnemonicFromDiceRolls(byte[] diceRolls) {
String entropy = Hex.toHexString(Objects.requireNonNull(HashUtil.sha256(diceRolls)));
//Use the same algorithm as https://iancoleman.io/bip39/
StringBuilder rolls = new StringBuilder();
for (byte b: diceRolls) {
rolls.append(b % 6);
}
String entropy = Hex.toHexString(Objects.requireNonNull(HashUtil.sha256(rolls.toString())));
String mnemonic = Bip39.generateMnemonic(entropy);
this.mnemonic.postValue(mnemonic);
}

Loading…
Cancel
Save