1.1. Preliminaries
1.1.1. PQXDH parameters
An application using PQXDH must decide on several parameters:
Name | Definition |
|---|---|
curve | A Montgomery curve for which XEdDSA [1] is specified, at present this is one of curve25519 or curve448 libsignal itself relies on the curve25519 implementation of the dalek library; example of key pair generation: src/curve.rs:327-341 |
hash | A 256 or 512-bit hash function (e.g. SHA-256 or SHA-512) I think that the implementation itself uses SHA-256 src/pqxdh.rs:79-92 |
info | An ASCII string identifying the application with a minimum length of 8 bytes |
pqkem | A post-quantum key encapsulation mechanism that has IND-CCA post-quantum security (e.g. Crystals-Kyber-1024 [2]) libsignal itself supports kem/kyber1024.rs, kem/kyber768.rs and kem/mlkem1024.rs and uses Kyber1024 by default src/session_management.rs:855 |
aead | A scheme for authenticated encryption with associated data that has IND-CPA and INT-CTXT post-quantum security libsignal uses AES-CBC src/triple_ratchet.rs:106-110, followed by HMAC src/protocol.rs:110-115 |
EncodeEC | A function that encodes a curve public key into a byte sequencesrc/curve.rs:122-132 |
DecodeEC | A function that decodes a byte sequence into a curve public key and is the inverse of EncodeECsrc/curve.rs:84-105 |
EncodeKEM | A function that encodes a pqkem public key into a byte sequencesrc/kem.rs:333-338 |
DecodeKEM | A function that decodes a byte sequence into a pqkem public key and is the inverse of EncodeKEMsrc/kem.rs:319-331 |
For example, an application could choose curve as curve25519, hash as SHA-512, info as "MyProtocol", and pqkem as CRYSTALS-KYBER-1024src/pqxdh.rs:72-77.
The ranges of all encoding functions must be pairwise disjoint.
The recommended implementation of EncodeEC consists of a single-byte constant representation of curve followed by little-endian encoding of the u-coordinate as specified in [3]. The single-byte representation of curve is defined by the implementer. Similarly the recommended implementation of DecodeEC reads the first byte to determine the parameter curve. If the first byte does not represent a recognized curve, the function fails. Otherwise it applies the little-endian decoding of the u-coordinate for curve as specified in [3].
The recommended implementation of EncodeKEM consists of a single-byte constant representation of pqkem followed by the encoding of the pqkem public key specified by pqkem. The single-byte representation of pqkem is defined by the implementer. Similarly the recommended implementation of DecodeKEM reads the first byte to determine the parameter pqkem. If the first byte does not represent a recognized key encapsulation mechanism, the function fails. Otherwise it applies the decoding specified by the selected key encapsulation mechanism.
1.1.2. Elliptic Curve Keys
PQXDH uses the following elliptic curve public keys:
Name | Definition |
|---|---|
IKA | Alice's identity key in example: tests/pqxdh.rs:27, support/mod.rs:226 |
IKB | Bob's identity key in example: tests/pqxdh.rs:26, support/mod.rs:226 |
EKA | Alice's ephemeral key src/session.rs:220, which is called tests/pqxdh.rs:53 in the example |
SPKB | Bob's signed prekey tests/pqxdh.rs:31 in example |
(OPKB1, OPKB2, …) | Bob's set of one-time prekeys tests/pqxdh.rs:30 in example |
The elliptic curve public keys used within a PQXDH protocol run must either all be in curve25519 formsrc/curve.rs:327-341, or they must all be in curve448 form, depending on the curve parameter [3].
Each party has a long-term identity elliptic curve public key (IKA for Alice, IKB for Bob).
Bob also has a signed prekey SPKB, which he changes periodically and signs each time with IKB, and a set of one-time prekeys (OPKB1, OPKB2, …), which are each used in a single PQXDH protocol run. For each signed prekey or one-time prekey, K, that Bob generates, he also computes an identifier, denoted IdEC(K)state/bundle.rs:52, support/mod.rs:373-378, that uniquely identifies this key on Bob's device. ("Prekeys" are so named because they are essentially protocol messages which Bob publishes to the server, along with their corresponding identifiers, prior to Alice beginning the protocol run.) These keys will be uploaded to the server as described in Section 3.2.
During each protocol run, Alice generates a new ephemeral key pair with public key EKA.
1.1.3. Post-Quantum Key Encapsulation Keys
PQXDH uses the following post-quantum key encapsulation public keys:
Name | Definition |
|---|---|
PQSPKB | Bob's signed last-resort pqkem prekey last note in section |
(PQOPKB1, PQOPKB2, …) | Bob's set of signed one-time pqkem prekeys prekey in example: tests/pqxdh.rs:32, support/mod.rs:308; signature: support/mod.rs:310 |
The pqkem public keys used within a PQXDH protocol run must all use the same pqkem parameter.
Bob has a signed last-resort post-quantum prekey PQSPKB, which he changes periodically and signs each time with IKB, and a set of signed one-time prekeys (PQOPKB1, PQOPKB2, …) which are also signed with IKB and each used in a single PQXDH protocol run. For each last-resort or ephemeral KEM key, K, that Bob generates, he also computes an identifier, denoted IdKEM(K), that uniquely identifies this key on Bob's device. These keys and their corresponding identifiers will be uploaded to the server as described in Section 3.2. The name "last-resort" refers to the fact that the last-resort prekey is only used when one-time pqkem prekeys are not available. This can happen when the number of prekey bundles downloaded for Bob exceeds the number of one-time pqkem prekeys Bob has uploaded (see Section 3 for details about the role of the server). An implementation should provide Bob a way to identify whether a pqkem public key corresponds to a one-time pqkem key or a last-resort pqkem key.