From dbe8174fa4915203a6cd011d9293a5076467264b Mon Sep 17 00:00:00 2001 From: Alexis Grojean Date: Wed, 15 Nov 2023 13:28:12 +0100 Subject: [PATCH] Stack usage optim : use slices, not arrays in Tx struct. Code cleanup. --- Cargo.lock | 380 +++++++++++++++++- src/app_ui/sign.rs | 2 +- src/handlers/sign_tx.rs | 52 +-- .../00001.png | Bin 517 -> 496 bytes .../00002.png | Bin 555 -> 507 bytes .../00003.png | Bin 530 -> 447 bytes .../00004.png | Bin 548 -> 341 bytes .../00005.png | Bin 535 -> 455 bytes .../00006.png | Bin 535 -> 0 bytes .../00007.png | Bin 500 -> 0 bytes .../00008.png | Bin 413 -> 0 bytes .../00001.png | Bin 517 -> 496 bytes .../00002.png | Bin 555 -> 507 bytes .../00003.png | Bin 530 -> 447 bytes .../00004.png | Bin 548 -> 341 bytes .../00005.png | Bin 535 -> 340 bytes .../00006.png | Bin 535 -> 455 bytes .../00007.png | Bin 500 -> 0 bytes .../00008.png | Bin 413 -> 0 bytes .../nanos/test_sign_tx_long_tx/00000.png | Bin 0 -> 358 bytes .../nanos/test_sign_tx_long_tx/00001.png | Bin 0 -> 355 bytes .../nanos/test_sign_tx_long_tx/00002.png | Bin 0 -> 525 bytes .../nanos/test_sign_tx_long_tx/00003.png | Bin 0 -> 536 bytes .../nanos/test_sign_tx_long_tx/00004.png | Bin 0 -> 456 bytes .../nanos/test_sign_tx_long_tx/00005.png | Bin 0 -> 436 bytes .../nanos/test_sign_tx_long_tx/00006.png | Bin 0 -> 435 bytes .../nanos/test_sign_tx_long_tx/00007.png | Bin 0 -> 436 bytes .../nanos/test_sign_tx_long_tx/00008.png | Bin 0 -> 447 bytes .../nanos/test_sign_tx_long_tx/00009.png | Bin 0 -> 456 bytes .../nanos/test_sign_tx_long_tx/00010.png | Bin 0 -> 436 bytes .../nanos/test_sign_tx_long_tx/00011.png | Bin 0 -> 454 bytes .../nanos/test_sign_tx_long_tx/00012.png | Bin 0 -> 448 bytes .../nanos/test_sign_tx_long_tx/00013.png | Bin 0 -> 476 bytes .../nanos/test_sign_tx_long_tx/00014.png | Bin 0 -> 455 bytes .../nanos/test_sign_tx_long_tx/00015.png | Bin 0 -> 465 bytes .../nanos/test_sign_tx_long_tx/00016.png | Bin 0 -> 462 bytes .../nanos/test_sign_tx_long_tx/00017.png | Bin 0 -> 456 bytes .../nanos/test_sign_tx_long_tx/00018.png | Bin 0 -> 455 bytes .../nanos/test_sign_tx_long_tx/00019.png | Bin 0 -> 478 bytes .../nanos/test_sign_tx_long_tx/00020.png | Bin 0 -> 464 bytes .../nanos/test_sign_tx_long_tx/00021.png | Bin 0 -> 479 bytes .../nanos/test_sign_tx_long_tx/00022.png | Bin 0 -> 464 bytes .../nanos/test_sign_tx_long_tx/00023.png | Bin 0 -> 462 bytes .../nanos/test_sign_tx_long_tx/00024.png | Bin 0 -> 468 bytes .../nanos/test_sign_tx_long_tx/00025.png | Bin 0 -> 447 bytes .../nanos/test_sign_tx_long_tx/00026.png | Bin 0 -> 452 bytes .../nanos/test_sign_tx_long_tx/00027.png | Bin 0 -> 429 bytes .../00028.png} | Bin .../00029.png} | Bin .../nanos/test_sign_tx_refused/00000.png | Bin 0 -> 358 bytes .../nanos/test_sign_tx_refused/00001.png | Bin 0 -> 355 bytes .../nanos/test_sign_tx_refused/00002.png | Bin 0 -> 525 bytes .../nanos/test_sign_tx_refused/00003.png | Bin 0 -> 536 bytes .../nanos/test_sign_tx_refused/00004.png | Bin 0 -> 456 bytes .../nanos/test_sign_tx_refused/00005.png | Bin 0 -> 437 bytes .../nanos/test_sign_tx_refused/00006.png | Bin 0 -> 445 bytes .../nanos/test_sign_tx_refused/00007.png | Bin 0 -> 419 bytes .../00008.png} | Bin .../00009.png} | Bin .../00010.png} | Bin .../nanos/test_sign_tx_short_tx/00000.png | Bin 0 -> 358 bytes .../nanos/test_sign_tx_short_tx/00001.png | Bin 0 -> 355 bytes .../nanos/test_sign_tx_short_tx/00002.png | Bin 0 -> 525 bytes .../nanos/test_sign_tx_short_tx/00003.png | Bin 0 -> 536 bytes .../nanos/test_sign_tx_short_tx/00004.png | Bin 0 -> 456 bytes .../nanos/test_sign_tx_short_tx/00005.png | Bin 0 -> 353 bytes .../nanos/test_sign_tx_short_tx/00006.png | Bin 0 -> 341 bytes .../nanos/test_sign_tx_short_tx/00007.png | Bin 0 -> 455 bytes tests/test_sign_cmd.py | 283 ++++++------- 69 files changed, 529 insertions(+), 188 deletions(-) delete mode 100644 tests/snapshots/nanos/test_get_public_key_confirm_accepted/00006.png delete mode 100644 tests/snapshots/nanos/test_get_public_key_confirm_accepted/00007.png delete mode 100644 tests/snapshots/nanos/test_get_public_key_confirm_accepted/00008.png delete mode 100644 tests/snapshots/nanos/test_get_public_key_confirm_refused/00007.png delete mode 100644 tests/snapshots/nanos/test_get_public_key_confirm_refused/00008.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00000.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00001.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00002.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00003.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00004.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00005.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00006.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00007.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00008.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00009.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00010.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00011.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00012.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00013.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00014.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00015.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00016.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00017.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00018.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00019.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00020.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00021.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00022.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00023.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00024.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00025.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00026.png create mode 100644 tests/snapshots/nanos/test_sign_tx_long_tx/00027.png rename tests/snapshots/nanos/{test_get_public_key_confirm_accepted/00009.png => test_sign_tx_long_tx/00028.png} (100%) rename tests/snapshots/nanos/{test_get_public_key_confirm_accepted/00010.png => test_sign_tx_long_tx/00029.png} (100%) create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00000.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00001.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00002.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00003.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00004.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00005.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00006.png create mode 100644 tests/snapshots/nanos/test_sign_tx_refused/00007.png rename tests/snapshots/nanos/{test_get_public_key_confirm_refused/00009.png => test_sign_tx_refused/00008.png} (100%) rename tests/snapshots/nanos/{test_get_public_key_confirm_refused/00010.png => test_sign_tx_refused/00009.png} (100%) rename tests/snapshots/nanos/{test_get_public_key_confirm_refused/00011.png => test_sign_tx_refused/00010.png} (100%) create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00000.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00001.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00002.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00003.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00004.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00005.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00006.png create mode 100644 tests/snapshots/nanos/test_sign_tx_short_tx/00007.png diff --git a/Cargo.lock b/Cargo.lock index 1205c81..76d750e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,24 +2,120 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "app-boilerplate-rust" +version = "1.0.0" +dependencies = [ + "include_gif", + "nanos_sdk", + "nanos_ui", + "numtoa", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "bindgen" +version = "0.65.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.20", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "cc" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "errno" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "gif" version = "0.11.4" @@ -30,15 +126,91 @@ dependencies = [ "weezl", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "include_gif" version = "0.1.0" source = "git+https://github.com/LedgerHQ/sdk_include_gif#699d28c6157518c4493899e2eeaa8af08346e5e7" dependencies = [ "gif", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "ledger-sdk-sys" +version = "0.2.0" +source = "git+https://github.com/LedgerHQ/secure-sdk-rust#d9a9868320a0d27194d93c7b4c55f48f2300abdc" +dependencies = [ + "bindgen", + "cc", ] +[[package]] +name = "libc" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "nanos_sdk" version = "0.2.1" @@ -52,10 +224,21 @@ dependencies = [ [[package]] name = "nanos_ui" version = "0.2.0" -source = "git+https://github.com/LedgerHQ/ledger-nanos-ui.git#6977cef7770c8c52738defe898fed6e274047498" dependencies = [ "include_gif", + "ledger-sdk-sys", "nanos_sdk", + "numtoa", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", ] [[package]] @@ -67,6 +250,34 @@ dependencies = [ "autocfg", ] +[[package]] +name = "numtoa" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "prettyplease" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" +dependencies = [ + "proc-macro2", + "syn 2.0.20", +] + [[package]] name = "proc-macro2" version = "1.0.60" @@ -92,13 +303,59 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] -name = "rust-app" -version = "0.2.1" +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ - "nanos_sdk", - "nanos_ui", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", ] +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "syn" version = "1.0.109" @@ -110,6 +367,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb8d4cebc40aa517dfb69618fa647a346562e67228e2236ae0042ee6ac14775" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "unicode-ident" version = "1.0.9" @@ -121,3 +389,103 @@ name = "weezl" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/src/app_ui/sign.rs b/src/app_ui/sign.rs index 3a703e3..758f623 100644 --- a/src/app_ui/sign.rs +++ b/src/app_ui/sign.rs @@ -46,7 +46,7 @@ pub fn ui_display_tx(tx: &Tx) -> Result { from_utf8(&addr_with_prefix_buf).map_err(|_| Reply(SW_TX_DISPLAY_FAIL))?; // Format memo - let memo_str = from_utf8(&tx.memo[..tx.memo_len]).map_err(|_| Reply(SW_TX_DISPLAY_FAIL))?; + let memo_str = from_utf8(&tx.memo[..tx.memo_len as usize]).map_err(|_| Reply(SW_TX_DISPLAY_FAIL))?; // Define transaction review fields let my_fields = [ diff --git a/src/handlers/sign_tx.rs b/src/handlers/sign_tx.rs index 146eff5..d9ff288 100644 --- a/src/handlers/sign_tx.rs +++ b/src/handlers/sign_tx.rs @@ -15,29 +15,28 @@ * limitations under the License. *****************************************************************************/ use crate::app_ui::sign::ui_display_tx; -use crate::utils::{read_bip32_path, varint_read, slice_or_err, MAX_ALLOWED_PATH_LEN, to_hex_all_caps}; +use crate::utils::{read_bip32_path, varint_read, slice_or_err, MAX_ALLOWED_PATH_LEN}; use crate::{SW_DENY, SW_TX_HASH_FAIL, SW_TX_PARSING_FAIL, SW_TX_SIGN_FAIL, SW_WRONG_TX_LENGTH}; use nanos_sdk::bindings::{ cx_hash_no_throw, cx_hash_t, cx_keccak_init_no_throw, cx_sha3_t, CX_LAST, CX_OK, }; use nanos_sdk::ecc::{Secp256k1, SeedDerive}; use nanos_sdk::io::{Comm, Reply}; -use nanos_sdk::testing; const MAX_TRANSACTION_LEN: usize = 510; -pub struct Tx { +pub struct Tx<'a> { nonce: u64, pub value: u64, - pub to: [u8; 20], - pub memo: [u8; 255], + pub to: &'a [u8], + pub memo: &'a [u8], pub memo_len: usize, } // Implement deserialize for Tx from a u8 array -impl TryFrom<&[u8]> for Tx { +impl<'a> TryFrom<&'a [u8]> for Tx<'a> { type Error = (); - fn try_from(raw_tx: &[u8]) -> Result { + fn try_from(raw_tx: &'a [u8]) -> Result { if raw_tx.len() > MAX_TRANSACTION_LEN { return Err(()); } @@ -46,23 +45,14 @@ impl TryFrom<&[u8]> for Tx { // Nonce let nonce = u64::from_be_bytes(slice_or_err(raw_tx, 0, 8)?.try_into().map_err(|_| ())?); // Destination address - let to = slice_or_err(raw_tx, 8, 20)?.try_into().map_err(|_| ())?; + let to = slice_or_err(raw_tx, 8, 20)?; // Amount value let value = u64::from_be_bytes(slice_or_err(raw_tx, 28, 8)?.try_into().map_err(|_| ())?); // Memo length - // Memo will be trimmed to 255 bytes if it is longer let (memo_len_u64, memo_len_size) = varint_read(&raw_tx[36..])?; - let memo_len = if memo_len_u64 < 255 { - memo_len_u64 as usize - } else { - 255 as usize - }; - + let memo_len = memo_len_u64 as usize; // Memo - let memo_slice = slice_or_err(raw_tx, 36 + memo_len_size, memo_len)?; - let mut memo = [0u8; 255]; - - memo[..memo_len].copy_from_slice(memo_slice); + let memo = slice_or_err(raw_tx, 36 + memo_len_size, memo_len)?; // Check memo ASCII encoding if !memo[..memo_len].iter().all(|&byte| byte.is_ascii()) { @@ -112,8 +102,7 @@ pub fn handler_sign_tx( more: bool, ctx: &mut TxContext, ) -> Result<(), Reply> { - // Try to get data from comm. If there is no data, - // the '?' operator will propagate the error. + // Try to get data from comm let data = comm.get_data()?; // First chunk, try to parse the path if chunk == 0 { @@ -137,15 +126,13 @@ pub fn handler_sign_tx( return Ok(()); // Otherwise, try to parse the transaction } else { - testing::debug_print("Last chunk : parse transaction\n"); let tx = match Tx::try_from(&ctx.raw_tx[..ctx.raw_tx_len]) { Ok(tx) => tx, Err(_) => return Err(Reply(SW_TX_PARSING_FAIL)), }; - testing::debug_print("Transaction parsed\n"); // Display transaction. If user approves // the transaction, sign it. Otherwise, - // return an error. + // return a "deny" status word. if ui_display_tx(&tx)? { return compute_signature_and_append(comm, ctx); } else { @@ -160,20 +147,10 @@ fn compute_signature_and_append(comm: &mut Comm, ctx: &mut TxContext) -> Result< let mut keccak256: cx_sha3_t = Default::default(); let mut message_hash: [u8; 32] = [0u8; 32]; - testing::debug_print("Signature is appended 1\n"); unsafe { - let res = cx_keccak_init_no_throw(&mut keccak256, 256); - if res != CX_OK { - // Print error - let err_buf = to_hex_all_caps(&res.to_be_bytes()).unwrap(); - let err_str = core::str::from_utf8(&err_buf).unwrap(); - testing::debug_print("Hashing err : "); - testing::debug_print(err_str); - testing::debug_print("\n"); - + if cx_keccak_init_no_throw(&mut keccak256, 256) != CX_OK { return Err(Reply(SW_TX_HASH_FAIL)); } - testing::debug_print("Signature is appended 1.1\n"); if cx_hash_no_throw( &mut keccak256.header as *mut cx_hash_t, CX_LAST, @@ -183,10 +160,8 @@ fn compute_signature_and_append(comm: &mut Comm, ctx: &mut TxContext) -> Result< message_hash.len() as u32, ) != CX_OK { - testing::debug_print("Hashing failed 2\n"); return Err(Reply(SW_TX_HASH_FAIL)); } - testing::debug_print("Signature is appended 1.2\n"); } let (sig, siglen, parity) = Secp256k1::derive_from_path(&ctx.path[..ctx.path_len]) @@ -195,8 +170,5 @@ fn compute_signature_and_append(comm: &mut Comm, ctx: &mut TxContext) -> Result< comm.append(&[siglen as u8]); comm.append(&sig[..siglen as usize]); comm.append(&[parity as u8]); - - testing::debug_print("Signature is appended 2\n"); - Ok(()) } diff --git a/tests/snapshots/nanos/test_get_public_key_confirm_accepted/00001.png b/tests/snapshots/nanos/test_get_public_key_confirm_accepted/00001.png index dce1ab738131945fb8fab9d2430efceb1d35d823..2d939069ef8d6b7418263a31339cc281d6c93fa8 100644 GIT binary patch delta 470 zcmV;{0V)241n>ipB!9O_L_t(|ob8#>u7fZLhU>}p{tvthci}<^Q2dKU-5Fn&#V|@K zEvT%uq9}@@DE=MmtF5nrpB(*J{`k|8WV;XwIlld67;TNYn;KIb9cz>2`T5>HLNj44 zkLeb7FxOya!}9#dbs%ub5g$$=Cj)xNjR#cxs^g`Po_Q)s=zmDW6k5Stf*#f8?^9+5 z2#*8j4!6Jq+S^eFJ%py-axsmxdq7LLsZwdCO3mjoCATMG18C(u(|hL#Ib4noQhz`) zkGVry28hzhuf^F!YAY`YydsH8ttH45y$51pCs5gtxqgM?^>9{2{pmfpaCnlbB1rAQ zl~nYvq@sT%Du4RR*hsv=LY*8g5t_)Glpdwk%=a&6;E=?$Gc<4lNNdx4ng$hyF0=)_ z!RMG78Wl5T5q%N6TetaZIlUcy1TedMJy*X{X&umkV>Ktb0isziTtU3SS1SziR6TCwADueF|_& z^c%VXX2Aiy;YPHa*N|ofv?tNUVP*ef?z)Po?LLWut`TB!A3FL_t(|ob8#*ZUZq0MV+eo{}1k>SyZwJFJCZIPgTyUnF1zY zV}^{;G)>bq%@H13+TUOA#-0mFCO{vm0=}KO`cliWMs=kR>T*kCqMF}do1EMRcAz+?ZVt3+q zOVGs08JJGIcLMvXv?qI9mH@Rs1NS2>xJwn*DS}nVuO#xhbq7SVd;1evjgya(3nO9V zUH(uBx&u`eCVy(@FWgK;6gEZW+}5#wK}Y{29sQGt=&z=sPMeh&1R~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irm_accepted/00003.png b/tests/snapshots/nanos/test_get_public_key_confirm_accepted/00003.png index 30a64c8a3823888e7505ded812807c6bd6f76cc9..700668eb7e0b4e10ed5361e791c5fa344dec7e61 100644 GIT binary patch delta 421 zcmV;W0b2f&1iu52B!7lUL_t(|ob8#-5`-WKfN5v<{U5kPdvL~aJ+>m@m- z<1n4CxkU+b0$7;VTA34gNopkH@8*v~22?YtvO!sS@VXvAsBFbAWS{m`+o}(F__6qtI#4eoE$N51-aMlG*pAKm8|+duHCFUylSf4M@jkN@-Dce z1ya&HlI&KK_5E=>iqJ6lCHx4kJ&x9(sR_1q!~0**qR1)FooSN~l6O;y%hxF*7qVUk z^g+5${>`ukQv+c5mzC_1y4Bu7RU%3W*5sbjG)}Ub`5v!}AP9mW2yVb1wuUCnYHZY{ P00000NkvXXu0mjf7)Z!4 delta 504 zcmV@C(F%0-;9q6IBE14dU=|3CA@65EMm zTTln&ESS#t-D$4-4>^-SBw$s^sF$;#aoTNN6?RPwb|KkqSaSz=q0I5___qCq9R}nh zb6{lbn8M!|{eR{~XH^0gs9Z4m=W>-C?8&vd&~9Ar9Nr2M-taWkoz+;A!e(62*gX|b z3*6BV^U89-9iXZL5hMB0EJ8l?%b$R-Dx*#lEtSZ=jCc|^$aGbCU_Z(}_ zE>_PTFfHf;G8}GzA`t{;2T3GguKb%8AT_=&$4_BDz_B}k?b)x0V3Jq@)MmO+YvOiD uk8!KxTQ4Sooyf@vi~#qFq9}@@*o!9&&~HY?B8yP~00004uc>JMe8#E|AT#S4;a$4l#R@IsowLnAtUTG zToFYGA%qY@{$}4~-_Vm7Rt#sf<#$}=)VJ~BlvESR-Jq3=$jydfC?r!$iuAw9oGJ!U-M%Y zMJ+y&Ch%TCM>9}$(GT~2qZ!TIc>6skNTK;?O1Y^i^a^-9EC6{n9}GT=eBR!K!~g&Q M07*qoM6N<$g7>wSY5)KL delta 523 zcmV+m0`&dW0;B|xB!BBkL_t(|ob6f5ZUZq0+*a-Xe{c@zp^`;;4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b}DKBW2r9r51rz{0Gk$~do#j*?dq=jWBIpcC0oN9m|iIc8R4 zDggDWZsRqE%a%!i`f+=}e&6;QpxHx^xo|IVYg1 zQ!cSiZI*pm-E10>odBjjovre14IPHswQx8~I>S`wWyEGAK$^-W@-4A2G7B9p$wT1}c7Q zU6Q`Y6s$a3M%yU2;*9hWwB!zmdQ^Wri)19W881A7Iv{7xbozTIXMdH9CxJ-7lB!WV zGpA*G)S4=+M|7S-Y9q@IcWGyI2ZVBLg!dQrYygmtbbS_|xTNLT&b+)|(tWiYa5b?$(PFdkX`Jiz2Uyw`@uR37!nHhryYRb~^AU%ot{ z0NBYMiXYsoX4)(-FW&)IA#Z{`c;+RnUU%|&Ar@=D&p?1yW;H!VJpG0G6t*aeq9}@e Z`2rO`lsc<-N}~V(002ovPDHLkV1i8R@h<=X diff --git a/tests/snapshots/nanos/test_get_public_key_confirm_accepted/00007.png b/tests/snapshots/nanos/test_get_public_key_confirm_accepted/00007.png deleted file mode 100644 index cfde67b4d8d5a664e05496ff1b161e39d1de0d91..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 500 zcmVICO{ii z0h?#^zSJ_<7?mVcd!#ahB!sW9rZSWyNsK46`mFaE6>|}33}!zMzQdYRjDbq0Hhh)| ztG;H)OBI#SYpuk}f~eR5IKcT+UvsTKbx-Q2hP-$1?-$oqgBXko0|fduRB*N-Ngpyk zYi}AO1SL=rf=bQ+Z;$Hy*+^z$JK=Xj(12kx(42Vg6pQ|@!6YCIP~|deat4yqXuDKl zX(AYfW|@qd1;|lJN!Rff{rm@E*duvhgn6dI|8Mn=)#_9kpg`q@tA8!-VuL+#uPC$| zZg&oE1+l#TYA9Izv(r$#<^v9CM(Zlj##$upxqlDf7O}f%Bvsd;5thSUqsIP`Fup5f*1Mq#v z%Ed`G#%Z*ilw71~>n>!%MOtZ$GY+xy4#w;60~!fnX(&Ba>|^Jc2L#4L$<@nxLs5N2 q(nrY|NIL0&!HG8-jYgx<*bW~+h<0}@GM`xh00004%P)9b)2)g92paL(i9{cLcOOt;HBu#1jH;My^e^WYIY`Tm zx==#ywGU^5gg0;-dK#9SqTqSI7{XpTs51Mo`ZhEP>V0Y&_Dq2K8pHOhlAF6q9}@@C@$p-4n^@LW*~M$00000NkvXX Hu0mjfmP@>b diff --git a/tests/snapshots/nanos/test_get_public_key_confirm_refused/00001.png b/tests/snapshots/nanos/test_get_public_key_confirm_refused/00001.png index dce1ab738131945fb8fab9d2430efceb1d35d823..2d939069ef8d6b7418263a31339cc281d6c93fa8 100644 GIT binary patch delta 470 zcmV;{0V)241n>ipB!9O_L_t(|ob8#>u7fZLhU>}p{tvthci}<^Q2dKU-5Fn&#V|@K zEvT%uq9}@@DE=MmtF5nrpB(*J{`k|8WV;XwIlld67;TNYn;KIb9cz>2`T5>HLNj44 zkLeb7FxOya!}9#dbs%ub5g$$=Cj)xNjR#cxs^g`Po_Q)s=zmDW6k5Stf*#f8?^9+5 z2#*8j4!6Jq+S^eFJ%py-axsmxdq7LLsZwdCO3mjoCATMG18C(u(|hL#Ib4noQhz`) zkGVry28hzhuf^F!YAY`YydsH8ttH45y$51pCs5gtxqgM?^>9{2{pmfpaCnlbB1rAQ zl~nYvq@sT%Du4RR*hsv=LY*8g5t_)Glpdwk%=a&6;E=?$Gc<4lNNdx4ng$hyF0=)_ z!RMG78Wl5T5q%N6TetaZIlUcy1TedMJy*X{X&umkV>Ktb0isziTtU3SS1SziR6TCwADueF|_& z^c%VXX2Aiy;YPHa*N|ofv?tNUVP*ef?z)Po?LLWut`TB!A3FL_t(|ob8#*ZUZq0MV+eo{}1k>SyZwJFJCZIPgTyUnF1zY zV}^{;G)>bq%@H13+TUOA#-0mFCO{vm0=}KO`cliWMs=kR>T*kCqMF}do1EMRcAz+?ZVt3+q zOVGs08JJGIcLMvXv?qI9mH@Rs1NS2>xJwn*DS}nVuO#xhbq7SVd;1evjgya(3nO9V zUH(uBx&u`eCVy(@FWgK;6gEZW+}5#wK}Y{29sQGt=&z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/test_get_public_key_confirm_refused/00003.png b/tests/snapshots/nanos/test_get_public_key_confirm_refused/00003.png index 30a64c8a3823888e7505ded812807c6bd6f76cc9..700668eb7e0b4e10ed5361e791c5fa344dec7e61 100644 GIT binary patch delta 421 zcmV;W0b2f&1iu52B!7lUL_t(|ob8#-5`-WKfN5v<{U5kPdvL~aJ+>m@m- z<1n4CxkU+b0$7;VTA34gNopkH@8*v~22?YtvO!sS@VXvAsBFbAWS{m`+o}(F__6qtI#4eoE$N51-aMlG*pAKm8|+duHCFUylSf4M@jkN@-Dce z1ya&HlI&KK_5E=>iqJ6lCHx4kJ&x9(sR_1q!~0**qR1)FooSN~l6O;y%hxF*7qVUk z^g+5${>`ukQv+c5mzC_1y4Bu7RU%3W*5sbjG)}Ub`5v!}AP9mW2yVb1wuUCnYHZY{ P00000NkvXXu0mjf7)Z!4 delta 504 zcmV@C(F%0-;9q6IBE14dU=|3CA@65EMm zTTln&ESS#t-D$4-4>^-SBw$s^sF$;#aoTNN6?RPwb|KkqSaSz=q0I5___qCq9R}nh zb6{lbn8M!|{eR{~XH^0gs9Z4m=W>-C?8&vd&~9Ar9Nr2M-taWkoz+;A!e(62*gX|b z3*6BV^U89-9iXZL5hMB0EJ8l?%b$R-Dx*#lEtSZ=jCc|^$aGbCU_Z(}_ zE>_PTFfHf;G8}GzA`t{;2T3GguKb%8AT_=&$4_BDz_B}k?b)x0V3Jq@)MmO+YvOiD uk8!KxTQ4Sooyf@vi~#qFq9}@@*o!9&&~HY?B8yP~00004uc>JMe8#E|AT#S4;a$4l#R@IsowLnAtUTG zToFYGA%qY@{$}4~-_Vm7Rt#sf<#$}=)VJ~BlvESR-Jq3=$jydfC?r!$iuAw9oGJ!U-M%Y zMJ+y&Ch%TCM>9}$(GT~2qZ!TIc>6skNTK;?O1Y^i^a^-9EC6{n9}GT=eBR!K!~g&Q M07*qoM6N<$g7>wSY5)KL delta 523 zcmV+m0`&dW0;B|xB!BBkL_t(|ob6f5ZUZq0+*a-Xe{c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GAK$^-W@-4AiRjLRg zN^3w3%%h33wa^I)yIpfCAAi4PIUE4ZO{b?Km?d}fT6HH2&km6 zxtYY2t?0?Vdg78W$~UYw9Gu>A)BWT-@}KCar_^|OW15hRAhQF2ZeR=QhlZ+`4$E`E zas@aBM%J9qx_?`Z@}YG&4+(>Ss6>vTo|8DdNh(RZPJp<3)s#@kFRJ-)IBvqU{IJh$I`BEW2o(ZqbW~Aj=iHXe`t5>R5M6Gbu7=jRaJU?# zsfH?7=n8p772u&LXYG3Td=fa%%;TKk?PR3-$H)hq9@NKv?0Taqe@qDagi X*_8FCW>a0$00000NkvXXu0mjf3c1oq delta 509 zcmVXeExJ3-#3HF+FKBXf2# zt1sV$wT1}c7QU6Q`Y6s$a3M%yU2;*9hWwB!zmdQ^Wri)19W z881A7Iv{7xbozTIXMdH9CxJ-7lB!WVGpA*G)S4=+M|7S-Y9q@IcWGyI2ZVBLg!dQr zYygmtmJ?>vAota)NCl(fBzmk zpl<_qCc6HSiVWr(pg8TFSq_6Ygq#QXB~=yBHJXmp0jDa42bpw&G~s<@aDZbJ;hemy zV$K5%Cj;+^My3vI7ONJrIim1X>zeBJ0E%Vwm0Anzb#_Qs{oLGApb}*;vS)SffQc|3 zS^Ye~D2k#eihcP46+e_Zt9MGH00000NkvXXu0mjfH+t{I diff --git a/tests/snapshots/nanos/test_get_public_key_confirm_refused/00007.png b/tests/snapshots/nanos/test_get_public_key_confirm_refused/00007.png deleted file mode 100644 index cfde67b4d8d5a664e05496ff1b161e39d1de0d91..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 500 zcmVICO{ii z0h?#^zSJ_<7?mVcd!#ahB!sW9rZSWyNsK46`mFaE6>|}33}!zMzQdYRjDbq0Hhh)| ztG;H)OBI#SYpuk}f~eR5IKcT+UvsTKbx-Q2hP-$1?-$oqgBXko0|fduRB*N-Ngpyk zYi}AO1SL=rf=bQ+Z;$Hy*+^z$JK=Xj(12kx(42Vg6pQ|@!6YCIP~|deat4yqXuDKl zX(AYfW|@qd1;|lJN!Rff{rm@E*duvhgn6dI|8Mn=)#_9kpg`q@tA8!-VuL+#uPC$| zZg&oE1+l#TYA9Izv(r$#<^v9CM(Zlj##$upxqlDf7O}f%Bvsd;5thSUqsIP`Fup5f*1Mq#v z%Ed`G#%Z*ilw71~>n>!%MOtZ$GY+xy4#w;60~!fnX(&Ba>|^Jc2L#4L$<@nxLs5N2 q(nrY|NIL0&!HG8-jYgx<*bW~+h<0}@GM`xh00004%P)9b)2)g92paL(i9{cLcOOt;HBu#1jH;My^e^WYIY`Tm zx==#ywGU^5gg0;-dK#9SqTqSI7{XpTs51Mo`ZhEP>V0Y&_Dq2K8pHOhlAF6q9}@@C@$p-4n^@LW*~M$00000NkvXX Hu0mjfmP@>b diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00000.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00000.png new file mode 100644 index 0000000000000000000000000000000000000000..e082b3c515cc7cb1940f5ebff3d06670575d4308 GIT binary patch literal 358 zcmV-s0h#`ZP)S|Nn#g&^@?xOb|tFYwJB}8fTDBP*9u$000000N`}|#oyo7U)wLXfhKt% zLmfcd)9||b4WKgVpM*D zL+BNPrl;*5AfC{Hg@#f@%G}n9LiN~Q+`FpLcoEx`oXjwr_3C0=AX=3GXMYp literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00001.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00001.png new file mode 100644 index 0000000000000000000000000000000000000000..5472cd148c6d7cdc8b7d41cc6c68f849f6a61e75 GIT binary patch literal 355 zcmV-p0i6DcP)c?x8#cdvV{x=L%X$E`tt0LW}aLDaBLN9~hPCoilIL zM2`exfQK=_!x$i;_mR;1NSya4$Tl|ghJ0V4USFCY<4e!>_EB;A|5Gf(O)tpU^{ad9 zw2yQL{USEvbN5D=UeGn_0zwHopr`;zmy9|U?M4YYWppQG1{Aye0rdJCpwEDcTlHU8 z@@kjwBoc{4B5?#?BS!c2$niVnLSZ{j za$gVTny^av^s9m}-;4YDcY^;OFkj-sJOo?$EBN(rlW`y-qMrd91idNKC0UJv8Mq>>Gp`a&BIHGrb7B&aQNXPAfn&l%ThU0K*6jeX zD$S>3RkCYVW}#Sqz|?S0ldmp8q@pa!POrP(a()-AD?uQ#kxjkNjU_{G^Is((zRExy z)Yk*9$<>NO5M9a5J<(4hq65s8?Neo1Wl3A(~dTD)>#usOWOp?Qf0 zI$ioexr?y=Ha&?C7co&7dK2y$Ac3)=7bMWt0UqlVQD+HyB@87%_usK{T<2DwrF3C6 zt%MLubm^!)5-+OU5I3`0a8#H9-+kJnJ5o}gn}2SW*{p_y;BH-~r*R%N#z zfdm8#j<-@o2{zfxX$!+hao6O{ua$bA-Qkay}kw_#GL`3ulzQ}~S>D!9u P00000NkvXXu0mjfV|V92 literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00003.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00003.png new file mode 100644 index 0000000000000000000000000000000000000000..9f97b45a02f77f5069b1c4af65fbc7f18cb8e0c6 GIT binary patch literal 536 zcmV+z0_XjSP)iy;dRP; z1IVrvpT<(;(2&F|5%4R%Qdp-=_gw1FPC>wCnWUY-MuXtyinGj7W(v}?>Z0p`6h_!J z-$@t17QnywN)qIE18j-SOnSzOhB#^fWp{6>A%@fO+3I zy-I^pflyv1@zU+o*F7p>ghM3-B~wk0=S*rb?g`|6ug>gWUtdQp$p1;{DfSY0C3y&E zd6~OVQftZ|EbhLJ1;CYh(+pSzSTx|jJrVb+4rVXnLO(D9Oz2!t4aJxTT0m;eJ&ja> z^svQ$E`5D3UI0ScmEd|8Bwr0_j`Xz_K)E=QcIN>=%=83p>WgZo3y)Nf$wR9silQir ar|LQPLd%0000Fhd#tru3OSvZ}2`x^oMUTE$zhU2i-P^jxH4e4vP!2k@6PC|!EB~6*?NFk{k zp$c7iqI_*?etdcwYhGX-SA}inO@c-`dDWygbtB!1Dwa{dNrpKMb+AVRehZ-Q#3LD_ zwly|qyPgGO2-ky+vw6HzP=ToF($4JOm%{lf`0W72vr@J>1MJAF>vN_63t*2jB?;o) zfND~;A(FCUggq@RT}T6#GAeuW>pc#pe8oL(;+Z#NQRlYauedD0y5`Nj|9o-{BFQWi zNuI-zfP0s!p)TlEqXO4El%T@URDnN(O6~K?NaYIrR@96?;kWc_1g^!nDQ*;Q8Yk3( zj=+|SjWuK`w+vVMNR9ekVK=^>g0NK38PU^@MHs=0?Enkx*=ww`M!Oq{I|D*|LEm;> ygZH_HD!0<2UM|b;n*_eFOV8^`k|arzT%QMT3r=~HHqwv)0000j}_{Dj70f0-FvEj=5D0-i?V{)IpB(;!nD_D8Y#_r)$SM-szP&<@CyKSw{mVMHsloC57y%MNu;;ut$XV?T=QYKV;n)&L6BjLp*)g21onepbsAd0 z6ZYQGrbeLB9QU)2jUHupc@{wtG63t+<{#G`#Y(WksugU>@-tYH0WzESO{~DE7ot`| z?*R19{WStZhsIIsMvN=T-hG)~0EP7zxufz^@y>wFolOuJ4T)^XT0f&nv0000I5x0-H0KVO5W7@0NjY_rR1~7d=9VAebqa>a`Dl29vfvt8|hUa_?k8& z6;aBeQ|L0X_SKYUZ~N+0`8`YdjeHp}2{CW3IBa8kQ9@&_GD#&d&cCZ89tQtDV1PTF zR7e91r%+aR`I#UMa3MX?SbuKZ$9q8Nw1jxf_O{nGI5E4qDB}AfW^T7FDUHo d?2h9c;R9;H5a6G+8ruK>002ovPDHLkV1klS$i)Bv literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00007.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00007.png new file mode 100644 index 0000000000000000000000000000000000000000..9d783deccf1d91edca026328fc3120ae7e63ff8f GIT binary patch literal 436 zcmV;l0ZaagP)|Np@*bis&B9=9nHLOVI*LV<)pNLs_TB}tMbNfN@%OY!^lo#CmrcuZQ9 z*SYv~rHc&XMv_K1o9|9~10Z`>KBT?&Zn`H#L9S#F4=24p%JC5wz>ixyxRn|eMj$eR zh>L)_%jCGVX~dE}cvo%VjYh+WpcY9Z2y#HX-NuFSVOUUf?FJtSnxH4nDTt&IEgeTO zWs5OWB4EhAbCDrR`t*#0IbhnMs9|o;Lj3JT>>_Hld?KbnE~w4e$IeO@2+4lzj*Qi; zsyg-V7yKOHuJ8i8e=gDokz6?otc-Cp_B

51}V5`eS;o)$uXC}&4qy*z7lGJR`e7^w$5j<^U| zt<28a8tgcqFptVqGmRpu$we)rHzNQS-_`QxCZ$*=etk+QP-9X* zz$cbjh1pFhcr<+cCpo|&3}utRC-!SvYE6rcoUJ8UYpz8xyq*~mp!N<`a6bggVUIeM pHVuT!oIuNgF5x6ek|arX@BvK(5hSYN)tCSP002ovPDHLkV1g`t$I$=) literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00009.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00009.png new file mode 100644 index 0000000000000000000000000000000000000000..fdd5105287cb43da1190e2c2448f1d93283a380c GIT binary patch literal 456 zcmV;(0XP1MP)pxt1K(yJLr8Hi8cjlqne#~2kHHzo*;G)^u$47ILjrCq_h~v z&O~(&8gU2o16&D2(_Lgvtn8 zrbls!i*>Hb02jYY*XbDzeJk;U1mMa;(K6j$h3F3$_ERC1O(|bc5-tW^`z~?X+2#Z( zd5VrJ_jSC1ZAMWBnA z3^*xMNF&;1&vqrydT>E=4S+EpJDR;-nQk#npCX?59-t8U25Uun!t=&21K8(77JXyz y7A@QJ2-3Xk9jSkLs7Ojx$iCAgNs=T<=H&+@StP;2nDUMQ0000qJ7EWj`&9`T!l5fR|avLGRN@6fI~I+3&>5!srh1y4DXJs<%XmJy}K>vtjg(}f*E#_4E*-3j56(4lfYPA6~b zU5}S&J8#Du7wz2I`x(;!*jih_`}ZPZ;K|Cn(EO}?4$sdZ_l}vyF;`|xQ}bVGW;43Z z(y1SSt{CAxTIGeiG^AXAN_O-%0J{?UPfd~(MfXb-410B6FVyYSKgr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/00015.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00015.png new file mode 100644 index 0000000000000000000000000000000000000000..cc729677d10a85bb91bb2f83db3f95d028021c4d GIT binary patch literal 465 zcmV;?0WSWDP)G53;x zGwNFeol&Fr67Ig@Vt~e?KiQT7v_ADj`Jmx7QN28T#r;v@h1HnG7wim2wQeJ&_1OTA zAYupXRz~r)Z*aQP*&wBtpx7PSqSuoOrwZ6O-2u?t%9ZF-N|O$Pj|*%H@@7~HLTQAq zA#~$oMw(b=@D6aXI~`(o9xEXtCWr%0h=qM$>$4DjTwyP15E2^H2dal21T20!&@*l) zn$SD)3KLZ&OltkYX$}}AXKL%uNctd>HM7txta%@vg*5LM7eh2XNv}r7vd0xQ4blwf z0jQwZRKG+T)8VzB8!2qa{cH98TDiX_mR$v0PQbrtHlXO2jSCQEf6c%{X|lo{v&fPg z8F?OH;qZ(_?(Z_Gev~2n;~XH@RcZw|`E1KhM`g)2b({k(RgUh%BlVwk9zYSU%C~eR zp&Xku9aze@(`c&;AqqF1DES*$=|g zj8z3-H$iRGXuXQ3tvCmurAl9sl{2uNdLn($Kq}-MFI#bc(q>`RrJDcb z`phr_jrm5JSY~7dnAn{T>2n?$#R~B_42T0p?}Z%H`Yc5MtFS+@(4;5iG^i5PP|jUV zRF>=)iT&sud6Bt_5>~W+Vx|K|$ywL>ixNKYHp#rG1sj0=63LET@?RaAnrt5pFnDD~UM!q!CYh<;QCYRcw zKz3feOty3Nz?1d2I4>|1()n8^B1lIJPC z+)cqE0-9bBl}BGw7NRoYyPGf_9VPV92n>QC2!dc4zNRuH_Rq26TL1t607*qoM6N<$ Ef__-ffB*mh literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00017.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00017.png new file mode 100644 index 0000000000000000000000000000000000000000..b511cebddb844b652e34a8747f8e443e474dd7b8 GIT binary patch literal 456 zcmV;(0XP1MP)oknDgWq1T+D_5HmE!mr|-%rP!)Z)lIG{%10fJG1dX4xrNKXZhO~HIy*Iw z1a6=KHYun|BV6*G2TK#Tv5Wu}yWImm$ANM|5Nb$K&_9SD1S_YplzHVLtSr_lX7Z~y1m+&jv5W4 zA=5MucsSt^P_4{PRt;^8@#gWwCaRY8xoqEKZ%l#9xIwG~sJWGUz-}g+SH2U?E65Zd z2e3UfJJ1`}k779Lc)4ddo)Lgsx?pY`GNgpLS#vUC0S9;=gc{NMTL?c?noW9yYmKgo zE|Pr?+<8=PG*5}%k&{f<9loOV3&9R>QL?V}7bSi0Bp-MSEyM@D!wcbJ-t^flIC)|c z2m36;q8@;WPt49!Ig`k_PfgB}Y0zi(^%6>NmdDU!T6*13DEuR<)hHL#p3bXLGLBn4 zpmJe}VRufml%^kRfxiQ`@r+GOP-FRFG|gwh`X$Mm^vZToSVw?R=ujd&%cThuqO6KL xTE8saa3D%(Id7szIFd;|N&hKn{Uk{eQ(gs?9Tschj|>0+002ovPDHLkV1hq+%dh|d literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00019.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00019.png new file mode 100644 index 0000000000000000000000000000000000000000..2ca2342197e6ffe6e9d6ee22f615df5f4a3028eb GIT binary patch literal 478 zcmV<40U`d0P)WpuuZgHunJLJF!%!b#7~S`TmO0>$YB`WU_e(A+mpt5l*uw*;A0 zDr7^DHEtmYg%P@jsg95FG_j7e2bkDhx;%Se6=s|XvH=6mLh^lQW~xE}VG}@4{y0g&&1A z%_`OUS<#Ljb6RnoDJ9E^8KolfgkUa{=Fr)6rj&N4`bu(N83Lt4bP))fDWc^IA^qEI z4I_Hr`dZ~@lSpNoyLi3_)L`jfNrdzaSJQEL zh&S~B<=yJCSK-op%6*8c*r&}K%B?yl;}nba+uM^9L(o<%a0#yfihG|PXM$iDe;lhO U%{WZ1UH||907*qoM6N<$f=KArCIA2c literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00020.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00020.png new file mode 100644 index 0000000000000000000000000000000000000000..2a41e2cb23f6e72e4e94e185091ca80576560a59 GIT binary patch literal 464 zcmV;>0WbcEP)l&MV0rP-bRkbeU2}kL!v7}VWzuob`#2KED5w@s(ZS15*B?1kNLz7cL18$m zwv0H}kfX>1AI|U!DDv^}!cp3|#>w==KP4*7v%tQ6{~D~tQ(!YX7#jfSZsi)dEu{)F z-bp+XxPjLAY(d2~f~}ud@+@vHmhr3r6TjmjR>2d_AKCzW9rZKvzR>Db{bdOtHb04_?__5Pwn3}$k}U1%Y0cn&XwqkHvV zwpH(-V-n(4X(unHcB!{=4S`)N0(LZOzgFa4JSSXCp={`r@~{;MC~f?>0@|1I`i7y0000%{TvV9e zb+(N3(P0;O1k)>^MY&sCt-7(yg_c4uQMFdCqJH$@9&-~w!>ybKid~q07su}JXpn6| z*7&rbu8rUXLaUy^GsH5U6<`u~yu~DWtdfXj0SWM43$3X2T?pS**h?eW{(}PLwJ}l; z<=%CQgDJ;V;&t?iT*TH;!;aCf%uIlno_(XgDVc*v-mnX8#2Y?`H)2wF+dEuHI_ayV zl`1#fHseQ0WbcEP)H9x$7o9~;J;War6>lBBRhs}Rh$fg29LI4S$63O|*xvi~G5i#-nDc(! zj9)Ec2e1!RGSl3~jA}x=H%`c&1*C(CZipRuPSK@M~!6#x+yezT(WH!c?m^ zjjCLe$&86i&j4vk#?;0fXQwCLqGlseE0NUq7Ms9sbTBsn)ZNN4pjg8+XX72RTf#+V z?J{D_5|k_>(#pFP!(5zaWCob{9aXG?$J&`bGavw?CjwoRm2KgJ3VW;ATt=Q<8)+w# z$ARWJ6^6Vh4ZF|>a+Bsn^%K2+F*yK3jGXKJL-81_Xm=iv6c=etjTYLXfTYNZv7RalORq~(ITjmA>L|lb1&ol2=EY2}QfzKT zqmucdZ=!}pj)e1k zyeZ!;q66pyy;JeL84R7sPoScmk-p@ytJ`8O8Aw3(LZCIlXbT@y*h>;v$Ca{1y`oMw zvfX+5Fy%?x(1ksb7cnP_uNeKE!3juFvTpPjrE)NnFRVff@rCE`LQDv6)-%HexUz5Y zB+b^NHo~Qd?*UD#693}s65H~Wv^C8PZ2hy=B`Z>ognhS?J_+bjqp@`4n{jr~F0S~X zTTy=K==vQ5HRJG`lxJz!#XCaK{mmeUhy*mHMr!N#X|vydN`HqxImC5Cv7~yOc8ae< z#17C8VW&2{Bpuoolw*0nBpGEj6v0$vXHwBGisJwA0;gjz(DnLSEC2ui07*qoM6N<$ Ef&;bEWdHyG literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00024.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00024.png new file mode 100644 index 0000000000000000000000000000000000000000..2470abae4cb775d754f71e37a412a095b8af5e85 GIT binary patch literal 468 zcmV;_0W1EAP)yEn1QZ@^VAEl(OHZ~>^fl@q{bmx9VwVVhy05W9?U2tidC zX@y-6?wHBV#4>IkU}AR^(I`=N#5M~*3}69VH$rh|eH6m46t?PUggDwGiWFE`I?n2g zV0fJ_W`l4~%NPm4l(@oDGqUig|<);@guU4b=6 z^^d^Yh7qQz2%1wXU?yG8cU~%?X!8EO>DB6i0aXPg0S95X342pzrS2%vw^yd~hQ&LX z^dJ)%QsZySJ@`Dx$h1=bN_r!}im~F&yeG-llbJ?vZJT!C<^jS%S5>jkkYkz=RF2OT z!U%-{EWHVwVy=98o9GN@^S>f)GJFo%VftTC!Ea(~{K}9di4iaTF)YX%At_z}0000< KMNUMnLSTY2QO^4S literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_long_tx/00025.png b/tests/snapshots/nanos/test_sign_tx_long_tx/00025.png new file mode 100644 index 0000000000000000000000000000000000000000..c7c4212cb09b6385f0cef7ba7def84c1a617d383 GIT binary patch literal 447 zcmV;w0YLtVP)m)3PaiG`EKYM5%KAI{+#V;w-vt$YpMtlF{a71)3aVG6RQPYTM? z2!DaD8}hJT7W9k&6T9;+8YR^>u)&PYfH|P|T1Y{y&qDmH0v`okiW71g?L}vpodvG= zsq)J6BC#F4BNrK~s9{IzM@BlJm!5sCzbWp6ncOf7ZNv@t;f)w)Ui~R>%($nT4P1rY zKEz6g<*Ajg1u-o}WaS4~%M@z&aw$Ks4Z27s~rVTRHvuZ zym2)&gMV1+eQ=kZAy^_|+f40%Uf zZ-m~VIVtq5OA**fxtau5g(n5&PsOm+Vk)-`SdPUH0M%LMqp!o@pQ+Ujntx3CH+ATa z8@KlW63!T;6A623-S&lV7Gn*Nn9M`kKnU&DsJ~E_D6y`Fp7S;C?d%Wehyd)iS&#DR uL_TTZ&cZ3zdI0MC3r}xB5ClOG+>H;=KQO{KP4cY(0000eu6TU0#}3R2sU(|P1c zX?O{FAQv%5itp(CjB@}?lBw5DbXOe%TM_xsBs3U!<_3Y zO6IX!0H|KjXbg;-%yRbsOEM81?@h4J0NyoxbFsM(;q^$}mfesH1?)tI1wjx5L9jYs XO}HG>PNpS|Nn#g&^@?xOb|tFYwJB}8fTDBP*9u$000000N`}|#oyo7U)wLXfhKt% zLmfcd)9||b4WKgVpM*D zL+BNPrl;*5AfC{Hg@#f@%G}n9LiN~Q+`FpLcoEx`oXjwr_3C0=AX=3GXMYp literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_refused/00001.png b/tests/snapshots/nanos/test_sign_tx_refused/00001.png new file mode 100644 index 0000000000000000000000000000000000000000..5472cd148c6d7cdc8b7d41cc6c68f849f6a61e75 GIT binary patch literal 355 zcmV-p0i6DcP)c?x8#cdvV{x=L%X$E`tt0LW}aLDaBLN9~hPCoilIL zM2`exfQK=_!x$i;_mR;1NSya4$Tl|ghJ0V4USFCY<4e!>_EB;A|5Gf(O)tpU^{ad9 zw2yQL{USEvbN5D=UeGn_0zwHopr`;zmy9|U?M4YYWppQG1{Aye0rdJCpwEDcTlHU8 z@@kjwBoc{4B5?#?BS!c2$niVnLSZ{j za$gVTny^av^s9m}-;4YDcY^;OFkj-sJOo?$EBN(rlW`y-qMrd91idNKC0UJv8Mq>>Gp`a&BIHGrb7B&aQNXPAfn&l%ThU0K*6jeX zD$S>3RkCYVW}#Sqz|?S0ldmp8q@pa!POrP(a()-AD?uQ#kxjkNjU_{G^Is((zRExy z)Yk*9$<>NO5M9a5J<(4hq65s8?Neo1Wl3A(~dTD)>#usOWOp?Qf0 zI$ioexr?y=Ha&?C7co&7dK2y$Ac3)=7bMWt0UqlVQD+HyB@87%_usK{T<2DwrF3C6 zt%MLubm^!)5-+OU5I3`0a8#H9-+kJnJ5o}gn}2SW*{p_y;BH-~r*R%N#z zfdm8#j<-@o2{zfxX$!+hao6O{ua$bA-Qkay}kw_#GL`3ulzQ}~S>D!9u P00000NkvXXu0mjfV|V92 literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_refused/00003.png b/tests/snapshots/nanos/test_sign_tx_refused/00003.png new file mode 100644 index 0000000000000000000000000000000000000000..9f97b45a02f77f5069b1c4af65fbc7f18cb8e0c6 GIT binary patch literal 536 zcmV+z0_XjSP)iy;dRP; z1IVrvpT<(;(2&F|5%4R%Qdp-=_gw1FPC>wCnWUY-MuXtyinGj7W(v}?>Z0p`6h_!J z-$@t17QnywN)qIE18j-SOnSzOhB#^fWp{6>A%@fO+3I zy-I^pflyv1@zU+o*F7p>ghM3-B~wk0=S*rb?g`|6ug>gWUtdQp$p1;{DfSY0C3y&E zd6~OVQftZ|EbhLJ1;CYh(+pSzSTx|jJrVb+4rVXnLO(D9Oz2!t4aJxTT0m;eJ&ja> z^svQ$E`5D3UI0ScmEd|8Bwr0_j`Xz_K)E=QcIN>=%=83p>WgZo3y)Nf$wR9silQir ar|LQPLd%0000Fhd#tru3OSvZ}2`x^oMUTE$zhU2i-P^jxH4e4vP!2k@6PC|!EB~6*?NFk{k zp$c7iqI_*?etdcwYhGX-SA}inO@c-`dDWygbtB!1Dwa{dNrpKMb+AVRehZ-Q#3LD_ zwly|qyPgGO2-ky+vw6HzP=ToF($4JOm%{lf`0W72vr@J>1MJAF>vN_63t*2jB?;o) zfND~;A(FCUggq@RT}T6#GAeuW>pc#pe8oL(;+Z#NQRlYauedD0y5`Nj|9o-{BFQWi zNuI-zfP0s!p)TlEqXO4El%T@URDnN(O6~K?NaYIrR@96?;kWc_1g^!nDQ*;Q8Yk3( zj=+|SjWuK`w+vVMNR9ekVK=^>g0NK38PU^@MHs=0?Enkx*=ww`M!Oq{I|D*|LEm;> ygZH_HD!0<2UM|b;n*_eFOV8^`k|arzT%QMT3r=~HHqwv)0000%5#E^A7xvy3!~c*55`ix$LP?UD=|(0 zc)8k!kOyc&z$t~@?=T+J$`hbcRI>pA0)XAETreHhdZ{-(-FOxCZF(kPK1j$m#-0MpfS z(yy7_$boSxN0;(%mxDBAeX3R?<%(-Rpf?7-YHe^zK|(jNRfg2~RK7eHuC>WFXOzv( fBuSDaNiNI>{GSBuM&fnH00000NkvXXu0mjfJomaM literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_refused/00006.png b/tests/snapshots/nanos/test_sign_tx_refused/00006.png new file mode 100644 index 0000000000000000000000000000000000000000..c88c94e48ba2dad3a989cf9c0eea52d947b0c8f4 GIT binary patch literal 445 zcmV;u0Yd(XP)NS=aDY(;QI4QqT;=fdinqgDS0N}DtYx9H<%jglDj3}Z`u37K2VdtnRNIg{ zQo9qj+r}5?WQYTlV0!*D>-#5sFq5mOkWa3%5BtR0yzGC$Qk{W=4(wBT!pbLM`@@b& z4tXFyI{>BK(X-GTY+kdT#9zpPE2lS5o{mmWl31-TbA$Vg2Hd_(}<)7U#milkaa n#NnbTl?W#s1VIo4!O3_5nfMmnhF&;700000NkvXXu0mjfH)+B6 literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_refused/00007.png b/tests/snapshots/nanos/test_sign_tx_refused/00007.png new file mode 100644 index 0000000000000000000000000000000000000000..28d495204a126ce3f4fe21134f7e8b03c3618064 GIT binary patch literal 419 zcmV;U0bKrxP)v>nU=1vGz9d+Du=q2ovM)OK(oKU3^o(Pt12hO6(vyPXE>I|`+8}*r6^!lyx7)@K+}xdyKL!J6Po%aH)@*0T znhZ&R5{%_Pi@tv%2Q%44g?zHhKJ1hA!n@uT_u-%vLHYNfLrl&CD5$swf1S|Nn#g&^@?xOb|tFYwJB}8fTDBP*9u$000000N`}|#oyo7U)wLXfhKt% zLmfcd)9||b4WKgVpM*D zL+BNPrl;*5AfC{Hg@#f@%G}n9LiN~Q+`FpLcoEx`oXjwr_3C0=AX=3GXMYp literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_short_tx/00001.png b/tests/snapshots/nanos/test_sign_tx_short_tx/00001.png new file mode 100644 index 0000000000000000000000000000000000000000..5472cd148c6d7cdc8b7d41cc6c68f849f6a61e75 GIT binary patch literal 355 zcmV-p0i6DcP)c?x8#cdvV{x=L%X$E`tt0LW}aLDaBLN9~hPCoilIL zM2`exfQK=_!x$i;_mR;1NSya4$Tl|ghJ0V4USFCY<4e!>_EB;A|5Gf(O)tpU^{ad9 zw2yQL{USEvbN5D=UeGn_0zwHopr`;zmy9|U?M4YYWppQG1{Aye0rdJCpwEDcTlHU8 z@@kjwBoc{4B5?#?BS!c2$niVnLSZ{j za$gVTny^av^s9m}-;4YDcY^;OFkj-sJOo?$EBN(rlW`y-qMrd91idNKC0UJv8Mq>>Gp`a&BIHGrb7B&aQNXPAfn&l%ThU0K*6jeX zD$S>3RkCYVW}#Sqz|?S0ldmp8q@pa!POrP(a()-AD?uQ#kxjkNjU_{G^Is((zRExy z)Yk*9$<>NO5M9a5J<(4hq65s8?Neo1Wl3A(~dTD)>#usOWOp?Qf0 zI$ioexr?y=Ha&?C7co&7dK2y$Ac3)=7bMWt0UqlVQD+HyB@87%_usK{T<2DwrF3C6 zt%MLubm^!)5-+OU5I3`0a8#H9-+kJnJ5o}gn}2SW*{p_y;BH-~r*R%N#z zfdm8#j<-@o2{zfxX$!+hao6O{ua$bA-Qkay}kw_#GL`3ulzQ}~S>D!9u P00000NkvXXu0mjfV|V92 literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_short_tx/00003.png b/tests/snapshots/nanos/test_sign_tx_short_tx/00003.png new file mode 100644 index 0000000000000000000000000000000000000000..9f97b45a02f77f5069b1c4af65fbc7f18cb8e0c6 GIT binary patch literal 536 zcmV+z0_XjSP)iy;dRP; z1IVrvpT<(;(2&F|5%4R%Qdp-=_gw1FPC>wCnWUY-MuXtyinGj7W(v}?>Z0p`6h_!J z-$@t17QnywN)qIE18j-SOnSzOhB#^fWp{6>A%@fO+3I zy-I^pflyv1@zU+o*F7p>ghM3-B~wk0=S*rb?g`|6ug>gWUtdQp$p1;{DfSY0C3y&E zd6~OVQftZ|EbhLJ1;CYh(+pSzSTx|jJrVb+4rVXnLO(D9Oz2!t4aJxTT0m;eJ&ja> z^svQ$E`5D3UI0ScmEd|8Bwr0_j`Xz_K)E=QcIN>=%=83p>WgZo3y)Nf$wR9silQir ar|LQPLd%0000Fhd#tru3OSvZ}2`x^oMUTE$zhU2i-P^jxH4e4vP!2k@6PC|!EB~6*?NFk{k zp$c7iqI_*?etdcwYhGX-SA}inO@c-`dDWygbtB!1Dwa{dNrpKMb+AVRehZ-Q#3LD_ zwly|qyPgGO2-ky+vw6HzP=ToF($4JOm%{lf`0W72vr@J>1MJAF>vN_63t*2jB?;o) zfND~;A(FCUggq@RT}T6#GAeuW>pc#pe8oL(;+Z#NQRlYauedD0y5`Nj|9o-{BFQWi zNuI-zfP0s!p)TlEqXO4El%T@URDnN(O6~K?NaYIrR@96?;kWc_1g^!nDQ*;Q8Yk3( zj=+|SjWuK`w+vVMNR9ekVK=^>g0NK38PU^@MHs=0?Enkx*=ww`M!Oq{I|D*|LEm;> ygZH_HD!0<2UM|b;n*_eFOV8^`k|arzT%QMT3r=~HHqwv)0000?5 zO+iH((UJwrBtH{-1)QS0?h+|@Dgcp|r%g`f+q00&{#f-J4#!vj2DlPHqU7yg4J|%-;$NVy2o-P5#!k+}rQedO*BF{rJkMqQw&X>-Dw;}jBm_TE=?d*z`ILyB?rWPOBAJIX+Y1mF^T9mvV3_wxG+Yry2qARt#sf<#$}=)VJ~ zBlvESR-Jq3=$jydfC?r!$iuAw9oGJ!U-M%YMJ+y&Ch%TCM^JUq5BGkf8O_{y`#mQ} nq4{V^xv44i3V1v$0C_ea3_go|-rj`700000NkvXXu0mjfd&QW1 literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanos/test_sign_tx_short_tx/00007.png b/tests/snapshots/nanos/test_sign_tx_short_tx/00007.png new file mode 100644 index 0000000000000000000000000000000000000000..68ffb394818b8a1144c7bdffd0e413ebb828eca8 GIT binary patch literal 455 zcmV;&0XY7NP)ktdMRJ7$jtQV?E0Jw2 zEX<>cv$fC(3cFo%Dj&aPIUE4ZO{b?Km?d}fT6HH2&km6xtYY2t?0?Vdg78W$~UYw9Gu>A)BWT- z@}KCar_^|OW15hRAhQF2ZeR=QhlZ+`4$E`Eas@aBM%J9qx?7F%p>;S934?&BM2?}J zlQ_IdDoMLegCO&ry@(xg1W(hjcYU6aul_=@0gb}dlu*bos`+p@Zo;(uu+MEe@Hx8( z6#{B>R8eT>+?LGx?SfhmU2dMPhSs@oxE!RZhALO+^5VzU*c}iW!q%g(soRz@=ckE) x>DmKY`<^6J1d`P&@3BZxxL8|~DvF{=%pcj5^`~Z2UDE&n002ovPDHLkV1l(T)B*qi literal 0 HcmV?d00001 diff --git a/tests/test_sign_cmd.py b/tests/test_sign_cmd.py index fb9affb..8e64813 100644 --- a/tests/test_sign_cmd.py +++ b/tests/test_sign_cmd.py @@ -1,141 +1,142 @@ -# import pytest - -# from application_client.boilerplate_transaction import Transaction -# from application_client.boilerplate_command_sender import BoilerplateCommandSender, Errors -# from application_client.boilerplate_response_unpacker import unpack_get_public_key_response, unpack_sign_tx_response -# from ragger.error import ExceptionRAPDU -# from ragger.navigator import NavInsID -# from utils import ROOT_SCREENSHOT_PATH, check_signature_validity - -# # In this tests we check the behavior of the device when asked to sign a transaction - - -# # In this test se send to the device a transaction to sign and validate it on screen -# # The transaction is short and will be sent in one chunk -# # We will ensure that the displayed information is correct by using screenshots comparison -# def test_sign_tx_short_tx(firmware, backend, navigator, test_name): -# # Use the app interface instead of raw interface -# client = BoilerplateCommandSender(backend) -# # The path used for this entire test -# path: str = "m/44'/1'/0'/0/0" - -# # First we need to get the public key of the device in order to build the transaction -# rapdu = client.get_public_key(path=path) -# _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) - -# # Create the transaction that will be sent to the device for signing -# transaction = Transaction( -# nonce=1, -# to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", -# value=666, -# memo="For u EthDev" -# ).serialize() - -# # Send the sign device instruction. -# # As it requires on-screen validation, the function is asynchronous. -# # It will yield the result when the navigation is done -# with client.sign_tx(path=path, transaction=transaction): -# # Validate the on-screen request by performing the navigation appropriate for this device -# if firmware.device.startswith("nano"): -# navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, -# [NavInsID.BOTH_CLICK], -# "Approve", -# ROOT_SCREENSHOT_PATH, -# test_name) -# else: -# navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, -# [NavInsID.USE_CASE_REVIEW_CONFIRM, -# NavInsID.USE_CASE_STATUS_DISMISS], -# "Hold to sign", -# ROOT_SCREENSHOT_PATH, -# test_name) - -# # The device as yielded the result, parse it and ensure that the signature is correct -# response = client.get_async_response().data -# _, der_sig, _ = unpack_sign_tx_response(response) -# assert check_signature_validity(public_key, der_sig, transaction) - - -# # In this test se send to the device a transaction to sign and validate it on screen -# # This test is mostly the same as the previous one but with different values. -# # In particular the long memo will force the transaction to be sent in multiple chunks -# def test_sign_tx_long_tx(firmware, backend, navigator, test_name): -# # Use the app interface instead of raw interface -# client = BoilerplateCommandSender(backend) -# path: str = "m/44'/1'/0'/0/0" - -# rapdu = client.get_public_key(path=path) -# _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) - -# transaction = Transaction( -# nonce=1, -# to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", -# value=666, -# memo=("This is a very long memo. " -# "It will force the app client to send the serialized transaction to be sent in chunk. " -# "As the maximum chunk size is 255 bytes we will make this memo greater than 255 characters. " -# "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.") -# ).serialize() - -# with client.sign_tx(path=path, transaction=transaction): -# if firmware.device.startswith("nano"): -# navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, -# [NavInsID.BOTH_CLICK], -# "Approve", -# ROOT_SCREENSHOT_PATH, -# test_name) -# else: -# navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, -# [NavInsID.USE_CASE_REVIEW_CONFIRM, -# NavInsID.USE_CASE_STATUS_DISMISS], -# "Hold to sign", -# ROOT_SCREENSHOT_PATH, -# test_name) -# response = client.get_async_response().data -# _, der_sig, _ = unpack_sign_tx_response(response) -# assert check_signature_validity(public_key, der_sig, transaction) - - -# # Transaction signature refused test -# # The test will ask for a transaction signature that will be refused on screen -# def test_sign_tx_refused(firmware, backend, navigator, test_name): -# # Use the app interface instead of raw interface -# client = BoilerplateCommandSender(backend) -# path: str = "m/44'/1'/0'/0/0" - -# rapdu = client.get_public_key(path=path) -# _, pub_key, _, _ = unpack_get_public_key_response(rapdu.data) - -# transaction = Transaction( -# nonce=1, -# to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", -# value=666, -# memo="This transaction will be refused by the user" -# ).serialize() - -# if firmware.device.startswith("nano"): -# with pytest.raises(ExceptionRAPDU) as e: -# with client.sign_tx(path=path, transaction=transaction): -# navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, -# [NavInsID.BOTH_CLICK], -# "Reject", -# ROOT_SCREENSHOT_PATH, -# test_name) - -# # Assert that we have received a refusal -# assert e.value.status == Errors.SW_DENY -# assert len(e.value.data) == 0 -# else: -# for i in range(3): -# instructions = [NavInsID.USE_CASE_REVIEW_TAP] * i -# instructions += [NavInsID.USE_CASE_REVIEW_REJECT, -# NavInsID.USE_CASE_CHOICE_CONFIRM, -# NavInsID.USE_CASE_STATUS_DISMISS] -# with pytest.raises(ExceptionRAPDU) as e: -# with client.sign_tx(path=path, transaction=transaction): -# navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, -# test_name + f"/part{i}", -# instructions) -# # Assert that we have received a refusal -# assert e.value.status == Errors.SW_DENY -# assert len(e.value.data) == 0 +import pytest + +from application_client.boilerplate_transaction import Transaction +from application_client.boilerplate_command_sender import BoilerplateCommandSender, Errors +from application_client.boilerplate_response_unpacker import unpack_get_public_key_response, unpack_sign_tx_response +from ragger.error import ExceptionRAPDU +from ragger.navigator import NavInsID +from utils import ROOT_SCREENSHOT_PATH, check_signature_validity + +# In this tests we check the behavior of the device when asked to sign a transaction + + +# In this test se send to the device a transaction to sign and validate it on screen +# The transaction is short and will be sent in one chunk +# We will ensure that the displayed information is correct by using screenshots comparison +def test_sign_tx_short_tx(firmware, backend, navigator, test_name): + # Use the app interface instead of raw interface + client = BoilerplateCommandSender(backend) + # The path used for this entire test + path: str = "m/44'/1'/0'/0/0" + + # First we need to get the public key of the device in order to build the transaction + rapdu = client.get_public_key(path=path) + _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) + + # Create the transaction that will be sent to the device for signing + transaction = Transaction( + nonce=1, + to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", + value=666, + memo="For u EthDev" + ).serialize() + + # Send the sign device instruction. + # As it requires on-screen validation, the function is asynchronous. + # It will yield the result when the navigation is done + with client.sign_tx(path=path, transaction=transaction): + # Validate the on-screen request by performing the navigation appropriate for this device + if firmware.device.startswith("nano"): + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Approve", + ROOT_SCREENSHOT_PATH, + test_name) + else: + navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, + [NavInsID.USE_CASE_REVIEW_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS], + "Hold to sign", + ROOT_SCREENSHOT_PATH, + test_name) + + # The device as yielded the result, parse it and ensure that the signature is correct + response = client.get_async_response().data + _, der_sig, _ = unpack_sign_tx_response(response) + + assert check_signature_validity(public_key, der_sig, transaction) + + +# In this test se send to the device a transaction to sign and validate it on screen +# This test is mostly the same as the previous one but with different values. +# In particular the long memo will force the transaction to be sent in multiple chunks +def test_sign_tx_long_tx(firmware, backend, navigator, test_name): + # Use the app interface instead of raw interface + client = BoilerplateCommandSender(backend) + path: str = "m/44'/1'/0'/0/0" + + rapdu = client.get_public_key(path=path) + _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) + + transaction = Transaction( + nonce=1, + to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", + value=666, + memo=("This is a very long memo. " + "It will force the app client to send the serialized transaction to be sent in chunk. " + "As the maximum chunk size is 255 bytes we will make this memo greater than 255 characters. " + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.") + ).serialize() + + with client.sign_tx(path=path, transaction=transaction): + if firmware.device.startswith("nano"): + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Approve", + ROOT_SCREENSHOT_PATH, + test_name) + else: + navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, + [NavInsID.USE_CASE_REVIEW_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS], + "Hold to sign", + ROOT_SCREENSHOT_PATH, + test_name) + response = client.get_async_response().data + _, der_sig, _ = unpack_sign_tx_response(response) + assert check_signature_validity(public_key, der_sig, transaction) + + +# Transaction signature refused test +# The test will ask for a transaction signature that will be refused on screen +def test_sign_tx_refused(firmware, backend, navigator, test_name): + # Use the app interface instead of raw interface + client = BoilerplateCommandSender(backend) + path: str = "m/44'/1'/0'/0/0" + + rapdu = client.get_public_key(path=path) + _, pub_key, _, _ = unpack_get_public_key_response(rapdu.data) + + transaction = Transaction( + nonce=1, + to="0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", + value=666, + memo="This transaction will be refused by the user" + ).serialize() + + if firmware.device.startswith("nano"): + with pytest.raises(ExceptionRAPDU) as e: + with client.sign_tx(path=path, transaction=transaction): + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Reject", + ROOT_SCREENSHOT_PATH, + test_name) + + # Assert that we have received a refusal + assert e.value.status == Errors.SW_DENY + assert len(e.value.data) == 0 + else: + for i in range(3): + instructions = [NavInsID.USE_CASE_REVIEW_TAP] * i + instructions += [NavInsID.USE_CASE_REVIEW_REJECT, + NavInsID.USE_CASE_CHOICE_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS] + with pytest.raises(ExceptionRAPDU) as e: + with client.sign_tx(path=path, transaction=transaction): + navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, + test_name + f"/part{i}", + instructions) + # Assert that we have received a refusal + assert e.value.status == Errors.SW_DENY + assert len(e.value.data) == 0