<?xml version="1.0" encoding="utf-8"?>
<!-- 
     draft-chins-dnsop-web3-wallet-mapping-00
     Documentation is at https://authors.ietf.org/en/templates-and-schemas
-->
<?xml-model href="rfc7991bis.rnc"?>  <!-- Required for schema validation and schema-aware editing -->
<!-- <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> -->
<!-- This third-party XSLT can be enabled for direct transformations in XML processors, including most browsers -->


<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- If further character entities are required then they should be added to the DOCTYPE above.
     Use of an external entity file is not recommended. -->

<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="std"
  docName="draft-chins-dnsop-web3-wallet-mapping-00"
  ipr="trust200902"
  obsoletes=""
  updates=""
  submissionType="IETF"
  xml:lang="en"
  consensus="true"
  version="3">
  <front>
    <title abbrev="Abbreviated Title">DNS to Web3 Wallet Mapping</title>

    <seriesInfo name="Internet-Draft" value="draft-chins-dnsop-web3-wallet-mapping-00"/>
   
    <author fullname="Shay Chin" initials="SC" role="editor" surname="Chin">
      <!-- [CHECK]
             * initials should not include an initial for the surname
             * role="editor" is optional -->
    <!-- Can have more than one author -->
      
    <!-- all of the following elements are optional -->
      <organization>D3 Global Inc</organization>
      <address>
        <email>shay@d3.email</email>  
      </address>
    </author>
   
    <date year="2024"/>
    <!-- On draft subbmission:
         * If only the current year is specified, the current day and month will be used.
         * If the month and year are both specified and are the current ones, the current day will
           be used
         * If the year is not the current one, it is necessary to specify at least a month and day="1" will be used.
    -->

    <area>General</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <!-- "Internet Engineering Task Force" is fine for individual submissions.  If this element is 
          not present, the default is "Network Working Group", which is used by the RFC Editor as 
          a nod to the history of the RFC Series. -->

    <keyword>Web3 Wallet DNS Mapping</keyword>
    <!-- [REPLACE/DELETE]. Multiple allowed.  Keywords are incorporated into HTML output files for 
         use by search engines. -->

    <abstract>
      <t>This document proposes a standard for mapping wallets to domain names using TXT records.  The goal is to provide a secure and scalable way to associate wallets with domain names, enabling seamless lookup as well as assisting in authentication.  The proposal heavily uses DNSSEC to ensure security.  We also will propose a mechanism for mapping a wallet back to a domain name.</t>
    </abstract>
 
  </front>

  <middle>
    <section>
      <name>Introduction</name>
      <t>There is fragmentation in the mapping of Web3 Wallets to Domain Names <xref target="RFC1034"/> as well as the reverse lookup process.  This document is putting forth a standard to map Web3 Wallet addresses to Domain Names and investigates the associated security and technical concerns.</t>
      <t>As the use of digital wallets and online services grows, the need for a standardized way to lookup wallet addresses in an human readable format becomes increasingly important. This proposal aims to provide a solution that is easy to implement, scalable, and secure.</t>
      <t>The proposed solution involves creating a TXT record with the record extension "_w3addr" to map a wallet to a domain name. The TXT record will contain a object that maps the wallet address to the registered coin type token <xref target="SLIP-0044"/>. It is assumed that the record will be part of a DNSSEC <xref target="RFC4033"/> <xref target="RFC9364"/> signed zonefile and that users of this service will verify the signatures to ensure that the record has been returned without alteration in flight.</t>
      <t>On the reverse mapping, we propose that we allow a singular coin type/address be mapped to a domain name in DNS. This will also be protected by DNSSEC. We encourage users to use a more centralized registry for this.</t>
      
      <section>
        <name>Requirements Language</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
          "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT
          RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
          interpreted as described in BCP 14 <xref target="RFC2119"/>
          <xref target="RFC8174"/> when, and only when, they appear in
          all capitals, as shown here.</t>
      </section>
    </section>
    
    <section>
      <name>Domain to Wallet Mapping</name>
      <section>
        <name>Record Format</name>
        <t>The TXT record SHALL have the following format:</t>
        <sourcecode>
          <![CDATA[
    _w3addr IN TXT "coin1:address1,coin2:address2,..."
          ]]>
        </sourcecode>
        <dl newline="true">
            <dt>_w3addr</dt>
            <dd>is the TXT record name</dd>
            <dt>IN</dt>
            <dd>is the class of the record</dd>
            <dt>TXT</dt>
            <dd>is the type of the record</dd>
            <dt>coin1:address1,coin2:address2,...</dt>
            <dd>is the value of the record, containing a comma-separated list of coin:address pairs</dd>
        </dl>
      </section>

      <section>
        <name>Grammar for the record in EBNF format</name>
        <sourcecode>
          <![CDATA[
          record_list = item ("," item)*
          item = (coin_name ("|" coin_name | "*")*) ":" address
          coin_name = [a-zA-Z0-9_]+
          address = [a-zA-Z0-9]+
          ]]>
        </sourcecode>

        <dl newline="true">
          <dt>record_list</dt>
          <dd>represents the entire list of coin-address pairs</dd>
          <dt>item</dt>
          <dd>represents a coin-address pair</dd>
          <dt>wildcard</dt>
          <dd>is the symbol representing the default match</dd>
          <dt>coin_name</dt>
          <dd>represents the Symbol of a chain represented in <xref target="SLIP-0044"/></dd>
          <dt>address</dt>
          <dd>represents the public wallet address associated with a coin (e.g., "0xabcdefg", "0x12345", etc.)</dd>
        </dl>
        <t>The * symbol indicates zero or more occurrences of the preceding element. The + symbol indicates one or more occurrences.</t>
        <t>This grammar can be used to parse the input string and extract the chain identifier and addresses.</t>
      </section>

      <section>
        <name>Example</name>
        <t>Suppose a user wants to map their wallet with the public key 0x1234567890abcdef to the domain example.com using the registered coin type tokens BTC and ETH. The TXT record would be:</t>
        <sourcecode><![CDATA[
          _w3addr IN TXT "BTC:0x1234567890abcd,ETH:0x987654321098765"
        ]]></sourcecode>
      </section>
      
      <section>
        <name>Wildcard Support</name>
        <t>To support multiple wallets and chains, the TXT record SHALL allow for a solitary wildcard * to substitute for the default chain name. For example:</t>
        <sourcecode>
          <![CDATA[
          _w3addr IN TXT "*:0x1234567890abcd,ETH:0x987654321098765"
          ]]>
        </sourcecode>
        <t>The lookup will return the most specific record for a chain.</t>
      </section>

      <section>
        <name>Multiple Records</name>
        <t>To support multiple records, the TXT record SHALL allow for multiple coin:address pairs separated by commas. If the record exceeds the 2048 character limit, it MAY be continued on additional TXT records.  There is no guarantees on ordering the records so overlapping records MAY ordered at the resolver's discretion.  In the event of duplicate chains it is RECOMMENDED that multiple records be returned dedupped for identical addresses.</t>
      </section>

      <section>
        <name>Implementation</name>
        <t>Implementations of this RFC SHALL:</t>
        <ol>
          <li>Support the creation and retrieval of TXT records with the _w3addr name for any given level of the DNS system.</li>
          <li>Order the lookup of the wallet address based on the returned records.</li>
          <li>Provide the wallet's public key for addressing by chain.</li>
        </ol>
      </section>
    </section>
    
    <section>
      <name>Wallet to Domain Reverse Mapping</name>
      <section>
        <name>Solution</name>
        <t>A wallet owner has the OPTIONAL ability to setup a reverse lookup using DNS in a similar manner for IANA in-addr.arpa and ip6.arpa against a centralized service. Queriants will be able to query a CNAME record with wallet information, to get a domain mapping, they have the OPTIONAL ability to query with a chain designation using the registered coin type defined in SLIP-0044.</t>
        <t>Until IANA decides to provide this service, this MAY be offered by outside parties.</t>
      </section>

      <section>
        <name>Limitations</name>
        <t>DNS is case insensitive, but some wallet addresses are case sensitive.  Because of the vast namespace available in Web3 Addresses, it is unlikely, but MAY result in a collision.</t>
      </section>

      <section>
        <name>Reverse Wallet Mapping Example</name>
        <t>There is currently no IANA support lookup path, but a user will be able to lookup from a reverse mapping provider until there is a centralized body.</t>
        <t>It can be qualified as a chain designation</t>
        <sourcecode>
          <![CDATA[
          0x1234567890abcd.eth.wallet.vana IN CNAME _w3addr.test.vana
          ]]>
        </sourcecode>
        <t>or</t>
        <t>Default</t>
        <sourcecode>
          <![CDATA[
          0x1234567890abcd.wallet.vana IN CNAME test.vana
          ]]>
        </sourcecode>
      </section>

      <section>
        <name>Multiple mappings</name>
        <t>It is NOT SUPPORTED for a wallet / network pair to point to multiple domains.  The CNAME record does not support returning multiple records.</t>
      </section>

      <section>
        <name>Potential Implementation</name>
        <ol>
          <li>A service will take a signed message telling the reverse lookup service for the wallet to point to a domain. OPTIONAL with chain information.</li>
          <li>The service SHALL validate the signed message.</li>
          <li>The service SHALL validate the domain to wallet mapping using the above Domain to Wallet Protocol.</li>
          <li>The service SHALL update the DNS record acting as a registry for Wallet to Domain mapping.</li>
          <li>OPTIONAL the service should validate the Domain to Wallet mapping on a periodic basis.</li>
        </ol>
      </section>
    </section>

    <section anchor="Security">
      <name>Security Considerations</name>
      <t>To ensure the security of the mapping, the following measures will be taken:</t>
      <ol>
        <li>The TXT record SHALL BE stored in a secure location, such as a DNSSEC-signed zone.</li>
        <li>The implementation SHALL validate the DNSSEC record.</li>
        <li>The wallet record SHALL be protected from replay attacks via DNSSEC time invalidation.</li>
      </ol>
      <t>If the source of the DNS zone is compromised, the wallet address mapping is compromised, it is imperative that this not occur.</t>
    </section>

    
    <section anchor="IANA">
    <!-- All drafts are required to have an IANA considerations section. See RFC 8126 for a guide.-->
      <name>IANA Considerations</name>
      <t>This proposal requests that IANA support reverse mapping of wallet addresses to domains.</t>
    </section>
    
    <!-- NOTE: The Acknowledgements and Contributors sections are at the end of this template -->
  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.1034.xml"/> 
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4033.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9364.xml"/>
        
        <!-- The recommended and simplest way to include a well known reference -->
        
      </references>
      <references>
        <name>Informational References</name>
        <reference anchor="SLIP-0044" target="https://raw.githubusercontent.com/satoshilabs/slips/master/slip-0044.md">
          <front>
            <title>Registered coin types for BIP-0044</title>
            <author/>
            <date/>
          </front>
        </reference>
      </references>
    </references>
    
    <section anchor="Appendix">
      <name>Appendix 1: Example code</name>
      <t>Here is an example of how to create and retrieve a TXT records using the _w3addr name:</t>
      <sourcecode>
        <![CDATA[
        import dns.resolver.wallet
        # Retrieve the TXT record
        record = dns.resolveWallet("example.com", "BTC")

        print(record.value)  # Output: "0x1234567890abcdef"
        ]]>
      </sourcecode>
    </section>

    <section anchor="Contributors" numbered="false">
      <name>Contributors</name>
      <t>Thanks to all of the contributors for contributions to security and clarity.</t>
      <contact fullname="Yevhenii Andrushchak"><address><email>yevhenii@d3.email</email></address></contact>
      <contact fullname="Kai Sung"><address><email>kai@d3.email</email></address></contact>
    </section>

    <section anchor="Acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>Reviewed by:</t>
      <contact fullname="Jothan Frakes"><address><email>jothan@frakes.com</email></address></contact>
    </section>
    
    
 </back>
</rfc>
