From a6e51434f25401d4caf982dfcae341a957dbc58f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 24 May 2019 16:01:28 +0200 Subject: [PATCH] core/eos: use new pubkey format --- core/src/apps/eos/get_public_key.py | 2 +- core/src/apps/eos/helpers.py | 4 ++-- core/src/apps/eos/sign_tx.py | 2 +- .../tests/device_tests/test_msg_eos_get_public_key.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/apps/eos/get_public_key.py b/core/src/apps/eos/get_public_key.py index d86ce71ca..366db42df 100755 --- a/core/src/apps/eos/get_public_key.py +++ b/core/src/apps/eos/get_public_key.py @@ -18,7 +18,7 @@ def _public_key_to_wif(pub_key: bytes) -> str: compressed_pub_key = pub_key else: raise wire.DataError("invalid public key") - return base58_encode("EOS", "", compressed_pub_key) + return base58_encode("PUB", "K1", compressed_pub_key) def _get_public_key(node): diff --git a/core/src/apps/eos/helpers.py b/core/src/apps/eos/helpers.py index 0fc6bac9b..9248e7e38 100644 --- a/core/src/apps/eos/helpers.py +++ b/core/src/apps/eos/helpers.py @@ -7,9 +7,9 @@ from apps.common import HARDENED def base58_encode(prefix: str, sig_prefix: str, data: bytes) -> str: b58 = base58.encode(data + base58.ripemd160_32(data + sig_prefix.encode())) if sig_prefix: - return prefix + sig_prefix + "_" + b58 + return prefix + "_" + sig_prefix + "_" + b58 else: - return prefix + b58 + return prefix + "_" + b58 def eos_name_to_string(value) -> str: diff --git a/core/src/apps/eos/sign_tx.py b/core/src/apps/eos/sign_tx.py index f959da686..9c2b787ac 100644 --- a/core/src/apps/eos/sign_tx.py +++ b/core/src/apps/eos/sign_tx.py @@ -36,7 +36,7 @@ async def sign_tx(ctx, msg: EosSignTx, keychain): node.private_key(), digest, True, secp256k1.CANONICAL_SIG_EOS ) - return EosSignedTx(signature=base58_encode("SIG_", "K1", signature)) + return EosSignedTx(signature=base58_encode("SIG", "K1", signature)) async def _init(ctx, sha, msg): diff --git a/python/trezorlib/tests/device_tests/test_msg_eos_get_public_key.py b/python/trezorlib/tests/device_tests/test_msg_eos_get_public_key.py index f7ff9f755..6ee28667f 100644 --- a/python/trezorlib/tests/device_tests/test_msg_eos_get_public_key.py +++ b/python/trezorlib/tests/device_tests/test_msg_eos_get_public_key.py @@ -14,7 +14,7 @@ class TestMsgEosGetpublickey(TrezorTest): public_key = get_public_key(self.client, parse_path("m/44'/194'/0'/0/0")) assert ( public_key.wif_public_key - == "EOS4u6Sfnzj4Sh2pEQnkXyZQJqH3PkKjGByDCbsqqmyq6PttM9KyB" + == "PUB_K1_4u6Sfnzj4Sh2pEQnkXyZQJqH3PkKjGByDCbsqqmyq6PtxkQ9TE" ) assert ( public_key.raw_public_key.hex() @@ -23,7 +23,7 @@ class TestMsgEosGetpublickey(TrezorTest): public_key = get_public_key(self.client, parse_path("m/44'/194'/0'/0/1")) assert ( public_key.wif_public_key - == "EOS5d1VP15RKxT4dSakWu2TFuEgnmaGC2ckfSvQwND7pZC1tXkfLP" + == "PUB_K1_5d1VP15RKxT4dSakWu2TFuEgnmaGC2ckfSvQwND7pZC1uLnJzD" ) assert ( public_key.raw_public_key.hex() @@ -32,7 +32,7 @@ class TestMsgEosGetpublickey(TrezorTest): public_key = get_public_key(self.client, parse_path("m/44'/194'/1'/0/0")) assert ( public_key.wif_public_key - == "EOS7UuNeTf13nfcG85rDB7AHGugZi4C4wJ4ft12QRotqNfxdV2NvP" + == "PUB_K1_7UuNeTf13nfcG85rDB7AHGugZi4C4wJ4ft12QRotqNfxeNPmwo" ) assert ( public_key.raw_public_key.hex()