> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Function do_private_message_delivery

Module: `noir_aztec::messages::delivery`

```rust
pub fn do_private_message_delivery<Env, let MESSAGE_PLAINTEXT_LEN: u32, D>(
    context: &mut PrivateContext,
    encode_into_message_plaintext: fn[Env]() -> [Field; MESSAGE_PLAINTEXT_LEN],
    maybe_note_hash_counter: Option<u32>,
    recipient: AztecAddress,
    delivery_mode: D,
)
where
    D: MessageDeliveryBuilder
```

Performs private delivery of a message to `recipient` according to `delivery_mode`.

The message is encoded into plaintext and then encrypted for `recipient`. This function takes a *function* that returns the plaintext instead of taking the plaintext directly in order to not waste constraints encoding the message in scenarios where the plaintext will be encrypted with unconstrained encryption.

`maybe_note_hash_counter` is only relevant for on-chain delivery modes (i.e. via protocol logs): if a newly created note hash's side effect counter is passed and constrained tagging is not in use, then the log will be squashed alongside the note should its nullifier be emitted in the current transaction. Constrained-tagged logs are not tied to note squashing, because recipient discovery scans those tags sequentially and a removed log would break the per-secret index sequence.

## Privacy

The emitted log always has the same length regardless of `MESSAGE_PLAINTEXT_LEN`, because all message ciphertexts also have the same length. This prevents accidental privacy leakage via the log length.
