aboutsummaryrefslogtreecommitdiffstats
path: root/PROTOCOL.md
diff options
context:
space:
mode:
Diffstat (limited to 'PROTOCOL.md')
-rw-r--r--PROTOCOL.md13
1 files changed, 12 insertions, 1 deletions
diff --git a/PROTOCOL.md b/PROTOCOL.md
index 42bf081..cd5253f 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -100,10 +100,11 @@ Two implementations that agree on this layout will always produce the same `id`
100|---|---|---| 100|---|---|---|
101| Signing | Ed25519 | `crypto/ed25519` (stdlib) | 101| Signing | Ed25519 | `crypto/ed25519` (stdlib) |
102| Key exchange | X25519 | `golang.org/x/crypto/curve25519` | 102| Key exchange | X25519 | `golang.org/x/crypto/curve25519` |
103| Key derivation | HKDF-SHA256 | `golang.org/x/crypto/hkdf` |
103| Encryption | ChaCha20-Poly1305 | `golang.org/x/crypto/chacha20poly1305` | 104| Encryption | ChaCha20-Poly1305 | `golang.org/x/crypto/chacha20poly1305` |
104| Hashing / event ID | SHA-256 | `crypto/sha256` (stdlib) | 105| Hashing / event ID | SHA-256 | `crypto/sha256` (stdlib) |
105 106
106All dependencies are from the Go standard library or `golang.org/x/crypto`. No third-party crypto. Ed25519 keys are converted to X25519 for ECDH — one keypair serves both signing and encryption. ChaCha20-Poly1305 provides authenticated encryption (AEAD); the ciphertext cannot be tampered with without detection. 107All dependencies are from the Go standard library or `golang.org/x/crypto`. No third-party crypto. Ed25519 keys are converted to X25519 for ECDH — one keypair serves both signing and encryption. The raw X25519 shared secret is passed through HKDF-SHA256 (info: `"axon-dm-v1"`) to derive the symmetric encryption key. ChaCha20-Poly1305 provides authenticated encryption (AEAD) with the sender and recipient public keys bound as associated data; the ciphertext cannot be tampered with or re-targeted without detection.
107 108
108--- 109---
109 110
@@ -303,6 +304,16 @@ Root marker is required on all replies. No fallback heuristics.
303Tag{ name: "p", values: ["<recipient-pubkey>"] } 304Tag{ name: "p", values: ["<recipient-pubkey>"] }
304``` 305```
305 306
307**Encryption details:**
308
3091. Compute the X25519 shared secret from the sender's private key and recipient's public key
3102. Derive a 32-byte symmetric key via HKDF-SHA256 (salt: nil, info: `"axon-dm-v1"`)
3113. Generate a 12-byte random nonce
3124. Encrypt with ChaCha20-Poly1305 using associated data = `sender_pubkey || recipient_pubkey`
3135. Wire format of content field: `nonce (12 bytes) || ciphertext`
314
315The associated data binds the ciphertext to both parties, preventing key-confusion attacks where an attacker re-targets a ciphertext to a different recipient.
316
306The relay indexes the `p` tag to route DMs to the recipient's subscription. Content is opaque; the relay cannot decrypt it. 317The relay indexes the `p` tag to route DMs to the recipient's subscription. Content is opaque; the relay cannot decrypt it.
307 318
308--- 319---