Sipa lists sources of tx malleability here: https://gist.github.com/sipa/8907691
It is clear to me how a change in the signature itself or the signature formating leads to a different tx hash (1. & 2.). But why is it allowed to modify the rest (may be "") of the scripts?
From what I understand only the txin script can be modified because the txout scripts are included in the signature hash(es). Obviously the signature itself can not be included in the signed hash.
For each signature the corresponding txin script is replaced by the appropriate previous output script (?) and all other txin scripts in the tx are removed.
Why is the txin script (without signature, so it is an empty string for a standard tx) not included in the hashed and signed data?
(Please correct me if I got something wrong.)
edit: trying to express myself more clearly:
Of course the range and format of the signature needs to be standardized. But there are other cases of malleability as Sipa points out like adding nonsense OPs to the tx_in script or using alternative OPs that have the same or a similar effect. I am only talking about these other cases.
My point is: The signature itself can not be signed but why are OP codes that may or may not be present in the txin script not signed?
Example:
Today:
normal txinscript: "sig" --> signature format: "" --> valid
malled txinscript: "OP_NULL sig" --> signature format: "" --> valid
Why not:
normal txinscript: "sig" --> signature format: "" --> valid
malled txinscript: "OP_NULL sig" --> signature format: "OP_NULL " --> FAIL
Signature format today replaces the whole txinscript with "". To me it seems that it would be safer to only remove the signature itself but keep the opcodes if present so that it is impossible to alter existing opcodes or add nonsense opcodes.
Is it because it is not know what part of the script is the signature? I think it could be marked as such should that be the issue.