diff --git a/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java b/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java index 2fb52b8..14f6f97 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/AuthorityType.java @@ -9,5 +9,10 @@ package cy.agorise.graphenej; public enum AuthorityType { OWNER, ACTIVE, - MEMO + MEMO; + + @Override + public String toString() { + return String.format("%d", this.ordinal()); + } } diff --git a/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java b/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java index b44131b..c1808f7 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/BrainKey.java @@ -1,5 +1,7 @@ package cy.agorise.graphenej; +import android.annotation.SuppressLint; + import org.bitcoinj.core.DumpedPrivateKey; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.NetworkParameters; @@ -69,7 +71,15 @@ public class BrainKey { public BrainKey(String words, int sequence) { this.mBrainKey = words; this.sequenceNumber = sequence; - String encoded = String.format("%s %d", words, sequence); + derivePrivateKey(); + } + + /** + * Generates the actual private key from the brainkey + sequence number + */ + private void derivePrivateKey(){ + @SuppressLint("DefaultLocale") + String encoded = String.format("%s %d", this.mBrainKey, this.sequenceNumber); try { MessageDigest md = MessageDigest.getInstance("SHA-512"); byte[] bytes = md.digest(encoded.getBytes("UTF-8")); @@ -142,5 +152,6 @@ public class BrainKey { */ public void setSequenceNumber(int sequenceNumber) { this.sequenceNumber = sequenceNumber; + derivePrivateKey(); } } \ No newline at end of file