Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Message Privacy and Key Management

Understanding how message content is protected determines where in your application a user is able to read their messages.

When a phone number is provisioned, the SDK generates a key pair on the device, registers the public key with the Telephony service, and retains the private key in the device key store. The service seals the text and the sender's number of each received message to that public key. Reading a message requires the private key to unseal it.

The following characteristics follow from this design.

  • Message content is readable only on a device that holds the private key. The Telephony service is unable to read it, and neither is a second device until the key is moved there.

  • A reinstalled application, or a second device, is unable to read existing messages until a key archive is imported. See [Export and Import Cryptographic Keys]#export-and-import-cryptographic-keys).

Export and Import Cryptographic Keys

Message content is sealed to a key held on a single device meaning a user who reinstalls the application or adds a second device is unable to read their existing messages until the key is moved there.

The exportKeys method returns a portable key archive, and the importKeys method restores one.

try {
  // On the device that holds the keys.
  const archive = await telephonyClient.exportKeys()

  // On the device that requires them.
  await telephonyClient.importKeys(archive)
} catch (error) {
  // Handle/notify user of error
}
do {
    /// On the device that holds the keys.
    let archive = try telephonyClient.exportKeys()

    /// On the device that requires them.
    try telephonyClient.importKeys(archiveData: archive)
} catch {
    /// Handle/notify user of error
}
launch {
    try {
        // On the device that holds the keys.
        val archive = withContext(Dispatchers.IO) {
            telephonyClient.exportKeys()
        }

        // On the device that requires them.
        withContext(Dispatchers.IO) {
            telephonyClient.importKeys(archive)
        }
    } catch (e: SudoTelephonyClient.CryptographicKeysException) {
        // Handle/notify user of exception
    }
}

Last updated