-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Attempting to sign pure IBC Txs (i.e. those not involving MASP) causes the hardware wallet to crash. The hardware wallet crashes before it has the chance to display the transaction. This issue should be reproducible using any of the pure IBC test vectors - 7_IBC_Transfer_0 for instance.
The cause is probably at
ledger-namada/app/src/parser_impl.c
Lines 30 to 32 in ef0450c
| if(ctx->tx_obj->transaction.isMasp || ctx->tx_obj->ibc.is_ibc) { | |
| CHECK_ERROR(verifyShieldedHash(ctx)) | |
| } |
ctx->tx_obj->ibc.is_ibc being true is sufficient to trigger the execution of verifyShieldedHash. This is problematic because a pure IBC Txs do not contain MASP Transactions nor do they contain MaspBuilders, hence lines inside verifyShieldedHash like ledger-namada/app/src/parser_impl_txn.c
Line 1426 in ef0450c
| if (tx_hash_txId(ctx->tx_obj, tx_id_hash) != zxerr_ok) { |
make cpp_test because these MASP assumptions only kick in when LEDGER_SPECIFIC is defined.
This regression seems to have been introduced in #69 in response to #67 . It seems to me that the root cause of this issue is that we have not specified precisely when to sign/display/reject certain kinds of transactions, apologies. So let me try to elaborate the conditions that the Ledger app must enforce.
- MASP Transactions must accompany MASP Transfers (regardless of whether they are pure, an IBC FT Transfer, or an IBC NFT Transfer). I.e. if inside a
Transferobject,shielded_hash = Some(...), then theTxmust contain aTransactionwith thatTxId. - MASP Builders must accompany MASP Transactions. I.e. if the
Txcontains a MASPTransaction, then there must be a builder whosetarget_hashis theTxIdof theTransaction. And the information in theMaspBuildermust be consistent with theTransaction. - Only display MASP data/fields when they are explicitly referenced by the
Tx'sDatasection. I.e. for MASP data to be relevant and displayed, it must be the case that theDatasection directly/indirectly contains aTransferwhoseshielded_hash = Some(...). - Only sign MASP sections that have been displayed to the user and confirmed by them. I.e. only include the MASP
Transactionhash in the wrapper signature if a (IBC or non-IBC)Transfersatisfying the condition thatshielded_hash = Some(...)is embedded in theTx. - Support signing non-MASP IBC Transfers. I.e. it can be the case that
namadacsends the hardware wallet an IBC FT or NFTTxwhich doe not utilize the MASP. These must be supported (as they were in the past).
Put differently, the following propositions can vary independently: Tx contains a MASP Transaction section, Tx contains a MaspBuilder section, Tx contains a Transfer that contains a shielded_hash, and Tx is IBC. And the Ledger app should be able to handle (whether it sends namadac an APDU error without displaying anything, or it correctly displays the Tx to the user and allows them to sign) all combinations without crashing. Thanks!