Beispiel #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")
Beispiel #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"
     )
Beispiel #3
0
    def create(self, passphrase):
        self.wallet_database.begin_updates()
        crypter = Crypter()
        #first create masterkey
        master_key = new_masterkey(passphrase)
        plain_masterkey = decrypt_masterkey(master_key, passphrase)
        self.wallet_database.add_master_key(master_key)
        #create transaction pool
        for i in range(100):
            k = KEY()
            k.generate(True)
            public_key = k.get_pubkey()
            crypter.set_key(plain_masterkey, doublesha256(public_key))
            crypted_secret = crypter.encrypt(k.get_secret())
            self.wallet_database.add_crypted_key(public_key, crypted_secret)
            pool_key = WalletPoolKey(i, 60000, time.time(), public_key)
            self.wallet_database.add_poolkey(pool_key)

        self.wallet_database.commit_updates()
        self.load()
Beispiel #4
0
 def create(self, passphrase):
     self.wallet_database.begin_updates()
     crypter = Crypter()
     #first create masterkey
     master_key =  new_masterkey(passphrase)
     plain_masterkey = decrypt_masterkey(master_key, passphrase)
     self.wallet_database.add_master_key(master_key)
     #create transaction pool
     for i in range(100):
         k = KEY()
         k.generate(True)
         public_key = k.get_pubkey()
         crypter.set_key(plain_masterkey, doublesha256(public_key))
         crypted_secret = crypter.encrypt(k.get_secret())
         self.wallet_database.add_crypted_key(public_key, crypted_secret)
         pool_key = WalletPoolKey(i, 60000, time.time(), public_key)
         self.wallet_database.add_poolkey(pool_key)
         
         
     self.wallet_database.commit_updates()
     self.load()
Beispiel #5
0
 def test_ssl_get_secret(self):
     key = KEY()
     key.set_privkey(decodehexstr("3081d3020101042030d1d8d1d243ab41a80a3cc1481a626a137f771a636b2daca06c1f86cdfecffba08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a124032200030a43196c8bf389c0ce5987a3f4dac57f4ca0d9733c232659717d9404074b4504"))
     self.assertEquals(hexstr(key.get_secret()), "30d1d8d1d243ab41a80a3cc1481a626a137f771a636b2daca06c1f86cdfecffb")