Bitcoin BIP66 Explained: Strict DER Signatures and Consensus Enforcement
BIP66 introduced strict DER encoding requirements for ECDSA signatures used by Bitcoin Script. The change was a soft fork: it narrowed which signatures could be accepted under the applicable consensus rules, rather than introducing an incompatible transaction format.
DER encoding versus cryptographic validity
ECDSA verifies a mathematical relationship between a message, a public key, and a pair of integers, conventionally called r and s. DER is a byte-level encoding for those integers. A signature can express mathematically valid values but still have a noncanonical or malformed DER representation.
Before strict encoding became a consensus rule, differences between signature-parsing libraries could create inconsistent behavior. A consensus system cannot safely depend on two nodes interpreting the same bytes differently. BIP66 specified a precise encoding check so that nodes enforce a consistent rule.
What the rule checks
The encoded signature must use the expected sequence and integer markers, lengths must match, integer encodings must not be negative, and unnecessary leading zero bytes are disallowed. In legacy Bitcoin Script, the signature's final sighash-type byte is handled separately from the DER-encoded ECDSA value. BIP66's byte checks are therefore not equivalent to simply asking whether a general-purpose cryptographic library accepts the whole script element.
Activation and the 2015 incident
BIP66 was deployed using version-3 block signaling and activated on mainnet in July 2015. During the transition, some miners built on blocks without independently validating the new rule. This led to short-lived invalid branches and demonstrated a crucial distinction: mining on the most recently announced block is not the same as verifying that block.
Upgraded validating nodes reject a block that violates the active strict-DER rule, even if the block has substantial proof of work. A miner's signal of readiness cannot substitute for actual validation.
Scope and modern signatures
BIP66 concerns ECDSA signature encoding in the relevant Script contexts. Taproot's Schnorr signatures use the BIP340 signature format and BIP341/BIP342 validation rules, not DER encoding. The fact that Bitcoin supports multiple signature schemes does not make their encodings interchangeable.
Practical verification lessons
Developers constructing raw legacy transactions should separate the ECDSA signature bytes from the sighash flag, serialize lengths carefully, and test against a fully validating node. A malformed signature can fail for encoding reasons before its mathematical verification is considered.
Primary references
BIP66 — Strict DER signatures: https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
BIP340 — Schnorr Signatures for secp256k1: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
