2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-17 21:25:37 +00:00
This commit is contained in:
quadrismegistus 2020-09-12 22:29:09 +01:00
parent 3940a19ff8
commit eb331cc780

View File

@ -240,25 +240,10 @@ class Keymaker(Logger):
def find_pubkey(self,name=None): def find_pubkey(self,name=None):
if not name: name=self.name return self.find_pubkey_and_name(name=name if name else self.name)[1]
if 'pubkey' in self._keychain and self._keychain['pubkey']:
return self._keychain['pubkey']
res = self.crypt_keys.get(name, prefix='/pubkey/') def find_name(self,pubkey):
self.log('result from crypt for name:',res) return self.find_pubkey_and_name(pubkey=pubkey)[0]
if res: return res
res = self.load_qr(self.name)
if res: return res
self.log('I don\'t know my public key! Do I need to register?')
# raise KomradeException(f'I don\'t know my public key!\n{self}\n{self._keychain}')
return res
def find_name(self,pubkey_b64):
res = self.crypt_keys.get(pubkey_b64.decode(), prefix='/name/')
self.log('result from crypt for name:',res)
return res
@property @property
@ -311,7 +296,8 @@ class Keymaker(Logger):
name,pubkey = self.find_pubkey_and_name() name,pubkey = self.find_pubkey_and_name()
# get uri # get uri
uri = b64encode(pubkey) if type(pubkey)==bytes else b64encode(pubkey.encode()) # uri = b64encode(pubkey) if type(pubkey)==bytes else b64encode(pubkey.encode())
uri = pubkey.data_b64_s
# get from cache # get from cache
for keyname in look_for: for keyname in look_for: