def initLocalKeys(name, baseDir, sigseed, override=False): sDir = os.path.join(baseDir, '__sDir') eDir = os.path.join(baseDir, '__eDir') os.makedirs(sDir, exist_ok=True) os.makedirs(eDir, exist_ok=True) (public_key, secret_key), (verif_key, sig_key) = createEncAndSigKeys(eDir, sDir, name, seed=sigseed) homeDir = ZStack.homeDirPath(baseDir, name) verifDirPath = ZStack.verifDirPath(homeDir) sigDirPath = ZStack.sigDirPath(homeDir) secretDirPath = ZStack.secretDirPath(homeDir) pubDirPath = ZStack.publicDirPath(homeDir) for d in (homeDir, verifDirPath, sigDirPath, secretDirPath, pubDirPath): os.makedirs(d, exist_ok=True) moveKeyFilesToCorrectLocations(sDir, verifDirPath, sigDirPath) moveKeyFilesToCorrectLocations(eDir, pubDirPath, secretDirPath) shutil.rmtree(sDir) shutil.rmtree(eDir) return hexlify(public_key).decode(), hexlify(verif_key).decode()
def setupOwnKeysIfNeeded(self): if not os.listdir(self.sigKeyDir): # If signing keys are not present, secret (private keys) should # not be present since they should be converted keys. assert not os.listdir(self.secretKeysDir) # Seed should be present assert self.seed, 'Keys are not setup for {}'.format(self) logger.display("Signing and Encryption keys were not found for {}. Creating them now". format(self), extra={"cli": False}) tdirS = os.path.join(self.homeDir, '__skeys__') tdirE = os.path.join(self.homeDir, '__ekeys__') os.makedirs(tdirS, exist_ok=True) os.makedirs(tdirE, exist_ok=True) createEncAndSigKeys(tdirE, tdirS, self.name, self.seed) moveKeyFilesToCorrectLocations(tdirE, self.publicKeysDir, self.secretKeysDir) moveKeyFilesToCorrectLocations(tdirS, self.verifKeyDir, self.sigKeyDir) shutil.rmtree(tdirE) shutil.rmtree(tdirS)
def initLocalKeys(name, baseDir, sigseed, override=False): sDir = os.path.join(baseDir, '__sDir') eDir = os.path.join(baseDir, '__eDir') os.makedirs(sDir, exist_ok=True) os.makedirs(eDir, exist_ok=True) (public_key, secret_key), (verif_key, sig_key) = \ createEncAndSigKeys(eDir, sDir, name, seed=sigseed) homeDir = ZStack.homeDirPath(baseDir, name) verifDirPath = ZStack.verifDirPath(homeDir) sigDirPath = ZStack.sigDirPath(homeDir) secretDirPath = ZStack.secretDirPath(homeDir) pubDirPath = ZStack.publicDirPath(homeDir) for d in (homeDir, verifDirPath, sigDirPath, secretDirPath, pubDirPath): os.makedirs(d, exist_ok=True) moveKeyFilesToCorrectLocations(sDir, verifDirPath, sigDirPath) moveKeyFilesToCorrectLocations(eDir, pubDirPath, secretDirPath) shutil.rmtree(sDir) shutil.rmtree(eDir) return hexlify(public_key).decode(), hexlify(verif_key).decode()