Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change blindsign flow according to guideline. #248

Merged
merged 5 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tests/integration/touch/snapshots/flex/test_basic/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified tests/integration/touch/snapshots/stax/test_basic/settings.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
spalmer25 marked this conversation as resolved.
Show resolved Hide resolved
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
7 changes: 1 addition & 6 deletions tests/integration/touch/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright 2023 Trilitech <[email protected]>
import os
spalmer25 marked this conversation as resolved.
Show resolved Hide resolved

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,13 +24,7 @@
app.welcome.settings()
app.assert_settings()

app.settings.toggle_blindsigning()
app.assert_settings(blindsigning=True)

app.settings.toggle_expert_mode()
app.assert_settings(blindsigning=True, expert_mode=True)

app.settings.toggle_blindsigning()
app.assert_settings(expert_mode=True)

app.settings.toggle_expert_mode()
Expand Down
39 changes: 3 additions & 36 deletions tests/integration/touch/test_blindsign_too_deep.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,24 @@

app.assert_home()

# Blindsigning disabled (default state)
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()

app.assert_screen("tbtd_review_0")
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()

app.assert_screen("blindsign_warning")
with app.fading_screen("loading_operation"):
app.review.next()
app.process_blindsign_warnings("loading_operation")
app.send_apdu("800f82001211020000000c02000000070200000002002a")

app.assert_screen("tbtd_review_1")
app.review.next()
app.assert_screen("operation_sign")

expected_apdu = "93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
app.review_confirm_signing(expected_apdu)

app.assert_home()

# Blindsign enabled
app.welcome.settings()
app.assert_settings(blindsigning=True)
# blind sign will be on because of previous test run.
app.settings.exit()

app.assert_home()

send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app,"800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("tbtd_review_0")
app.assert_screen("tbtd_start_review_blindsign")
app.review.next()
app.assert_screen("too_deep_blindsign_notify")
app.review.next()
app.assert_screen("blindsign_warning")
with app.fading_screen("loading_operation"):
app.review.next()
app.send_apdu("800f82001211020000000c02000000070200000002002a")

app.assert_screen("tbtd_review_1")
app.review.next()

app.assert_screen("operation_sign")

expected_apdu = "93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
app.review_confirm_signing(expected_apdu)

app.assert_home()
app.quit()
65 changes: 27 additions & 38 deletions tests/integration/touch/test_blindsign_too_deep_rejections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,82 +17,71 @@
tezos_app,
send_initialize_msg,
send_payload,
verify_err_reject_response
verify_err_reject_response,
reject_flow
)

def toggle_blindsigning(app):
app.assert_home()
app.welcome.settings()
app.settings.toggle_blindsigning()
app.settings.exit()
app.assert_home()

if __name__ == "__main__":
app = tezos_app(__file__)

app.assert_home()

# Rejecting at error screen (blindsign disabled)
# Rejecting at 1st warning msg
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("too_deep_expression")
app.assert_screen("tbtdr_review_0")
app.review.next()
verify_err_reject_response(app, "too_deep_enable_blindsign")
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.confirm()
reject_flow(app,"9405")



# Rejecting at error screen (blindsign enabled)
toggle_blindsigning(app) # Enable blindsigning

# Rejecting at 2nd warning
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("too_deep_expression")
app.assert_screen("tbtdr_review_0")
app.review.next()
verify_err_reject_response(app, "too_deep_blindsign_notify")
app.assert_screen("unsafe_operation_warning_1")
app.review.reject()
verify_err_reject_response(app, "unsafe_operation_warning_2")

# Rejecting at blindsigning splash screen
toggle_blindsigning(app) # Disable blindsigning at home
# Rejecting at review blindsign operation
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("too_deep_expression")
app.assert_screen("tbtdr_review_0")
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
verify_err_reject_response(app,"blindsign_warning")
app.process_blindsign_warnings("loading_operation")
app.send_apdu("800f82001211020000000c02000000070200000002002a")
verify_err_reject_response(app, "tbtdr_start_review_blindsign")

# Rejecting at blindsign review screen
toggle_blindsigning(app) # Disable blindsigning at home
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("too_deep_expression")
app.assert_screen("tbtdr_review_0")
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
app.assert_screen("blindsign_warning")
with app.fading_screen("loading_operation"):
app.review.next()
app.process_blindsign_warnings("loading_operation")
app.send_apdu("800f82001211020000000c02000000070200000002002a")
app.assert_screen("tbtdr_start_review_blindsign")
app.review.next()
verify_err_reject_response(app,"tbtd_review_1")


# Rejecting at final sign operation screen
toggle_blindsigning(app) # Disable blindsigning at home
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.next()
app.assert_screen("too_deep_expression")
app.assert_screen("tbtdr_review_0")
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
app.assert_screen("blindsign_warning")
with app.fading_screen("loading_operation"):
app.review.next()
app.process_blindsign_warnings("loading_operation")
app.send_apdu("800f82001211020000000c02000000070200000002002a")
app.assert_screen("tbtdr_start_review_blindsign")
app.review.next()
app.assert_screen("tbtd_review_1")
app.review.next()
verify_err_reject_response(app,"operation_sign")
Expand Down
35 changes: 1 addition & 34 deletions tests/integration/touch/test_blindsign_too_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@
if __name__ == "__main__":
app = tezos_app(__file__)

# Switch to blindsign mode
app.assert_home()

# Blindsigning disabled (default state)
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")
app.review.next()

app.assert_screen("too_large_enable_blindsign")
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()

app.assert_screen("blindsign_warning")
app.review.next()

app.process_blindsign_warnings("tbtd_start_review_blindsign")
app.assert_screen("tbtl_review_1")
app.review.next()
app.assert_screen("operation_sign")
Expand All @@ -45,29 +37,4 @@
app.review_confirm_signing(expected_apdu)

app.assert_home()

# Blindsign enabled
app.welcome.settings()
app.assert_settings(blindsigning=True)
# blind sign will be on because of previous test run.
app.settings.exit()

app.assert_home()

send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app,"800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")
app.review.next()
app.assert_screen("too_large_blindsign_notify")
app.review.next()

app.assert_screen("blindsign_warning")
app.review.next()

app.assert_screen("tbtl_review_1")
app.review.next()
app.assert_screen("operation_sign")

expected_apdu = "ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
app.review_confirm_signing(expected_apdu)

app.quit()
10 changes: 0 additions & 10 deletions tests/integration/touch/test_blindsign_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
if __name__ == "__main__":
app = tezos_app(__file__)

# Switch to blindsign mode
app.assert_home()

app.welcome.settings()
app.assert_settings()

app.settings.toggle_blindsigning()
app.assert_settings(blindsigning=True)

app.settings.exit()
app.assert_home()

send_initialize_msg(app,"800f000011048000002c800006c18000000080000000")
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/touch/test_parsing_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f81005e0100000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "invalid_tag")

send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f81005e03000000000000000000000000000000000000000000000000000000000000000001016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "invalid_tag")

print("Invalid input: 1 byte removed inside")
Expand All @@ -48,6 +52,8 @@
app.review.next()
app.assert_screen("tpe_review_0_02")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "invalid_tag")

print("Invalid input: 1 byte introduce at the end")
Expand All @@ -62,6 +68,8 @@
app.review.next()
app.assert_screen("tpe_review_0_03_full")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "invalid_tag")

print("Invalid input: 1 byte introduced inside")
Expand All @@ -72,13 +80,17 @@
app.review.next()
app.assert_screen("tpe_review_0_02_dest_only")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "invalid_tag")

# full output: 12345678901234567890123456789012345678901234567890123456789012345678901234567890
print("Too Large input")
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "too_large")

# full output: {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{42}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
Expand All @@ -88,6 +100,8 @@
app.review.next()
app.assert_screen('tpe_review_too_deep_0')
app.review.next()
app.assert_screen("unsafe_operation_warning_1")
app.review.enable_blindsign.reject()
verify_err_reject_response(app, "too_deep")

print("wrong last packet")
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/touch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ def review_reject_signing(self, cancel_rejection = False):
with self.fading_screen("reject_review"):
self.review.reject_tx.confirm()

def process_blindsign_warnings(self, landing_screen: str):
self.assert_screen("unsafe_operation_warning_1")
self.review.reject()
self.assert_screen("unsafe_operation_warning_2")
with self.fading_screen(landing_screen):
self.review.enable_blindsign.confirm()



def tezos_app(prefix) -> TezosAppScreen:
port = os.environ["PORT"]
commit = os.environ["COMMIT_BYTES"]
Expand Down Expand Up @@ -373,6 +382,9 @@ def verify_reject_response(app, tag):
def verify_reject_response_common(app, tag, err_code):
app.assert_screen(tag)
app.review.reject()
reject_flow(app, err_code)

def reject_flow(app,err_code):
app.assert_screen("reject_review")
with app.fading_screen("rejected"):
app.review.reject_tx.confirm()
Expand Down