mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-03 03:11:17 +00:00
apps: move ed25519 prefix common function
This commit is contained in:
parent
7f767eec46
commit
96a91b56e9
@ -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:]
|
||||
|
@ -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:]
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user