Publish direct connection data
A device behind an Internet gateway first obtains a local address/port and an externally reachable address/port using an operator-selected mechanism such as UPnP. It publishes both to approved presence subscribers:Authenticate the P2P peer
Network location is only a first check. The receiver verifies that the claimed full JID is an approved, present roster contact whose published endpoint matches the incoming address. All P2P stanzas then use E2E protection; the sender’s signature binds the stream claim to its published key. Reject the connection if any check fails. Do not use local-network location as an authentication substitute.End-to-end encryption
E2E uses a hybrid cipher:- an asymmetric endpoint publishes a short-lived public key, derives or transports a per-stanza secret, and signs plaintext;
- a symmetric algorithm encrypts the message or complete IQ payload;
- the receiver decrypts with its private key and validates the sender signature.
Security requirements
- Generate keys and nonces with a cryptographically secure random source.
- Rotate asymmetric keys according to data sensitivity and after a session/compromise.
- Authenticate associated stanza metadata; reject altered sender, recipient, type, or request ID.
- Reject algorithm downgrade and unadvertised keys.
- Never reuse a per-stanza symmetric key or nonce.
- Bound retention of the previous private key.
- Treat decryption, signature, replay, and recipient failures as hard failures without exposing an oracle.