aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-common/src/meshbay_common/device.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-common/src/meshbay_common/device.py')
-rw-r--r--packages/meshbay-common/src/meshbay_common/device.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/meshbay-common/src/meshbay_common/device.py b/packages/meshbay-common/src/meshbay_common/device.py
index 3a598d0..2d6747f 100644
--- a/packages/meshbay-common/src/meshbay_common/device.py
+++ b/packages/meshbay-common/src/meshbay_common/device.py
@@ -37,6 +37,7 @@ import hashlib
DEVICE_REQUEST_PREFIX = b"meshbay:device_req:v1"
DEVICE_ADD_PREFIX = b"meshbay:device_add:v1"
DEVICE_HELLO_PREFIX = b"meshbay:device_hello:v1"
+DEVICE_REVOKE_PREFIX = b"meshbay:device_revoke:v1"
# Same as the join and admin transcripts: interactive exchanges that complete in
# milliseconds, so anything older is a replay.
@@ -126,6 +127,30 @@ def device_add_transcript(
])
+def device_revoke_transcript(
+ node_pk_b64: str,
+ user_id: str,
+ pk_ed25519_b64: str,
+ nonce_node: bytes,
+ ts: int,
+) -> bytes:
+ """
+ Signed by a pinned device, retiring one of the account's devices.
+
+ A prefix of its own, never the admission transcript: a signature given to
+ retire a key would otherwise admit that same key on a node where it is not
+ pinned yet, and whoever asks a device to sign a retirement could turn it
+ into an addition.
+ """
+ return _pack(DEVICE_REVOKE_PREFIX, [
+ node_pk_b64.encode(),
+ user_id.encode(),
+ pk_ed25519_b64.encode(),
+ nonce_node,
+ str(ts).encode(),
+ ])
+
+
def device_hello_transcript(
node_pk_b64: str,
group_id: str,