- getBrainKeyFromBytes gets the BrainKey!

This commit is contained in:
Henry Varona 2016-12-01 22:39:04 -04:00
parent ed21b70ba2
commit f7f2952769

View file

@ -44,12 +44,11 @@ public abstract class FileBin {
*/ */
public static String getBrainkeyFromByte(byte[] input, String password) { public static String getBrainkeyFromByte(byte[] input, String password) {
try { try {
byte[] publicKey = new byte[34]; byte[] publicKey = new byte[33];
byte[] rawData = new byte[input.length-34]; byte[] rawData = new byte[input.length-33];
System.arraycopy(input, 0, publicKey, 0, publicKey.length); System.arraycopy(input, 0, publicKey, 0, publicKey.length);
System.arraycopy(input, 34, rawData, 0, rawData.length); System.arraycopy(input, 33, rawData, 0, rawData.length);
MessageDigest md = MessageDigest.getInstance("SHA-256"); MessageDigest md = MessageDigest.getInstance("SHA-256");
ECKey randomECKey = ECKey.fromPublicOnly(publicKey); ECKey randomECKey = ECKey.fromPublicOnly(publicKey);
@ -64,9 +63,14 @@ public abstract class FileBin {
System.arraycopy(rawData, 4, compressedData, 0, compressedData.length); System.arraycopy(rawData, 4, compressedData, 0, compressedData.length);
byte[] wallet_object_bytes = Util.decompress(compressedData); byte[] wallet_object_bytes = Util.decompress(compressedData);
String wallet_string = byteToString(wallet_object_bytes); String wallet_string = byteToString(wallet_object_bytes);
JsonObject wallet = new JsonParser().parse(wallet_string).getAsJsonObject();
byte[] encKey_enc = wallet.get("encryption_key").getAsString().getBytes();
byte[] encKey = decryptAES(encKey_enc, password.getBytes("UTF-8"));
byte[] encBrain = wallet.get("encrypted_brainkey").getAsString().getBytes();
String BrainKey = byteToString(decryptAES(encBrain, encKey));
return BrainKey;
return wallet_string;
//JsonObject wallet = new JsonParser().parse(wallet_string).getAsJsonObject();
} catch (UnsupportedEncodingException | NoSuchAlgorithmException ex){ } catch (UnsupportedEncodingException | NoSuchAlgorithmException ex){