#chacha20-poly1305 #ml-kem #protocols #crystals-kyber

bin+lib kychacha_crypto

A Post-Quantum Secure Encryption Protocol using chacha20poly1305 and CRYSTALS-kyber

13 stable releases

Uses new Rust 2024

new 3.2.1 May 13, 2025
3.1.0 May 12, 2025
2.2.0 Apr 30, 2025
1.1.6 Mar 21, 2025
1.1.2 Jan 31, 2025

#429 in Cryptography

Download history 113/week @ 2025-01-29 129/week @ 2025-02-05 20/week @ 2025-02-12 89/week @ 2025-03-05 37/week @ 2025-03-12 109/week @ 2025-03-19 4/week @ 2025-03-26 195/week @ 2025-04-09 330/week @ 2025-04-16 57/week @ 2025-04-23 167/week @ 2025-04-30 663/week @ 2025-05-07

1,243 downloads per month

MIT license

21KB
242 lines

Kychacha-crypto: Post-Quantum Secure Encryption Protocol

A post-quantum simple to use implementation for ML-KEM and ChaCha20

CI Security audit CodSpeed Badge Crates.io Version

Hybrid cryptographic implementation using:

  • ML-KEM (formerly Crystals-Kyber): Post-Quantum secure Key Encapsulation Mechanism (KEM) for key exchange, standardized by NIST.
  • ChaCha20-Poly1305: Authenticated symmetric encryption.

Architecture

The following diagram describes the protocol flow between the "Sender" and the "Recipient":

sequenceDiagram
    participant Sender
    participant Recipient

    Recipient-->>Sender: Recipient public key (ML-KEM pub key 1184 bytes)
    
    Sender->>Sender: Encapsulate secret (ML-KEM)
    Note right of Sender: Generates ephemeral keypair and derives shared secret
    Sender->>Sender: Derive ChaCha key (HKDF-SHA256)
    Note right of Sender: Uses shared secret to derive symmetric key
    Sender->>Sender: Encrypt message (ChaCha20-Poly1305)
    
    Sender->>Recipient: Send {ciphertext, nonce, encrypted message}
    
    Recipient->>Recipient: Decapsulate secret (ML-KEM)
    Note right of Recipient: Recovers shared secret
    Recipient->>Recipient: Derive ChaCha key (HKDF-SHA256)
    Note right of Recipient: Derives the same symmetric key
    Recipient->>Recipient: Decrypt message

Note: During the encapsulation process on the sender's side, an ephemeral keypair is generated.

Usage and documentation

https://docs.rs/kychacha_crypto

Safety Considerations

  1. Randomness: Depends on the secure generator of the system.
  2. HKDF context: Used for protocol binding.
  3. Nonces: Generated with CSPRNG for each message.

Dependencies

~5MB
~97K SLoC