Exemplo n.º 1
0
 def getNewSiteData(self):
     import random
     bip32_index = random.randrange(2**256) % 100000000
     site_privatekey = CryptArk.hdPrivatekey(self.master_seed, bip32_index)
     site_address = CryptArk.privatekeyToAddress(site_privatekey)
     if site_address in self.sites:
         raise Exception("Random error: site exist!")
     # Save to sites
     self.getSiteData(site_address)
     self.sites[site_address]["privatekey"] = site_privatekey
     self.saveDelayed()
     return site_address, bip32_index, self.sites[site_address]
Exemplo n.º 2
0
    def getEncryptPrivatekey(self, address, param_index=0):
        assert param_index >= 0 and param_index <= 1000
        site_data = self.getSiteData(address)

        if site_data.get("cert"):  # Different privatekey for different cert provider
            index = param_index + self.getAddressAuthIndex(site_data["cert"])
        else:
            index = param_index

        if "encrypt_privatekey_%s" % index not in site_data:
            address_index = self.getAddressAuthIndex(address)
            crypt_index = address_index + 1000 + index
            site_data["encrypt_privatekey_%s" % index] = CryptArk.hdPrivatekey(self.master_seed, crypt_index)
            self.log.debug("New encrypt privatekey generated for %s:%s" % (address, index))
        return site_data["encrypt_privatekey_%s" % index]
Exemplo n.º 3
0
 def generateAuthAddress(self, address):
     s = time.time()
     try:
         address = CryptArk.getAddress(address)
     except:
         pass
     address_id = self.getAddressAuthIndex(
         address)  # Convert site address to int
     auth_privatekey = CryptArk.hdPrivatekey(self.master_seed, address_id)
     self.sites[address] = {
         "auth_address": CryptArk.privatekeyToAddress(auth_privatekey),
         "auth_privatekey": auth_privatekey
     }
     self.saveDelayed()
     self.log.debug("Added new site: %s in %.3fs" %
                    (address, time.time() - s))
     return self.sites[address]
Exemplo n.º 4
0
 def cryptGetPrivatekey(self, master_seed, site_address_index=None):
     from Crypt import CryptArk
     print CryptArk.hdPrivatekey(master_seed, site_address_index)