The data of the scriptSig is mooved from TransactionInput to RawTransaction, so the Raw transaction doesn't is malleability? maybe I can't imagine what really happened to non-witness transactions during malleability, can you give me an example?
The transaction ID is a hash of the entire transaction data structure (the version, inputs, outputs, signatures, number of inputs and outputs, locktime, everything). Elliptic Curve signatures, such as the ones used by Bitcoin, contain a random number as part of the signature. Using another random number will also lead to a valid, but different signature. If the signature changes, the hash of the entire transaction object would also change.
In segregated witness transactions, this signature data is not part of the base transaction data structure - this means that changing the signature will no longer change the txid, since the rest of the transaction has not been altered.
Why the witness data is stored outside the block? what do you mean? I think I don't understand the sense of this space-saving because the witness data is present inside the blk file
Moving the witness data outside the block allows Bitcoin to effectively pack more transactions into a block - The space previously used by all the signatures is now available to add more transactions.
How (If I understand correctly) bitcoin core use the Merkle-tree for verifying the signature? (this question is related to the first, I don't think I understood the phenomenon of malleability as it happens)
Merkle trees having nothing to do with signature verification. Merkle trees are used to build a commitment to which transactions are included in a block, which is then placed in the block header and locked in using the proof of work system. Transaction malleability affected this, since altering a transaction ID within the transactions selected for the block would alter the merkle tree - this is no longer possible for the reasons stated above.
Thank so much for your answer but I don't understand because Is defined that the witness data is to extern of the block, What is meant outside the block? why then if the data is deserialized inside the block? – vincenzopalazzo – 2019-08-19T15:06:02.147
1Segregated witness data is still part of the block, and even committed to it. It's just in an area that (a) doesn't contribute to txids (to fix malleability) and (b) is not seen by old nodes, thus bypassing the existing size limits. – Pieter Wuille – 2019-08-19T15:07:46.597
Ah, ok thanks, on the problem of the existing size limits exist a BIP? if yes what is your name? – vincenzopalazzo – 2019-08-19T15:22:18.840
Another question @PieterWuille on the malleability of the transaction id, if I create a new transaction not witness and I send to the network bitcoin, how this transaction id change? What is the way in which txid was calculated allows anyone to make small changes to the transaction – vincenzopalazzo – 2019-08-19T15:37:39.190
2BIP62 lists a number of known ways to malleate transactions. – Pieter Wuille – 2019-08-19T15:38:38.470