Skip to content

Commit c77d04c

Browse files
committed
add base64 option
1 parent 405ac1e commit c77d04c

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

proposals/1543-qr_code_key_verification.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ This proposal defines three verification methods that can be used in
170170

171171
### QR code format
172172

173-
Note: only one of the following will be supported. They are both being
173+
Note: only one of the following will be supported. They are all being
174174
documented here while we determine how well different formats are supported.
175175

176176
#### Binary format
@@ -259,6 +259,74 @@ strings generated as follows:
259259

260260
The QR code is then generated using alphanumeric encoding mode.
261261

262+
#### Base64 format
263+
264+
The QR codes to be displayed and scanned using this format will be a string of
265+
the following form:
266+
267+
- the string "MATRIX"
268+
- one character indicating the version (must by "2")
269+
- one character indicating the QR code verification mode. May be one of the
270+
following values:
271+
- "0" verifying another user with cross-signing
272+
- "1" self-verifying in which the current device does trust the master key
273+
- "2" self-verifying in which the current device does not yet trust the
274+
master key
275+
- the event ID or `transaction_id` of the associated verification
276+
request event, encoded as:
277+
- two bytes in network byte order (big-endian), encoded in unpadded base64 (3
278+
characters), indicating the length in bytes of the ID as a UTF-8 string
279+
- the ID as a UTF-8 string
280+
- the first key as unpadded base64 (43 characters). The key to use depends on
281+
the mode field:
282+
- if "0" or "1", then the user's own master cross-signing public key
283+
- if "2", then the current device's device key
284+
- the second key as unpadded base64 (43 characters). The key to use depends on
285+
the mode field:
286+
- if "0", then what the device thinks the other user's master
287+
cross-signing key is
288+
- if "1", then what the device thinks the other device's device key is
289+
- if "2", then what the device thinks the user's master cross-signing key
290+
is
291+
- a random shared secret, as an ASCII string. It is suggested to use a secret
292+
that is about 11 bytes long. (This is approximately the length of 8 bytes as
293+
a base64 string.) Note: as we do not share the length of the secret, and it
294+
is not a fixed size, clients will just use the remainder of binary string as
295+
the shared secret.
296+
297+
1. generate a binary string by concatenating:
298+
- the event ID or `transaction_id` of the associated verification
299+
request event, encoded as:
300+
- two bytes in network byte order (big-endian) indicating the length in
301+
bytes of the ID as a UTF-8 string
302+
- the ID as a UTF-8 string
303+
- the first key, as 32 bytes. The key to use depends on the mode field as
304+
described in step 3:
305+
- if "0" or "1", then the user's own master cross-signing public key
306+
- if "2", then the current device's device key
307+
- the second key, as 32 bytes. The key to use depends on the mode field:
308+
- if "0", then what the device thinks the other user's master
309+
cross-signing key is
310+
- if "1", then what the device thinks the other device's device key is
311+
- if "2", then what the device thinks the user's master cross-signing key
312+
is
313+
- a random shared secret, as a byte string. It is suggested to use a secret
314+
that is about 8 bytes long. Note: as we do not share the length of the
315+
secret, and it is not a fixed size, clients will just use the remainder of
316+
binary string as the shared secret.
317+
2. encode the above string using unpadded base64
318+
3. prepend the resulting string with
319+
- the string "MATRIX"
320+
- one character indicating the version (must by "2")
321+
- one character indicating the QR code verification mode. May be one of the
322+
following values:
323+
- "0" verifying another user with cross-signing
324+
- "1" self-verifying in which the current device does trust the master key
325+
- "2" self-verifying in which the current device does not yet trust the
326+
master key
327+
328+
The QR code is then generated using byte encoding mode.
329+
262330
### Message types
263331

264332
#### `m.key.verification.start`

0 commit comments

Comments
 (0)