Skip to content

Commit 4077064

Browse files
gnpricetimabbott
authored andcommitted
1 parent f2c1956 commit 4077064

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

zaps/0002-encrypt-push-notifications.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ class Account:
118118
# The client should be careful about case with this field, since
119119
# APNs at least is case-insensitive.
120120
last_acked_push_token: str
121-
# Private part of the asymmetric key pair generated by the client.
122-
push_private_key: PrivateKey
123-
# Public key corresponding to push_private_key
124-
push_public_key: PublicKey
121+
# Key shared (or to be shared) with the server.
122+
push_key: SymmetricKey
125123
```
126124

127125
The client is responsible for ensuring that these secrets are stored
@@ -162,8 +160,8 @@ class zerver.models.push_notifications.PushDevice:
162160
encrypted_push_registration: Ciphertext | None
163161
# 64-bit random integer generated by client. Need not be globally unique.
164162
push_account_id: int
165-
# Public part of the asymmetric key pair generated by the client.
166-
push_public_key: PublicKey
163+
# Key shared with the client.
164+
push_key: SymmetricKey
167165
# Provided by client.
168166
token_kind: "apns" | "fcm"
169167
# The user on this server to whom this PushDevice belongs.
@@ -262,7 +260,7 @@ The steps are:
262260
prepare an FCM-style or an APNs-style payload.
263261

264262
1. Encrypt the notification content to
265-
`PushDevice.push_public_key`, as `encrypted_content`.
263+
`PushDevice.push_key`, as `encrypted_content`.
266264

267265
1. The result is a pair `(device_id, encrypted_content)`.
268266

@@ -302,7 +300,7 @@ The steps are:
302300

303301
1. Use `push_account_id` to look up the Account record.
304302

305-
1. Use `Account.push_private_key` to decrypt `encrypted_content`.
303+
1. Use `Account.push_key` to decrypt `encrypted_content`.
306304

307305
1. Process the resulting plaintext as a notification.
308306

@@ -338,11 +336,11 @@ Some steps may happen repeatedly due to retries, as detailed below.
338336

339337
2. On the client:
340338

341-
If `push_account_id`, `push_public_key`, and `push_private_key` are
339+
If `push_account_id` and `push_key` are
342340
already set on the `Account` record, proceed to the next step.
343341

344342
Otherwise, generate a random 64-bit integer `push_account_id` and
345-
an asymmetric key pair `push_public_key` and `push_private_key`.
343+
a symmetric key `push_key`.
346344
Store these on the `Account` record.
347345

348346
3. On the client:
@@ -356,7 +354,7 @@ Some steps may happen repeatedly due to retries, as detailed below.
356354

357355
3. Make an API request to the server with arguments `push_account_id`,
358356
`encrypted_push_registration`, `bouncer_public_key`,
359-
`push_public_key`, and `token_kind`.
357+
`push_key`, and `token_kind`.
360358

361359
The request is authenticated with the user’s API key, in the
362360
same way as other requests the client makes to the server.

0 commit comments

Comments
 (0)