Segregated Witness, Segwit - Discussion

Hi @filip,

It’s my very first time with blockchain, krypto and programing so probably my question will be an easy one.

So when we talk about Segwit, how is it possible for Bob to change Alices signature? what will the procedure be?

is it also possible if we were on the regular blockchain of BTC?

Thank you!

Alice creates a signature of the unlocking script that allows her to spend the Bitcoin locked in the UTXO, this is the input of the transaction and only a part of it. The rest of the transaction is serialized and hashed to get the txid.
The reason Bob can then change the id is because he can make changes to the locking scrpit which (also called a witness) like inserting an OP_DROP at the end of it which does nothing but it does chane the txid. To learn this in more detail I recommend the Bitcoin programming course in the academy :slight_smile:

4 Likes

Hi @filip,

I have another question :grin:

I understand that with segwit the TX ID it’s not part anymore of the TX Data, so some how this will become “secret” and we will just be able to see the hash of the TX?

Also, if the signature it’s not store anymore inside the TX data, where is it store? It will still be information added to the TX? how doesn’t it count as space in the 1MB block?

Thank you!

The witness is part of a different data structure that all segwit nodes have. By doing this segwit was able to be implemented as a soft fork since non updated nodes don’t need to download it.

1 Like

@Alko89 thank you for your fast reply!
I’m understanding better now, thank you! I’m watching the video you linked :+1:

Hello again class. I have to say segwit section has been the most complex section so far. For the most part I get it, but I do have one question that puzzles me. How does bitcoin remain secure even after the nodes remove the digital signature from a block?

Signature has not been removed, its just not included in the hashing of the tx.

1 Like

That’s what confuses me I guess. If it’s not included in the Hash but still included in the Block, how is it recorded and does that still not effect the block’s weight?

Thanks for the answer! I’m starting to understand Segwit better now!

It is still included, but not in the block data, that is how segwit was possible to implement as a soft fork. Because outdated nodes don’t need to download this data.

The process of block hashing isn’t really affected because for block hash only the txids are used so the witness can be omitted. :slight_smile:

2 Likes

What if the attacker has an otherwise honest node, get’s the transaction (no surround) and posts an altered transaction with a (much) higher fee, so it gets mined first. Wouldn’t the result be that both transactions go through (or the original get’s droped because it’s ITXOs are incorrect)?

This can be an issue when accidental forks happen and a tx gets dropped back into the mempool. The sender might rebroadcast the tx with higher fee thus invalidating the initial transaction.
This is the reason why you should wait for more than one confirmation when sending/receiving a tx.

1 Like

SegWit fixed transaction malleability by removing the signature information (otherwise known as the “witness” information) and storing it outside the base transaction block…

WHERE DO ALL THESE SIGNATURES GO? WHERE ARE THEY STORED?

The witness is part of a different data structure that all segwit nodes have. By doing this segwit was able to be implemented as a soft fork since non updated nodes don’t need to download it.

1 Like

Hi Filip,

Why are the tx inputs and outputs less malleable than the signature?

Thanks,

Dave

I’m not sure I fully understand your question. Signature is is part of the redeem script, which defines how a UTXO can be spent. :slight_smile:

1 Like

Thanks. The module content mentions that by moving the malleable part of the tx block (the sig) to outside the block, that the tx block is no longer malleable (or at least less so) - the Tx ID can no longer change. Before SegWit, if the Tx ID could be changed by changing the Sig then what is stopping the Tx ID (hash) by changing other content in the block, like inputs and outputs data?

Well inputs and outputs are usually predetermined. If you would for example want to change an output it would basically mean you changed your mind where you want the transaction be sent (to a new address) this would technically be a new transaction and it can still be done.

For example before the transaction is confirmed you can create a new transaction from the same inputs and send it to a new address using a higher fee, thus making the old transaction invalid. This can also be an issue in case of a stale block occurring when the tx is sent back to the mempool.

This video by Anton makes a good explanation of tx malleability:


You can also learn more in detail how segwit changes transaction structure to prevent the malleability issue in the Bitcoin Programing course in the academy :slight_smile:

I saw a post from a person at an exchange begging for help because he says he sent 17 btcs and the operation that was on hold like it froze and neither he had confirmation of the shipment nor the exchange received anything and the balance did not return the wallet, this it’s possible?

This could be a number of things, either he sent to the wrong address or the exchange kept the BTC for themselves :stuck_out_tongue:
I would have to know the txid or the address to find out more.

2 Likes

Thank you very much. I appreciate the help.