'Set parameters that depend on state_dir.'

def init_keypair(self):

    permid_module.init()
    pair_filename = self.config.get_permid_keypair_filename()
    if os.path.exists(pair_filename):
        self.keypair = permid_module.read_keypair(pair_filename)
    else:
        self.keypair = permid_module.generate_keypair()
        public_key_filename = os.path.join(self.config.get_state_dir(), 'ecpub.pem')
        permid_module.save_keypair(self.keypair, pair_filename)
        permid_module.save_pub_key(self.keypair, public_key_filename)
    trustchain_pairfilename = self.config.get_trustchain_permid_keypair_filename()
    if os.path.exists(trustchain_pairfilename):
        self.trustchain_keypair = permid_module.read_keypair_trustchain(trustchain_pairfilename)
    else:
        self.trustchain_keypair = permid_module.generate_keypair_trustchain()
        trustchain_pubfilename = os.path.join(self.config.get_state_dir(), 'ecpub_multichain.pem')
        permid_module.save_keypair_trustchain(self.trustchain_keypair, trustchain_pairfilename)
        permid_module.save_pub_key_trustchain(self.trustchain_keypair, trustchain_pubfilename)
    tradechain_pairfilename = self.config.get_tradechain_permid_keypair_filename()
    if os.path.exists(tradechain_pairfilename):
        self.tradechain_keypair = permid_module.read_keypair_trustchain(tradechain_pairfilename)
    else:
        self.tradechain_keypair = permid_module.generate_keypair_trustchain()
        tradechain_pubfilename = os.path.join(self.config.get_state_dir(), 'ecpub_tradechain.pem')
        permid_module.save_keypair_trustchain(self.tradechain_keypair, tradechain_pairfilename)
        permid_module.save_pub_key_trustchain(self.tradechain_keypair, tradechain_pubfilename)
