ledger-stacks icon indicating copy to clipboard operation
ledger-stacks copied to clipboard

Feat: Add support for arbitrary # of multisig signers

Open jbencin opened this issue 1 year ago • 19 comments

Description

This PR aims to support Stacks multisig with an arbitrary number of signers. Current code only works for a max of 2 multisig signers

UPDATE: This PR now also adds support for a new SIP enabling non-sequential multisig transactions (PR, Document)

Current Status

  • [x] Rust unit tests passing
  • [x] C code compiles without warnings
  • [x] ZEMU tests pass
  • [x] Tested to run on Ledger
  • [x] Tested and working m-of-n sequential multisig transactions
  • [ ] Tested and working m-of-n non-sequential multisig transactions

Breaking Changes

  • Do not use custom data format in remainder field while parsing transaction. Transactions should instead be updated with new signature after each signing round, as described in SIP-005 (step 5 under "Transaction Signing and Verifying"). Wallet software will need to be updated to modify transaction accordingly.

TODO / Limitations

  • Currently iteration through multisig fields is O(n^2) due to having to parse the structure on each access. Need to figure out how to handle a variable length array in a no_std environment or limit to a max number of signers in order to use an ArrayVec. I have a branch where it parses a fixed number of TransactionAuthFields into an fixed-size ArrayVec, and keeps a reference to the start of the unparsed data (if any), so it can be parsed on-demand later, but currently tests are failing on it
  • As I can't figure out how to recover a pubkey from a ECDSA signature on a Ledger, the signatures of previous signers are not validated before signing. This isn't really necessary

:link: zboto Link

jbencin avatar Aug 11 '23 17:08 jbencin