Answer the question
In order to leave comments, you need to log in
How to create a seed from a 128 bit number?
the input is a string containing 128 bits;
the output must be a valid seed phrase. but the 12th word is not working for me. I suspect that the matter is in the hashing of the incoming string. But I don't know how to fix it. Help me please.
private String[] generateMnemonic2(String seedEntropy) { // на вход сид
System.out.println(seedEntropy);
String[] mnemonicWords = new String[12];
for (int i = 0; i < 11; i++) {
int mnemWord = Integer.parseInt(seedEntropy.substring(i * 11, i * 11 + 11), 2);
mnemonicWords[i] = English.getWord(mnemWord);
}
mnemonicWords[11]=seedEntropy.substring(121,128); //тут храню остаток временно
String g=DigestUtils.sha256Hex(seedEntropy.getBytes()).substring(0,1);
System.out.println(g);
String v=mnemonicWords[11]+hexToBinary(g);
System.out.println(v);
BigInteger sha =new BigInteger(v,2);
System.out.println(sha.toString());
mnemonicWords[11] = English.getWord(sha.intValue());
return mnemonicWords;
}
String hexToBinary(String hex) {
int i = Integer.parseInt(hex, 16);
String bin = Integer.toBinaryString(i);
return bin;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question