mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
flake8: fix complaints
This commit is contained in:
parent
46307cc4ba
commit
23b58cc0cb
4
.flake8
4
.flake8
@ -19,4 +19,6 @@ ignore =
|
||||
# E722: do not use bare except
|
||||
E722,
|
||||
# E741: ambiguous variable name
|
||||
E741
|
||||
E741,
|
||||
##### E266: too many leading '#' for block comment
|
||||
E266,
|
||||
|
@ -460,7 +460,6 @@ class ProtocolMixin(object):
|
||||
def clear_session(self):
|
||||
return self.call(proto.ClearSession())
|
||||
|
||||
|
||||
# Device functionality
|
||||
self_test = MovedTo(device.self_test)
|
||||
|
||||
@ -516,7 +515,7 @@ class ProtocolMixin(object):
|
||||
stellar_get_address = MovedTo(stellar.get_address)
|
||||
stellar_sign_transaction = MovedTo(stellar.sign_tx)
|
||||
|
||||
# Miscellaneous cryptography
|
||||
# Miscellaneous cryptographic functionality
|
||||
get_entropy = MovedTo(misc.get_entropy)
|
||||
sign_identity = MovedTo(misc.sign_identity)
|
||||
get_ecdh_session_key = MovedTo(misc.get_ecdh_session_key)
|
||||
|
@ -183,10 +183,10 @@ def load_device_by_mnemonic(client, mnemonic, pin, passphrase_protection, label,
|
||||
raise RuntimeError("Device is initialized already. Call wipe_device() and try again.")
|
||||
|
||||
resp = client.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin,
|
||||
passphrase_protection=passphrase_protection,
|
||||
language=language,
|
||||
label=label,
|
||||
skip_checksum=skip_checksum))
|
||||
passphrase_protection=passphrase_protection,
|
||||
language=language,
|
||||
label=label,
|
||||
skip_checksum=skip_checksum))
|
||||
client.init_device()
|
||||
return resp
|
||||
|
||||
@ -228,10 +228,10 @@ def load_device_by_xprv(client, xprv, pin, passphrase_protection, label, languag
|
||||
node.private_key = binascii.unhexlify(data[92:156]) # skip 0x00 indicating privkey
|
||||
|
||||
resp = client.call(proto.LoadDevice(node=node,
|
||||
pin=pin,
|
||||
passphrase_protection=passphrase_protection,
|
||||
language=language,
|
||||
label=label))
|
||||
pin=pin,
|
||||
passphrase_protection=passphrase_protection,
|
||||
language=language,
|
||||
label=label))
|
||||
client.init_device()
|
||||
return resp
|
||||
|
||||
|
@ -152,7 +152,7 @@ def update(client, fp):
|
||||
|
||||
# TREZORv1 method
|
||||
if isinstance(resp, proto.Success):
|
||||
fingerprint = hashlib.sha256(data[256:]).hexdigest()
|
||||
# fingerprint = hashlib.sha256(data[256:]).hexdigest()
|
||||
# LOG.debug("Firmware fingerprint: " + fingerprint)
|
||||
resp = client.call(proto.FirmwareUpload(payload=data))
|
||||
if isinstance(resp, proto.Success):
|
||||
|
@ -12,6 +12,7 @@ def get_entropy(client, size):
|
||||
def sign_identity(client, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=None):
|
||||
return client.call(proto.SignIdentity(identity=identity, challenge_hidden=challenge_hidden, challenge_visual=challenge_visual, ecdsa_curve_name=ecdsa_curve_name))
|
||||
|
||||
|
||||
@expect(proto.ECDHSessionKey)
|
||||
def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=None):
|
||||
return client.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name))
|
||||
@ -22,22 +23,22 @@ def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=Non
|
||||
def encrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||
n = client._convert_prime(n)
|
||||
return client.call(proto.CipherKeyValue(address_n=n,
|
||||
key=key,
|
||||
value=value,
|
||||
encrypt=True,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv))
|
||||
key=key,
|
||||
value=value,
|
||||
encrypt=True,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv))
|
||||
|
||||
|
||||
@field('value')
|
||||
@expect(proto.CipheredKeyValue)
|
||||
def decrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||
n = client._convert_prime(n)
|
||||
return client.call(proto.CipherKeyValue(address_n=n,
|
||||
key=key,
|
||||
value=value,
|
||||
encrypt=False,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv))
|
||||
|
||||
key=key,
|
||||
value=value,
|
||||
encrypt=False,
|
||||
ask_on_encrypt=ask_on_encrypt,
|
||||
ask_on_decrypt=ask_on_decrypt,
|
||||
iv=iv))
|
||||
|
@ -188,4 +188,3 @@ def sign_tx(client, n, transaction):
|
||||
assert msg.transaction is not None
|
||||
msg.transaction.address_n = n
|
||||
return client.call(msg)
|
||||
|
||||
|
@ -162,7 +162,6 @@ def parse_path(nstr: str) -> Address:
|
||||
raise ValueError('Invalid BIP32 path', nstr)
|
||||
|
||||
|
||||
|
||||
def normalize_nfc(txt):
|
||||
'''
|
||||
Normalize message to NFC and return bytes suitable for protobuf.
|
||||
|
Loading…
Reference in New Issue
Block a user