Skip to content

Commit

Permalink
stax: implement 'accept' workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
emturner committed Sep 26, 2023
1 parent edab669 commit 9707169
Show file tree
Hide file tree
Showing 22 changed files with 142 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/src/ui_stream_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,27 @@ tz_reject_ui(void)
nbgl_useCaseStatus("Rejected", false, tz_reject);
}

void
tz_accept_cb(void)
{
tz_ui_stream_t *s = &global.stream;

FUNC_ENTER(("void"));

global.apdu.sign.step = SIGN_ST_WAIT_USER_INPUT;
s->cb(TZ_UI_STREAM_CB_ACCEPT);
ui_home_init();

FUNC_LEAVE();
}

void
tz_choice_ui(bool accept)
{
FUNC_ENTER(("accept=%d", accept));

if (accept) {
// FIXME: implement accept workflow
nbgl_useCaseStatus("SIGNING\nSUCCESSFUL", true, tz_accept_cb);
} else {
tz_reject_ui();
}
Expand Down
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.
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.
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.
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.
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.
64 changes: 64 additions & 0 deletions tests/integration/stax/test_sign_execute_outbox_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
# Copyright 2023 Trilitech <[email protected]>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *

# full input: 0000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834
# signer: tz1dyX3B1CFYa2DfdFLyPtiJCfQRUgPVME6E

if __name__ == "__main__":
app = stax_app()

app.assert_screen(SCREEN_HOME_DEFAULT)

app.send_apdu("800f000011048000002c800006c18000000080000000");
app.expect_apdu_return("9000");

app.assert_screen("review_request_sign_operation");

app.send_apdu("800f0100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631");

app.review.tap()
app.assert_screen("operation_0_sr_outbox")

app.review.tap()
app.assert_screen("operation_fee_0.01")

app.review.tap()
app.assert_screen("operation_storage_limit_4")

app.review.tap()
app.assert_screen("operation_rollup_sr163L...v57")

app.review.tap()
app.assert_screen("operation_commitment_src12UJ...LY8")

app.review.tap()
app.expect_apdu_return("9000")

app.send_apdu("800f82004f63313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834")

for i in range(7):
app.review.tap()
app.assert_screen(f"operation_proof_396...834_{i}")

app.review.tap()
app.assert_screen("operation_sign")

expected_apdu = "c08f5e1a02d15b05c4066b43fc31aa1ccad30f6c7a18f44723e5af0b6584292236e919219e90793ef502e8883f5317206277607438695933fcb954f4ef451db19628a114880836193c755ddda4bf188b9764231975b2c5ecb64bc4bdc9c459039000"
app.review_confirm_signing(expected_apdu)

app.assert_screen(SCREEN_HOME_DEFAULT)
app.welcome.quit()
63 changes: 63 additions & 0 deletions tests/integration/stax/test_sign_transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
# Copyright 2023 Trilitech <[email protected]>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *

# full input: 0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316
# full output: CAR
# signer: tz1dyX3B1CFYa2DfdFLyPtiJCfQRUgPVME6E
# path: m/44'/1729'/0'/0'

if __name__ == "__main__":
app = stax_app()

app.assert_screen(SCREEN_HOME_DEFAULT)

app.send_apdu("800f000011048000002c800006c18000000080000000");
app.expect_apdu_return("9000");

app.assert_screen("review_request_sign_operation");

app.send_apdu("800f81005e0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316");

app.review.tap()
app.assert_screen("operation_0_transaction")

app.review.tap()
app.assert_screen("operation_fee_0.05")

app.review.tap()
app.assert_screen("operation_storage_limit_45")

app.review.tap()
app.assert_screen("operation_amount_0.24tz")

app.review.tap()
app.assert_screen("operation_destination_kt18am...rHT");

app.review.tap()
app.assert_screen("operation_entrypoint_do")

app.review.tap()
app.assert_screen("operation_parameter_CAR")

app.review.tap()
app.assert_screen("operation_sign")

expected_apdu = "f6d5fa0e79cac216e25104938ac873ca17ee9d7f06763719293b413cf2ed475cf63d045a1cc9f73eee5775c5d496fa9d3aa9ae57fb97217f746a8728639795b7b2220e84ce5759ed111399ea3263d810c230d6a4fffcb6e82797c5ca673a17089000"
app.review_confirm_signing(expected_apdu)

app.assert_screen(SCREEN_HOME_DEFAULT)
app.welcome.quit()

0 comments on commit 9707169

Please sign in to comment.