encrypt_note_data

Function encrypt_note_data 

Source
pub fn encrypt_note_data(
    recipient_pubkey_bytes: &[u8],
    plaintext: &[u8],
) -> Result<Vec<u8>, JsValue>
Expand description

Encrypt note data using X25519-XSalsa20-Poly1305 (NaCl crypto_box).

When sending a note to someone, we encrypt the sensitive data (amount and blinding) with their X25519 public key. Only they can decrypt it.

§Output Format

[ephemeral_pubkey (32)] [nonce (24)] [ciphertext (40) + tag (16)]
Total: 112 bytes minimum

§Arguments

  • recipient_pubkey_bytes - Recipient’s X25519 encryption public key (32 bytes)
  • plaintext - Note data: [amount (8 bytes LE)] [blinding (32 bytes)] = 40 bytes

§Returns

Encrypted data (112 bytes)