mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-07 15:18:08 +00:00
core/tools: make keyctl-proxy output nicer
This commit is contained in:
parent
7c56a1296f
commit
388843f772
@ -28,7 +28,7 @@ indexmap = {
|
|||||||
PATH = "10018h/{}h"
|
PATH = "10018h/{}h"
|
||||||
|
|
||||||
|
|
||||||
def make_commit(index, digest):
|
def make_commit(name, index, digest):
|
||||||
path = PATH.format(index)
|
path = PATH.format(index)
|
||||||
address_n = parse_path(path)
|
address_n = parse_path(path)
|
||||||
first_pass = True
|
first_pass = True
|
||||||
@ -39,13 +39,20 @@ def make_commit(index, digest):
|
|||||||
t.clear_session()
|
t.clear_session()
|
||||||
first_pass = False
|
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)
|
commit = cosi.commit(t, address_n, digest)
|
||||||
return commit.pubkey, commit.commitment
|
return commit.pubkey, commit.commitment
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
click.echo(e)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print("Trying again ...")
|
click.echo("Trying again ...")
|
||||||
|
|
||||||
|
|
||||||
@Pyro4.expose
|
@Pyro4.expose
|
||||||
@ -58,13 +65,13 @@ class KeyctlProxy:
|
|||||||
|
|
||||||
def _check_name_digest(self, name, digest):
|
def _check_name_digest(self, name, digest):
|
||||||
if name != self.name or digest != self.digest:
|
if name != self.name or digest != self.digest:
|
||||||
print(f"ERROR! Remote wants to sign {name} with digest {digest.hex()}")
|
click.echo(f"ERROR! Remote wants to sign {name} with digest {digest.hex()}")
|
||||||
print(f"Expected: {self.name} with digest {self.digest.hex()}")
|
click.echo(f"Expected: {self.name} with digest {self.digest.hex()}")
|
||||||
raise ValueError("Unexpected index/digest")
|
raise ValueError("Unexpected index/digest")
|
||||||
|
|
||||||
def get_commit(self, name, digest):
|
def get_commit(self, name, digest):
|
||||||
self._check_name_digest(name, digest)
|
self._check_name_digest(name, digest)
|
||||||
print("Sending commitment!")
|
click.echo("Sending commitment!")
|
||||||
return self.commit
|
return self.commit
|
||||||
|
|
||||||
def get_signature(self, name, digest, global_R, global_pk):
|
def get_signature(self, name, digest, global_R, global_pk):
|
||||||
@ -72,14 +79,14 @@ class KeyctlProxy:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
t = get_default_client()
|
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)
|
signature = cosi.sign(t, self.address_n, digest, global_R, global_pk)
|
||||||
print("Sending signature!")
|
click.echo("Sending signature!")
|
||||||
return signature.signature
|
return signature.signature
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
click.echo(e)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print("Trying again ...")
|
click.echo("Trying again ...")
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
Loading…
Reference in New Issue
Block a user