TeachMeBitcoin

Signature Malleability (Low S)

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Signature Malleability (Low S)

One of the most complex "Bugs" in early Bitcoin was Signature Malleability. It allowed a third party to change the look of a signature without invalidating it, which could confuse the network and break Layer-2 protocols.

1. The Math of Duality

On an elliptic curve, for every valid signature $(r, s)$, there is another valid signature $(r, -s)$.

2. The Transaction ID Problem

If you change $s$ to $(n - s)$:

  1. The signature is still valid.

  2. The Transaction Hash (TXID) changes because the raw bytes of the transaction have changed.

  3. The Hack: A malicious node could see your transaction, change the signature, and broadcast the new version. If their version gets mined first, your original TXID is "forgotten." This made it hard to track payments or build smart contracts.

3. The Fix: BIP62 (Low S)

To stop this, Bitcoin developers introduced the Low S rule.

4. SegWit and Malleability

While the Low S rule helped, the real fix came with SegWit.

Term Meaning Status
High S $s > n/2$ Invalid / Non-standard
Low S $s \le n/2$ Current Standard
Malleability Changing a signature's hex without breaking it Fixed by SegWit

In the final section, we will build a Python Signature Auditor.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!