Over the years policy surrounding multisig scripts, particularly for legacy multisig scripts, has evolved in a haphazard way with various PRs affecting legacy multisig script policy without considering the ramifications.
The current status of legacy multisig script policy is as follows:
- Legacy multisig outputs in transactions can be at most m-of-3. All pubkeys in such outputs must be of the form of a compressed pubkey, or uncompressed pubkey, or a hybrid pubkey.
- Legacy multisig inputs being redeemed in transaction can be m-of-n with m and n 20 or less. Any public keys processed by OP_CHECKMULTISIG must be compressed or uncompressed pubkeys. hybrid or other data blobs are only allowed in the unprocessed part of the public key list.
While it is acceptable for legacy multisig output creation policy to be stricter than redemption policy, it makes no sense to allow hybrid keys in outputs by policy, but then to disallow them as inputs by policy.
However, there are further issues. Legacy multisig policy has evolved over time. In the beginning when legacy multisig outputs were introduced as standard by BIP 11, “pubkeys” were allowed by policy to be any value between 33 and 120 bytes. Some Bitcoin users have taken advantage of those liberal policies and created legacy multisig script UTXOs that were redeemable by policy at the time they were created, but are no longer redeemable by policy today. The UTXO 4dacd03d73cb497229dbfe2e7209adc4221540efe0e4c57f408b09b2fd36ece6:1 from 2014-01-12 is but one example. @ajtowns’s analysis in #33755 suggests there are at least 147,470 such UTXOs that have become soft-confiscated over time, meaning that when they were created they were redeemable by policy, but become no longer redeemable by policy and would require direct miner assistance to be spent.
Based on my research, I believe there are 4 tasks that need to be done to make legacy Multisig policy coherent again.
1. Ban hybrid keys in legacy outputs
We should strengthen the rules surrounding creating legacy multisig (and legacy single sig) to ban the use of hybrid keys. Such keys are nearly irredeemable. However, we should only strengthen policy around the creating new legacy script outputs without further restricting policy around redeeming legacy script UTXOs.
2. Bring legacy script redemption policy in line with P2SH redeem script policy.
P2SH redeem script policy has also evolved over time. Current policy for P2SH redemption allow any scripts so long as they have a limited number of CHECKSIG related operations. I see no reason why legacy script should be subject to significantly more stringent constraints than P2SH redeem scripts are.
3. Relax SCRIPT_VERIFY_STRICTENC policy to only ban hybrid keys.
PR #5247 went unnecessarily overboard in its quest to stomp out uses of hybrid keys and made UTXOs that already existed at the time unspendable. PR #33755 partially reverts this change so that only hybrid keys are excluded from processing in CHECKMULTISIG.
4. Bring SCRIPT_VERIFY_WITNESS_PUBKEYTYPE policy in line with BIP 143 requirements.
This task is technically unrelated to legacy multisig policy, being instead about Segwit V0 multisig policy. However the policy implemented in Bitcoin Core does not match the policy stated in BIP 143, and they ought to be brought into agreement. Either by implementing the policy correctly (as #33759 does), or by amending BIP 143 to describe the current policy as implemented.
In particular, both tasks 2 and 3 need to be completed in order to make stuck UTXOs, such as 4dacd03d73cb497229dbfe2e7209adc4221540efe0e4c57f408b09b2fd36ece6:1 spendable by policy again.
I want to make it clear that UTXOs such as the above are not particularly abusive. They were simply caught up incidentally in the policy changes of PR #5247, which was only about banning the use of hybrid keys. 4dacd03d73cb497229dbfe2e7209adc4221540efe0e4c57f408b09b2fd36ece6:1 has no hybrid nor hybrid looking pubkeys in it.
0OP_PUSHNUM_1
1OP_PUSHBYTES_33 035bceeb417f25beaa28d133ee7b28faa1e4f5c2f76b8daf12c3fab18261718790
2OP_PUSHBYTES_33 1c434e545250525459000000000000000000000001000000004190ab0000000000
3OP_PUSHNUM_2
4OP_CHECKMULTISIG
The script from UTXO 4dacd03d73cb497229dbfe2e7209adc4221540efe0e4c57f408b09b2fd36ece6:1