<?xml version="1.0" encoding="utf-8"?>

<?xml-model href="rfc7991bis.rnc"?>
<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="info"
  docName="draft-kostin-xchange-kem-00"
  ipr="trust200902"
  obsoletes=""
  updates=""
  submissionType="IRTF"
  xml:lang="en"
  version="3"
>
    <front>
        <title abbrev="xchange">
            X-Change: High-Security Purpose Hybrid KEM Exchange
        </title>
        <seriesInfo name="Internet-Draft" value="draft-kostin-xchange-kem-00"/>
        <author fullname="Stepan Kostin">
        <address>
            <email>s_kostin@proton.me</email>
        </address>
        </author>
        <date year="2025" month="December" day="14"/>
        <area>IRTF</area>
        <workgroup>Crypto Forum</workgroup>
        <keyword>post quantum</keyword>
        <keyword>high-security</keyword>
        <keyword>kem</keyword>
        <keyword>PQ/T hybrid</keyword>
        <abstract>
        <t>This draft defines X-Change, a high-security-purpose post-quantum/traditional 
        hybrid key encapsulation mechanism (PQ/T KEM) built on X25519 and ML-KEM-1024.</t>
        </abstract>
    </front>

    <middle>
        <section anchor="intro">
            <name>Introduction</name>
            <section anchor="motivation">
                <name>Motivation</name>
                <t>
                    There are many different choices for hybrid KEM exchanges with 
                    varying security and performance parameters. 
                    Most of them aim at the average performance-security trade-off, 
                    while this draft defines a security-first option.
                </t>
                <t>
                    The aim of X-Change is to provide a concrete and the most secure choice 
                    for post-quantum hybrid KEM that is suitable for the most sensitive environments.
                </t>
            </section>

            <section anchor="goals">
                <name>Goals</name>
                <t>Our design goal is to prioritize the security of the exchange above all else.</t>
                <ul spacing="normal">
                    <li>
                        <t>
                            Simplicity of Standardization: By adopting standardization formats for high-security hybrid KEM exchanges, 
                            we significantly reduce the risk of misuse of incorrect components. Our architecture tries to achieve as simple design as possible.
                        </t>
                    </li>
                    <li>
                        <t>
                            Security Analysis: Since ML-KEM-1024 already meets security category 5 per <xref target="FIPS203"/>, 
                            we do not need to complicate the analysis of X-Change by considering stronger models. 
                            Additionally, X25519 complies with traditional security proofs as outlined in <xref target="RFC7748"/>.
                        </t>
                    </li>
                    <li>
                        <t>
                            Performance: In the current design, we prioritize security over performance by using ML-KEM-1024
                            , while favoring the use of 512-bit (64-byte) keys and SHA3-512. 
                            In this design, performance trade-offs may be significant compared to simpler designs.
                        </t>
                    </li>
                </ul>
                    <t>
                        We aim for 256-bit security in most of the environments by adopting ML-KEM-1024 
                        (which is classified as security category 5, equivalent to 256 bits of classical security) 
                        and using X25519 as the preferred traditional exchange. 
                        However, this may not be suitable for all applications or low-end environments.
                    </t>
            </section>
        </section>

        <section anchor="requirements-notation">
            <name>Requirements Notation</name>
            <t>
                The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", 
                "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", 
                "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>","<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" 
                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 anchor="conventions-and-definitions">
            <name>Conventions and Definitions</name>
            <t>This document is consistent with all terminology defined in I-D.driscoll-pqt-hybrid-terminology.</t>
            <ul spacing="normal">
                <li>
                    <t><tt>concat(x0, ..., xN)</tt>: returns the concatenation of byte strings. <tt>concat(0x01, 0x0203, 0x040506) = 0x010203040506</tt>.</t>
                </li>
                <li>
                    <t><tt>random(N)</tt>: returns a byte string of length <tt>N</tt> bytes produced by a cryptographically-secure pseudorandom number generator.</t>
                </li>
            </ul>
        </section>

        <section anchor="base-crypto">
            <name>Cryptographic Dependencies</name>
            <t>X-Change relies on the following primitives:</t>

            <ul spacing="normal">
                <li>
                    <t>ML-KEM-1024 post-quantum key-encapsulation mechanism (KEM): </t>
                    <ul spacing="normal">
                        <li>
                            <t>
                                <tt>ML-KEM-1024.KeyGen_internal(d, z)</tt>: 
                                Deterministic algorithm to generate an ML-KEM-768 key pair <tt>(pk_M, sk_M)</tt> 
                                of an encapsulation key <tt>pk_M</tt> and decapsulation key <tt>sk_M</tt>. 
                                <tt>d</tt> and <tt>z</tt> are both 32 byte values.
                            </t>
                            <t><tt>ML-KEM-1024.KeyGen_internal(d, z)</tt> <bcp14>MUST</bcp14> be as described at the <xref target="FIPS203"/> paragraph 6.1.</t>
                        </li>

                        <li>
                            <t>
                                <tt>ML-KEM-1024.Encaps_internal(pk_M, m)</tt>: 
                                Deterministic algorithm to generate <tt>(ss_M, ct_M)</tt>, an 32 byte shared key <tt>ss_M</tt>, 
                                and a fixed-length encapsulation (ciphertext) of that key <tt>ct_M</tt> for encapsulation key <tt>pk_M</tt>. 
                                <tt>m</tt> is a 32 byte string.
                            </t>
                            <t><tt>ML-KEM-1024.Encaps_internal(pk_M, m)</tt> <bcp14>MUST</bcp14> be as described at the <xref target="FIPS203"/> paragraph 6.2.</t>
                        </li>

                        <li>
                            <t>
                                <tt>ML-KEM-1024.Decap_internal(sk_M, ct)</tt>: Deterministic algorithm to decapsulate 
                                <tt>ct</tt> using the previously generated <tt>sk_M</tt> and recover the shared key from <tt>ss_M</tt>.
                            </t>
                            <t><tt>ML-KEM-1024.Decap_internal(sk_M, ct)</tt> <bcp14>MUST</bcp14> be as described at the <xref target="FIPS203"/> paragraph 6.3.</t>
                        </li>
                    </ul>
                </li>

                <li>
                    <t>X25519/X448 elliptic curve Diffie-Hellman key-exchange defined in <xref target="RFC7748"/>: </t>
                    <ul spacing="normal">
                        <li>
                            <t>
                                <tt>X25519(k, u)</tt>: 
                                takes 32 byte strings k and u representing a
                                Curve25519 scalar and the u-coordinate of a point respectively, and returns
                                the 32 byte string representing the u-coordinate of their scalar multiplication.
                            </t>
                            <t><tt>X25519(k, v)</tt> <bcp14>MUST</bcp14> be as described at the <xref target="RFC7748"/> paragraph 5.</t>
                        </li>

                        <li>
                            <t>
                                <tt>X25519_BASE</tt>: the bytes string representing the standard base point of Curve25519.
                            </t>
                            <t><tt>X25519_BASE</tt> <bcp14>MUST</bcp14> be as described at the <xref target="RFC7748"/> paragraph 6.</t>
                        </li>
                    </ul>
                </li>

                <li>
                    <t>Symmetric cryptography: </t>
                    <ul spacing="normal">
                        <li>
                            <t><tt>SHA3-512(message)</tt>: The hash with that name defined in Section 6.1 of <xref target="FIPS202"/>.</t>
                            <t><tt>SHA3-512(message)</tt> <bcp14>MUST</bcp14> be as described at the <xref target="FIPS202"/> paragraph 6.1.</t>
                        </li>
                    </ul>
                </li>
            </ul>
        </section>


        <section anchor="x-change-construction">
            <name>X-Change Construction</name>
            <section anchor="encoding">
                <name>Encoding and sizes</name>
                <t>X-Change encapsulation key, decapsulation key, ciphertexts and shared secrets are all fixed-length byte strings.</t>
                <dl>
                    <dt>Decapsulation key (private):</dt>
                    <dd>
                        <t>96 bytes</t>
                    </dd>
                    <dt>Encapsulation key (public):</dt>
                    <dd>
                        <t>1600 bytes</t>
                    </dd>
                    <dt>Ciphertext:</dt>
                    <dd>
                        <t>1632 bytes</t>
                    </dd>
                    <dt>Proof:</dt>
                    <dd>
                        <t>64 bytes</t>
                    </dd>
                    <dt>Shared secret:</dt>
                    <dd>
                        <t>64 bytes</t> 
                    </dd>
                </dl>
            </section>

            <section anchor="derive-static-key-pair">
                <name>Static Key Derivation</name>
                <t>Derivation of static keys within the X-Change framework is implemented as follows.</t>
                <artwork><![CDATA[
                    def GetStaticKeyPair(sk):
                        (pk_M, sk_S) = ML-KEM-1024.KeyGen_internal(sk[0:32], sk[32:64])
                        sk_X = sk[64:96]
                        pk_X = X25519(sk_X, X25519_BASE)
                        return (sk_M, sk_X, pk_M, pk_X)
                ]]></artwork>
                <t>The <tt>sk</tt> <bcp14>MUST</bcp14> be a randomly generated 96-byte value.</t>
                <t>
                    The <tt>GetStaticKeyPair(sk)</tt> function returns the decapsulation key from ML-KEM-1024, the secret key 
                    for X25519, the encapsulation key from ML-KEM-1024, and the public key from X25519.
                </t>
            </section>

            <section anchor="key-generation">
                <name>Key Generation</name>
                <t>An X-Change key pair (decapsulation key and encapsulation key) is generated as outlined below.</t>
                <artwork><![CDATA[
                    def GenerateKeyPair():
                        sk = random(96)
                        (sk_M, sk_X, pk_M, pk_X) = GetStaticKeyPair(sk)
                        return (sk, concat(pk_M, pk_X))
                ]]></artwork>
                <t>
                    The <tt>GenerateKeyPair()</tt> function returns a 96-byte secret key <tt>sk</tt> and a 1600-byte encapsulation key <tt>pk</tt>.
                </t>
            </section>

            <section anchor="share-secret-derivation">
                <name>Share Secret Derivation</name>
                <t>This section details the derivation of a shared secret and its corresponding proof in the X-Change framework.</t>
                <artwork><![CDATA[
                    def KeyDerivation(salt, ss_X, ss_M, ct):
                        ikm = concat(salt, ct)
                        ss = concat(ss_X, ss_M)
                        okm = SHA3-512(concat(ikm, ss, x-change-key-context))
                        proof = SHA3-512(concat(okm, x-change-proof-context))
                        return (okm, proof)
                ]]></artwork>
                <t>The <tt>salt</tt> <bcp14>MUST</bcp14> be a randomly generated 32-byte value.</t>
                <t>
                    The <tt>KeyDerivation()</tt> function returns a 64-byte final shared secret key, <tt>okm</tt>, along with a 64-byte proof. 
                    This proof assists in identifying various potential attack vectors, such as:
                </t>
                <ul>
                    <li>Bit flips within the ciphertext, public key, or shared keys, which may not trigger immediate errors.</li>
                    <li>Simple Man-in-the-Middle (MITM) attacks that do not replicate the full exchange.</li>
                </ul>
                <t>
                    The current setup ensures resilience against corruption in shared keys, public keys, or ciphertext, 
                    thereby enforcing an early exit when such issues are detected.
                </t>
            </section>

            <section anchor="encapsulation-key">
                <name>Encapsulation Key Derivation</name>
                <t>This section explains the derivation of an X-Change encapsulation key <tt>pk</tt>.</t>
                <artwork><![CDATA[
                    def EncapsulationStatic(pk, seed):
                        pk_M = pk[0:1568] 
                        pk_X = pk[1568:1600]
                        ek_X = seed[0:32]
                        salt = seed[64:96]

                        ct_X = X25519(ek_X, X25519_BASE)
                        ss_X = X25519(ek_X, pk_X)
                        (ss_M, ct_M) = ML-KEM-1024.Encaps_internal(pk_M, seed[32:64])

                        ct = concat(ct_M, ct_X, salt)
                        (ss, proof) = KeyDerivation(salt, ss_X, ss_M, ct)
                        return (ss, ct, proof)
                ]]></artwork>
                <t>
                    The <tt>pk</tt> is 1600-byte value from GenerateKeyPair() function.
                    The <tt>seed</tt> <bcp14>MUST</bcp14> be a randomly generated 96-byte value.
                </t>
                <t>
                    The <tt>EncapsulationStatic()</tt> function returns shared secret <tt>ss</tt>, ciphertext <tt>ct</tt> and proof used to verify keys after decapsulation.
                </t>
            </section>


            <section anchor="decapsulation-key">
                <name>Decapsulation Key Derivation</name>
                <t>This section explains the derivation of an X-Change decapsulation key <tt>sk</tt>.</t>
                <artwork><![CDATA[
                    def Decapsulate(sk, ct, given_proof):
                        (sk_M, sk_X, pk_M, pk_X) = GetStaticKeyPair(sk)
                        ct_M = ct[0:1568]
                        ct_X = ct[1568:1600]
                        salt = ct[1600:1632]

                        ss_M = ML-KEM-1024.Decap_internal(sk_M, ct_M)
                        ss_X = X25519(sk_X, ct_X)
                        (ss, proof) = KeyDerivation(salt, ss_X, ss_M, ct)

                        if proof != given_proof:
                            print("Proof mismatch!")
                        return ss
                ]]></artwork>
                <t>
                    The <tt>sk</tt> is private 1632-byte value.
                    The <tt>ct</tt> is ciphertext we get from EncapsulationStatic() operation.
                    The <tt>given_proof</tt> is proof we got from EncapsulationStatic() operation.
                </t>
                <t>
                    The <tt>Decapsulate()</tt> function returns shared secret <tt>ss</tt>, and checks proofs together to detect keys mismatch.
                </t>
            </section>
        </section>


       <section anchor="secc">
            <name>Security Considerations</name>
            <t>Informally, X-Change is secure if SHA3-512 is secure, and either X25519 is secure, or ML-KEM-1024 is secure.</t>
            <t>
                More precisely, if SHA3-512 may be modeled as a random oracle, then the IND-CCA security of X-Change 
                is bounded by the IND-CCA security of ML-KEM-1024, and the gap-CDH security of Curve25519.
            </t>
            <t>
                The security of X-Change relies crucially on the specifics of the Fujisaki-Okamoto transformation 
                used in ML-KEM-1024: the X-Change combiner cannot be assumed to be secure when used with different KEMs. 
                In particular, it is not known to be safe to leave out the post-quantum ciphertext from the combiner in the general case.
            </t>
            <t>
                X-Change also adds additional security features as <tt>proof</tt>. 
                This proof is used to detect mismatches and protect against common errors, 
                such as using the wrong decapsulating key on ciphertext. 
                Additionally, the proof system could be integrated and sent over more secure channels 
                than the ciphertext to guarantee Man-in-the-Middle (MITM) security.
            </t>
        </section>

        <section anchor="iana">
            <name>IANA Considerations</name>
            <t>This document do not requests/registers a new entry in the registry.</t>
        </section>


        <section anchor="use-case">
            <name>Use Cases</name>
            <t>
                The X-Change mechanism provides a secure hybrid key encapsulation method suitable for a variety of applications, particularly in high-security environments. Below are some potential use cases:
            </t>
            <dl>
                <dt>Secure Communication</dt>
                <dd>
                    <t>
                        This use case involves secure peer-to-peer communication channels, 
                        such as instant messaging apps or VoIP services, 
                        requiring robust confidentiality and integrity for message exchanges.
                    </t>
                </dd>
                <dt>Cloud-based Security Solutions</dt>
                <dd>
                    <t>
                        X-Change can enhance the high-security clouds computing environments, 
                        enabling secure key exchanges for encrypting data transmitted between users and cloud services.
                    </t>
                </dd>
                <dt>Financial Sector Applications</dt>
                <dd>
                    <t>
                        Financial institutions can utilize X-Change for secure transactions 
                        and communications of highest possible security level, 
                        reducing the risks associated with financial data breaches.
                    </t>
                </dd>
            </dl>
        </section>

    </middle>
    <back>
        <references anchor="sec-combined-references">
            <name>References</name>
            <references anchor="sec-normative-references">
                <name>Normative References</name>
                <reference anchor="RFC2119">
                    <front>
                        <title>Key words for use in RFCs to Indicate Requirement Levels</title>
                        <author fullname="S. Bradner" initials="S." surname="Bradner"/>
                        <date month="March" year="1997"/>
                        <abstract>
                            <t>
                                In many standards track documents several words are used to signify the requirements in the specification. 
                                These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. 
                                This document specifies an Internet Best Current Practices for the Internet Community, 
                                and requests discussion and suggestions for improvements.
                            </t>
                        </abstract>
                    </front>
                    <seriesInfo name="BCP" value="14"/>
                    <seriesInfo name="RFC" value="2119"/>
                    <seriesInfo name="DOI" value="10.17487/RFC2119"/>
                </reference>
                <reference anchor="RFC8174">
                    <front>
                        <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
                        <author fullname="B. Leiba" initials="B." surname="Leiba"/>
                        <date month="May" year="2017"/>
                        <abstract>
                        <t>
                            RFC 2119 specifies common key words that may be used in protocol specifications. 
                            This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.
                        </t>
                        </abstract>
                    </front>
                    <seriesInfo name="BCP" value="14"/>
                    <seriesInfo name="RFC" value="8174"/>
                    <seriesInfo name="DOI" value="10.17487/RFC8174"/>
                </reference>
            </references>

            <references anchor="sec-informative-references">
                <name>Informative References</name>

                <reference anchor="FIPS202" target="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf">
                    <front>
                        <title>FIPS 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions</title>
                        <author initials="" surname="National Institute of Standards and Technology">
                        <organization/>
                        </author>
                    </front>
                </reference>

                <reference anchor="FIPS203" target="https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.203.pdf">
                    <front>
                        <title>FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard</title>
                        <author initials="" surname="National Institute of Standards and Technology">
                        <organization/>
                        </author>
                    </front>
                 </reference>


                 <reference anchor="RFC7748">
                    <front>
                        <title>Elliptic Curves for Security</title>
                        <author fullname="A. Langley" initials="A." surname="Langley"/>
                        <author fullname="M. Hamburg" initials="M." surname="Hamburg"/>
                        <author fullname="S. Turner" initials="S." surname="Turner"/>
                        <date month="January" year="2016"/>
                        <abstract>
                        <t>This memo specifies two elliptic curves over prime fields that offer a high level of practical security in cryptographic applications, including Transport Layer Security (TLS). These curves are intended to operate at the ~128-bit and ~224-bit security level, respectively, and are generated deterministically based on a list of required properties.</t>
                        </abstract>
                    </front>
                </reference>

            </references>
        </references>
    </back>
</rfc>
