This page is the Simplified Technical English version of ZIP 213. The source ZIP is the normative text. Read the writing rules to understand the marked words.
ZIP 213: Shielded Coinbase
ZIP: 213 Title: Shielded Coinbase Owners: Jack Grigg <jack@z.cash> Status: Final Category: Consensus Created: 2019-03-30 License: MIT
Terminology
On this page, STE words are in the place of the BCP 14 key words of the source. Refer to the key word table.
In this document, the term "network upgrade" has the definition in ZIP 200 [zip-0200].
In this document, the term "Sapling" has the definition in ZIP 205 [zip-0205].
In this document, the terms "Founders' Reward" and "funding stream" have the definitions in ZIP 207 [zip-0207].
Abstract
This ZIP contains changes to the Zcash consensus rules. With these changes, miners can mine coinbase funds to Sapling (and later Orchard) addresses. Miners can still use transparent addresses in coinbase transactions.
Motivation
Zcash inherited the concept of "coinbase transactions" from Bitcoin. A coinbase transaction is a special transaction inside each block. It can have no inputs. Miners create these transactions when they create a block. In these transactions, the block subsidy and the transaction fees are collected into new transparent outputs. These outputs can then be spent.
Zcash also uses coinbase transactions for the Founders' Reward (and potentially for funding streams [zip-0207]).
The Zcash network has transparent addresses that come from Bitcoin. On the path to the deprecation and removal of these addresses, one step is necessary: the ability to create coinbase transactions that have no transparent outputs.
But Zcash was launched with a consensus rule on coinbase transactions. Under this rule, a coinbase transaction that contained shielded outputs was invalid. Instead, Zcash enforced that it was not possible to spend coinbase funds in transactions with transparent outputs. This was partly to reduce the complexity of the original Zcash changes to the Bitcoin Core codebase. But it was also because, at that time, significant memory and CPU resources were necessary to create a shielded transaction.
The Sapling network upgrade [zip-0205] has architectural changes and performance improvements. With these changes and improvements, it is feasible to shield funds directly in the coinbase transaction. To reduce the complexity of the Sapling network upgrade, the existing consensus rules against shielded outputs in coinbase transactions were extended to cover Sapling outputs. Thus it is now necessary to change the consensus rules, to let miners start to use Sapling addresses.
Miners can also use Orchard addresses from activation of the NU5 network upgrade [zip-0252]. After the NU6.3 network upgrade, a miner can mine to an Orchard address only if the miner sends the funds to the Ironwood pool.
Specification
Before activation of the Heartwood network upgrade, this existing consensus rule on coinbase transactions applies:
A coinbase transaction must not have any JoinSplit descriptions, Spend descriptions, or Output descriptions.
From activation of the Heartwood network upgrade:
-
Coinbase transactions can contain Sapling outputs. More precisely, the existing consensus rule above changes to this:
A coinbase transaction must not have any JoinSplit descriptions or Spend descriptions.
[Pre-Heartwood] A coinbase transaction also must not have any Output descriptions.
-
The consensus rules that apply to
valueBalance,vShieldedOutput, andbindingSigin non-coinbase transactions must also apply to coinbase transactions. -
Only transparent outputs in coinbase transactions are subject to the existing restrictions on spending coinbase funds. More precisely:
- The existing consensus rule that a transaction has an empty
voutif it spends coinbase outputs is amended. It applies only to transactions that spend transparent coinbase outputs. -
The existing consensus rule on coinbase maturity is amended to apply only to transparent coinbase outputs. In this rule, a coinbase output has 100 confirmations before it can be spent. Specifically, the rule becomes:
A transaction must not contain a spend of a transparent output of a coinbase transaction from a block less than 100 blocks before the spend. Note that outputs of coinbase transactions include Founders’ Reward outputs [and potentially funding stream outputs].
- The existing consensus rule that a transaction has an empty
-
Full note decryption of shielded coinbase outputs must succeed with the all-zero outgoing viewing key. More precisely: all shielded coinbase outputs must have valid note commitments when they are recovered with a sequence of 32 zero bytes as the outgoing viewing key.
From activation of the NU5 network upgrade:
- Coinbase transactions can contain Sapling-pool outputs, Orchard-pool outputs, or both.
For this statement, no change to the consensus rule above is necessary. The statement is a consequence of other rules as of NU5 activation.
From activation of the NU6.3 network upgrade:
- Coinbase transactions can contain Sapling-pool outputs, Ironwood-pool outputs, or both.
- As specified in [zip-0229], coinbase transactions must not contain any Orchard-pool component.
Interaction with the Founders' Reward
The existing Founders' Reward addresses stay the same under this ZIP.
Rationale
In this ZIP, there is no rule that all coinbase must be shielded immediately from activation of the network upgrade. The purpose is that miners and mining pools can migrate gradually from their existing transparent addresses to Sapling addresses. This also makes the consensus rules simpler, because the Founders' Reward goes to transparent addresses. Thus it is still necessary for the time being to support them. A future ZIP can include a rule to shield all coinbase immediately.
If coinbase maturity is enforced at the consensus level for Sapling outputs, the result is significant complexity in the consensus rules. The cause is that special cases are then necessary for coinbase note commitments in the Sapling commitment tree. When a wallet spends a note, the standard recommendation is that the wallet selects an anchor 3 blocks back from the current chain tip (refer to ZIP 315 [zip-0315-anchor-selection]). With this recommendation, all notes, coinbase included, have a de-facto 3-block maturity. This can be proposed as a consensus rule in the future.
Shielded coinbase maturity is unnecessary for another reason: shielded coinbase outputs have the same effect on economic activity as regular shielded outputs.
Consider a transparent address. Its owner receives a coin in a "parent" transaction and later spends it. The result is a tree of "direct child" transactions. All of these transactions depend on the validity of the original parent transaction.
But most wallets treat unspent transparent outputs as a single "bucket of money". These wallets select coins to spend without direct user input. As a result, a disconnect can occur between the economic activity of users and their on-chain transaction graph. The users can intend to spend funds that they just received, and thus create "logical child" transactions.
For example, the operator of a mining pool successfully mines a block and receives a coinbase output. But for the later payout to miners, the operator can instead spend ZEC that the operator already had before the block was mined. In this example, the operator pays out for block X. Then a reorg or rollback occurs, and as a result the transparent coinbase in block X becomes invalid. The payout transaction can still be mined on the new chain. This is true even though the funds that the miner logically spent do not exist there.
By contrast, a shielded coinbase output can disappear because of a reorg or rollback. In this case, every shielded transaction also becomes invalid if its anchor descends from the tree that the shielded coinbase output was appended to. That is, all shielded economic activity is rolled back, as well as the shielded coinbase output. Thus all logical child transactions are invalid, not just direct child transactions. Thus there is no reason to make shielded coinbase a special case, because the same behavior already occurs with regular shielded notes.
This ZIP has a rule that note commitments are valid when they are recovered with a fixed outgoing viewing key. As a result, the target addresses and values for all Sapling outputs in the coinbase are revealed.
This is necessary to enforce shielded Founders' Reward or funding stream outputs correctly. It is simpler to enforce this on all outputs. Also, with this rule, network observers can still track miners and mining pools. At the same time, the miners and the mining pool operators can put useful or identifying text in the memo fields of the outputs. This is an alternative to ad-hoc storage of the text elsewhere in the coinbase transaction.
Security and Privacy Considerations
Sapling outputs in coinbase transactions are by design publicly viewable, in contrast to Sapling outputs in normal transactions. This is not a privacy regression relative to existing coinbase transactions, because coinbase output values and recipient addresses are, and always were, public information.
But some users have threat models that depend on keeping their Sapling address private (for example, to keep post-quantum privacy). We recommend that these users, if they are also miners or mining pools, use a coinbase-specific address when they create blocks.
The coinbase output notes are revealed, but other persons cannot detect when the note is spent. Thus a separate shielding step is not necessary. Such a step is enforced for transparent coinbase outputs.
Deployment
This ZIP is deployed with the Heartwood network upgrade [zip-0250].
Reference Implementation
References
- [BCP14]
- Information on BCP 14 — "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels" and "RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words"
- [zip-0200]
- ZIP 200: Network Upgrade Mechanism
- [zip-0205]
- ZIP 205: Deployment of the Sapling Network Upgrade
- [zip-0207]
- ZIP 207: Funding Streams
- [zip-0229]
- ZIP 229: Version 6 Transaction Format
- [zip-0250]
- ZIP 250: Deployment of the Heartwood Network Upgrade
- [zip-0252]
- ZIP 252: Deployment of the NU5 Network Upgrade
- [zip-0315-anchor-selection]
- ZIP 315: Best Practices for Wallet Implementations — Anchor selection