forked from BitBoxSwiss/bitbox02-firmware
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bitcoin: add support for tr() wallet policies/descriptors
Support for Taproot wallet policies: `tr(INTERNALKEY,{TREE})` where `TREE=SCRIPT` or `TREE={TREE,TREE}`. SCRIPT can be an arbitrary miniscript like we already suppot in `wsh(<miniscript>)` policies, with slight adaptations for the tr() context. References: - https://github.com/bitcoin/bips/blob/master/bip-0388.mediawiki - https://github.com/bitcoin/bitcoin/blob/efbf4e71ce8e3cd49ccdfb5e55e14fa4b338453c/doc/descriptors.md `tr(@0/**)` is equivalent to BIP-86 that we already support as a SimpleType (single signature). The Taproot output key (which is in the Taproot address) is `internalkey + tweak` where tweak is either a standard tweak if no tree is present, or the merkle root hash of the tree. A tr() UTXO can be spent by signing with the private key of the output key (i.e. the tweaked private key of the internal key), called a key path spend, or by providing and satisfying a script that is a leaf of the tree, called a script path spend. When spending using the the output key, it is the same as BIP-86 and the BIP341 sighash computation is the same. When spending using a leaf script, the sighash algo is extended - see the changes to bip341.rs and the documentation that is referenced there. We change keystore_secp256k1_schnorr_bip86_sign to keystore_secp256k1_schnorr_sign, taking the tweak as an argument instead, which we feed from signtx.rs depending on whether we are spending BIP-86, a policy with/without a tree. This commit adds significant binary bloat (~47kB), in large part because rust-miniscript uses generics, so Miniscript<Tr> duplicates a lot of the code of Miniscript<Wsh>, even though it is nearly identical. This can be solved over time in rust-miniscript to reduce the binary size cost of this feature. With these commits since the previous release, we also reduced space by more than this feature pulls in: daa745f debb871 2fa257c 61a82ff ``` 749548 build/bin/firmware.bin (based on this commit) 753272 firmware.v9.19.0.bin ```
- Loading branch information
Showing
11 changed files
with
613 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.