rust-bitcoin / rust-bitcoin/rust-miniscript
API improvements suggestions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 426
- Forks
- 200
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 8
Description
We used miniscript to identify which M of N PubKeys correspond to the M signatures in a spent M of N multisig output, for the P2SH, P2WSH and P2TR (script path) outputs.
I wanted to make two suggestions about potential Miniscript API improvements:
-
The
interpreter.verify_sig()function requiresprevoutsargument, that is a vector of all outpoints corresponding to all the transaction’s inputs. Only in the case of Taproot the signed message commits to the scriptPubKeys of all outputs spent by the transaction, per BIP 341. Even for the Witness case per BIP 143, only the amount from a single outpoint corresponding to the input being verified is required (and not the whole vector). For the legacy P2SH or bare script cases, no outpoints are required. Preparing thisprevoutsVecfor all legacy cases is an unnecessary computation in the program that is using the miniscript API.
We suggest either:- making the prevouts argument an enum with three variants:
ALL(& [T])(for taproot),ONE(T)(for witness) orNONE(for legacy) - or replacing the
interpreter.verify_sigfunction with three functionsinterpreter.verify_sig_taproot(),interpreter.verify_sig_witness(),interpreter.verify_sig_legacy().
- making the prevouts argument an enum with three variants:
-
interpreter.verify_sig()returnsfalseinstead of a concrete error. For example, we mistakenly passed aprevoutsvector that did not correspond to inputs length. The Error::PrevoutsSize thatcache.taproot_script_spend_signature_hash()returned was transformed intofalsehere, and returned.
It would be desirable to return aResult<bool, sighash::Error>frominterpreter.verify_sig(), instead ofbool.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/interpreter/mod.rs, especially interpreter.verify_sig() and the linked cache.taproot_script_spend_signature_hash() call. Compare the proposed prevouts API alternatives and Result<bool, sighash::Error> behavior across legacy, witness, and Taproot cases. Done means an agreed API design addresses both suggestions without converting concrete errors into false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100