From 5c19f28e431d63f9958faf4636091bda28d053d5 Mon Sep 17 00:00:00 2001 From: Ariel Mendelzon Date: Wed, 10 Apr 2024 08:32:45 +1200 Subject: [PATCH] Version 5.0.0 release (#174) - Bump version to 5.0.0 - Updated version references in firmware, middleware, unit tests, CI workflows and documentation - Updated CHANGELOG --- .github/workflows/coverage.yml | 4 +- .github/workflows/run-tests.yml | 2 +- CHANGELOG.md | 15 ++ README.md | 4 +- docs/attestation.md | 4 +- docs/heartbeat.md | 4 +- docs/protocol.md | 24 +-- ledger/src/signer/src/attestation.h | 2 +- ledger/src/signer/src/defs.h | 4 +- ledger/src/signer/src/heartbeat.h | 2 +- ledger/src/ui/src/attestation.h | 2 +- ledger/src/ui/src/defs.h | 4 +- ledger/src/ui/src/ui_heartbeat.h | 2 +- .../ui/test/attestation/test_attestation.c | 8 +- ledger/src/ui/test/onboard/test_onboard.c | 4 +- .../ui/test/ui_heartbeat/test_ui_heartbeat.c | 2 +- ledger/test/cases/heartbeat.py | 2 +- middleware/admin/verify_attestation.py | 4 +- middleware/comm/protocol.py | 2 +- middleware/ledger/protocol.py | 4 +- .../tests/admin/test_verify_attestation.py | 4 +- middleware/tests/comm/test_protocol.py | 197 +++++++++--------- middleware/tests/ledger/test_protocol.py | 136 ++++++------ middleware/tests/ledger/test_protocol_v1.py | 2 +- 24 files changed, 226 insertions(+), 212 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dc205902..ae0095d5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -34,7 +34,7 @@ jobs: run: | aws s3 sync \ middleware/coverage/ \ - s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_4.1.x/middleware_coverage_report \ + s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_5.0.x/middleware_coverage_report \ --sse aws:kms --sse-kms-key-id ${{ secrets.CODECOVERAGE_KMS_KEY_ID }} \ --no-progress --follow-symlinks --delete --only-show-errors @@ -49,7 +49,7 @@ jobs: run: | aws s3 sync \ ledger/coverage/output/ \ - s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_4.1.x/firmware_coverage_report \ + s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_5.0.x/firmware_coverage_report \ --sse aws:kms --sse-kms-key-id ${{ secrets.CODECOVERAGE_KMS_KEY_ID }} \ --no-progress --follow-symlinks --delete --only-show-errors diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 49e45de1..3906d9a0 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -65,7 +65,7 @@ jobs: uses: actions/checkout@v3 with: repository: rootstock/hsm-integration-test - ref: 4.0.0.segwit.plus + ref: 5.0.0.plus path: hsm-integration-test ssh-key: ${{ secrets.HSM_INTEGRATION_TEST_SSH_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index cf25ad7c..b3e9c6f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [5.0.0] - 09/04/2024 + +### Features/enhancements + +- Implemented authorised segwit transaction signing +- Added firmware static analysis to CI +- Middleware and Firmware code coverage +- Unified wa_store function into unique WA_STORE macro +- Updated bug bounty program handler, domains and program response time + +### Fixes + +- Brother validation on advance blockchain payload +- Bumped pyinstaller, pycryptodome, pycryptodomex to address dependabot findings + ## [4.0.2] - 01/12/2023 ### Features/enhancements diff --git a/README.md b/README.md index 11933a13..39596598 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ ![Tests](https://github.com/rsksmart/rsk-powhsm/actions/workflows/run-tests.yml/badge.svg) ![Python linter](https://github.com/rsksmart/rsk-powhsm/actions/workflows/lint-python.yml/badge.svg) ![C linter](https://github.com/rsksmart/rsk-powhsm/actions/workflows/lint-c.yml/badge.svg) -[![Middleware coverage](https://img.shields.io/endpoint?url=https://d16sboe9lzo4ru.cloudfront.net/powhsm_4.1.x/middleware_coverage_report/badge.json)](https://d16sboe9lzo4ru.cloudfront.net/powhsm_4.1.x/middleware_coverage_report/index.html) -[![Firmware coverage](https://img.shields.io/endpoint?url=https://d16sboe9lzo4ru.cloudfront.net/powhsm_4.1.x/firmware_coverage_report/badge.json)](https://d16sboe9lzo4ru.cloudfront.net/powhsm_4.1.x/firmware_coverage_report/index.html) +[![Middleware coverage](https://img.shields.io/endpoint?url=https://d16sboe9lzo4ru.cloudfront.net/powhsm_5.0.x/middleware_coverage_report/badge.json)](https://d16sboe9lzo4ru.cloudfront.net/powhsm_5.0.x/middleware_coverage_report/index.html) +[![Firmware coverage](https://img.shields.io/endpoint?url=https://d16sboe9lzo4ru.cloudfront.net/powhsm_5.0.x/firmware_coverage_report/badge.json)](https://d16sboe9lzo4ru.cloudfront.net/powhsm_5.0.x/firmware_coverage_report/index.html) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) diff --git a/docs/attestation.md b/docs/attestation.md index abab8503..87eba73f 100644 --- a/docs/attestation.md +++ b/docs/attestation.md @@ -52,7 +52,7 @@ Before diving into the UI attestation, it is important to recall a few relevant To generate the attestation, the UI uses the configured attestation scheme to sign a message generated by the concatenation of: -- A predefined header (`HSM:UI:4.0`). +- A predefined header (`HSM:UI:5.0`). - A 32 byte user-defined value. By default, the attestation generation client supplies the latest RSK block hash as this value, so it can then be used as a minimum timestamp reference for the attestation generation. - The compressed public key corresponding to the private key obtained by deriving the generated seed with the BIP32 path `m/44'/0'/0'/0/0` (normally used as the BTC key by the Signer application). - The hash of the currently authorized Signer version. @@ -62,7 +62,7 @@ As a consequence of the aforementioned features, this message guarantees that th ### Signer attestation -To generate the attestation, the Signer uses the configured attestation scheme to sign a message containing a predefined header (`HSM:SIGNER:4.0`) and the `sha256sum` of the concatenation of the authorized public keys (see the [protocol](./protocol.md) for details on this) lexicographically ordered by their UTF-encoded derivation path. This message guarantees that the device is running a specific version of the Signer and that those keys are in control of the ledger device. +To generate the attestation, the Signer uses the configured attestation scheme to sign a message containing a predefined header (`HSM:SIGNER:5.0`) and the `sha256sum` of the concatenation of the authorized public keys (see the [protocol](./protocol.md) for details on this) lexicographically ordered by their UTF-encoded derivation path. This message guarantees that the device is running a specific version of the Signer and that those keys are in control of the ledger device. ## Attestation file format diff --git a/docs/heartbeat.md b/docs/heartbeat.md index cce65330..43755c6c 100644 --- a/docs/heartbeat.md +++ b/docs/heartbeat.md @@ -37,7 +37,7 @@ certification -- to verify. To generate the heartbeat, the Signer uses the configured endorsement scheme to sign a message generated by the concatenation of: -- A predefined header (`HSM:SIGNER:HB:4.0:`). +- A predefined header (`HSM:SIGNER:HB:5.0:`). - A 32 byte value corresponding to the currently known best block hash. - A value corresponding to the first 8 bytes of the last successful authorized signed operation's transaction hash. @@ -53,7 +53,7 @@ transactions. To generate the heartbeat, the UI uses the configured endorsement scheme to sign a message generated by the concatenation of: -- A predefined header (`HSM:UI:HB:4.0:`). +- A predefined header (`HSM:UI:HB:5.0:`). - A 32 byte user-defined value. This value can vary and could be, for example, used as a timestamp reference for the end user. - A 32 byte value corresponding to the currently authorized Signer hash. diff --git a/docs/protocol.md b/docs/protocol.md index c9fd7f60..95e0ac4f 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -1,4 +1,4 @@ -# FedHM protocol definition v4.x +# PowHSM protocol definition v5.x ## Definitions @@ -21,7 +21,7 @@ #### Response ``` { - "version": 4, + "version": 5, "errorcode": i } ``` @@ -61,7 +61,7 @@ inputs. "hhhh", "hhhh", ..., "hhhh" ] }, - "version": 4 + "version": 5 } ``` @@ -120,7 +120,7 @@ section for details). "message": { "hash": "hhhh", // (**) }, - "version": 4 + "version": 5 } // (*) the given string must be the @@ -150,7 +150,7 @@ This operation can return `0`, `-101`, `-102`, `-103`, and generic errors. See t { "command": "getPubKey", "keyId": "xxxxx", // (*) - "version": 4 + "version": 5 } // (*) the given string must be the @@ -181,7 +181,7 @@ This operation can return `0`, `-103`, and generic errors. See the error codes s "brothers": [ ["hhhh", ..., "hhhh"], ..., ["hhhh", ..., "hhhh"] // (**) ], - "version": 4 + "version": 5 } // (*) each element must be the binary serialization of a block header as @@ -215,7 +215,7 @@ This operation can return `0`, `1`, `-201`, `-202`, `-204`, `-205`, and generic ``` { "command": "resetAdvanceBlockchain", - "version": 4 + "version": 5 } ``` @@ -235,7 +235,7 @@ This operation can return `0` and generic errors. See the error codes section fo ``` { "command": "blockchainState", - "version": 4 + "version": 5 } ``` @@ -277,7 +277,7 @@ This operation can return `0` and generic errors. See the error codes section fo "blocks": [ "hhhh", "hhhh", ..., "hhhh" // (*) ], - "version": 4 + "version": 5 } // (*) each element must be the binary serialization of a block header as @@ -301,7 +301,7 @@ This operation can return `0`, `-201`, `-203`, `-204`, and generic errors. See t ``` { "command": "blockchainParameters", - "version": 4 + "version": 5 } ``` @@ -330,7 +330,7 @@ This operation can return `0` and generic errors. See the error codes section fo { "command": "signerHeartbeat", "udValue": "hhhh" (*), - "version": 4 + "version": 5 } // (*) Value corresponds to the user-defined value, and must be 16 bytes in size. @@ -364,7 +364,7 @@ This operation can return `0`, `-301` and generic errors. See the error codes se { "command": "uiHeartbeat", "udValue": "hhhh" (*), - "version": 4 + "version": 5 } // (*) Value corresponds to the user-defined value, and must be 32 bytes in size. diff --git a/ledger/src/signer/src/attestation.h b/ledger/src/signer/src/attestation.h index 1516ee8d..eeaabc79 100644 --- a/ledger/src/signer/src/attestation.h +++ b/ledger/src/signer/src/attestation.h @@ -33,7 +33,7 @@ // ----------------------------------------------------------------------- // Attestation message prefix -#define ATT_MSG_PREFIX "HSM:SIGNER:4.0" +#define ATT_MSG_PREFIX "HSM:SIGNER:5.0" #define ATT_MSG_PREFIX_LENGTH (sizeof(ATT_MSG_PREFIX) - sizeof("")) // ----------------------------------------------------------------------- diff --git a/ledger/src/signer/src/defs.h b/ledger/src/signer/src/defs.h index e852af22..b96749ab 100644 --- a/ledger/src/signer/src/defs.h +++ b/ledger/src/signer/src/defs.h @@ -28,8 +28,8 @@ #include "constants.h" // Version and patchlevel -#define VERSION_MAJOR 0x04 +#define VERSION_MAJOR 0x05 #define VERSION_MINOR 0x00 -#define VERSION_PATCH 0x02 +#define VERSION_PATCH 0x00 #endif // __DEFS_H diff --git a/ledger/src/signer/src/heartbeat.h b/ledger/src/signer/src/heartbeat.h index 5e0cc2bc..ba8de8c9 100644 --- a/ledger/src/signer/src/heartbeat.h +++ b/ledger/src/signer/src/heartbeat.h @@ -45,7 +45,7 @@ typedef enum { } err_code_heartbeat_t; // Heartbeat message prefix -#define HEARTBEAT_MSG_PREFIX "HSM:SIGNER:HB:4.0:" +#define HEARTBEAT_MSG_PREFIX "HSM:SIGNER:HB:5.0:" #define HEARTBEAT_MSG_PREFIX_LENGTH (sizeof(HEARTBEAT_MSG_PREFIX) - sizeof("")) // User-defined value size diff --git a/ledger/src/ui/src/attestation.h b/ledger/src/ui/src/attestation.h index 08a7f5f2..9d2fb260 100644 --- a/ledger/src/ui/src/attestation.h +++ b/ledger/src/ui/src/attestation.h @@ -48,7 +48,7 @@ typedef enum { } err_code_att_t; // Attestation message prefix -#define ATT_MSG_PREFIX "HSM:UI:4.0" +#define ATT_MSG_PREFIX "HSM:UI:5.0" #define ATT_MSG_PREFIX_LENGTH (sizeof(ATT_MSG_PREFIX) - sizeof("")) // User defined value size diff --git a/ledger/src/ui/src/defs.h b/ledger/src/ui/src/defs.h index aff231cf..16d823f9 100644 --- a/ledger/src/ui/src/defs.h +++ b/ledger/src/ui/src/defs.h @@ -29,8 +29,8 @@ #include "constants.h" // Version and patchlevel -#define VERSION_MAJOR 0x04 +#define VERSION_MAJOR 0x05 #define VERSION_MINOR 0x00 -#define VERSION_PATCH 0x02 +#define VERSION_PATCH 0x00 #endif // __DEFS_H diff --git a/ledger/src/ui/src/ui_heartbeat.h b/ledger/src/ui/src/ui_heartbeat.h index 9344aac7..10db6271 100644 --- a/ledger/src/ui/src/ui_heartbeat.h +++ b/ledger/src/ui/src/ui_heartbeat.h @@ -46,7 +46,7 @@ typedef enum { } err_code_ui_heartbeat_t; // Heartbeat message prefix -#define UI_HEARTBEAT_MSG_PREFIX "HSM:UI:HB:4.0:" +#define UI_HEARTBEAT_MSG_PREFIX "HSM:UI:HB:5.0:" #define UI_HEARTBEAT_MSG_PREFIX_LENGTH \ (sizeof(UI_HEARTBEAT_MSG_PREFIX) - sizeof("")) diff --git a/ledger/src/ui/test/attestation/test_attestation.c b/ledger/src/ui/test/attestation/test_attestation.c index e25be823..ef624272 100644 --- a/ledger/src/ui/test/attestation/test_attestation.c +++ b/ledger/src/ui/test/attestation/test_attestation.c @@ -160,7 +160,7 @@ void test_get_attestation_ud_value() { assert(3 == get_attestation(rx, &G_att_ctx)); // PREFIX + UD_VALUE + Compressed pubkey + Signer hash + Iteration ASSERT_MEMCMP( - "HSM:UI:4.0" + "HSM:UI:5.0" "\x46\x8d\xa8\x7f\x6a\x85\xe6\x40\x93\x27\xe1\x17\xe8\xc7\xd2\x11\x0c" "\x73\x60\x22\x26\xbb\xb5\xed\xf2\x7d\x98\xc8\xa3\x1b\xcc\xf0" "\x02\xe6\xd7\x1d\x5c\x2b\x06\x36\x03\x53\xfb\xd8\x22\x7a\xb3\xab\xfc" @@ -208,7 +208,7 @@ void test_get_attestation_get_msg() { *N_onboarded_ui = 1; memcpy( G_att_ctx.msg, - "HSM:UI:4.0" + "HSM:UI:5.0" "\x46\x8d\xa8\x7f\x6a\x85\xe6\x40\x93\x27\xe1\x17\xe8\xc7\xd2\x11\x0c" "\x73\x60\x22\x26\xbb\xb5\xed\xf2\x7d\x98\xc8\xa3\x1b\xcc\xf0" "\x03\xe6\xd7\x1d\x5c\x2b\x06\x36\x03\x53\xfb\xd8\x22\x7a\xb3\xab\xfc" @@ -225,7 +225,7 @@ void test_get_attestation_get_msg() { assert((APDU_TOTAL_DATA_SIZE_OUT + 3) == get_attestation(rx, &G_att_ctx)); ASSERT_APDU( "\x80\x50\x02\x01" - "HSM:UI:4.0" + "HSM:UI:5.0" "\x46\x8d\xa8\x7f\x6a\x85\xe6\x40\x93\x27\xe1\x17\xe8\xc7\xd2\x11\x0c" "\x73\x60\x22\x26\xbb\xb5\xed\xf2\x7d\x98\xc8\xa3\x1b\xcc\xf0" "\x03\xe6\xd7\x1d\x5c\x2b\x06\x36\x03\x53\xfb\xd8\x22\x7a\xb3\xab\xfc" @@ -249,7 +249,7 @@ void test_get_attestation_get_msg_wrong_state() { *N_onboarded_ui = 1; memcpy( &G_att_ctx.msg, - "HSM:UI:4.0" + "HSM:UI:5.0" "\x46\x8d\xa8\x7f\x6a\x85\xe6\x40\x93\x27\xe1\x17\xe8\xc7\xd2\x11\x0c" "\x73\x60\x22\x26\xbb\xb5\xed\xf2\x7d\x98\xc8\xa3\x1b\xcc\xf0" "\x03\xe6\xd7\x1d\x5c\x2b\x06\x36\x03\x53\xfb\xd8\x22\x7a\xb3\xab\xfc" diff --git a/ledger/src/ui/test/onboard/test_onboard.c b/ledger/src/ui/test/onboard/test_onboard.c index cb7f469e..f893ca2b 100644 --- a/ledger/src/ui/test/onboard/test_onboard.c +++ b/ledger/src/ui/test/onboard/test_onboard.c @@ -313,11 +313,11 @@ void test_is_onboarded() { G_device_onboarded = true; assert(5 == is_onboarded()); - ASSERT_APDU("\x80\x01\x04\x00\x02"); + ASSERT_APDU("\x80\x01\x05\x00\x00"); G_device_onboarded = false; assert(5 == is_onboarded()); - ASSERT_APDU("\x80\x00\x04\x00\x02"); + ASSERT_APDU("\x80\x00\x05\x00\x00"); } int main() { diff --git a/ledger/src/ui/test/ui_heartbeat/test_ui_heartbeat.c b/ledger/src/ui/test/ui_heartbeat/test_ui_heartbeat.c index d06823f8..04256818 100644 --- a/ledger/src/ui/test/ui_heartbeat/test_ui_heartbeat.c +++ b/ledger/src/ui/test/ui_heartbeat/test_ui_heartbeat.c @@ -230,7 +230,7 @@ void test_op_ud_value() { assert_ok("\x80\x60\x01"); - const char expected_msg[] = "HSM:UI:HB:4.0:" // Prefix + const char expected_msg[] = "HSM:UI:HB:5.0:" // Prefix "\x11" // UD "\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22" // . "\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22" // . diff --git a/ledger/test/cases/heartbeat.py b/ledger/test/cases/heartbeat.py index 5e9a814c..01aabd1d 100644 --- a/ledger/test/cases/heartbeat.py +++ b/ledger/test/cases/heartbeat.py @@ -27,7 +27,7 @@ class Heartbeat(TestCase): - EXPECTED_HEADER = "HSM:SIGNER:HB:4.0:" + EXPECTED_HEADER = "HSM:SIGNER:HB:5.0:" EHL = len(EXPECTED_HEADER) @classmethod diff --git a/middleware/admin/verify_attestation.py b/middleware/admin/verify_attestation.py index fb6d5e1a..348f1973 100644 --- a/middleware/admin/verify_attestation.py +++ b/middleware/admin/verify_attestation.py @@ -28,8 +28,8 @@ from .certificate import HSMCertificate -UI_MESSAGE_HEADER = b"HSM:UI:4.0" -SIGNER_MESSAGE_HEADER = b"HSM:SIGNER:4.0" +UI_MESSAGE_HEADER = b"HSM:UI:5.0" +SIGNER_MESSAGE_HEADER = b"HSM:SIGNER:5.0" UI_DERIVATION_PATH = "m/44'/0'/0'/0/0" UD_VALUE_LENGTH = 32 PUBKEY_COMPRESSED_LENGTH = 33 diff --git a/middleware/comm/protocol.py b/middleware/comm/protocol.py index 41572cd9..1cb3b0b4 100644 --- a/middleware/comm/protocol.py +++ b/middleware/comm/protocol.py @@ -72,7 +72,7 @@ class HSM2Protocol: ERROR_CODE_UNKNOWN = -906 # Protocol version - VERSION = 4 + VERSION = 5 # Commands VERSION_COMMAND = "version" diff --git a/middleware/ledger/protocol.py b/middleware/ledger/protocol.py index 35ac427b..04c0ee3f 100644 --- a/middleware/ledger/protocol.py +++ b/middleware/ledger/protocol.py @@ -37,8 +37,8 @@ class HSM2ProtocolLedger(HSM2Protocol): # Current manager supported versions for HSM UI and HSM SIGNER (<=) - UI_VERSION = HSM2FirmwareVersion(4, 0, 2) - APP_VERSION = HSM2FirmwareVersion(4, 0, 2) + UI_VERSION = HSM2FirmwareVersion(5, 0, 0) + APP_VERSION = HSM2FirmwareVersion(5, 0, 0) # Amount of time to wait to make sure the app is opened OPEN_APP_WAIT = 1 # second diff --git a/middleware/tests/admin/test_verify_attestation.py b/middleware/tests/admin/test_verify_attestation.py index bb74a3ef..e214a960 100644 --- a/middleware/tests/admin/test_verify_attestation.py +++ b/middleware/tests/admin/test_verify_attestation.py @@ -65,14 +65,14 @@ def setUp(self): ) self.pubkeys_hash = pubkeys_hash.digest() - self.ui_msg = b"HSM:UI:4.0" + \ + self.ui_msg = b"HSM:UI:5.0" + \ bytes.fromhex("aa"*32) + \ bytes.fromhex("bb"*33) + \ bytes.fromhex("cc"*32) + \ bytes.fromhex("0123") self.ui_hash = bytes.fromhex("ee" * 32) - self.signer_msg = b"HSM:SIGNER:4.0" + \ + self.signer_msg = b"HSM:SIGNER:5.0" + \ bytes.fromhex(self.pubkeys_hash.hex()) self.signer_hash = bytes.fromhex("ff" * 32) diff --git a/middleware/tests/comm/test_protocol.py b/middleware/tests/comm/test_protocol.py index 37724d30..79dbf2ba 100644 --- a/middleware/tests/comm/test_protocol.py +++ b/middleware/tests/comm/test_protocol.py @@ -46,7 +46,7 @@ def test_invalid_request(self): {"errorcode": -902}) def test_invalid_request_no_command(self): - self.assertEqual(self.protocol.handle_request({"version": "4"}), + self.assertEqual(self.protocol.handle_request({"version": 5}), {"errorcode": -902}) def test_invalid_request_no_version(self): @@ -73,7 +73,7 @@ def test_version_2_not_supported(self): self.assertEqual( self.protocol.handle_request({ "command": "whatever", - "version": 4 + "version": 5 }), {"errorcode": -903}, ) @@ -89,7 +89,7 @@ def test_version_3_not_supported(self): self.assertEqual( self.protocol.handle_request({ "command": "whatever", - "version": 4 + "version": 5 }), {"errorcode": -903}, ) @@ -98,7 +98,7 @@ def test_invalid_command(self): self.assertEqual( self.protocol.handle_request({ "command": "invalid", - "version": 4 + "version": 5 }), {"errorcode": -903}, ) @@ -108,7 +108,7 @@ def test_version(self): self.protocol.handle_request({"command": "version"}), { "errorcode": 0, - "version": 4 + "version": 5 }, ) @@ -120,7 +120,7 @@ def test_getpubkey_keyId_presence(self): self.assertEqual( self.protocol.handle_request({ "command": "getPubKey", - "version": 4 + "version": 5 }), {"errorcode": -103}, ) @@ -129,7 +129,7 @@ def test_getpubkey_keyId_notastring(self): self.assertEqual( self.protocol.handle_request({ "command": "getPubKey", - "version": 4, + "version": 5, "keyId": 123 }), {"errorcode": -103}, @@ -139,7 +139,7 @@ def test_getpubkey_keyId_invalid(self): self.assertEqual( self.protocol.handle_request({ "command": "getPubKey", - "version": 4, + "version": 5, "keyId": "not-a-key-id" }), {"errorcode": -103}, @@ -149,14 +149,14 @@ def test_getpubkey_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "getPubKey", - "version": 4, + "version": 5, "keyId": "m/0/0/0/0/0" }) def test_sign_keyId_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign" }), {"errorcode": -103}, @@ -165,7 +165,7 @@ def test_sign_keyId_presence(self): def test_sign_keyId_not_a_string(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": 1234 }), @@ -175,7 +175,7 @@ def test_sign_keyId_not_a_string(self): def test_sign_keyId_invalid(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "not-a-key-id" }), @@ -185,7 +185,7 @@ def test_sign_keyId_invalid(self): def test_sign_auth_type_components(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": 123 @@ -195,7 +195,7 @@ def test_sign_auth_type_components(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": "" @@ -205,7 +205,7 @@ def test_sign_auth_type_components(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -218,7 +218,7 @@ def test_sign_auth_type_components(self): def test_sign_receipt_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -230,7 +230,7 @@ def test_sign_receipt_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -243,7 +243,7 @@ def test_sign_receipt_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -256,7 +256,7 @@ def test_sign_receipt_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -270,7 +270,7 @@ def test_sign_receipt_presence_type(self): def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -282,7 +282,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -295,7 +295,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -308,7 +308,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -321,7 +321,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -334,7 +334,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -348,7 +348,7 @@ def test_sign_receipt_merkle_proof_presence_type(self): def test_sign_message_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -361,7 +361,7 @@ def test_sign_message_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -375,7 +375,7 @@ def test_sign_message_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0" }), @@ -384,7 +384,7 @@ def test_sign_message_presence_type(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": "" @@ -395,7 +395,7 @@ def test_sign_message_presence_type(self): def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -411,7 +411,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -427,7 +427,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -444,7 +444,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -461,7 +461,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -478,7 +478,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -496,7 +496,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -514,7 +514,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -532,7 +532,7 @@ def test_sign_legacy_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -551,7 +551,7 @@ def test_sign_legacy_message_value(self): def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -567,7 +567,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -586,7 +586,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -605,7 +605,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -624,7 +624,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -643,7 +643,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -662,7 +662,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -682,7 +682,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -702,7 +702,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -722,7 +722,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -742,7 +742,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -762,7 +762,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -782,7 +782,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -802,7 +802,7 @@ def test_sign_segwit_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -824,7 +824,7 @@ def test_sign_hash_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -840,7 +840,7 @@ def test_sign_hash_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -856,7 +856,7 @@ def test_sign_hash_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -872,7 +872,7 @@ def test_sign_hash_message_value(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "auth": { @@ -890,7 +890,7 @@ def test_sign_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "sign", - "version": 4, + "version": 5, "keyId": "m/0/0/0/0/0", "auth": { "receipt": "ddeeff", @@ -906,7 +906,7 @@ def test_sign_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "sign", - "version": 4, + "version": 5, "keyId": "m/0/0/0/0/0", "auth": { "receipt": "ddeeff", @@ -919,7 +919,7 @@ def test_sign_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -931,7 +931,7 @@ def test_sign_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -945,7 +945,7 @@ def test_sign_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -956,7 +956,7 @@ def test_sign_notimplemented(self): def test_sign_noauth_message_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0" }), @@ -966,7 +966,7 @@ def test_sign_noauth_message_presence(self): def test_sign_noauth_message_notobject(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": 123 @@ -977,7 +977,7 @@ def test_sign_noauth_message_notobject(self): def test_sign_noauth_message_hash_notpresent(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -990,7 +990,7 @@ def test_sign_noauth_message_hash_notpresent(self): def test_sign_noauth_message_hash_invalid(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -1003,7 +1003,7 @@ def test_sign_noauth_message_hash_invalid(self): def test_sign_noauth_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/0/0/0/0/0", "message": { @@ -1014,7 +1014,7 @@ def test_sign_noauth_notimplemented(self): def test_advance_blockchain_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "brothers": [], }), @@ -1023,7 +1023,7 @@ def test_advance_blockchain_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": 123, "brothers": [], @@ -1033,7 +1033,7 @@ def test_advance_blockchain_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": [], "brothers": [], @@ -1043,7 +1043,7 @@ def test_advance_blockchain_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", 333, "another-ok"], "brothers": [[], [], []], @@ -1054,7 +1054,7 @@ def test_advance_blockchain_blocks_presence(self): def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], }), @@ -1063,7 +1063,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": "notalist", @@ -1073,7 +1073,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": [[], 123, []], @@ -1083,7 +1083,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": [["bb11", "bb12"], ["bb21", 123], ["bb31", "bb32", "bb33"]], @@ -1093,7 +1093,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": [["bb11", "bb12"], ["bb21"]], @@ -1103,7 +1103,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": [["bb11", "bb12"], ["bb21"], ["bb31", "bb32", "bb33"], []], @@ -1113,7 +1113,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok"], "brothers": [[""]], @@ -1123,7 +1123,7 @@ def test_advance_blockchain_brothers_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["ok", "another-ok", "yet-another-ok"], "brothers": [["bb11", "bb12"], ["bb21"], ["bb31", "bb32", "not-hex"]], @@ -1135,7 +1135,7 @@ def test_advance_blockchain_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "advanceBlockchain", - "version": 4, + "version": 5, "blocks": ["fist-block", "second-block"], "brothers": [["bb11", "bb12"], ["bb21", "bb22", "bb23"]], }) @@ -1144,17 +1144,17 @@ def test_reset_advance_blockchain_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "resetAdvanceBlockchain", - "version": 4 + "version": 5 }) def test_blockchain_status_notimplemented(self): with self.assertRaises(NotImplementedError): - self.protocol.handle_request({"command": "blockchainState", "version": 4}) + self.protocol.handle_request({"command": "blockchainState", "version": 5}) def test_update_ancestor_block_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock" }), {"errorcode": -204}, @@ -1162,7 +1162,7 @@ def test_update_ancestor_block_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": 123 }), @@ -1171,7 +1171,7 @@ def test_update_ancestor_block_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": [] }), @@ -1180,7 +1180,7 @@ def test_update_ancestor_block_blocks_presence(self): self.assertEqual( self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["ok", 333, "another-ok"], }), @@ -1191,7 +1191,7 @@ def test_update_ancestor_block_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "updateAncestorBlock", - "version": 4, + "version": 5, "blocks": ["a-block"] }) @@ -1199,8 +1199,7 @@ def test_update_ancestor_block_notimplemented(self): self.protocol.handle_request({ "command": "updateAncestorBlock", - "version": - 4, + "version": 5, "blocks": ["first-block", "second-block", "third-block"], }) @@ -1208,14 +1207,14 @@ def test_blockchain_parameters_notimplemented(self): with self.assertRaises(NotImplementedError): self.protocol.handle_request({ "command": "blockchainParameters", - "version": 4 + "version": 5 }) def test_signer_heartbeat_invalid_ud_value(self): self.assertEqual( self.protocol.handle_request({ "command": "signerHeartbeat", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1224,7 +1223,7 @@ def test_signer_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "signerHeartbeat", "udValue": 123, - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1233,7 +1232,7 @@ def test_signer_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "signerHeartbeat", "udValue": "notahex", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1242,7 +1241,7 @@ def test_signer_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "signerHeartbeat", "udValue": "aabbcc", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1252,14 +1251,14 @@ def test_signer_heartbeat_notimplemented(self): self.protocol.handle_request({ "command": "signerHeartbeat", "udValue": "aa"*16, - "version": 4 + "version": 5 }) def test_ui_heartbeat_invalid_ud_value(self): self.assertEqual( self.protocol.handle_request({ "command": "uiHeartbeat", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1268,7 +1267,7 @@ def test_ui_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "uiHeartbeat", "udValue": 123, - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1277,7 +1276,7 @@ def test_ui_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "uiHeartbeat", "udValue": "notahex", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1286,7 +1285,7 @@ def test_ui_heartbeat_invalid_ud_value(self): self.protocol.handle_request({ "command": "uiHeartbeat", "udValue": "aabbcc", - "version": 4 + "version": 5 }), {"errorcode": -301}, ) @@ -1296,5 +1295,5 @@ def test_ui_heartbeat_notimplemented(self): self.protocol.handle_request({ "command": "uiHeartbeat", "udValue": "aa"*32, - "version": 4 + "version": 5 }) diff --git a/middleware/tests/ledger/test_protocol.py b/middleware/tests/ledger/test_protocol.py index e37891ab..aac06697 100644 --- a/middleware/tests/ledger/test_protocol.py +++ b/middleware/tests/ledger/test_protocol.py @@ -49,7 +49,7 @@ def setUp(self): self.dongle.disconnect = Mock() self.dongle.is_onboarded = Mock(return_value=True) self.dongle.get_current_mode = Mock(return_value=HSM2Dongle.MODE.SIGNER) - self.dongle.get_version = Mock(return_value=HSM2FirmwareVersion(4, 0, 0)) + self.dongle.get_version = Mock(return_value=HSM2FirmwareVersion(5, 0, 0)) self.dongle.get_signer_parameters = Mock(return_value=Mock( min_required_difficulty=123)) self.protocol = HSM2ProtocolLedger(self.pin, self.dongle) @@ -66,7 +66,7 @@ def test_get_pubkey_ok(self, BIP32PathMock): "pubKey": "this-is-the-public-key" }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }), @@ -82,7 +82,7 @@ def test_get_pubkey_error(self, BIP32PathMock): self.assertEqual( {"errorcode": -103}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }), @@ -98,7 +98,7 @@ def test_get_pubkey_timeout(self, BIP32PathMock): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }), @@ -114,7 +114,7 @@ def test_get_pubkey_commerror_reconnection(self, BIP32PathMock): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }), @@ -132,7 +132,7 @@ def test_get_pubkey_commerror_reconnection(self, BIP32PathMock): "pubKey": "this-is-the-public-key" }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }), @@ -147,7 +147,7 @@ def test_get_pubkey_unexpected_error(self, BIP32PathMock): with self.assertRaises(HSM2ProtocolError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "getPubKey", "keyId": "m/44'/1'/2'/3/4" }) @@ -173,7 +173,7 @@ def test_sign_authorized_legacy_ok(self, BIP32PathMock, get_unsigned_tx_mock, _) } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -223,7 +223,7 @@ def test_sign_authorized_segwit_ok(self, BIP32PathMock, get_unsigned_tx_mock, _) } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -284,7 +284,7 @@ def test_sign_authorized_legacy_error( self.assertEqual( {"errorcode": protocol_error_code}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -343,7 +343,7 @@ def test_sign_authorized_segwit_error( self.assertEqual( {"errorcode": protocol_error_code}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -388,7 +388,7 @@ def test_sign_authorized_legacy_timeout(self, BIP32PathMock, get_unsigned_tx_moc self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -431,7 +431,7 @@ def test_sign_authorized_segwit_timeout(self, BIP32PathMock, get_unsigned_tx_moc self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -477,7 +477,7 @@ def test_sign_authorized_legacy_commerror_reconnection(self, BIP32PathMock, self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -523,7 +523,7 @@ def test_sign_authorized_legacy_commerror_reconnection(self, BIP32PathMock, } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -552,7 +552,7 @@ def test_sign_authorized_segwit_commerror_reconnection(self, BIP32PathMock, self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -600,7 +600,7 @@ def test_sign_authorized_segwit_commerror_reconnection(self, BIP32PathMock, } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -630,7 +630,7 @@ def test_sign_authorized_legacy_exception(self, BIP32PathMock, with self.assertRaises(HSM2ProtocolError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -672,7 +672,7 @@ def test_sign_authorized_segwit_exception(self, BIP32PathMock, with self.assertRaises(HSM2ProtocolError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -716,7 +716,7 @@ def test_sign_authorized_legacy_error_unsigning(self, BIP32PathMock, self.assertEqual( {"errorcode": -102}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -745,7 +745,7 @@ def test_sign_authorized_segwit_error_unsigning(self, BIP32PathMock, self.assertEqual( {"errorcode": -102}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -775,7 +775,7 @@ def test_sign_authorized_message_invalid(self, BIP32PathMock, get_unsigned_tx_mo self.assertEqual( {"errorcode": -102}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -803,7 +803,7 @@ def test_sign_authorized_auth_invalid(self, BIP32PathMock, get_unsigned_tx_mock, self.assertEqual( {"errorcode": -101}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "auth": { @@ -837,7 +837,7 @@ def test_sign_unauthorized_ok(self, BIP32PathMock): } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -867,7 +867,7 @@ def test_sign_unauthorized_error(self, _, dongle_error_code, protocol_error_code self.assertEqual( {"errorcode": protocol_error_code}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -890,7 +890,7 @@ def test_sign_unauthorized_timeout(self, BIP32PathMock): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -913,7 +913,7 @@ def test_sign_unauthorized_commerror_reconnection(self, BIP32PathMock): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -942,7 +942,7 @@ def test_sign_unauthorized_commerror_reconnection(self, BIP32PathMock): } }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -960,7 +960,7 @@ def test_sign_unauthorized_exception(self, BIP32PathMock): with self.assertRaises(HSM2ProtocolError): self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -981,7 +981,7 @@ def test_sign_unauthorized_message_invalid(self, BIP32PathMock): self.assertEqual( {"errorcode": -102}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "sign", "keyId": "m/44'/1'/2'/3/4", "message": { @@ -1028,7 +1028,7 @@ def test_blockchain_state_ok(self): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainState" }), ) @@ -1042,7 +1042,7 @@ def test_blockchain_state_dongle_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainState" }), ) @@ -1056,7 +1056,7 @@ def test_blockchain_state_dongle_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainState" }), ) @@ -1070,7 +1070,7 @@ def test_blockchain_state_dongle_commerror_reconnection(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainState" }), ) @@ -1114,7 +1114,7 @@ def test_blockchain_state_dongle_commerror_reconnection(self): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainState" }), ) @@ -1125,7 +1125,7 @@ def test_reset_advance_blockchain_ok(self): self.assertEqual( {"errorcode": 0}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "resetAdvanceBlockchain" }), ) @@ -1139,7 +1139,7 @@ def test_reset_advance_blockchain_dongle_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "resetAdvanceBlockchain" }), ) @@ -1153,7 +1153,7 @@ def test_reset_advance_blockchain_dongle_commerror_reconnection(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "resetAdvanceBlockchain" }), ) @@ -1167,7 +1167,7 @@ def test_reset_advance_blockchain_dongle_commerror_reconnection(self): self.assertEqual( {"errorcode": 0}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "resetAdvanceBlockchain" }), ) @@ -1180,7 +1180,7 @@ def test_reset_advance_blockchain_dongle_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "resetAdvanceBlockchain" }), ) @@ -1208,7 +1208,7 @@ def test_advance_blockchain_mapping(self, _, response, expected_code): self.assertEqual( {"errorcode": expected_code}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["aabbcc", "ddeeff"], "brothers": [["bb11"], ["bb21", "bb22"]], @@ -1230,7 +1230,7 @@ def test_advance_blockchain_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["aabbcc", "ddeeff"], "brothers": [["bb11", "bb12", "bb13"], ["bb21", "bb22"]], @@ -1252,7 +1252,7 @@ def test_advance_blockchain_commerror_reconnection(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["aabbcc", "ddeeff"], "brothers": [["bb11", "bb12", "bb13"], ["bb21", "bb22"]], @@ -1274,7 +1274,7 @@ def test_advance_blockchain_commerror_reconnection(self): self.assertEqual( {"errorcode": 0}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["aabbcc", "ddeeff"], "brothers": [["bb11", "bb12", "bb13"], ["bb21", "bb22"]], @@ -1289,7 +1289,7 @@ def test_advance_blockchain_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "advanceBlockchain", "blocks": ["aabbcc", "ddeeff"], "brothers": [["bb11", "bb12", "bb13"], ["bb21", "bb22"]], @@ -1323,7 +1323,7 @@ def test_update_ancestor_mapping(self, _, response, expected_code): self.assertEqual( {"errorcode": expected_code}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["aabbcc", "ddeeff"], }), @@ -1341,7 +1341,7 @@ def test_update_ancestor_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["aabbcc", "ddeeff"], }), @@ -1359,7 +1359,7 @@ def test_update_ancestor_commerror_reconnection(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["aabbcc", "ddeeff"], }), @@ -1377,7 +1377,7 @@ def test_update_ancestor_commerror_reconnection(self): self.assertEqual( {"errorcode": 0}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["aabbcc", "ddeeff"], }), @@ -1391,7 +1391,7 @@ def test_update_ancestor_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "updateAncestorBlock", "blocks": ["aabbcc", "ddeeff"], }), @@ -1420,7 +1420,7 @@ def test_get_blockchain_parameters_ok(self): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainParameters" }), ) @@ -1431,7 +1431,7 @@ def test_get_blockchain_parameters_dongle_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainParameters" }), ) @@ -1442,7 +1442,7 @@ def test_get_blockchain_parameters_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "blockchainParameters" }), ) @@ -1467,7 +1467,7 @@ def test_signer_heartbeat_ok(self): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "signerHeartbeat", "udValue": "77"*16, }), @@ -1479,7 +1479,7 @@ def test_signer_heartbeat_dongle_error(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "signerHeartbeat", "udValue": "99"*16, }), @@ -1491,7 +1491,7 @@ def test_signer_heartbeat_dongle_timeout(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "signerHeartbeat", "udValue": "11"*16, }), @@ -1503,7 +1503,7 @@ def test_signer_heartbeat_exception(self): self.assertEqual( {"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "signerHeartbeat", "udValue": "22"*16, }), @@ -1541,7 +1541,7 @@ def test_ui_heartbeat_from_signer_ok(self, sleep_mock): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, }), @@ -1555,7 +1555,7 @@ def test_ui_heartbeat_exit_signer_error(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1571,7 +1571,7 @@ def test_ui_heartbeat_from_signer_no_ui_heartbeat(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1588,7 +1588,7 @@ def test_ui_heartbeat_from_signer_hb_error(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1612,7 +1612,7 @@ def test_ui_heartbeat_from_signer_hb_error_result(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1640,7 +1640,7 @@ def test_ui_heartbeat_from_signer_back_to_signer_error(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1669,7 +1669,7 @@ def test_ui_heartbeat_from_signer_no_back_to_signer(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1682,7 +1682,7 @@ def test_ui_heartbeat_from_invalid_start_mode(self, sleep_mock): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1709,7 +1709,7 @@ def test_ui_heartbeat_from_hb_ok(self): }, }, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, }), @@ -1724,7 +1724,7 @@ def test_ui_heartbeat_from_hb_hb_error(self): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) @@ -1738,7 +1738,7 @@ def test_ui_heartbeat_from_hb_hb_error_result(self): self.assertEqual({"errorcode": -905}, self.protocol.handle_request({ - "version": 4, + "version": 5, "command": "uiHeartbeat", "udValue": "77"*32, })) diff --git a/middleware/tests/ledger/test_protocol_v1.py b/middleware/tests/ledger/test_protocol_v1.py index d2945f67..246b28a0 100644 --- a/middleware/tests/ledger/test_protocol_v1.py +++ b/middleware/tests/ledger/test_protocol_v1.py @@ -47,7 +47,7 @@ def setUp(self): self.dongle.disconnect = Mock() self.dongle.is_onboarded = Mock(return_value=True) self.dongle.get_current_mode = Mock(return_value=HSM2Dongle.MODE.SIGNER) - self.dongle.get_version = Mock(return_value=HSM2FirmwareVersion(4, 0, 0)) + self.dongle.get_version = Mock(return_value=HSM2FirmwareVersion(5, 0, 0)) self.dongle.get_signer_parameters = Mock(return_value=Mock( min_required_difficulty=123)) self.protocol = HSM1ProtocolLedger(self.pin, self.dongle)