Encryption and identity

How can a relay carry a message it cannot read?

A relay can carry a message it cannot read because the sender encrypts the message for the recipient before it leaves the device, and the relay never holds the key. The relay sees only ciphertext and the routing details it needs, and authenticated encryption lets the recipient detect any change the relay makes.

TL;DR

A relay cannot read a message that the sender encrypts end to end for the recipient, whereas TLS on each hop lets the relay see the plaintext. Authenticated encryption and sender signatures let recipients detect tampering, and gift wraps hide most of the envelope. A relay still sees metadata and can withhold, delay or resend messages.

Learning objectives

After reading this article you will be able to:

  • Explain why per-hop TLS lets a relay read messages and end-to-end encryption does not
  • Describe how authenticated encryption and associated data stop a relay tampering with messages
  • Identify what a relay can still see and do, such as withholding or resending

Relay routing data vs message content

A relay is any system that passes a message along without being its final destination. To do its job, a relay needs to know where a message is going. It does not need to know what the message says. Mail servers relay email, TURN servers relay packets between hosts that cannot reach each other directly behind NATs, Nostr relays store and forward events over WebSockets, and in a mesh, ordinary phones relay messages for each other. What is a relay server? covers the role in general.

RFC 5321, the email transport standard, makes not reading the content a rule: a relay SMTP server “has no need to inspect or act upon the header section or body of the message data” and must not do so, apart from adding its own trace header.

Not reading is a policy, though. Cannot read is a property of the cryptography, and only the second survives a relay that is careless, compromised or hostile.

Preventing relays from reading messages

A relay cannot read a message when the sender encrypts it for the recipient’s key before sending, and the relay never holds the matching private key. That is end-to-end encryption: the ends hold the keys, and everything in between carries ciphertext. In Offline Protocol on WendyOS, a Dragonwing IQ9 carries a message from a Raspberry Pi to a Jetson it was sealed for, and the IQ9 cannot read it.

The alternative, encrypting each hop separately, does not achieve this. With TLS from sender to relay and again from relay to recipient, the relay decrypts and re-encrypts, so it sees the plaintext in between. The TURN standard is explicit: confidentiality for relayed application data is best provided by the application protocol itself, because running TURN over TLS does not protect the data between the server and the peer. RFC 5321 says the same of mail, that real mail security lies only in end-to-end methods applied to message bodies, such as PGP or S/MIME.

Authenticated encryption against relay tampering

If the ciphertext has been altered, authenticated encryption returns a failure instead of plaintext. Hiding content is half of the job, because a relay that cannot read a message might still try to change it. Authenticated encryption with associated data (AEAD), specified as an interface in RFC 5116, handles both: it provides confidentiality and a way to check integrity and authenticity.

AEAD also fits the relay problem neatly through its associated data. RFC 5116 explains that some fields, such as addresses, ports and sequence numbers, must stay in the clear so the network can handle and forward the message, but should still be authenticated. Those fields go in the associated data: readable by the relay, protected against change.

In a group, AEAD only proves that the sender held the group key, so protocols such as MLS also sign messages with each member’s key. RFC 9750 states that even a malicious MLS delivery service cannot add itself to a group or recover the group key.

Hiding the message envelope from relays

End-to-end encrypted content still travels with a visible envelope, and Nostr’s NIP-59 defines a gift wrap that hides most of it:

  • A rumor is the unsigned event holding the content.
  • A seal encrypts the rumor and is signed by the real author, with no tag naming the recipient.
  • A gift wrap encrypts the seal and is signed by a random, one-time key. Its visible tags carry what routing needs, such as a tag for the recipient.

The encryption at each layer follows NIP-44. A relay sees a one-time author key, a recipient tag, a timestamp the specification says should be tweaked, and ciphertext.

Offline Protocol’s SDK documents both layers. In its mesh, phones that relay a message forward MLS ciphertext. Its Nostr envelopes are sealed by default as NIP-59 gift wraps with NIP-44 encryption, around application messages that are already encrypted with MLS, and its docs note that a Nostr relay still sees subscriptions, timing and volume.

Relay metadata and delivery control

A relay that cannot read or alter content still sees metadata, and it can withhold, delay or resend messages.

  • It sees metadata. NIP-44 lists its own limits, including that relays may see a user’s IP address and that padding only partially hides message length. What is metadata, and does encryption hide it? goes further.
  • It can withhold. RFC 9750 notes that a delivery service can refuse to relay messages to and from a client, and that other clients generally cannot detect this without side information.
  • It can delay or resend. A relay can hold messages back or send copies again. RFC 9750 says MLS aims to stop even a compromised delivery service from undetectably removing, reordering or replaying messages, but apps still meet duplicates and late arrivals, which is why receivers use deduplication and acknowledgments.

End-to-end encryption turns the relay from a party you must trust with content into one you only rely on to deliver. Which relays to rely on, and what they may observe, remains a decision for each deployment.

Frequently asked questions

Is TLS to the relay enough?

No. TLS protects each hop, so the relay decrypts what it receives. RFC 8656 makes the point for TURN, noting that running TURN over TLS does not protect application data between the server and the peer, so the application should encrypt it.

Can a relay change or fake a message?

Not without detection, if the message uses authenticated encryption and sender signatures. It can still drop or delay messages and send copies again, so receivers need deduplication and acknowledgments.

What can a Nostr relay see in a gift-wrapped message?

A relay sees a one-time author key, a recipient tag, a timestamp that NIP-59 says should be tweaked, and ciphertext. The seal signed by the real author is encrypted inside the gift wrap.

Can a relay block my messages without anyone noticing?

It can withhold them. RFC 9750 notes that a delivery service can refuse to relay messages to and from a client, and that other clients generally cannot detect this without side information.

Can a malicious MLS delivery service add itself to a group?

No. RFC 9750 states that even a malicious MLS delivery service cannot add itself to a group or recover the group key.

Why do some fields of an encrypted message stay readable to the relay?

Some fields, such as addresses, ports and sequence numbers, must stay in the clear so the network can handle and forward the message. With authenticated encryption they go in the associated data, which keeps them readable by the relay but protected against change.

Sources

Build it with Offline Protocol

The Reticulum and Nostr page explains how the mesh SDK uses Nostr relays as an extra network path, why envelope sealing should stay on, and what a relay can still observe.

Read the Reticulum and Nostr page