2020-06-27 13:24:04 +02:00
|
|
|
#ifdef HAVE_STARKWARE
|
|
|
|
|
|
2022-03-08 17:59:36 +01:00
|
|
|
#include "os_io_seproxyhal.h"
|
2020-06-27 13:24:04 +02:00
|
|
|
#include "shared_context.h"
|
|
|
|
|
#include "stark_utils.h"
|
2022-09-09 17:21:35 +02:00
|
|
|
#include "common_ui.h"
|
2020-06-27 13:24:04 +02:00
|
|
|
|
2021-07-05 11:01:51 +02:00
|
|
|
unsigned int io_seproxyhal_touch_stark_ok(__attribute__((unused)) const bagl_element_t *e) {
|
2020-06-27 13:24:04 +02:00
|
|
|
uint8_t privateKeyData[32];
|
|
|
|
|
uint8_t signature[72];
|
|
|
|
|
uint32_t tx = 0;
|
|
|
|
|
io_seproxyhal_io_heartbeat();
|
2022-07-08 11:12:50 +02:00
|
|
|
starkDerivePrivateKey(tmpCtx.transactionContext.bip32.path,
|
|
|
|
|
tmpCtx.transactionContext.bip32.length,
|
2020-12-01 16:20:13 +01:00
|
|
|
privateKeyData);
|
2020-06-27 13:24:04 +02:00
|
|
|
io_seproxyhal_io_heartbeat();
|
2020-12-01 16:20:13 +01:00
|
|
|
stark_sign(signature,
|
|
|
|
|
privateKeyData,
|
|
|
|
|
dataContext.starkContext.w1,
|
|
|
|
|
dataContext.starkContext.w2,
|
|
|
|
|
dataContext.starkContext.w3,
|
|
|
|
|
(dataContext.starkContext.conditional ? dataContext.starkContext.w4 : NULL));
|
|
|
|
|
G_io_apdu_buffer[0] = 0;
|
2020-06-27 13:24:04 +02:00
|
|
|
format_signature_out(signature);
|
|
|
|
|
tx = 65;
|
|
|
|
|
G_io_apdu_buffer[tx++] = 0x90;
|
|
|
|
|
G_io_apdu_buffer[tx++] = 0x00;
|
|
|
|
|
reset_app_context();
|
|
|
|
|
// Send back the response, do not restart the event loop
|
|
|
|
|
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx);
|
|
|
|
|
// Display back the original UX
|
|
|
|
|
ui_idle();
|
2020-12-01 16:20:13 +01:00
|
|
|
return 0; // do not redraw the widget
|
2020-06-27 13:24:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-03-08 17:59:36 +01:00
|
|
|
#endif // HAVE_STARKWARE
|