diff --git a/src/apps/common/seed.py b/src/apps/common/seed.py index aba0a23d69..a2a27aab02 100644 --- a/src/apps/common/seed.py +++ b/src/apps/common/seed.py @@ -45,6 +45,6 @@ def derive_node_without_passphrase( return node -def remove_ed25519_public_key_prefix(pubkey: bytes) -> bytes: +def remove_ed25519_prefix(pubkey: bytes) -> bytes: # 0x01 prefix is not part of the actual public key, hence removed return pubkey[1:] diff --git a/src/apps/nem/signing.py b/src/apps/nem/signing.py index 184ff41627..2af18c1cbd 100644 --- a/src/apps/nem/signing.py +++ b/src/apps/nem/signing.py @@ -18,7 +18,7 @@ async def sign_tx(ctx, msg: NEMSignTx): await multisig.ask(ctx, msg) common = msg.multisig else: - public_key = _get_public_key(node) + public_key = seed.remove_ed25519_prefix(node.public_key()) common = msg.transaction if msg.transfer: @@ -48,10 +48,15 @@ async def sign_tx(ctx, msg: NEMSignTx): # wrap transaction in multisig wrapper if msg.cosigning: tx = multisig.cosign( - _get_public_key(node), msg.transaction, tx, msg.multisig.signer + seed.remove_ed25519_prefix(node.public_key()), + msg.transaction, + tx, + msg.multisig.signer, ) else: - tx = multisig.initiate(_get_public_key(node), msg.transaction, tx) + tx = multisig.initiate( + seed.remove_ed25519_prefix(node.public_key()), msg.transaction, tx + ) signature = ed25519.sign(node.private_key(), tx, NEM_HASH_ALG) @@ -59,8 +64,3 @@ async def sign_tx(ctx, msg: NEMSignTx): resp.data = tx resp.signature = signature return resp - - -def _get_public_key(node) -> bytes: - # 0x01 prefix is not part of the actual public key, hence removed - return node.public_key()[1:] diff --git a/src/apps/stellar/get_address.py b/src/apps/stellar/get_address.py index 31cd9931db..ea662fb1f8 100644 --- a/src/apps/stellar/get_address.py +++ b/src/apps/stellar/get_address.py @@ -7,7 +7,7 @@ from trezor.messages.StellarGetAddress import StellarGetAddress async def get_address(ctx, msg: StellarGetAddress): node = await seed.derive_node(ctx, msg.address_n, helpers.STELLAR_CURVE) - pubkey = seed.remove_ed25519_public_key_prefix(node.public_key()) # todo better? + pubkey = seed.remove_ed25519_prefix(node.public_key()) address = helpers.address_from_public_key(pubkey) if msg.show_display: diff --git a/src/apps/stellar/get_public_key.py b/src/apps/stellar/get_public_key.py index 36d7356303..28ead6b3de 100644 --- a/src/apps/stellar/get_public_key.py +++ b/src/apps/stellar/get_public_key.py @@ -12,7 +12,7 @@ from ubinascii import hexlify async def get_public_key(ctx, msg: StellarGetPublicKey): node = await seed.derive_node(ctx, msg.address_n, helpers.STELLAR_CURVE) - pubkey = seed.remove_ed25519_public_key_prefix(node.public_key()) # todo better? + pubkey = seed.remove_ed25519_prefix(node.public_key()) if msg.show_display: while True: diff --git a/src/apps/stellar/sign_tx.py b/src/apps/stellar/sign_tx.py index 774da77f5c..8ce6de7065 100644 --- a/src/apps/stellar/sign_tx.py +++ b/src/apps/stellar/sign_tx.py @@ -18,7 +18,7 @@ async def sign_tx(ctx, msg: StellarSignTx): raise ValueError('Stellar: At least one operation is required') node = await seed.derive_node(ctx, msg.address_n, consts.STELLAR_CURVE) - pubkey = seed.remove_ed25519_public_key_prefix(node.public_key()) + pubkey = seed.remove_ed25519_prefix(node.public_key()) w = bytearray() await _init(ctx, w, pubkey, msg)