From 1019792188a1d72f8ca9c63f0d7ca7099f888315 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 25 Jan 2024 21:45:44 -0700 Subject: [PATCH] ZIP 320: Specify Alternative 2 in terms of a MUST-understand metadata item. --- zip-0320.html | 107 +++++++++++++++++++++++++++++++++----------------- zip-0320.rst | 83 +++++++++++++++++++++++---------------- 2 files changed, 122 insertions(+), 68 deletions(-) diff --git a/zip-0320.html b/zip-0320.html index 7fa655df..ab0df2d6 100644 --- a/zip-0320.html +++ b/zip-0320.html @@ -21,7 +21,7 @@ Pull-Request: <https://githu

Terminology

The key words "MUST", "SHOULD", and "MAY" in this document are to be interpreted as described in BCP 14 1 when, and only when, they appear in all capitals.

The terms "Recipient", "Producer", "Consumer", "Sender", "Receiver", "Item", "Metadata Item", "Typecode", "Address", "Unified Address" (UA), "Unified Viewing Key" (UVK), "Unified Full Viewing Key" (UFVK), and "Unified Incoming Viewing Key" (UIVK) are to be interpreted as described in ZIP 316 5.

-

The terms "Testnet" and "Mainnet" are to be interpreted as described in section 3.12 of the Zcash Protocol Specification 9.

+

The terms "Testnet" and "Mainnet" are to be interpreted as described in section 3.12 of the Zcash Protocol Specification 11.

Abstract

This ZIP defines a new encoding for transparent Zcash addresses. Wallets must ensure that no shielded notes are spent in transactions that send to a transparent address encoded in the specified fashion.

@@ -44,7 +44,7 @@ Pull-Request: <https://githu

Alternative 1

This alternative was suggested by @hanh in 4.

TEX Addresses

-

A TEX Address is a Bech32m 14 reencoding of a transparent Zcash P2PKH address 10.

+

A TEX Address is a Bech32m 16 reencoding of a transparent Zcash P2PKH address 12.

Motivations for Alternative 1

The TEX Address is the simplest possible approach to creating a new address type that indicates that only transparent sources of funds should be used.

@@ -52,11 +52,11 @@ Pull-Request: <https://githu

Specification (Alternative 1)

A TEX address is produced from a Mainnet Zcash P2PKH Address by executing the following steps:

    -
  1. Decode the address to a byte sequence using the Base58Check decoding algorithm 12.
  2. +
  3. Decode the address to a byte sequence using the Base58Check decoding algorithm 14.
  4. If the length of the resulting byte sequence is not 22 bytes or if its two-byte address prefix is not \([\mathtt{0x1C}, \mathtt{0xB8}]\) , return an error. Otherwise, let the validating key hash be the remaining 20 bytes of the sequence after removing the two-byte address prefix.
  5. -
  6. Reencode the 20-byte validating key hash using the Bech32m encoding defined in 14 with the human-readable prefix (HRP) "tex".
  7. +
  8. Reencode the 20-byte validating key hash using the Bech32m encoding defined in 16 with the human-readable prefix (HRP) "tex".

For Testnet addresses, the required lead bytes of a P2PKH address in step 2 are \([\mathtt{0x1D}, \mathtt{0x25}]\) @@ -90,14 +90,20 @@ console.log(t1)

A Traceable Unified Address is a reencoding of a transparent Zcash P2PKH address into a Unified Address 6.

Motivations for Alternative 2

-

Traceable Unified Addresses fit into the existing Zcash Unified Address ecosystem. Existing Consumers that support Unified Addresses will automatically be able to recognize a Traceable Unified Address as a valid Zcash address, but will not be able to send to that address unless they update their code to understand the new Receiver Typecode defined in this ZIP. Even in the case that Traceable P2PKH Receivers are not understood by the sending wallet, a Unified Address-supporting wallet will be able to automatically provide good error messages for their users to indicate that the wallet needs to be updated to understand and send to these addresses.

-

In addition, by integrating with the Unified Address framework, it becomes possible for the addresses being generated to include extra metadata; in particular, metadata items such as an Address Expiry Height or Address Expiry Date 8 may be included. For exchange use cases such as Binance's, it is useful to ensure that an address provided to a user has a limited utility life, such that after expiration the user must obtain a new address in order to be able to continue to send funds 11.

+

Traceable Unified Addresses fit into the Zcash Unified Address ecosystem defined by ZIP 316, Revision 1 7. Existing Consumers of Unified Addresses will not be able to send to these address unless they update their code to understand the new MUST-understand Metadata Typecode defined in this ZIP.

+

By integrating with the Unified Address framework, it becomes possible for the addresses being generated to include extra metadata; in particular, metadata items such as an Address Expiry Height or Address Expiry Date 9 may be included. For exchange use cases such as Binance's, it is useful to ensure that an address provided to a user has a limited utility life, such that after expiration the user must obtain a new address in order to be able to continue to send funds 13.

Specification (Alternative 2)

-

Upon activation of this ZIP, the section Encoding of Unified Addresses of ZIP 316 6 will be modified to define a new Traceable P2PKH Receiver Type having Typecode - \(\mathtt{0x04}\) - , the value of which MUST be the 20-byte validating key hash of a Zcash P2PKH Address as defined in 10.

-

The "Requirements for both Unified Addresses and Unified Viewing Keys" section of ZIP 316 7 will be modified as follows — the text:

+

Upon activation of this ZIP, the section Metadata Items of ZIP 316 10 will be modified to define a new MUST-understand Metadata Item type: Source Restriction Metadata, having Typecode + \(\mathtt{0xE2}\) + , the value of which must be a single byte:

+
    +
  • + \(\mathtt{0x00}\) + - Transparent Source Only
  • +
+

Additional Source Restriction Metadata values may be defined in the future.

+

The "Requirements for both Unified Addresses and Unified Viewing Keys" section of ZIP 316 8 will be modified as follows — the text:

A Unified Address or Unified Viewing Key MUST contain at least one shielded Item (Typecodes \(\mathtt{0x02}\) @@ -113,12 +119,18 @@ console.log(t1) \(\mathtt{0x02}\) and \(\mathtt{0x03}\) - ), and no Traceable P2PKH Receiver (Typecode - \(\mathtt{0x04}\) - ); or -

  • contain only a Traceable P2PKH Receiver (Typecode - \(\mathtt{0x04}\) - ).
  • + ), and no Source Restriction Metadata Item having value + \(\mathtt{0x00}\) + ; or +
  • contain both a Transparent Receiver (Typecode + \(\mathtt{0x00}\) + or Typecode + \(\mathtt{0x01}\) + ) and a Source Restriction Metadata Item (Typecode + \(\mathtt{0xE2}\) + ) having value + \(\mathtt{0x00}\) + , and no other Receivers.
  • A Unified Viewing Key MUST contain at least one shielded Item (Typecodes \(\mathtt{0x02}\) @@ -126,24 +138,32 @@ console.log(t1) \(\mathtt{0x03}\) ).

    +

    In the following, the “u+” Human Readable Part of Revision 1 Unified Addresses is a placeholder value, pending the finalization of Revision 1 7.

    A Traceable Unified Address is produced from a Mainnet Zcash P2PKH address by executing the following steps:

      -
    1. Decode the address to a byte sequence using the Base58Check decoding algorithm 12.
    2. +
    3. Decode the address to a byte sequence using the Base58Check decoding algorithm 14.
    4. If the length of the resulting byte sequence is not 22 bytes or if its two-byte address prefix is not \([\mathtt{0x1C}, \mathtt{0xB8}]\) , return an error. Otherwise, let the validating key hash be the remaining 20 bytes of the array after removing the two-byte address prefix.
    5. -
    6. Construct a new Unified Address using a single Traceable P2PKH Receiver +
    7. Construct a new Revision 1 Unified Address using a single P2PKH Receiver \(\mathtt{0x04}\) - with the 20-byte validating key hash as its value. In addition, metadata items such as an Address Expiry Height or Address Expiry Date 8 MAY be included.
    8. + with the 20-byte validating key hash as its value, and a Source Restriction Metadata Item (Typecode + \(\mathtt{0xE2}\) + ) having value + \(\mathtt{0x00}\) + (Transparent Source Only). In addition, metadata items such as an Address Expiry Height or Address Expiry Date 9 MAY be included. +
    9. Encode the Unified Address using the “u+” Human Readable Part as specified for Revision 1 of ZIP 316 6.

    For Testnet addresses, the required lead bytes of a P2PKH address in step 2 are \([\mathtt{0x1D}, \mathtt{0x25}]\) .

    -

    The HRP of the resulting Unified Address is the same as for any other Unified Address on the relevant network as specified in 6, i.e. "u" for Mainnet and "utest" for Testnet.

    -

    Wallets and other Senders sending to a Traceable P2PKH Receiver MUST ensure that only transparent UTXOs are spent in the creation of a transaction.

    +

    The HRP of the resulting Unified Address is the same as for any other Revision 1 Unified Address on the relevant network as specified in 7, i.e. "u+" for Mainnet and "u+test" for Testnet.

    +

    Wallets and other Senders MUST ensure that only transparent UTXOs are spent in the creation of a transaction to any Unified Address containing a Source Restriction Metadata Item having value + \(\mathtt{0x00}\) + .

    Reference Implementation (Alternative 2)

    -

    Javascript using zcash_address_wasm 15:

    +

    Javascript using zcash_address_wasm 17:

    import init, { to_traceable_address, traceable_to_p2pkh, addr_expiry_time } from 'zcash_address_wasm';
     init().then(() => {
       var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
    @@ -183,7 +203,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT

    Cons to Alternative 1

    • Existing wallets and other Consumers will regard the new address type as entirely invalid, and will not automatically prompt their users that they need to upgrade in order to send to this type of address.
    • -
    • Creation of a new fully distinct address type further fragments the Zcash address ecosystem. Avoiding such fragmentation and providing smooth upgrade paths and good error messages to users is exactly the problem that Unified Addresses 6 were intended to avoid.
    • +
    • Creation of a new fully distinct address type further fragments the Zcash address ecosystem. Avoiding such fragmentation and providing smooth upgrade paths and good error messages to users is exactly the problem that Unified Addresses 6 were intended to avoid.
    • The TEX address type does not provide any mechanism for address expiration. One of the questions Binance has asked has been what to do about users who have stored their existing transparent deposit address in their wallets, or use them as a withdrawal address for other exchanges or services. This is a challenging problem to mitigate now because address expiration was not previously implemented. We should not further compound this problem by defining a new distinct address type that does not provide a mechanism for address expiry.
    @@ -191,9 +211,9 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT

    Analysis of Alternative 2

    Pros To Alternative 2

      -
    • By integrating with the Unified Address framework, Consumers of Traceable Unified Addresses that have not yet been upgraded to recognize these addresses can automatically be prompted to upgrade their wallets or services to understand the unrecognized Receiver Typecode.
    • +
    • By integrating with the Unified Address framework, Consumers of Revision 1 Unified Addresses that have not yet been upgraded to recognize these addresses can automatically be prompted to upgrade their wallets or services to understand the unrecognized MUST-understand Metadata Typecode.
    • It is possible to include address expiration metadata in a Traceable Unified Address, which can help to mitigate problems related to stored addresses in the future.
    • -
    • Traceable Unified Addresses benefit from the robustness to errors and protection against malleation of Unified Addresses 13.
    • +
    • Traceable Unified Addresses benefit from the robustness to errors and protection against malleation of Unified Addresses 15.
    • Regardless of which proposal is adopted, the Zcash Community will need to work with exchanges other than Binance to update their address parsing logic to understand the new address format. By encouraging Consumers such as exchanges to adopt parsing for Unified Addresses, this proposal furthers the original goal of Unified Addresses to reduce fragmentation in the address ecosystem.

      Whenever any new feature is added, wallets have a choice whether or not to support that new feature. The point of Unified Address parsing is that wallets don’t have to upgrade to recognize a different address format as a valid Zcash address. Instead of returning a “Not a valid Zcash address” error, which could be confusing for users, they can return an error more like “This is a valid Zcash address, but this wallet does not support sending to it.” This can be used as a prompt to upgrade the wallet to a version (or alternative) that does support that feature.

      For example: numerous wallets have already upgraded to being able to parse Unified Addresses. Those wallets, on seeing a Traceable Unified Address from Binance, will report to their users that the address is a valid Zcash address, but not yet supported by the wallet. Instead of a user thinking that Binance has made some error, they can contact the wallet’s developer and ask that the wallet be updated.

      @@ -202,7 +222,8 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT

    Cons to Alternative 2

      -
    • Unified Address encoding is slightly more complex than the proposed TEX address encoding, and requires use of the F4Jumble encoding algorithm 13. However, this can be readily mitigated by providing a purpose-built library for Traceable Unified Address encoding to Producers.
    • +
    • Existing wallets and other Consumers of Revision 0 Unified Addresses will regard the new address type as entirely invalid, and will not automatically prompt their users that they need to upgrade in order to send to this type of address.
    • +
    • Unified Address encoding is slightly more complex than the proposed TEX address encoding, and requires use of the F4Jumble encoding algorithm 15. However, this can be readily mitigated by providing a purpose-built library for Traceable Unified Address encoding to Producers.
    • A Traceable Unified Address is somewhat longer than a TEX address, although not excessively so.
    @@ -256,10 +277,18 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT - +
    + + + +
    7ZIP 316: Unified Addresses and Unified Viewing Keys — Revision 1
    + + + + @@ -267,15 +296,23 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    8 ZIP 316: Unified Addresses and Unified Viewing Keys — Requirements for both Unified Addresses and Unified Viewing Keys
    - +
    89 ZIP 316: Unified Addresses and Unified Viewing Keys — Address Expiration Metadata
    + + + + + + + +
    10ZIP 316: Unified Addresses and Unified Viewing Keys — Metadata Items
    - + @@ -283,7 +320,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    911 Zcash Protocol Specification, Version 2023.4.0. Section 3.12: Mainnet and Testnet
    - + @@ -291,7 +328,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    1012 Zcash Protocol Specification, Version 2023.4.0. Section 5.6.1.1 Transparent Addresses
    - + @@ -299,7 +336,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    1113 Zcash Community Forum post describing motivations for address expiry
    - + @@ -307,7 +344,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    1214 Base58Check encoding — Bitcoin Wiki
    - + @@ -315,7 +352,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    1315 ZIP 316: Unified Addresses and Unified Viewing Keys — Jumbling
    - + @@ -323,7 +360,7 @@ expiry time: Mon Feb 13 2024 01:14:18 GMT
    1416 BIP 350: Bech32m format for v1+ witness addresses
    - + diff --git a/zip-0320.rst b/zip-0320.rst index 652d28f5..61934495 100644 --- a/zip-0320.rst +++ b/zip-0320.rst @@ -157,21 +157,17 @@ address into a Unified Address [#zip-0316-unified-addresses]_. Motivations for Alternative 2 ----------------------------- -Traceable Unified Addresses fit into the existing Zcash Unified Address -ecosystem. Existing Consumers that support Unified Addresses will automatically -be able to recognize a Traceable Unified Address as a valid Zcash address, but -will not be able to send to that address unless they update their code to -understand the new Receiver Typecode defined in this ZIP. Even in the case that -Traceable P2PKH Receivers are not understood by the sending wallet, a Unified -Address-supporting wallet will be able to automatically provide good error -messages for their users to indicate that the wallet needs to be updated to -understand and send to these addresses. +Traceable Unified Addresses fit into the Zcash Unified Address ecosystem +defined by ZIP 316, Revision 1 [#zip-0316-revision-1]_. Existing Consumers of +Unified Addresses will not be able to send to these address unless they update +their code to understand the new MUST-understand Metadata Typecode defined in +this ZIP. -In addition, by integrating with the Unified Address framework, it becomes -possible for the addresses being generated to include extra metadata; in -particular, metadata items such as an Address Expiry Height or Address Expiry -Date [#zip-0316-address-expiry]_ may be included. For exchange use cases such -as Binance's, it is useful to ensure that an address provided to a user has a +By integrating with the Unified Address framework, it becomes possible for the +addresses being generated to include extra metadata; in particular, metadata +items such as an Address Expiry Height or Address Expiry Date +[#zip-0316-address-expiry]_ may be included. For exchange use cases such as +Binance's, it is useful to ensure that an address provided to a user has a limited utility life, such that after expiration the user must obtain a new address in order to be able to continue to send funds [#binance-address-expiry]_. @@ -179,11 +175,14 @@ address in order to be able to continue to send funds Specification (Alternative 2) ----------------------------- -Upon activation of this ZIP, the section `Encoding of Unified Addresses` of ZIP -316 [#zip-0316-unified-addresses]_ will be modified to define a new Traceable -P2PKH Receiver Type having Typecode :math:`\mathtt{0x04}`, the value of which -MUST be the 20-byte **validating key hash** of a Zcash P2PKH Address as defined -in [#protocol-transparentaddrencoding]_. +Upon activation of this ZIP, the section `Metadata Items` of ZIP 316 +[#zip-0316-metadata-items]_ will be modified to define a new MUST-understand +Metadata Item type: Source Restriction Metadata, having Typecode +:math:`\mathtt{0xE2}`, the value of which must be a single byte: + +* :math:`\mathtt{0x00}` - Transparent Source Only + +Additional Source Restriction Metadata values may be defined in the future. The "Requirements for both Unified Addresses and Unified Viewing Keys" section of ZIP 316 [#zip-0316-unified-requirements]_ will be modified as follows — the @@ -203,13 +202,20 @@ will be replaced by: such that a Unified Address MUST **either**: * contain at least one shielded Receiver (Typecodes :math:`\mathtt{0x02}` - and :math:`\mathtt{0x03}`), and no Traceable P2PKH Receiver (Typecode - :math:`\mathtt{0x04}`); **or** - * contain **only** a Traceable P2PKH Receiver (Typecode :math:`\mathtt{0x04}`). + and :math:`\mathtt{0x03}`), and **no** Source Restriction Metadata Item + having value :math:`\mathtt{0x00}`; **or** + * contain **both** a Transparent Receiver (Typecode :math:`\mathtt{0x00}` or + Typecode :math:`\mathtt{0x01}`) **and** a Source Restriction Metadata Item + (Typecode :math:`\mathtt{0xE2}`) having value :math:`\mathtt{0x00}`, and + **no other** Receivers. A Unified Viewing Key MUST contain at least one shielded Item (Typecodes :math:`\mathtt{0x02}` and :math:`\mathtt{0x03}`). +In the following, the “``u+``” Human Readable Part of Revision 1 Unified +Addresses is a placeholder value, pending the finalization of Revision 1 +[#zip-0316-revision-1]_. + A Traceable Unified Address is produced from a Mainnet Zcash P2PKH address by executing the following steps: @@ -219,20 +225,25 @@ executing the following steps: two-byte address prefix is not :math:`[\mathtt{0x1C}, \mathtt{0xB8}]`, return an error. Otherwise, let the **validating key hash** be the remaining 20 bytes of the array after removing the two-byte address prefix. -3. Construct a new Unified Address using a single Traceable P2PKH Receiver - :math:`\mathtt{0x04}` with the 20-byte **validating key hash** as its value. - In addition, metadata items such as an Address Expiry Height or Address - Expiry Date [#zip-0316-address-expiry]_ MAY be included. +3. Construct a new Revision 1 Unified Address using a single P2PKH Receiver + :math:`\mathtt{0x04}` with the 20-byte **validating key hash** as its value, + and a Source Restriction Metadata Item (Typecode :math:`\mathtt{0xE2}`) + having value :math:`\mathtt{0x00}` (Transparent Source Only). In addition, + metadata items such as an Address Expiry Height or Address Expiry Date + [#zip-0316-address-expiry]_ MAY be included. +4. Encode the Unified Address using the “``u+``” Human Readable Part as + specified for Revision 1 of ZIP 316 [#zip-0316-unified-addresses]_. For Testnet addresses, the required lead bytes of a P2PKH address in step 2 are :math:`[\mathtt{0x1D}, \mathtt{0x25}]`. -The HRP of the resulting Unified Address is the same as for any other Unified -Address on the relevant network as specified in [#zip-0316-unified-addresses]_, -i.e. ``"u"`` for Mainnet and ``"utest"`` for Testnet. +The HRP of the resulting Unified Address is the same as for any other Revision 1 +Unified Address on the relevant network as specified in [#zip-0316-revision-1]_, +i.e. ``"u+"`` for Mainnet and ``"u+test"`` for Testnet. -Wallets and other Senders sending to a Traceable P2PKH Receiver MUST ensure -that only transparent UTXOs are spent in the creation of a transaction. +Wallets and other Senders MUST ensure that only transparent UTXOs are spent in +the creation of a transaction to any Unified Address containing a Source +Restriction Metadata Item having value :math:`\mathtt{0x00}`. Reference Implementation (Alternative 2) ---------------------------------------- @@ -304,10 +315,10 @@ Analysis of Alternative 2 Pros To Alternative 2 --------------------- -- By integrating with the Unified Address framework, Consumers of Traceable +- By integrating with the Unified Address framework, Consumers of Revision 1 Unified Addresses that have not yet been upgraded to recognize these addresses can automatically be prompted to upgrade their wallets or services - to understand the unrecognized Receiver Typecode. + to understand the unrecognized MUST-understand Metadata Typecode. - It is possible to include address expiration metadata in a Traceable Unified Address, which can help to mitigate problems related to stored addresses in the future. @@ -339,6 +350,10 @@ Pros To Alternative 2 Cons to Alternative 2 --------------------- +- Existing wallets and other Consumers of Revision 0 Unified Addresses will + regard the new address type as entirely invalid, and will not automatically + prompt their users that they need to upgrade in order to send to this type of + address. - Unified Address encoding is slightly more complex than the proposed TEX address encoding, and requires use of the F4Jumble encoding algorithm [#F4Jumble]_. However, this can be readily mitigated by providing a @@ -355,8 +370,10 @@ References .. [#hanh-suggestion] `Ywallet developer @hanh's proposal `_ .. [#zip-0316-terminology] `ZIP 316: Unified Addresses and Unified Viewing Keys — Terminology `_ .. [#zip-0316-unified-addresses] `ZIP 316: Unified Addresses and Unified Viewing Keys — Encoding of Unified Addresses `_ +.. [#zip-0316-revision-1] `ZIP 316: Unified Addresses and Unified Viewing Keys — Revision 1 `_ .. [#zip-0316-unified-requirements] `ZIP 316: Unified Addresses and Unified Viewing Keys — Requirements for both Unified Addresses and Unified Viewing Keys `_ .. [#zip-0316-address-expiry] `ZIP 316: Unified Addresses and Unified Viewing Keys — Address Expiration Metadata `_ +.. [#zip-0316-metadata-items] `ZIP 316: Unified Addresses and Unified Viewing Keys — Metadata Items `_ .. [#protocol-networks] `Zcash Protocol Specification, Version 2023.4.0. Section 3.12: Mainnet and Testnet `_ .. [#protocol-transparentaddrencoding] `Zcash Protocol Specification, Version 2023.4.0. Section 5.6.1.1 Transparent Addresses `_ .. [#binance-address-expiry] `Zcash Community Forum post describing motivations for address expiry `_
    1517 zcash_address_wasm: Proof-of-concept library for Traceable Unified Address Encoding