From c8d977c1314b7b25de024b965b4a07926059b798 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Sat, 24 Sep 2022 14:38:35 +0200 Subject: [PATCH 1/3] fix: use the same message prefix for signing as in sdk --- src/signMessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/signMessage.c b/src/signMessage.c index 1609f35..916b422 100644 --- a/src/signMessage.c +++ b/src/signMessage.c @@ -7,7 +7,7 @@ static uint32_t accountNumber; static uint8_t *data; static uint32_t dataLength; -static const char SIGN_MAGIC[] = "æternity Signed Message:\n"; +static const char SIGN_MAGIC[] = "aeternity Signed Message:\n"; static unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) { uint8_t message[0xFC + sizeof(SIGN_MAGIC) - 1 + 2]; From f541c3017f237e53fe15b43cc653ffe03ce0f986 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Sat, 24 Sep 2022 14:44:54 +0200 Subject: [PATCH 2/3] chore: fix typo --- scripts/prepare-devenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare-devenv.sh b/scripts/prepare-devenv.sh index 0ed7214..2dee36d 100755 --- a/scripts/prepare-devenv.sh +++ b/scripts/prepare-devenv.sh @@ -2,7 +2,7 @@ set -e if [ -d clang-arm-fropi -a -d gcc-arm-none-eabi-5_3-2016q1 -a -d nanos-secure-sdk-f9e1c7b8904df2eee0ae7e603f552b876c169334 ]; then - echo "Devend is already prepared. Exiting." + echo "Devenv is already prepared. Exiting." exit fi From cf660a28af07fa2c400565b5171800226a70f18a Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Sat, 24 Sep 2022 17:08:13 +0200 Subject: [PATCH 3/3] fix: hash message before signing as in sdk --- src/signMessage.c | 11 +++++------ src/signTransaction.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/signMessage.c b/src/signMessage.c index 916b422..8b004c1 100644 --- a/src/signMessage.c +++ b/src/signMessage.c @@ -1,6 +1,7 @@ #include "signMessage.h" #include "os.h" #include "utils.h" +#include "blake2b.h" static char message[0xFC]; static uint32_t accountNumber; @@ -26,12 +27,10 @@ static unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) os_memmove(message + messageLength, data, dataLength); messageLength += dataLength; - sign( - accountNumber, - message, - messageLength, - G_io_apdu_buffer - ); + uint8_t hash[32]; + blake2b(&hash, 32, message, messageLength); + + sign(accountNumber, hash, 32, G_io_apdu_buffer); sendResponse(64, true); return 0; // do not redraw the widget } diff --git a/src/signTransaction.c b/src/signTransaction.c index 7c68fb5..99903fb 100644 --- a/src/signTransaction.c +++ b/src/signTransaction.c @@ -11,7 +11,7 @@ static char payload[80]; static uint32_t accountNumber; static uint32_t remainTransactionLength; static char networkId[NETWORK_ID_MAX_LENGTH + 1]; -cx_blake2b_t hash; +static cx_blake2b_t hash; static txType transactionType; static void singAndSend() {