Esempio n. 1
0
 def get_private_key_secret(self, public_key):
     if public_key in self.wallet_database.keys: # private key is not crypted
         k = KEY()
         k.set_privkey(self.wallet_database.keys[public_key].private_key)
         return k.get_secret()
     crypted_secret = self.wallet_database.get_crypted_keys()[public_key]
     for key in self.plain_masterkeys:
         self.crypter.set_key(key, doublesha256(public_key))
         secret = self.crypter.decrypt(crypted_secret)
         k = KEY()
         is_compressed = len(public_key) == 33
         k.set_secret(secret, is_compressed)
         if k.get_pubkey() == public_key:
             return secret
     raise KeyDecryptException("Can't decrypt private key, wallet not unlocked or incorrect masterkey")
Esempio n. 2
0
 def get_private_key_secret(self, public_key):
     if public_key in self.wallet_database.keys:  # private key is not crypted
         k = KEY()
         k.set_privkey(self.wallet_database.keys[public_key].private_key)
         return k.get_secret()
     crypted_secret = self.wallet_database.get_crypted_keys()[public_key]
     for key in self.plain_masterkeys:
         self.crypter.set_key(key, doublesha256(public_key))
         secret = self.crypter.decrypt(crypted_secret)
         k = KEY()
         is_compressed = len(public_key) == 33
         k.set_secret(secret, is_compressed)
         if k.get_pubkey() == public_key:
             return secret
     raise KeyDecryptException(
         "Can't decrypt private key, wallet not unlocked or incorrect masterkey"
     )
Esempio n. 3
0
 def test_ssl_get_secret(self):
     key = KEY()
     key.set_privkey(decodehexstr("3081d3020101042030d1d8d1d243ab41a80a3cc1481a626a137f771a636b2daca06c1f86cdfecffba08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a124032200030a43196c8bf389c0ce5987a3f4dac57f4ca0d9733c232659717d9404074b4504"))
     self.assertEquals(hexstr(key.get_secret()), "30d1d8d1d243ab41a80a3cc1481a626a137f771a636b2daca06c1f86cdfecffb")