Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 52974d9

Browse files
author
bitfl0wer
committed
feat: beta.1: add diagram to 4.1.1, move 4.1.2 to 4.2
1 parent 0dc56fa commit 52974d9

2 files changed

Lines changed: 102 additions & 40 deletions

File tree

.markdownlint.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": false,
5+
"MD041": false,
6+
"MD025": false,
7+
"MD026": {
8+
"punctuation": ".,;:!"
9+
},
10+
"MD037": false,
11+
"MD046": false,
12+
"MD007": false
13+
}

docs/protocols/core.md

Lines changed: 89 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ title: polyproto Core Protocol Specification
88

99
**Namespace:** `core`
1010

11-
**Version:** `v1.0-alpha.1`
11+
**Version:** `v1.0-beta.1`
1212

1313
**Base Path:** `/.p2/core/v1/`
1414

1515
**API documentation:** [apidocs.polyproto.org](https://apidocs.polyproto.org)
1616

1717
:::warning
1818

19-
The polyproto specification document is in an **alpha** phase. Please report any inconsistencies,
20-
missing or duplicate information and other mistakes at [github.com/polyphony-chat/docs/issues](https://github.com/polyphony-chat/docs/issues).
19+
The polyproto specification document is in an **early beta** phase. Please report any
20+
inconsistencies, missing or duplicate information and other mistakes at
21+
[github.com/polyphony-chat/docs/issues](https://github.com/polyphony-chat/docs/issues).
2122

2223
:::
2324

@@ -382,9 +383,10 @@ this channel are defined by the service's specification.
382383

383384
##### 3.2.3.4 New session event
384385

385-
The "New Session" event is sent by the server to all sessions except the new one. The `d` payload
386-
of this event contains the ASCII-PEM encoded ID-Cert of the new session. You can find more information
387-
about the new session mechanism in [section 4.3](#43-protection-against-misuse-by-malicious-home-servers).
386+
The "New Session" event is sent by the server to all sessions except the new one. The `d` payload of
387+
this event contains the ASCII-PEM encoded ID-Cert of the new session. You can find more information
388+
about the new session mechanism in
389+
[section 4.4](#44-protection-against-misuse-by-malicious-home-servers).
388390

389391
:::tip[Example new session event payload]
390392

@@ -888,10 +890,10 @@ An actor can choose to use the same identity for multiple polyproto implementati
888890
### 4.1 Authentication
889891

890892
The core polyproto specification does not contain a strict definition of authentication procedures
891-
and endpoints. This allows for a wide range of authentication methods to be used. However, if
892-
implementations want to closely interoperate with each other, they should highly consider
893-
implementing the [polyproto-auth](./auth.md) standard for authenticating on home servers and
894-
foreign servers alike.
893+
and endpoints for home servers. This allows for a wide range of authentication methods to be used,
894+
such as OIDC or LDAP. To achieve the highest level of interoperability, all polyproto
895+
implementations should highly consider implementing the [polyproto-auth](./auth.md) standard for
896+
authenticating on home servers and foreign servers alike.
895897

896898
:::warning
897899

@@ -918,15 +920,57 @@ protected route.
918920
#### 4.1.1 Authenticating on a foreign server
919921

920922
Regardless of the authentication method used, the foreign server must verify the actor's identity
921-
before allowing them to perform any actions. This verification must be done by proving the cryptographic
922-
connection between an actors' home server's public identity key and the actor's ID-Cert through
923-
ID-Cert signature verification.
923+
before allowing them to perform any actions. This verification must be done by proving that the
924+
actor is in possession of the private key for their ID-Cert, and that the ID-Cert actually belongs
925+
to the home server that the actor claims. This is done via
926+
[a challenge string](#43-challenge-strings) in the following flow:
927+
928+
```mermaid
929+
sequenceDiagram
930+
autonumber
931+
participant HomeserverA as "Homeserver A"
932+
actor Alice
933+
participant HomeserverB as "Homeserver B"
934+
935+
note over Alice, HomeserverA: Alice is registered on Homeserver A
936+
937+
Alice->>HomeserverB: GET /.p2/core/v1/session/auth
938+
HomeserverB->>HomeserverB: Generate challenge & lifetime
939+
940+
HomeserverB-->>Alice: keytrial { challenge, lifetime }
941+
Alice->>Alice: Sign challenge with private identity key
942+
943+
Alice->>HomeserverB: POST keytrial { signature, federation_id, cert_serial }
944+
HomeserverB->>HomeserverB: Check request format
945+
946+
HomeserverB->>HomeserverA: GET cert (federation_id, cert_serial)
947+
HomeserverA->>HomeserverA: Look up certificate & status
948+
949+
HomeserverA-->>HomeserverB: cert, status (valid/invalid)
950+
HomeserverB->>HomeserverB: Check certificate validity
951+
HomeserverB->>HomeserverB: Check certificate expiry
952+
HomeserverB->>HomeserverB: Verify signature
953+
954+
alt Signature and cert valid
955+
HomeserverB->>HomeserverB: Generate authentication token
956+
HomeserverB->>HomeserverB: Hash and store token in DB
957+
HomeserverB-->>Alice: auth token (secret)
958+
Alice->>Alice: Store authentication token
959+
Alice->>HomeserverB: Use auth token for further requests
960+
HomeserverB->>HomeserverB: Validate token for each request
961+
else Signature or cert invalid
962+
HomeserverB-->>Alice: error (authentication failed)
963+
end
964+
```
965+
966+
_Fig. X: Demonstration of authentication on a foreign server._
924967

925968
Before a foreign actor is allowed to send messages on the server, the server must also check with
926-
the actor's home server to ensure that the ID-Cert has not been revoked. See [section 6.4.1](#641-verifying-that-a-newly-retrieved-id-cert-is-not-out-of-date)
927-
for information on how this is done.
969+
the actor's home server to ensure that the ID-Cert has not been revoked (steps #9 and #10 in the
970+
diagram). See [section 6.4.1](#641-verifying-that-a-newly-retrieved-id-cert-is-not-out-of-date) for
971+
information on how this is done.
928972

929-
#### 4.1.2 Sensitive actions
973+
#### 4.2 Sensitive actions
930974

931975
TODO: Better describe "Sensitive-Solution".
932976

@@ -962,7 +1006,7 @@ value of this header is to be that password.
9621006

9631007
:::
9641008

965-
### 4.2 Challenge strings
1009+
### 4.3 Challenge strings
9661010

9671011
Servers use challenge strings to verify an actor's private identity key
9681012
possession without revealing the private key itself. These strings, ranging from 32 to 256
@@ -972,8 +1016,8 @@ ID-Cert to the server, which then verifies the signature's authenticity.
9721016

9731017
:::warning
9741018

975-
Challenge strings provide a different set of security guarantees than [sensitive actions](#412-sensitive-actions)
976-
do. They are not to be used interchangeably.
1019+
Challenge strings provide a different set of security guarantees than
1020+
[sensitive actions](#42-sensitive-actions) do. They are not to be used interchangeably.
9771021

9781022
:::
9791023

@@ -1020,7 +1064,12 @@ else
10201064
end
10211065
```
10221066

1023-
### 4.3 Protection against misuse by malicious home servers
1067+
<!-- prettier-ignore-start -->
1068+
<!-- markdownlint-disable-next-line MD036 -->
1069+
_Fig. X: Challenge string validation_
1070+
<!-- prettier-ignore-end -->
1071+
1072+
### 4.4 Protection against misuse by malicious home servers
10241073

10251074
To protect users from misuse by malicious home servers, a mechanism is needed to prevent home
10261075
servers from generating federation tokens for users without their consent and knowledge.
@@ -1054,11 +1103,11 @@ excluding the new session. The `NEW_SESSION` event's stored data can be accessed
10541103
:::note
10551104

10561105
With proper safety precautions and strong encryption, it is extremely unlikely for a malicious
1057-
server to be able to listen in on encrypted conversations, without all users in that
1058-
conversation noticing. When implementing the polyproto-mls P2 extension, MLS's forward secrecy
1059-
guarantees ensure that, in theory, a malicious session cannot decrypt any messages sent before
1060-
its' join epoch. If secrecy or confidentiality are of concern, users should host their own home
1061-
server and use end-to-end encryption, such as polyproto-mls.
1106+
server to be able to listen in on encrypted conversations, without all users in that conversation
1107+
noticing. When implementing the polyproto-mls P2 extension, MLS's forward secrecy guarantees ensure
1108+
that, in theory, a malicious session cannot decrypt any messages sent before its join epoch. If
1109+
secrecy or confidentiality are of concern, users should host their own home server and use
1110+
end-to-end encryption, such as polyproto-mls.
10621111

10631112
:::
10641113

@@ -1106,7 +1155,7 @@ The ID-Cert, an [X.509](https://en.wikipedia.org/wiki/X.509) certificate, valida
11061155
identity key. It is an actor-generated CSR ([Certificate Signing Request](https://en.wikipedia.org/wiki/Certificate_signing_request)),
11071156
signed by a home server, encompassing actor identity information and the client's public identity key.
11081157
Clients can get an ID-Cert in return for a valid and well-formed CSR. Generating a new ID-Cert is
1109-
considered a [sensitive action](#412-sensitive-actions) and therefore should require a second factor
1158+
considered a [sensitive action](#42-sensitive-actions) and therefore should require a second factor
11101159
of authentication.
11111160

11121161
A CSR in the context of polyproto will be referred to as an ID-CSR. ID-CSRs are DER- or PEM-encoded
@@ -1257,13 +1306,13 @@ malicious server cannot generate an identity key pair for Alice, which is signed
12571306

12581307
#### 6.1.3 Key rotation
12591308

1260-
A session can choose to regenerate their ID-Cert at any time. This is done by taking an identity
1261-
key pair, using the private key to generate a new CSR, and sending the new Certificate Signing
1262-
Request to the home server. The home server will then generate the new ID-Cert, given that
1263-
the CSR is valid. Actors can only regenerate ID-Certs for their current session, identified by their
1264-
session ID and session token. Other sessions can only be invalidated by [revoking them](#614-early-revocation-of-id-certs).
1265-
Re-generating an ID-Cert is a [sensitive action](#412-sensitive-actions), performed by using the
1266-
appropriate API route.
1309+
A session can choose to regenerate their ID-Cert at any time. This is done by taking an identity key
1310+
pair, using the private key to generate a new CSR, and sending the new Certificate Signing Request
1311+
to the home server. The home server will then generate the new ID-Cert, given that the CSR is valid.
1312+
Actors can only regenerate ID-Certs for their current session, identified by their session ID and
1313+
session token. Other sessions can only be invalidated by
1314+
[revoking them](#614-early-revocation-of-id-certs). Re-generating an ID-Cert is a
1315+
[sensitive action](#42-sensitive-actions), performed by using the appropriate API route.
12671316

12681317
Home servers must keep track of the ID-Certs of all users (and their clients) registered on them
12691318
and must offer a clients' ID-Cert for a given timestamp on request. This is to ensure messages
@@ -1345,7 +1394,7 @@ reasons, such as
13451394
- keeping the number of ID-Certs associated with an actor within a desired boundary
13461395

13471396
When an ID-Cert is revoked, the server must revoke the session associated with the revoked ID-Cert.
1348-
Revoking an ID-Cert is considered a [sensitive action](#412-sensitive-actions) and therefore should
1397+
Revoking an ID-Cert is considered a [sensitive action](#42-sensitive-actions) and therefore should
13491398
require a second factor of authentication.
13501399

13511400
{/*TODO*/}
@@ -2294,12 +2343,12 @@ JSON file.
22942343
### 7.4 Challenges and trust
22952344

22962345
Changing the publicly visible ownership of actor data requires the chain of trust to be maintained.
2297-
If an "old" account wants to change the publicly visible ownership of its data, the "old"
2298-
account must prove that it possesses the private keys that were used to
2299-
sign the messages. This is done by signing a [challenge string](#42-challenge-strings) with the private
2300-
keys. If the server verifies the challenge, it authorizes the new account to re-sign the old
2301-
account's messages signed with the verified key. Instead of overwriting the message, a new message variant
2302-
with the new signature is created, preserving the old message.
2346+
If an "old" account wants to change the publicly visible ownership of its data, the "old" account
2347+
must prove that it possesses the private keys that were used to sign the messages. This is done by
2348+
signing a [challenge string](#42-sensitive-actions) with the private keys. If the server verifies
2349+
the challenge, it authorizes the new account to re-sign the old account's messages signed with the
2350+
verified key. Instead of overwriting the message, a new message variant with the new signature is
2351+
created, preserving the old message.
23032352

23042353
Implementations and protocol extensions should carefully consider the extent of messages that can be
23052354
re-signed.

0 commit comments

Comments
 (0)