Improving the BrainKey class
This commit is contained in:
parent
2059093be4
commit
f93f91fc1f
2 changed files with 19 additions and 3 deletions
|
@ -20,11 +20,18 @@ public class BrainKey {
|
||||||
// The size of the word dictionary
|
// The size of the word dictionary
|
||||||
public static final int DICT_WORD_COUNT = 49744;
|
public static final int DICT_WORD_COUNT = 49744;
|
||||||
|
|
||||||
// The required number of words
|
/* The required number of words */
|
||||||
public static final int BRAINKEY_WORD_COUNT = 12;
|
public static final int BRAINKEY_WORD_COUNT = 12;
|
||||||
|
|
||||||
|
/* The corresponding private key derivated from the brain key */
|
||||||
private ECKey mPrivateKey;
|
private ECKey mPrivateKey;
|
||||||
|
|
||||||
|
/* The actual words from this brain key + the sequence number */
|
||||||
|
private String mBrainKey;
|
||||||
|
|
||||||
|
/* The sequence number */
|
||||||
|
private int sequenceNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that will generate a random brain key
|
* Method that will generate a random brain key
|
||||||
*
|
*
|
||||||
|
@ -49,7 +56,6 @@ public class BrainKey {
|
||||||
stringBuilder.append(word);
|
stringBuilder.append(word);
|
||||||
stringBuilder.append(" ");
|
stringBuilder.append(" ");
|
||||||
}
|
}
|
||||||
System.out.println("Suggestion: '"+stringBuilder.toString().trim()+"'");
|
|
||||||
return stringBuilder.toString().trim();
|
return stringBuilder.toString().trim();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +66,8 @@ public class BrainKey {
|
||||||
* @param sequence Sequence number
|
* @param sequence Sequence number
|
||||||
*/
|
*/
|
||||||
public BrainKey(String words, int sequence) {
|
public BrainKey(String words, int sequence) {
|
||||||
|
this.mBrainKey = words;
|
||||||
|
this.sequenceNumber = sequence;
|
||||||
String encoded = String.format("%s %d", words, sequence);
|
String encoded = String.format("%s %d", words, sequence);
|
||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
|
@ -100,4 +108,12 @@ public class BrainKey {
|
||||||
DumpedPrivateKey wif = this.mPrivateKey.decompress().getPrivateKeyEncoded(NetworkParameters.fromID(NetworkParameters.ID_MAINNET));
|
DumpedPrivateKey wif = this.mPrivateKey.decompress().getPrivateKeyEncoded(NetworkParameters.fromID(NetworkParameters.ID_MAINNET));
|
||||||
return wif.toString();
|
return wif.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBrainKey(){
|
||||||
|
return mBrainKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSequenceNumber(){
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue