-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi: implement BIP 341 and 342 a.k.a complete taproot and tapscript consensus verification logic #1787
Commits on Mar 16, 2022
-
txscript: add taproot script type
Add the WitnessV1TaprootTy script class and return it from GetScriptClass / typeOfScript. Bump the btcutil dep to leverage new taproot address type.
Configuration menu - View commit details
-
Copy full SHA for bfd0f4a - Browse repository at this point
Copy the full SHA bfd0f4aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 37964e5 - Browse repository at this point
Copy the full SHA 37964e5View commit details -
txscript: add taproot support to PayToAddrScript
Add taproot address handling in PayToAddrScript. Adds a test and also some missing tests for p2wsh and p2wpkh addresses.
Configuration menu - View commit details
-
Copy full SHA for 3ddf1b5 - Browse repository at this point
Copy the full SHA 3ddf1b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for cfe801f - Browse repository at this point
Copy the full SHA cfe801fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 81a546b - Browse repository at this point
Copy the full SHA 81a546bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 30d9327 - Browse repository at this point
Copy the full SHA 30d9327View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ecc72e - Browse repository at this point
Copy the full SHA 6ecc72eView commit details -
txscript: implement BIP 341+342 segwit v1 taproot+tapscript
In this commit, we implement the new BIP 341+342 taproot sighash digest computation. The digest is similar, but re-orders some fragments and also starts to commit to the input values of all the transactions in the SIGHASH_ALL case. A new implicit sighash flag, SIGHASH_DEFAULT has been added that allows signatures to always be 64-bytes for the common case. The hashcache has been updated as well to store both the v0 and v1 mid state hashes. The v0 hashes are a double-sha of the contents, while the v1 hash is a single sha. As a result, if a transaction spends both v0 and v1 inputs, then we 're able to re-use all the intermediate hashes. As the sighash computation needs the input values and scripts, we create an abstraction: the PrevOutFetcher to give the caller flexibility w.r.t how this is done. We also create a `CannedPrevOutputFetcher` that holds the information in a map for a single input. A series of function options are also added to allow re-use of the same base sig hash calculation for both BIP 341 and 342.
Configuration menu - View commit details
-
Copy full SHA for e781b66 - Browse repository at this point
Copy the full SHA e781b66View commit details -
txscript: update SigCache to cache both ECDSA and Schnorr signatures
In this commit, we make the sigCache slightly more general in order to be able to cache both ECDSA and Schnorr signatures. The cache is now based off of byte slices (the values) rather than the direct objects. We rely on the fact that the sighash for ecdsa and the schnorr types are distinct, so we can keep using the same top-level sighash key. In the future with Go type params, we can use a type param here instead as they all have an `IsEqual` method.
Configuration menu - View commit details
-
Copy full SHA for 1cd509d - Browse repository at this point
Copy the full SHA 1cd509dView commit details -
txscript: introduce new signatureVerifier interface to abstract over …
…schnorr/ecdsa In this commit, we add a new signatureVerifier interface that will allow us to consolidate a lot of code as we'll now have 4 distinct sig+sighash types to verify: 1. pre-segwit 2. segwit v0 3. segwit v1 (taproot key spend) 4. tapscript spends We'll need to be able to handle 3 of the cases for the modified OP_CHECKSIG operator. This new abstraction allows us to keep the implementation of the function somewhat succinct. In this commit we implement a verifier for #3 which is needed to verify the top-level taproot keyspend. We expose the verifier using a new VerifyTaprootKeySpend function.
Configuration menu - View commit details
-
Copy full SHA for abeaf4e - Browse repository at this point
Copy the full SHA abeaf4eView commit details -
txscript: use new signature verifiers for existing CHECKSIG ops
In this commit, we use the recently added checksig verifiers to validate signatures for pre-segwit, and segwit v0 scripts.
Configuration menu - View commit details
-
Copy full SHA for 1ac34b7 - Browse repository at this point
Copy the full SHA 1ac34b7View commit details -
txscript: add new functions for signing a top-level taproot output
In this commit, we add two new functions: one for signing a raw top-level taproot keyspend, and another for generating a valid witness for a keyspend.
Configuration menu - View commit details
-
Copy full SHA for 938c193 - Browse repository at this point
Copy the full SHA 938c193View commit details -
txscript: add VM verification logic for top-level taproot keyspends
In this commit, we add the initial verification logic for top-level taproot keyspends. Keyspends use the base BIP 341 sighash digest and don't require any tapscript level functionality for validation.
Configuration menu - View commit details
-
Copy full SHA for 2ac743d - Browse repository at this point
Copy the full SHA 2ac743dView commit details -
Configuration menu - View commit details
-
Copy full SHA for a7c3db4 - Browse repository at this point
Copy the full SHA a7c3db4View commit details -
txscript: add new ScriptHasOpSuccess utility method
We'll use this to examine if a script has any OP_SUCCESS op codes during pre-processing before we attempt full tapscript execution.
Configuration menu - View commit details
-
Copy full SHA for 11dd820 - Browse repository at this point
Copy the full SHA 11dd820View commit details -
txscript: introduce new ControlBlock struct along w/ parsing routine
In this commit, we add a new struct to represent the ControlBlock structure used to feed in the tapscript leaf inclusion proof into the witness tack. The `ParseControlBlock` parses a would-be control block and returns an error if it's incorrectly formatted.
Configuration menu - View commit details
-
Copy full SHA for 5c4a29b - Browse repository at this point
Copy the full SHA 5c4a29bView commit details -
txscript: add VerifyTaprootLeafCommitment function
In this commit, we add a new function to verify the taproot merkle commitment of a given tapscript leaf. Along the way we add some helper functions which can be used to construct a taproot output given the raw script root.
Configuration menu - View commit details
-
Copy full SHA for 37f8c8b - Browse repository at this point
Copy the full SHA 37f8c8bView commit details -
txscript: add new RawTxInTapscriptSignature to generate tapsript sigs
In this commit, we add a new function `RawTxInTapscriptSignature` that will be used to generate signatures in the _tapscript_ context. Note that this differs from top-level taproot as a distinct sighash is used, and we _always_ accept a root hash to perform the proper tweak.
Configuration menu - View commit details
-
Copy full SHA for 6fc4199 - Browse repository at this point
Copy the full SHA 6fc4199View commit details -
txscript: add AssembleTaprootScriptTree func for creating input witne…
…sses In this commit, we add a new AssembleTaprootScriptTree function that given a list of tapscript leaves, generates a valid tapscript root, along with the auxiliary proof data needed to spend each output.
Configuration menu - View commit details
-
Copy full SHA for 17e4609 - Browse repository at this point
Copy the full SHA 17e4609View commit details -
txscript: implement script path verification
In this commit, we use the recently added control block and script tree verification+generation routines to implement full script path verification within the VM. This includes verifying the script reveal commitment, and recursing one layer deeper to execute the revealed witness script as specified by BIP 342.
Configuration menu - View commit details
-
Copy full SHA for c1eb150 - Browse repository at this point
Copy the full SHA c1eb150View commit details -
Configuration menu - View commit details
-
Copy full SHA for a7a8ad7 - Browse repository at this point
Copy the full SHA a7a8ad7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3c6be73 - Browse repository at this point
Copy the full SHA 3c6be73View commit details -
txscript: add new OpcodePosition method to tokenizer to save code sep…
… position We'll need this to properly generate the sighash during tapscript validation later
Configuration menu - View commit details
-
Copy full SHA for a4beed9 - Browse repository at this point
Copy the full SHA a4beed9View commit details -
txscript: implement OP_CHECKSIG semantics for tapscript validation
In this commit, we implement the new checksig semantics as part of tapscript validation. Namely: * OP_CHECKSIGVERIFY no longer pops the OP_TRUE off the stack (TODO(roasbeef): verify)) * the new sig ops semantics are added where each sig deducts 50 from a starting budget of 50+the weight of the witness * NULLFAIL is always enforced, meaning invalid sigs MUST be an empty sig array
Configuration menu - View commit details
-
Copy full SHA for 3ce6130 - Browse repository at this point
Copy the full SHA 3ce6130View commit details -
txscript: implement OP_CHECKSIGADD
In this commit, we implement OP_CHECKSIGADD which replaces OP_CHECKMULTISIG* in the tapscript execution environment.
Configuration menu - View commit details
-
Copy full SHA for 5f8660e - Browse repository at this point
Copy the full SHA 5f8660eView commit details -
txscript: add taproot JSON success/fail reference tests
In this commit, we add a total of 2760 taproot reference tests generated by the bitcoind functional tests located at: https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_taproot.py. The tests aren't deterministic (fresh private keys are generated), so we time we go to update the set of tests, we'll end up with fresh hashes (the file name is the sha1 of the raw json test) and tests.
Configuration menu - View commit details
-
Copy full SHA for 79c314d - Browse repository at this point
Copy the full SHA 79c314dView commit details -
chaincfg: add taproot BIP deployment parameters
In this commit, we add the deployment parameters of taproot as specified in the deployment section of BIp 341: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#deployment. Take note of the custom activation threshold, as well as the specified min activation heights for mainnet only.
Configuration menu - View commit details
-
Copy full SHA for ba9fb8e - Browse repository at this point
Copy the full SHA ba9fb8eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 23cf18b - Browse repository at this point
Copy the full SHA 23cf18bView commit details -
Configuration menu - View commit details
-
Copy full SHA for f7f7bb3 - Browse repository at this point
Copy the full SHA f7f7bb3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ab97a3 - Browse repository at this point
Copy the full SHA 6ab97a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 99e4e00 - Browse repository at this point
Copy the full SHA 99e4e00View commit details -
build: add temporary replace directives for btcec+chainhash
This PR includes some changes to them, so we'll need to use a temporary replace directives to ensure the build passes.
Configuration menu - View commit details
-
Copy full SHA for 30d58b9 - Browse repository at this point
Copy the full SHA 30d58b9View commit details