core/tools: make keyctl-proxy output nicer

pull/785/head
matejcik 4 years ago committed by Pavol Rusnak
parent 7c56a1296f
commit 388843f772
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -28,7 +28,7 @@ indexmap = {
PATH = "10018h/{}h"
def make_commit(index, digest):
def make_commit(name, index, digest):
path = PATH.format(index)
address_n = parse_path(path)
first_pass = True
@ -39,13 +39,20 @@ def make_commit(index, digest):
t.clear_session()
first_pass = False
click.echo(f"\n\n\nCommiting to hash {digest.hex()} with path {path}")
click.echo(f"\n\n\nCommiting to {click.style(name, bold=True)} hash:")
for partid in range(4):
digest_part = digest[partid * 8 : (partid + 1) * 8]
color = "red" if partid % 2 else "blue"
digest_str = click.style(digest_part.hex().upper(), fg=color)
click.echo(digest_str)
click.echo(f"Using path: {click.style(path, bold=True)}")
commit = cosi.commit(t, address_n, digest)
return commit.pubkey, commit.commitment
except Exception as e:
print(e)
click.echo(e)
traceback.print_exc()
print("Trying again ...")
click.echo("Trying again ...")
@Pyro4.expose
@ -58,13 +65,13 @@ class KeyctlProxy:
def _check_name_digest(self, name, digest):
if name != self.name or digest != self.digest:
print(f"ERROR! Remote wants to sign {name} with digest {digest.hex()}")
print(f"Expected: {self.name} with digest {self.digest.hex()}")
click.echo(f"ERROR! Remote wants to sign {name} with digest {digest.hex()}")
click.echo(f"Expected: {self.name} with digest {self.digest.hex()}")
raise ValueError("Unexpected index/digest")
def get_commit(self, name, digest):
self._check_name_digest(name, digest)
print("Sending commitment!")
click.echo("Sending commitment!")
return self.commit
def get_signature(self, name, digest, global_R, global_pk):
@ -72,14 +79,14 @@ class KeyctlProxy:
while True:
try:
t = get_default_client()
print("\n\n\nSigning...")
click.echo("\n\n\nSigning...")
signature = cosi.sign(t, self.address_n, digest, global_R, global_pk)
print("Sending signature!")
click.echo("Sending signature!")
return signature.signature
except Exception as e:
print(e)
click.echo(e)
traceback.print_exc()
print("Trying again ...")
click.echo("Trying again ...")
@click.command()

Loading…
Cancel
Save