Skip to main content

encrypt_event

Function encrypt_event 

Source
pub fn encrypt_event(
    group_key: &[u8; 32],
    prefix: &str,
    plaintext: &[u8],
    _privacy_mode: EventPrivacy,
) -> Result<(Vec<u8>, Vec<u8>, [u8; 12], [u8; 16]), String>
Expand description

Encrypt an EventEnvelopeV2 payload with a group key.

Returns (tag, ciphertext, nonce, key_commitment) suitable for populating a TaggedPayload on the wire.

§Arguments

  • group_key - 32-byte group encryption key
  • prefix - Topic prefix used as AAD for domain separation
  • plaintext - Event payload bytes to encrypt
  • _privacy_mode - Privacy mode (reserved for future routing decisions)

§Returns

  • tag - 16-byte AES-GCM authentication tag (last 16 bytes of AEAD output)
  • ciphertext - Encrypted payload (AEAD output minus trailing tag)
  • nonce - 12-byte random nonce
  • key_commitment - 16-byte commitment for fast key rejection