DeviceRecovery

Device recovery format version 1 (docs/device-recovery.md). All three constructions share the recovery statement:

u32 length | target userId (UTF-8)     | u32 length | target deviceId (UTF-8)
u32 length | authorizer userId (UTF-8) | u32 length | authorizer deviceId (UTF-8)
replacement public key (32)
timestamp: i64, epoch milliseconds
nonce (16)

and prefix it with u32 length | domain (UTF-8):

  • authorization, Ed25519 by the authorizer's registered key: KSecureMessage-DeviceRecovery-v1;

  • proof of possession, Ed25519 by the replacement key: KSecureMessage-DeviceRecovery-PoP-v1;

  • DeviceRecoveryId, SHA-256: KSecureMessage-DeviceRecoveryId-v1.

Integers are big-endian. The domains keep the three apart from each other and from server request signatures (KSecureMessage-ServerAuth-v1).

Properties

Link copied to clipboard
const val PUBLIC_KEY_SIZE: Int

Size of a device authentication public key (Ed25519).

Link copied to clipboard
const val SIGNATURE_SIZE: Int

Size of a recovery signature (Ed25519).

Link copied to clipboard

Accepted clock difference in each direction, by the authorizer and the server: now - VALIDITY_WINDOW <= timestamp <= now + VALIDITY_WINDOW. The same as for server requests.

Functions

Link copied to clipboard

The bytes the authorizer signs.

Link copied to clipboard

Signs request with the authorizer's device authentication key pair. Checks nothing: the caller verifies the request first.

Link copied to clipboard
fun prepare(replacement: DeviceAuthenticationKeyPair, target: DeviceAddress, authorizer: DeviceAddress, timestamp: Instant, nonce: RequestNonce = RequestNonce.random()): DeviceRecoveryRequest

The target's request: replacement is the new key pair, target the device whose registration it replaces, authorizer the device that is asked to authorize it. timestamp is truncated to milliseconds.

Link copied to clipboard

The bytes the replacement key signs.

Link copied to clipboard

The ID of request's statement.

Link copied to clipboard
fun verifyAuthorization(authorizerPublicKey: ByteArray, authorization: DeviceRecoveryAuthorization): Boolean

true if authorization's authorizer signature verifies with authorizerPublicKey. Does not check the proof of possession.

Link copied to clipboard

true if the request's proof of possession verifies with its replacement key.