coderofstuff / app-kaspa

Kaspa Ledger Integration
MIT License
3 stars 5 forks source link

Merkle inputs #8

Open coderofstuff opened 1 year ago

coderofstuff commented 1 year ago

With a limited amount of memory in a ledger device, we cannot have more than some small number of inputs. In testing, a Nano S will only allow us to have 14 UTXOS in a transaction.

To support more UTXOs (an arbitrary number, so we're only limited by mass limit), use Merkle Trees.

Reference: https://www.youtube.com/watch?v=n6nEPaE7KZ8

Change in sign_tx APDU:

  1. First APDU will receive the version, output length, input length and merkle root
  2. For {0...input_length}: ask the client to give provide the input along with the merkle proof. Verify the merkle proof to legitimize the input.
  3. Request approval from user to continue with signing
  4. After all inputs are verified this way, For {0..input_length}: ask the client to give provide the input along with the merkle proof. This time, sign them then ask for the next input.
coderofstuff commented 1 year ago

This can be deferred since the input limit looks to only apply to a Nano S.

A Nano SP and Nano X can take up to 128 inputs.