From f93f91fc1f76154d80d74f4cc6e40ce5f5eed19b Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Sun, 18 Dec 2016 17:15:41 -0500 Subject: [PATCH] Improving the BrainKey class --- .../bitsharesmunich/graphenej/BrainKey.java | 22 ++++++++++++++++--- ...tAccountNameById.java => GetAccounts.java} | 0 2 files changed, 19 insertions(+), 3 deletions(-) rename src/main/java/de/bitsharesmunich/graphenej/api/{GetAccountNameById.java => GetAccounts.java} (100%) diff --git a/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java b/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java index c8f966a..4fcfdae 100644 --- a/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java +++ b/src/main/java/de/bitsharesmunich/graphenej/BrainKey.java @@ -20,11 +20,18 @@ public class BrainKey { // The size of the word dictionary 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; + /* The corresponding private key derivated from the brain key */ 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 * @@ -49,7 +56,6 @@ public class BrainKey { stringBuilder.append(word); stringBuilder.append(" "); } - System.out.println("Suggestion: '"+stringBuilder.toString().trim()+"'"); return stringBuilder.toString().trim(); } /** @@ -60,6 +66,8 @@ public class BrainKey { * @param sequence Sequence number */ public BrainKey(String words, int sequence) { + this.mBrainKey = words; + this.sequenceNumber = sequence; String encoded = String.format("%s %d", words, sequence); try { MessageDigest md = MessageDigest.getInstance("SHA-512"); @@ -100,4 +108,12 @@ public class BrainKey { DumpedPrivateKey wif = this.mPrivateKey.decompress().getPrivateKeyEncoded(NetworkParameters.fromID(NetworkParameters.ID_MAINNET)); return wif.toString(); } -} + + public String getBrainKey(){ + return mBrainKey; + } + + public int getSequenceNumber(){ + return sequenceNumber; + } +} \ No newline at end of file diff --git a/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java b/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java similarity index 100% rename from src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java rename to src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java