Browse Source

modify dice to mnemonic algorithm (#56)

btc_only_dev
JunZhang 4 years ago
committed by GitHub
parent
commit
cd4a8c837b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/src/main/java/com/cobo/cold/viewmodel/SetupVaultViewModel.java

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

@ -190,7 +190,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