<?xml version="1.0" encoding="utf-8"?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     ipr="trust200902"
     submissionType="independent"
     category="info"
     docName="draft-ribeiro-silva-cnp-00"
     version="3">

  <front>
    <title abbrev="CNP">Crystal Network Protocol (CNP) Version 1.0</title>
    <author fullname="Theo Ribeiro Silva" initials="T." surname="Ribeiro Silva">
        <address>
        <email>theo.ribeiro.5000@protonmail.com</email>
        <email>theo.ribeiro.5000@gmail.com</email>
      </address>
    </author>
    <date month="March" year="2026"/>
    <abstract>
      <t>CNP is a decentralized general purpose network protocol, meant
      to allow the seamless production of decentralized yet internet
      dependent applications.</t>
    </abstract>
  </front>

  <middle>

    <section anchor="intro" numbered="true" toc="default">
      <name>Introduction</name>
      <t>At this point in time, web applications (critically, ones
      regarding communication) are highly centralized and often rely on
      a single entity. As a means to make decentralized applications
      easier to implement, this protocol defines a standard for such.</t>
    </section>

    <section anchor="terminology" numbered="true" toc="default">
      <name>Terminology</name>
      <t>Over the text, the words "crystal", "node", "packet", and
      "blob" will be used. In the said order, to describe an
      inter-connected network, a member of the crystal, a blob with
      the CNP format, a contiguous sequence of bytes. Also, this
      document follows the <xref target="RFC2119" /> definitions.</t>
    </section>

    <section anchor="format" numbered="true" toc="default">
      <name>Format</name>
      <t>A packet is a blob with a fixed-length of one kibibyte, the
      starting byte signaling the method, 64 bytes being a key, 12
      bytes for nonce, and the remaining 947 bytes being the cipher
      text. The cipher text being preferably AES-GCM-SIV derived, the
      nonce stored at its field.</t>

      <section anchor="key" numbered="true" toc="default">
        <name>Key</name>
        <t>This field is used to identify a packet, which has to be
        derived from a hash, which is preferably blake2b. There is no
        verification regarding the hash algorithm used, specifically
        because since the key is for identification purposes, if the
        implementation uses argon2id or does not use a hashing
        algorithm, what would happen is a higher likelihood of
        collisions, thus poor behavior.</t>
      </section>

      <section anchor="ciphertext-nonce" numbered="true" toc="default">
        <name>Cipher Text and Nonce</name>
        <t>Cipher text is a preferably encrypted blob, and the nonce
        field SHOULD be used to store a nonce.</t>
      </section>

      <section anchor="ciphers-hashes" numbered="true" toc="default">
        <name>Ciphers and Hashes</name>
        <t>The use of an encryption method is highly recommended to
        maintain security, and it is recommended to use AES-GCM-SIV
        since it has built-in authentication and nonce mis-use
        protection.</t>
        <t>Even so, the protocol itself is not dependent on the
        implementation that derived the packet, as the server is
        agnostic about the contents of the cipher text and nonce. As
        for the key, it is used as a blob.</t>
      </section>

      <section anchor="method" numbered="true" toc="default">
        <name>Method</name>
        <t>If 0xFF the method means "insert", if 0x00 "get". Insert
        being used to clone a packet from node-to-node across the
        crystal, and "get" to fetch a packet.</t>
      </section>

    </section>

    <section anchor="node" numbered="true" toc="default">
      <name>Node</name>
      <t>A node SHALL keep IPv6s for running the protocol, MAY have a
      method to keep these persistent, the data-structure SHOULD have
      a limit of items, the node MAY store IPv6s it contacts in any
      shape or form (preferably yes, for the crystal to grow), the
      node MAY drop IPv6s it identifies as permanently shut down, and
      the node SHOULD be listening to port 3017 by default and accepting
      connections.</t>
      <t>When a node registers a packet by itself, it sends the packet
      to all the nodes it has (IPv6s) with the method "insert". Those
      which MAY retransmit their packets to any other node.</t>
      <t>Upon receipt of an "insert", the packet SHOULD be stored in
      the node in some manner, but MAY refuse if the node assumes that
      doing so would be problematic for it.</t>
      <t>When a node encounters itself on a position of needing a
      packet, it sends a "get" to all nodes it holds. This request MAY
      be retransmitted to their own nodes.</t>
      <t>Upon receipt of a "get", the node SHALL seek if it has a
      packet with the key of the received packet. If it does, the node
      SHALL "insert" it on the sender.</t>
      <t>If a node receives a packet, and it already has one with the
      same key, the new one is ignored.</t>
      <t>All implementations that by any shape or form retransmit a
      packet SHOULD limit retransmission rate to prevent flood
      behavior.</t>
      <t>The retransmission of a "get" SHOULD be sequential.</t>
    </section>

    <section anchor="no-response" numbered="true" toc="default">
      <name>No Response Protocol</name>
      <t>Given that "get" and "insert" neither require a response to
      work. If a "get", after sending this request to all of its
      nodes, and the crystal does not have the requested key, instead
      of responding "not found", the node simply does not receive a
      packet with this key. Same for insert, it simply can be
      inserted, no guarantee.</t>
    </section>

    <section anchor="tcp" numbered="true" toc="default">
      <name>Use of TCP</name>
      <t>Used to guarantee the delivery of packets. For sending a
      packet, a node SHALL make a connection with another, send the
      packet, and either one MAY close the connection right after.</t>
    </section>

    <section anchor="lifetime" numbered="true" toc="default">
      <name>Packet Lifetime</name>
      <t>All packets SHALL be deleted after an hour, but MAY be
      deleted before.</t>
    </section>

    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>The protocol by itself is insecure, it does not guarantee any
      sort of security. Even so, it is recommended (and explicitly
      said so) that encryption is used on the data blob (mentioned as
      cipher text), and for the key to be derived from a cryptographic
      hash. These do increase the safety significantly.</t>
      <t>Another problem could be DoS related, but these can be
      mitigated with proper firewalls, and out-of-spec solutions.</t>
    </section>

  </middle>

  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author initials="S." surname="Bradner" fullname="S. Bradner"/>
          <date month="March" year="1997"/>
        </front>
        <seriesInfo name="RFC" value="2119"/>
      </reference>
    </references>
  </back>

</rfc>
