JunZhang
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
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); |
|
|
|
} |
|
|
|