<p>The key words "MUST", "MUST NOT", "SHOULD", "RECOMMENDED", and "MAY" in this document are to be interpreted as described in BCP 14 <aid="footnote-reference-1"class="footnote_reference"href="#bcp14">1</a> when, and only when, they appear in all capitals.</p>
<p>The terms below are to be interpreted as follows:</p>
<dl>
<dt>Recipient</dt>
<dd>A wallet or other software that can receive transfers of assets (such as ZEC) or in the future potentially other transaction-based state changes.</dd>
<dd>A wallet or other software that can send transfers of assets, or other consensus state side-effects defined in future. Senders are a subset of Consumers.</dd>
<dd>The necessary information to transfer an asset to a Recipient that generated that Receiver using a specific Transfer Protocol. Each Receiver is associated unambiguously with a specific Receiver Type, identified by an integer Typecode.</dd>
<dd>The necessary information to view information about payments to an Address, or (in the case of a Full Viewing Key) from an Address. An Incoming Viewing Key can be derived from a Full Viewing Key, and an Address can be derived from an Incoming Viewing Key.</dd>
<dt>Viewing Key Encoding</dt>
<dd>An encoding of a Viewing Key as a byte sequence.</dd>
<dd>Either a Legacy Address or a Unified Address.</dd>
<dt>Transfer Protocol</dt>
<dd>A specification of how a Sender can transfer assets to a Recipient. For example, the Transfer Protocol for a Sapling Receiver is the subset of the Zcash protocol required to successfully transfer ZEC using Sapling Spend/Output Transfers as specified in the Zcash Protocol Specification. (A single Zcash transaction can contain transfers of multiple Transfer Protocols. For example a t→z transaction that shields to the Sapling pool requires both Transparent and Sapling Transfer Protocols.)</dd>
<dd>An encoding of a UA/UVK as a US-ASCII string, intended either for display and transfer by Zcash end-users, or internal use by Zcash-related software.</dd>
<dt>Unified QR Encoding</dt>
<dd>An encoding of a UA/UVK as a QR code, intended for display and transfer by Zcash end-users in situations where usability advantages of a 2D bar code may be relevant.</dd>
<p>Notation for sequences, conversions, and arithmetic operations follows the Zcash protocol specification <aid="footnote-reference-2"class="footnote_reference"href="#protocol-notation">3</a>.</p>
<p>This proposal defines Unified Addresses, which bundle together Zcash Addresses of different types in a way that can be presented as a single Address Encoding. It also defines Unified Viewing Keys, which perform a similar function for Zcash viewing keys.</p>
<p>Each of these has its own Address Encodings, as a string and as a QR code. (Since the QR code is derivable from the string encoding as described in <aid="footnote-reference-3"class="footnote_reference"href="#protocol-addressandkeyencoding">9</a>, for many purposes it suffices to consider the string encoding.)</p>
<p>The Orchard proposal <aid="footnote-reference-4"class="footnote_reference"href="#zip-0224">26</a> adds a new Address type, Orchard Addresses.</p>
<p>The difficulty with defining new Address Encodings for each Address type, is that end-users are forced to be aware of the various types, and in particular which types are supported by a given Consumer or Recipient. In order to make sure that transfers are completed successfully, users may be forced to explicitly generate Addresses of different types and re-distribute encodings of them, which adds significant friction and cognitive overhead to understanding and using Zcash.</p>
<li>Provide a “bridging mechanism” to allow shielded wallets to successfully interact with conformant Transparent-Only wallets.</li>
<li>Allow older conformant wallets to interact seamlessly with newer wallets.</li>
<li>Enable users of newer wallets to upgrade to newer transaction technologies and/or pools while maintaining seamless interactions with counterparties using older wallets.</li>
<li>Facilitate wallets to assume more sophisticated responsibilities for shielding and/or migrating user funds.</li>
<li>Allow wallets to potentially develop new transfer mechanisms without underlying protocol changes.</li>
<li>Provide forward compatibility that is standard for all wallets across a range of potential future features. Some examples might include Layer 2 features, cross-chain interoperability and bridging, and decentralized exchange.</li>
<li>The standard should work well for Zcash today and upcoming potential upgrades, and also anticipate even broader use cases down the road such as cross-chain functionality.</li>
<p>Unified Addresses specify multiple methods for payment to a Recipient's wallet. The Sender's wallet can then non-interactively select the method of payment.</p>
<p>Importantly, any wallet can support Unified Addresses, even when that wallet only supports a subset of payment methods for receiving and/or sending.</p>
<p>Despite having some similar characteristics, the Unified Address standard is orthogonal to Payment Request URIs <aid="footnote-reference-5"class="footnote_reference"href="#zip-0321">29</a> and similar schemes. Since Payment Requests encode addresses as alphanumeric strings, no change to ZIP 321 is required in order to use Unified Addresses in Payment Requests.</p>
<li>The Producer wallet or human user <em>distributes</em> this Address Encoding. This ZIP leaves distribution mechanisms out of scope.</li>
<li>A Consumer wallet or user <em>imports</em> the Address Encoding through any of a variety of mechanisms (QR code scanning, Payment URIs, cut-and-paste, or “in-band” protocols like <code>Reply-To</code> memos).</li>
<li>A Consumer wallet <em>decodes</em> the Address Encoding and performs validity checks.</li>
<li>(Perhaps later in time) if the Consumer wallet is a Sender, it can execute a transfer of ZEC (or other assets or protocol state changes) to the Address.</li>
<p>Encodings of the same Address may be distributed zero or more times through different means. Zero or more Consumers may import Addresses. Zero or more of those (that are Senders) may execute a Transfer. A single Sender may execute multiple Transfers over time from a single import.</p>
<p>When new Transport Protocols are introduced to the Zcash protocol after Unified Addresses are standardized, those should introduce new Receiver Types but <em>not</em> different Address types outside of the UA standard. There needs to be a compelling reason to deviate from the standard, since the benefits of UA come precisely from their applicability across all new protocol upgrades.</p>
<p>The Unified String Encoding is “opaque” to human readers: it does <em>not</em> allow visual identification of which Receivers or Receiver Types are present.</p>
<p>The Unified String Encoding is resilient against typos, transcription errors, cut-and-paste errors, truncation, or other likely UX hazards.</p>
<p>There is a well-defined Unified QR Encoding of a Unified Address (or UFVK or UIVK) as a QR code, which produces QR codes that are reasonably compact and robust.</p>
<p>There is a well-defined transformation between the Unified QR Encoding and Unified String Encoding of a given UA/UVK in either direction.</p>
<p>The Unified String Encoding fits into ZIP-321 Payment URIs <aid="footnote-reference-6"class="footnote_reference"href="#zip-0321">29</a> and general URIs without introducing parse ambiguities.</p>
<li>This property is crucial for forward compatibility to ensure users who upgrade to newer protocols / UAs don't lose the ability to smoothly interact with older wallets.</li>
<li>This property is crucial for allowing Transparent-Only UA-Conformant wallets to interact with newer shielded wallets, removing a disincentive for adopting newer shielded wallets.</li>
<li>This property also allows Transparent-Only wallets to upgrade to shielded support without re-acquiring counterparty UAs. If they are re-acquired, the user flow and usability will be minimally disrupted.</li>
<p>Unified Addresses and Unified Viewing Keys must be able to include Receivers and Viewing Keys of experimental types, possibly alongside non-experimental ones. These experimental Receivers or Viewing Keys must be used only by wallets whose users have explicitly opted into the corresponding experiment.</p>
<p>A Unified Full Viewing Key (resp. Unified Incoming Viewing Key) can be used in a similar way to a Full Viewing Key (resp. Incoming Viewing Key) as described in the Zcash Protocol Specification <aid="footnote-reference-7"class="footnote_reference"href="#protocol">2</a>.</p>
<p>For a Transparent P2PKH Address that is derived according to BIP 32 <aid="footnote-reference-8"class="footnote_reference"href="#bip-0032">30</a> and BIP 44 <aid="footnote-reference-9"class="footnote_reference"href="#bip-0044">33</a>, the nearest equivalent to a Full Viewing Key or Incoming Viewing Key for a given BIP 44 account is an extended public key, as defined in the section “Extended keys” of BIP 32. Therefore, UFVKs and UIVKs should be able to include such extended public keys.</p>
<sectionid="open-issues-and-known-concerns"><h3><spanclass="section-heading">Open Issues and Known Concerns</span><spanclass="section-anchor"><arel="bookmark"href="#open-issues-and-known-concerns"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<li>Revision 1: This version adds support for <ahref="#must-understand-typecodes">MUST-understand Typecodes</a> and <ahref="#address-expiration-metadata">Address Expiration Metadata</a>. It also drops the restriction that a UA/UVK must contain at least one shielded Item.</li>
<p>Let <em>prefix</em> be: * “<code>u</code>”, if this is a UA/UVK prior to <ahref="#revision-1">Revision 1</a>; * “<code>ur</code>”, if this is a UA/UVK from <ahref="#revision-1">Revision 1</a> onward.</p>
<p>The Human-Readable Parts (as defined in <aid="footnote-reference-10"class="footnote_reference"href="#bip-0350">36</a>) of Unified Addresses are defined as: * <em>prefix</em>, for Unified Addresses on Mainnet; * <em>prefix</em> || “<code>test</code>”, for Unified Addresses on Testnet.</p>
<sectionid="encoding-of-unified-addresses"><h3><spanclass="section-heading">Encoding of Unified Addresses</span><spanclass="section-anchor"><arel="bookmark"href="#encoding-of-unified-addresses"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>Rather than defining a Bech32 string encoding of Orchard Shielded Payment Addresses, we instead define a Unified Address format that is able to encode a set of Receivers of different types. This enables the Consumer of a Unified Address to choose the Receiver of the best type it supports, providing a better user experience as new Receiver Types are added in the future.</p>
<p>Assume that we are given a set of one or more Receiver Encodings for distinct types. That is, the set may optionally contain one Receiver of each of the Receiver Types in the following fixed Priority List:</p>
<p>If, and only if, the user of a Producer or Consumer wallet explicitly opts into an experiment as described in <ahref="#experimental-usage">Experimental Usage</a>, the specification of the experiment MAY include additions to the above Priority List (such additions SHOULD maintain the intent of preferring more recent shielded protocols).</p>
<p>We say that a Receiver Type is “preferred” over another when it appears earlier in this Priority List (as potentially modified by experiments).</p>
<p>The Sender of a payment to a Unified Address MUST use the Receiver of the most preferred Receiver Type that it supports from the set.</p>
<p>For example, consider a wallet that supports sending funds to Orchard Receivers, and does not support sending to any Receiver Type that is preferred over Orchard. If that wallet is given a UA that includes an Orchard Receiver and possibly other Receivers, it MUST send to the Orchard Receiver.</p>
<p>Let <code>padding</code> be the Human-Readable Part of the Unified Address in US-ASCII, padded to 16 bytes with zero bytes. We append <code>padding</code> to the concatenated encodings, and then apply the
is defined in <ahref="#jumbling">Jumbling</a>.) The output is then encoded with Bech32m <aid="footnote-reference-15"class="footnote_reference"href="#bip-0350">36</a>, ignoring any length restrictions. This is chosen over Bech32 in order to better handle variable-length inputs.</p>
<li>Let <code>padding</code> be the Human-Readable Part, padded to 16 bytes as for encoding. If the result ends in <code>padding</code>, remove these 16 bytes; otherwise reject.</li>
<p>A wallet MAY allow its user(s) to configure which Receiver Types it can send to. It MUST NOT allow the user(s) to change the order of the Priority List used to choose the Receiver Type, except by opting into experiments.</p>
<p>Unified Full or Incoming Viewing Keys are encoded and decoded analogously to Unified Addresses. A Consumer MUST use the decoding procedure from the previous section. For Viewing Keys, a Consumer will normally take the union of information provided by all contained Receivers, and therefore the Priority List defined in the previous section is not used.</p>
<p>For each FVK Type or IVK Type currently defined in this specification, the same Typecode is used as for the corresponding Receiver Type in a Unified Address. Additional FVK Types and IVK Types MAY be defined in future, and these will not necessarily use the same Typecode as the corresponding Unified Address.</p>
<p>The following FVK or IVK Encodings are used in place of the
is defined in <aid="footnote-reference-16"class="footnote_reference"href="#zip-0032-sapling-helper-functions">15</a>. This SHOULD be derived from the Extended Full Viewing Key at the Account level of the ZIP 32 hierarchy.</li>
<li>There is no defined way to represent a Viewing Key for a Transparent P2SH Address in a UFVK or UIVK (because P2SH Addresses cannot be diversified in an unlinkable way). The Typecode
<li>For Transparent P2PKH Addresses that are derived according to BIP 32 <aid="footnote-reference-17"class="footnote_reference"href="#bip-0032">30</a> and BIP 44 <aid="footnote-reference-18"class="footnote_reference"href="#bip-0044">33</a>, the FVK and IVK Encodings have Typecode
. (This is the same as the last 65 bytes of the extended public key format defined in section “Serialization format” of BIP 32 <aid="footnote-reference-19"class="footnote_reference"href="#bip-0032-serialization-format">31</a>.) However, the FVK uses the key at the Account level, i.e. at path
<sectionid="rationale-for-address-derivation"><h4><spanclass="section-heading">Rationale for address derivation</span><spanclass="section-anchor"><arel="bookmark"href="#rationale-for-address-derivation"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>The design of address derivation is designed to maintain unlinkability between addresses derived from the same UIVK, to the extent possible. (This is only partially achieved if the UA contains a Transparent P2PKH Address, since the on-chain transaction graph can potentially be used to link transparent addresses.)</p>
<p>Note that it may be difficult to retain this property for Metadata Items, and this should be taken into account in the design of such Items.</p>
<sectionid="requirements-for-both-unified-addresses-and-unified-viewing-keys"><h3><spanclass="section-heading">Requirements for both Unified Addresses and Unified Viewing Keys</span><spanclass="section-anchor"><arel="bookmark"href="#requirements-for-both-unified-addresses-and-unified-viewing-keys"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<aid="footnote-reference-20"class="footnote_reference"href="#bitcoin-compactsize">39</a> (Although existing Receiver Encodings and Viewing Key Encodings are all less than 256 bytes and so could use a one-byte length field, encodings for experimental types may be longer.)</li>
<li>Within a single UA or UVK, all HD-derived Receivers, FVKs, and IVKs SHOULD represent an Address or Viewing Key for the same account (as used in the ZIP 32 or BIP 44 Account level).</li>
<li>There is intentionally no Typecode defined for a Sprout Shielded Payment Address or Sprout Incoming Viewing Key. Since it is no longer possible (since activation of ZIP 211 in the Canopy network upgrade <aid="footnote-reference-21"class="footnote_reference"href="#zip-0211">25</a>) to send funds into the Sprout chain value pool, this would not be generally useful.</li>
<li>Consumers MUST reject Unified Addresses/Viewing Keys in which the same Typecode appears more than once, or that include both P2SH and P2PKH Transparent Addresses, or that contain only a Transparent Address.</li>
<li>Consumers MUST reject Unified Addresses/Viewing Keys in which <em>any</em> constituent Item does not meet the validation requirements of its encoding, as specified in this ZIP and the Zcash Protocol Specification <aid="footnote-reference-22"class="footnote_reference"href="#protocol">2</a>.</li>
<li>Consumers MUST reject Unified Addresses/Viewing Keys in which the constituent Items are not ordered in ascending Typecode order. Note that this is different to priority order, and does not affect which Receiver in a Unified Address should be used by a Sender.</li>
<li>If the encoding of a Unified Address/Viewing Key is shown to a user in an abridged form due to lack of space, at least the first 20 characters MUST be included.</li>
<sectionid="rationale-for-dropping-the-at-least-one-shielded-item-restriction"><h4><spanclass="section-heading">Rationale for dropping the "at least one shielded Item" restriction</span><spanclass="section-anchor"><arel="bookmark"href="#rationale-for-dropping-the-at-least-one-shielded-item-restriction"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<details>
<summary>Click to show/hide</summary>
<p>The original rationale for this restriction was that the existing P2SH and P2PKH transparent-only address formats, and the existing P2PKH extended public key format, sufficed for representing transparent Items and were already supported by the existing ecosystem.</p>
<p>However, as of <ahref="#revision-1">Revision 1</a> there are uses for transparent-only UAs and UVKs that are not covered by the existing formats. In particular, they can use Metadata Items to represent expiration heights/dates as described in <ahref="#address-expiration-metadata">Address Expiration Metadata</a>, or source restrictions as proposed in ZIP 320 <aid="footnote-reference-23"class="footnote_reference"href="#zip-0320">28</a>.</p>
<sectionid="rationale-for-item-ordering"><h4><spanclass="section-heading">Rationale for Item ordering</span><spanclass="section-anchor"><arel="bookmark"href="#rationale-for-item-ordering"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>The rationale for requiring Items to be canonically ordered by Typecode is that it enables implementations to use an in-memory representation that discards ordering, while retaining the same round-trip serialization of a UA/UVK (provided that unrecognised Items are retained).</p>
<sectionid="rationale-for-showing-at-least-the-first-20-characters"><h4><spanclass="section-heading">Rationale for showing at least the first 20 characters</span><spanclass="section-anchor"><arel="bookmark"href="#rationale-for-showing-at-least-the-first-20-characters"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>Showing fewer than 20 characters of the String Encoding of a UA/UVK would potentially allow practical attacks in which the adversary constructs another UA/UVK that matches in the characters shown. When a UA/UVK is abridged it is preferable to show a prefix rather than some other part, both for a more consistent user experience across wallets, and because security analysis of the cost of partial UA/UVK string matching attacks is more complicated if checksum characters are included in the characters that are compared.</p>
<sectionid="adding-new-types"><h3><spanclass="section-heading">Adding new types</span><spanclass="section-anchor"><arel="bookmark"href="#adding-new-types"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>It is intended that new Receiver Types and Viewing Key Types SHOULD be introduced either by a modification to this ZIP or by a new ZIP, in accordance with the ZIP Process <aid="footnote-reference-24"class="footnote_reference"href="#zip-0000">14</a>.</p>
<p>For experimentation prior to proposing a ZIP, experimental types MAY be added using the reserved Typecodes
<spanclass="math">\(\mathtt{0xFFFA}\)</span>
to
<spanclass="math">\(\mathtt{0xFFFF}\)</span>
inclusive. This provides for six simultaneous experiments, which can be referred to as experiments A to F. This should be sufficient because experiments are expected to be reasonably short-term, and should otherwise be either standardized in a ZIP (and allocated a Typecode outside this reserved range) or discontinued.</p>
<p>New types SHOULD maintain the same distinction between FVK and IVK authority as existing types, i.e. an FVK is intended to give access to view all transactions to and from the address, while an IVK is intended to give access only to view incoming payments (as opposed to change).</p>
inclusive are reserved to indicate Metadata Items other than Receivers or Viewing Keys. These Items MAY affect the overall interpretation of the UA/UVK (for example, by specifying an expiration date).</p>
<pid="must-understand-typecodes">As of <ahref="#revision-1">Revision 1</a> of this ZIP, the subset of Metadata Typecodes in the range
inclusive are designated as "MUST-understand": if a Consumer is unable to recognise the meaning of a Metadata Item with a Typecode in this range, then it MUST regard the entire UA/UVK as unsupported and not process it further.</p>
<p>A <ahref="#revision-0">Revision 0</a> UA/UVK (determined by its HRP as specified in <ahref="#revisions">Revisions</a>) MUST NOT include any Metadata Items with a MUST-understand Typecode; a Consumer MUST reject as invalid any UA/UVK that violates this requirement.</p>
<p>Since Metadata Items are not Receivers, they MUST NOT be selected by a Sender when choosing a Receiver to send to, and since they are not Viewing Keys, they MUST NOT provide additional authority to view information about transactions.</p>
<p>New Metadata Types SHOULD be introduced either by a modification to this ZIP or by a new ZIP, in accordance with the ZIP Process <aid="footnote-reference-25"class="footnote_reference"href="#zip-0000">14</a>.</p>
<sectionid="rationale-for-making-revision-0-ua-uvks-with-must-understand-typecodes-invalid"><h4><spanclass="section-heading">Rationale for making Revision 0 UA/UVKs with MUST-understand Typecodes invalid</span><spanclass="section-anchor"><arel="bookmark"href="#rationale-for-making-revision-0-ua-uvks-with-must-understand-typecodes-invalid"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>A Consumer implementing this ZIP prior to <ahref="#revision-1">Revision 1</a> will not recognize the Human-Readable Parts beginning with “<code>ur</code>” that mark a <ahref="#revision-1">Revision 1</a> UA/UVK. So if a UA/UVK that includes MUST-understand Typecodes is required to use these <ahref="#revision-1">Revision 1</a> HRPs, this will ensure that the MUST-understand specification is correctly enforced even for such implementations.</p>
<p>As of <ahref="#revision-1">Revision 1</a>, Typecodes
<spanclass="math">\(\mathtt{0xE0}\)</span>
and
<spanclass="math">\(\mathtt{0xE1}\)</span>
are reserved for optional address expiry metadata. A producer MAY choose to generate Unified Addresses containing either or both of the following Metadata Item Types, or none.</p>
<p>The value of a
<spanclass="math">\(\mathtt{0xE0}\)</span>
item MUST be an unsigned 32-bit integer in little-endian order specifying the Address Expiry Height, a block height of the Zcash chain associated with the UA/UVK. A Unified Address containing metadata Typecode
<spanclass="math">\(\mathtt{0xE0}\)</span>
MUST be considered expired when the height of the Zcash chain is greater than this value.</p>
<p>The value of a
<spanclass="math">\(\mathtt{0xE1}\)</span>
item MUST be an unsigned 64-bit integer in little-endian order specifying a Unix Epoch Time, hereafter referred to as the Address Expiry Time. A Unified Address containing Metadata Typecode
<spanclass="math">\(\mathtt{0xE1}\)</span>
MUST be considered expired when the current time is after the Address Expiry Time.</p>
<p>A Sender that supports <ahref="#revision-1">Revision 1</a> of this specification MUST set a non-zero <code>nExpiryHeight</code> field in transactions it creates that are sent to a Unified Address that defines an Address Expiry Height. If the <code>nExpiryHeight</code> normally constructed by the Sender would be greater than the Address Expiry Height, then the transaction MUST NOT be sent. If only an Address Expiry Time is specified, then the Sender SHOULD choose a value for <code>nExpiryHeight</code> such that the transaction will expire no more than 24 hours after the current time. If both
<p>If a Sender sends to multiple Unified Addresses in the same transaction, then all of the Address Expiry constraints imposed by the individual addresses apply.</p>
<p>If a wallet user attempts to send to an expired address, the error presented to the user by the wallet SHOULD include a suggestion that the user should attempt to obtain a currently-valid address for the intended recipient. A wallet MUST NOT send to an address that it knows to have expired.</p>
<p>Address expiration imposes no constraints on the Producer of an address. A Producer MAY generate multiple Unified Addresses with the same Receivers but different expiration metadata and/or any number of distinct Diversified Unified Addresses with the same or different expiry metadata, in any combination. Note that although changes to metadata will result in a visually distinct address, such updated addresses will be directly linkable to the original addresses because they share the same Receivers.</p>
<p>Producers of Diversified Unified Addresses should be aware that the expiration metadata could potentially be used to link addresses from the same source. Normally, if Diversified Unified Addresses derived from the same UIVK contain only Sapling and/or Orchard Receivers and no Metadata Items, they will be unlinkable as described in <aid="footnote-reference-26"class="footnote_reference"href="#protocol-concretediversifyhash">8</a>; this property does not hold when Metadata Items are present. It is RECOMMENDED that when deriving Unified Addresses from a UFVK or UIVK containing expiry metadata that the Expiry Height and Expiry Time of each distinct address vary from one another, so as to reduce the likelihood that addresses may be linked via their expiry metadata.</p>
<p>The intent of this specification is that Consumers of Unified Addresses must not send to expired addresses. If only an Address Expiry Time is specified, a transaction to the associated address could be mined after the Address Expiry Time within a 24-hour window.</p>
<p>The reason that the transaction MUST NOT be sent when its <code>nExpiryHeight</code> as normally constructed is greater than the Address Expiry Height is to avoid unnecessary information leakage in that field about which address was used as the destination. If a sender were to instead use the expiry height to directly set the <code>nExpiryHeight</code> field, this would leak the expiry information of the destination address, which may then be identifiable.</p>
<p>When honoring an Address Expiry Time, the reason that a sender SHOULD choose a <code>nExpiryHeight</code> that is expected to occur within 24 hours of the time of transaction construction is to, when possible, ensure that the expiry time is respected to within a day. Address Expiry Times are advisory and do not represent hard bounds because computer clocks often disagree, but every effort should be made to ensure that transactions expire instead of being mined more than 24 hours after a recipient address's expiry time. When chain height information is available to the Sender, it is both permissible and advisable to set this bound more tightly; a common expiry delta used by many wallets is 40 blocks from the current chain tip, as suggested in ZIP 203 <aid="footnote-reference-27"class="footnote_reference"href="#zip-0203-default-expiry">24</a>.</p>
<p>In addition to external addresses suitable for giving out to Senders, a wallet typically requires addresses for internal operations such as change and auto-shielding.</p>
<p>We desire the following properties for viewing authority of both shielded and transparent key trees:</p>
<ul>
<li>A holder of an FVK can derive external and internal IVKs, and external and internal
<spanclass="math">\(\mathsf{ovk}\)</span>
components.</li>
<li>A holder of the external IVK cannot derive the internal IVK, or any of the
<spanclass="math">\(\mathsf{ovk}\)</span>
components.</li>
<li>A holder of the external
<spanclass="math">\(\mathsf{ovk}\)</span>
component cannot derive the internal
<spanclass="math">\(\mathsf{ovk}\)</span>
component, or any of the IVKs.</li>
</ul>
<p>For shielded keys, these properties are achieved by the one-wayness of
(for Sapling and Orchard respectively). Derivation of an internal shielded FVK from an external shielded FVK is specified in the "Sapling internal key derivation" <aid="footnote-reference-28"class="footnote_reference"href="#zip-0032-sapling-internal-key-derivation">18</a> and "Orchard internal key derivation" <aid="footnote-reference-29"class="footnote_reference"href="#zip-0032-orchard-internal-key-derivation">20</a> sections of ZIP 32.</p>
<p>Since an external P2PKH FVK encodes the chain code and public key at the Account level, we can derive both external and internal child keys from it, as described in BIP 44 <aid="footnote-reference-31"class="footnote_reference"href="#bip-0044-path-change">34</a>. It is possible to derive an internal P2PKH FVK from the external P2PKH FVK (i.e. its parent) without having the external spending key, because child derivation at the Change level is non-hardened.</p>
<sectionid="deriving-a-uivk-from-a-ufvk"><h3><spanclass="section-heading">Deriving a UIVK from a UFVK</span><spanclass="section-anchor"><arel="bookmark"href="#deriving-a-uivk-from-a-ufvk"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>As a consequence of the specification in <ahref="#must-understand-typecodes">MUST-understand Typecodes</a>, as of <ahref="#revision-1">Revision 1</a> a Consumer of a UFVK MUST understand the meaning of all "MUST-understand" Metadata Item Typecodes present in the UFVK in order to derive a UIVK from it.</p>
<p>If the source UFVK is Revision 1 then the derived UIVK SHOULD be Revision 1; if the source UFVK includes any Metadata Items then the derived UIVK MUST be Revision 1.</p>
<p>For Metadata Items recognised by the Consumer, the processing of the Item when deriving a UIVK is specified in the section or ZIP describing that Item.</p>
<li>For a Sapling FVK, the corresponding Sapling IVK is obtained as specified in <aid="footnote-reference-32"class="footnote_reference"href="#protocol-saplingkeycomponents">4</a>.</li>
<li>For an Orchard FVK, the corresponding Orchard IVK is obtained as specified in <aid="footnote-reference-33"class="footnote_reference"href="#protocol-orchardkeycomponents">5</a>.</li>
<p>Items (including Metadata Items that are not "MUST-understand") that are unrecognised by a given Consumer, or that are specified in experiments that the user has not opted into (see <ahref="#experimental-usage">Experimental Usage</a>), MUST be dropped when the Consumer derives a UIVK from a UFVK.</p>
<sectionid="deriving-a-unified-address-from-a-uivk"><h3><spanclass="section-heading">Deriving a Unified Address from a UIVK</span><spanclass="section-anchor"><arel="bookmark"href="#deriving-a-unified-address-from-a-uivk"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>As a consequence of the specification in <ahref="#must-understand-typecodes">MUST-understand Typecodes</a>, as of <ahref="#revision-1">Revision 1</a> a Consumer of a UIVK MUST understand the meaning of all "MUST-understand" Metadata Item Typecodes present in the UIVK in order to derive a Unified Address from it.</p>
<p>If the source UIVK is Revision 1 then the derived Unified Address SHOULD be Revision 1; if the source UIVK includes any Metadata Items then the derived Unified Address MUST be Revision 1.</p>
<p>For Metadata Items recognised by the Consumer, the processing of the Item when deriving a Unified Address is specified in the section or ZIP describing that Item.</p>
<p>To derive a Unified Address from a UIVK we need to choose a diversifier index, which MUST be valid for all of the Viewing Key Types in the UIVK. That is,</p>
<li>A Sapling diversifier index MUST generate a valid diversifier as defined in ZIP 32 section “Sapling diversifier derivation” <aid="footnote-reference-35"class="footnote_reference"href="#zip-0032-sapling-diversifier-derivation">17</a>.</li>
<li>For a Sapling IVK, the corresponding Sapling Receiver is obtained as specified in <aid="footnote-reference-36"class="footnote_reference"href="#protocol-saplingkeycomponents">4</a>.</li>
<li>For an Orchard IVK, the corresponding Orchard Receiver is obtained as specified in <aid="footnote-reference-37"class="footnote_reference"href="#protocol-orchardkeycomponents">5</a>.</li>
<li>For a Transparent P2PKH IVK, the diversifier index is used as a BIP 44 child key index at the Index level <aid="footnote-reference-38"class="footnote_reference"href="#bip-0044-path-index">35</a> to derive the corresponding Transparent P2PKH Receiver. As is usual for derivations below the BIP 44 Account level, non-hardened (public) derivation <aid="footnote-reference-39"class="footnote_reference"href="#bip-0032-public-to-public">32</a> MUST be used. The IVK is assumed to correspond to the extended public key for the external (non-change) element of the path. That is, if the UIVK was constructed correctly then the BIP 44 path of the Transparent P2PKH Receiver will be
<p>Items (including Metadata Items that are not "MUST-understand") that are unrecognised by a given Consumer, or that are specified in experiments that the user has not opted into (see <ahref="#experimental-usage">Experimental Usage</a>), MUST be dropped when the Consumer derives a Unified Address from a UIVK.</p>
<p>See <ahref="#address-expiration-metadata">Address Expiration Metadata</a> for discussion of potential linking of Diversified Unified Addresses via their metadata.</p>
<sectionid="usage-of-outgoing-viewing-keys"><h3><spanclass="section-heading">Usage of Outgoing Viewing Keys</span><spanclass="section-anchor"><arel="bookmark"href="#usage-of-outgoing-viewing-keys"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>When a Sender constructs a transaction that creates Sapling or Orchard notes, it uses an outgoing viewing key, as described in <aid="footnote-reference-40"class="footnote_reference"href="#protocol-saplingsend">6</a> and <aid="footnote-reference-41"class="footnote_reference"href="#protocol-orchardsend">7</a>, to encrypt an outgoing ciphertext. Decryption with the outgoing viewing key allows recovering the sent note plaintext, including destination address, amount, and memo. The intention is that this outgoing viewing key should be associated with the source of the funds.</p>
<p>However, the specification of which outgoing viewing key should be used is left somewhat open in <aid="footnote-reference-42"class="footnote_reference"href="#protocol-saplingsend">6</a> and <aid="footnote-reference-43"class="footnote_reference"href="#protocol-orchardsend">7</a>; in particular, it was unclear whether transfers should be considered as being sent from an address, or from a ZIP 32 account <aid="footnote-reference-44"class="footnote_reference"href="#zip-0032-specification-wallet-usage">21</a>. The adoption of multiple shielded protocols that support outgoing viewing keys (i.e. Sapling and Orchard) further complicates this question, since from NU5 activation, nothing at the consensus level prevents a wallet from spending both Sapling and Orchard notes in the same transaction. (Recommendations about wallet usage of multiple pools will be given in ZIP 315 <aid="footnote-reference-45"class="footnote_reference"href="#zip-0315">27</a>.)</p>
<p>Here we refine the protocol specification in order to allow more precise determination of viewing authority for UFVKs.</p>
<p>A Sender will attempt to determine a "sending Account" for each transfer. The preferred approach is for the API used to perform a transfer to directly specify a sending Account. Otherwise, if the Sender can ascertain that all funds used in the transfer are from addresses associated with some Account, then it SHOULD treat that as the sending Account. If not, then the sending Account is undetermined.</p>
<p>The Sender also determines a "preferred sending protocol" —one of "transparent", "Sapling", or "Orchard"— corresponding to the most preferred Receiver Type (as given in <ahref="#encoding-of-unified-addresses">Encoding of Unified Addresses</a>) of any funds sent in the transaction.</p>
(according to the type of transfer), as specified by the preferred sending protocol, of the full viewing key for that Account (i.e. at the ZIP 32 Account level).</p>
<p>If the sending Account is undetermined, then the Sender SHOULD choose one of the addresses, restricted to addresses for the preferred sending protocol, from which funds are being sent (for example, the first one for that protocol), and then use the external or internal
<li>has a string encoding matching that of <em>one of</em> the input Addresses/Viewing Keys on some subset of characters (for concreteness, consider the first
<li>is controlled by the adversary (for concreteness, the adversary knows <em>at least one</em> of the private keys of the constituent Addresses).</li>
<li>In this variant, part b) above is replaced by the meaning of the new Address/Viewing Key being “usefully” different than the one it is based on, even though the adversary does not know any of the private keys. For example, if it were possible to delete a shielded constituent Address from a UA leaving only a Transparent Address, that would be a significant malleability attack.</li>
<p>There is a generic brute force attack against near second preimage resistance. The adversary generates UAs / UVKs at random with known keys, until one has an encoding that partially collides with one of the
<p>There is also a generic brute force attack against nonmalleability. The adversary modifies the target UA/UVK slightly and computes the corresponding decoding, then repeats until the decoding is valid and also useful to the adversary (e.g. it would lead to the Sender using a Transparent Address). With
<sectionid="usage-for-unified-addresses-ufvks-and-uivks"><h4><spanclass="section-heading">Usage for Unified Addresses, UFVKs, and UIVKs</span><spanclass="section-anchor"><arel="bookmark"href="#usage-for-unified-addresses-ufvks-and-uivks"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>In order to prevent the generic attack against nonmalleability, there needs to be some redundancy in the encoding. Therefore, the Producer of a Unified Address, UFVK, or UIVK appends the HRP, padded to 16 bytes with zero bytes, to the raw encoding, then applies
<p>(48 bytes allows for the minimum size of a shielded UA, UFVK, or UIVK Item encoding to be 32 bytes, taking into account 16 bytes of padding. Although there is currently no shielded Item encoding that short, it is plausible that one might be added in future.
<p>It would be possible to make an attack more expensive by making the work done by a Producer more expensive. (This wouldn't necessarily have to increase the work done by the Consumer.) However, given that Unified Addresses may need to be produced on constrained computing platforms, this was not considered to be beneficial overall.</p>
<p>The padding contains the HRP so that the HRP has the same protection against malleation as the rest of the address. This may help against cross-network attacks, or attacks that confuse addresses with viewing keys.</p>
bytes. The restriction to a single Address with a given Typecode (and at most one Transparent Address) means that this is also the maximum length of a Unified Address containing only defined Receiver Types as of NU5 activation.</p>
<p>For longer UAs (when other Receiver Types are added) or UVKs, the cost increases to 6 BLAKE2b compressions for
bytes plus the size of a BLAKE2b hash state. However, it is possible to reduce this by streaming the
<spanclass="math">\(d\)</span>
part of the jumbled encoding three times from a less memory-constrained device. It is essential that the streamed value of
<spanclass="math">\(d\)</span>
is the same on each pass, which can be verified using a Message Authentication Code (with key held only by the Consumer) or collision-resistant hash function. After the first pass of
<spanclass="math">\(d\)</span>
, the implementation is able to compute
<spanclass="math">\(y;\)</span>
after the second pass it is able to compute
<spanclass="math">\(a;\)</span>
and the third allows it to compute and incrementally parse
<spanclass="math">\(b.\)</span>
The maximum memory usage during this process would be 128 bytes plus two BLAKE2b hash states.</p>
is quite complicated, we do not require all Consumers to support streaming. If a Consumer implementation cannot support UAs / UVKs up to the maximum length, it MUST nevertheless support UAs / UVKs with
bytes. Note that this effectively defines two conformance levels to this specification. A full implementation will support UAs / UVKs up to the maximum length.</p>
<p>The authors would like to thank Benjamin Winston, Zooko Wilcox, Francisco Gindre, Marshall Gaucher, Joseph Van Geffen, Brad Miller, Deirdre Connolly, Teor, Eran Tromer, Conrado Gouvêa, and Marek Bielik for discussions on the subject of Unified Addresses and Unified Viewing Keys.</p>
<td><ahref="https://www.rfc-editor.org/info/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"</a></td>
<td><ahref="protocol/protocol.pdf#addressandkeyencoding">Zcash Protocol Specification, Version 2023.4.0. Section 5.6: Encodings of Addresses and Keys</a></td>
<td><ahref="protocol/protocol.pdf#orchardfullviewingkeyencoding">Zcash Protocol Specification, Version 2023.4.0. Section 5.6.4.4: Orchard Raw Full Viewing Keys</a></td>