BIP 118 describes SIGHASH_ANYPREVOUT, but also mentions SIGHASH_ANYPREVOUTANYSCRIPT. What is the difference, and why is the later sighash flag needed?
1 Answer
Christian Decker answered this on the Stephan Livera podcast.
ANYPREVOUT (as you probably already know if you have read BIP 118) relaxes the requirement for an input to spend a particular output. Instead a specific signature can be used to spend any UTXO with the same script.
Rather than binding by both the explicit reference (e.g. transaction 100 connects to transaction 99) and the scripts matching, ANYPREVOUT only requires the scripts to match. The script is still committed to (hashed) in the sighash and hence can't be modified.
ANYPREVOUTANYSCRIPT relaxes this further by not committing to the script in the sighash (the script is not hashed). This allows outputs to bind to different inputs even if the scripts don't entirely match. In eltoo the output script will contain a different state number that changes from state to state in a Lightning setting. With eltoo we want to take a later state and attach it to any of the previous states.
For more information on eltoo see this Christian Decker presentation at Chaincode Labs.
So eltoo would use ANYPREVOUTANYSCRIPT but there are still possible use cases for ANYPREVOUT:
For example if we have any sort of transaction malleability and we still want to take a transaction that connects to a potentially malleable transaction, then we can use SIGHASH_ANYPREVOUT. If the transaction gets malleated in the public network before it is being confirmed we can still connect to it using the connection between the output script and the input script and the commitment of the output script in the spending transaction.
Jeremy Rubin has this cheatsheet for what is signed under the various existing and proposed sighashes that he sent to the Lightning dev mailing list.
Richard Myers included this table in a blog post which outlines what is hashed under ANYPREVOUT and ANYPREVOUTANYSCRIPT.
-
1My read of the section Signature Message is that an input with SIGHASH_ANYPREVOUT commits to the
scriptPubKey
and theamount
of the spent UTXO.– Murch ♦Commented Jul 29, 2021 at 14:03 -
@Michael Folkson But Eltoo would use both APO and APOAS, correct? APOAS is used to sign updates, allowing rebinding to any updates with newer state, while APO is used to sign settlements, commiting to a specific script i.e. channel balance (?). Commented Mar 5, 2023 at 18:59