I am little confused about what types of transaction malleability exist in bitcoin and which one of them does SegWit solve.
Here Antoine Poinsot talks about txid malleability and third-party malleability and says that SegWit solves only txid malleability. In the comment on that question, Murch mentioned first-party malleability. Furthermore, Master bitcoin 3rd edition talks about third-party and second-party malleability. In this answer Pieter Wuille says that SegWit doesn't prevent malleability (that is, in many ways the actual transaction data can still be changed by third parties).
Looking at all this, I'm a bit confused.
What I do know is that the transaction malleability comes from the fact that the digital signature does not cover the unlock script field (scriptSig), so if a third party (or anyone) changes its content (for example, adds something extra to the stack that will not affect the unlock validity of the referenced UTXO) it is possible to change the transaction ID and therefore if this transaction is accepted instead of the original one, it may invalidate all transactions in the descendant chain. Of course, this is only possible if we are working with an unconfirmed transaction and referencing its unconfirmed ID. SegWit solves this by moving the digital signature from the unlocking script (input portion of transaction) to separated witness data and therefore digital signature is not the part of transaction ID. So referencing this type of unconfirmed transaction is fine since its ID can't be changed (at least not by this way).
So my questions are the following:
- What types of transaction malleability exist and what situations do they represent?
- What type/types of transaction malleability does SegWit solve?
- If SegWit does not solve all types of transaction malleability, how these other types are overcome, if there is a solution for them?
- What type of transaction malleability does the situation I described represent? (I guess I'll find out by myself from the answer to the first question)