From 9268b6ca134e7438c33939ddcd38343fdb08c2e9 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 21 Sep 2018 13:10:16 -0400 Subject: [PATCH] fix double-double sha --- torba/baseaccount.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/torba/baseaccount.py b/torba/baseaccount.py index 9a90d8244..4e21127c6 100644 --- a/torba/baseaccount.py +++ b/torba/baseaccount.py @@ -291,16 +291,17 @@ class BaseAccount: def decrypt(self, password): assert self.encrypted, "Key is not encrypted." - secret = double_sha256(password) - self.seed = aes_decrypt(secret, self.seed) - self.private_key = from_extended_key_string(self.ledger, aes_decrypt(secret, self.private_key)) + self.seed = aes_decrypt(password, self.seed.encode()).decode() + self.private_key = from_extended_key_string( + self.ledger, aes_decrypt(password, self.private_key.encode()).decode() + ) self.encrypted = False def encrypt(self, password): assert not self.encrypted, "Key is already encrypted." - secret = double_sha256(password) - self.seed = aes_encrypt(secret, self.seed) - self.private_key = aes_encrypt(secret, self.private_key.extended_key_string()) + self.seed = aes_encrypt(password, self.seed.encode()).decode() + private_key: PrivateKey = self.private_key + self.private_key = aes_encrypt(password, private_key.extended_key_string().encode()).decode() self.encrypted = True @defer.inlineCallbacks