
Hybrid encrypt: ML-KEM-768 + ChaCha20-Poly1305
Source:R/crypto_hybrid.R
morie_crypto_hybrid_encrypt.RdThe same container as morie.crypto.hybrid_encrypt (morie 1.4.0), so
either arm opens the other's files. Encapsulates under the recipient's
ML-KEM-768 public key, derives the wrapping key from
HKDF(shared_secret || kem_ct || pk) (the KEM shared secret is what
keeps it private), wraps a random 32-byte symmetric key with
ChaCha20-Poly1305, then encrypts the payload under that symmetric key.
Container format (big-endian lengths): "MORIEHYB" 0x02 || len(kem_ct)[4] || kem_ct || wrap_nonce[12] || wrapped_key[32] || wrap_tag[16] || payload_nonce[12] || aead_ct || payload_tag[16].
Examples
kp <- morie_crypto_hybrid_keygen()
ct <- morie_crypto_hybrid_encrypt("hello", kp$pk)
rawToChar(morie_crypto_hybrid_decrypt(ct, kp$sk))
#> [1] "hello"