Skip to contents

Inverse of morie_crypto_hybrid_encrypt(), and of morie's hybrid_encrypt: decapsulates the KEM ciphertext with the secret key and re-derives the wrapping key from the shared secret, the ciphertext and the public key embedded in the ML-KEM-768 secret key (bytes 1153..2336). A 1.3.x container (no marker) still opens, with a warning: its wrapping key needed no secret, so anyone with the file and the public key can open it too; encrypt it again.

Usage

morie_crypto_hybrid_decrypt(ciphertext, recipient_sk)

Arguments

ciphertext

Raw vector container.

recipient_sk

Raw vector: recipient's ML-KEM-768 secret key (2400 bytes).

Value

Raw vector of decrypted plaintext.

Examples

kp <- morie_crypto_hybrid_keygen()
ct <- morie_crypto_hybrid_encrypt(charToRaw("secret"), kp$pk)
rawToChar(morie_crypto_hybrid_decrypt(ct, kp$sk))
#> [1] "secret"