GHOST Protocol sheetSheet Note N1 · Sheet 01 TR / EN

Note N1 · GHOST Protocol

HYBRID KEY EXCHANGE

X25519 + Kyber-1024 hybrid key exchange in Rust: two locks for the post-quantum era

Sheet
GHOST PROTOCOL
Topic
Rust · X25519 · Kyber-1024
Source
crypto/hybrid.rs
Date
2026-11-12
Reading
2 min

Short answer: run two key exchanges and feed both shared secrets into a key derivation function together. X25519 is trusted and fast today; Kyber-1024 is designed to resist quantum computers. Because the session key derives from both, an attacker has to break both. GHOST concatenates the two secrets, uses the SHA3-256 hash of all public keys as salt, and HKDF-SHA3-256 produces a 64-byte key.

01Why hybrid

X25519 breaks in front of a large enough quantum computer. Traffic recorded today could be decrypted tomorrow. Kyber, on the other hand, is new: it was standardised in 2024 as ML-KEM (FIPS 203). Implementation bugs and new attacks still turn up in post-quantum schemes.

A hybrid covers each side's weakness with the other: as long as one algorithm stands, the session key stays safe.

02Sender side

The sender generates a fresh X25519 key for each connection and runs Diffie-Hellman with the receiver's public key. At the same time it encapsulates against the receiver's Kyber public key, which yields a ciphertext and a second shared secret.

let ephemeral_sk = StaticSecret::random_from_rng(&mut OsRng);
let ephemeral_pk = PublicKey::from(&ephemeral_sk);
let x25519_ss = ephemeral_sk.diffie_hellman(&PublicKey::from(*responder_x25519_pk));

let (kyber_ct, kyber_ss) = PQCModule::kyber_encapsulate(responder_kyber_pk)?;

03Combining the two secrets

The two secrets are concatenated and given to HKDF as input. The salt is the SHA3-256 hash of the three public keys taking part in the exchange: the derived key belongs only to the exchange made with those keys. The Ghost_Hybrid_V1 label separates the key from other uses and from other protocol versions.

let mut ikm = Vec::new();
ikm.extend_from_slice(x25519_ss.as_bytes());
ikm.extend_from_slice(&kyber_ss);

// salt = SHA3-256(ephemeral X25519 || receiver X25519 || receiver Kyber)
let hkdf = Hkdf::<Sha3_256>::new(Some(&salt_hash), &ikm);
let mut shared_secret = vec![0u8; 64];
hkdf.expand(b"Ghost_Hybrid_V1", &mut shared_secret)?;

The receiver runs the same computation with its private keys and gets the same 64 bytes. The packet sent across is simple: the first 32 bytes are the sender's ephemeral X25519 public key, the rest is the Kyber ciphertext.

04Size checks

Before any Kyber function is called, every input's length is compared with the library's constants. A malformed or truncated packet returns an error before it reaches the library.

if ct_bytes.len() != KYBER_CT_SIZE { return Err(anyhow!("Invalid Kyber Ciphertext Size")); }
if sk_bytes.len() != KYBER_SK_SIZE { return Err(anyhow!("Invalid Kyber Secret Key Size")); }

05Limit

The pqc_kyber crate in use implements pre-standard Kyber; it is not byte-for-byte FIPS 203 ML-KEM. Because all Kyber calls live in one module (pqc.rs), moving to ML-KEM only changes that module; the hybrid layer stays the same.

→More notes from this project

—End of notewritten by MUHAMMEDPYZ