So I am attempting to generate a JWE using an X25519 to encrypt the for the Content Encryption Key (CEK) and AES-256-GCM for the content.
My issue however is that NaCl needs an IV (nonce in NaCl) for both the asymmetric encryption of the key and the symmetric encryption of the content.
Looking at other examples such as the ietf-jose cookbook, (X25519, A128GCM), they only have the one "top level" IV.
Is it ok to use the same IV for both the x25519 and the A256GCM?
If not, where does the IV for the x25519 get placed in the JWE?
Or is there something else I am missing entirely?
{
header: {
enc: "A256GCM",
alg: "ECDH-ES",
epk: {
crv: "X25519",
kty: "OKP",
x: ephemPublicKey
iv: "Perhaps we stuff the X25519 iv here?",
},
iv: "Perhaps we stuff the X25519 iv here?",
encrypted_key,
},
ciphertext,
tag,
iv: "iv for the A256GCM only or both?",
}