Skip to main content

Configure to the SDK

Configure Message Signer to React Native Silent Shard SDK

The createEcdsaDuoSession function creates a session to handle MPC operations between mobile device and Duo services. Key configuration properties are:

  • cloudVerifyKey: The Duo server's public key used to verify messages sent by Duo services in the mobile SDK.
  • messageSigner: An instance of the message signer that will be used to sign messages sent to Duo services.

The cloudVerifyKey is mandatory to configure for the session. While the messageSigner is optional. If not provided, the SDK will generate a new Ed25519 key pair internally. But we strongly recommend to provide your own message signer implementation to ensure the message exchange between parties is secure and more features enabled like auth-svc.

We also provide a utility package for the message signer. The @silencelaboratories/react-native-secure-key package offers a simple way to create and manage message signers in your React Native application.

Create a ECDSA key pair in the secure environment (TEE) using the utility package:

MessageSignerConfig.ts
import * as SecureKey from "@silencelaboratories/react-native-secure-key";

const KEY_ALIAS = "my-key";

SecureKey.createIfNotExistSecureKey(KEY_ALIAS)

The createIfNotExistSecureKey function checks if a key with the specified alias already exists in the secure environment. If it does not exist, it generates a new ECDSA_P256 key pair and stores along with the alias. The alias can be used later to retrieve the key pair for signing operations.

Next, create a message signer instance using the created key pair:

MessageSignerConfig.ts
import * as SecureKey from "@silencelaboratories/react-native-secure-key";

const KEY_ALIAS = "my-key";
export const messageSigner = SecureKey.createMessageSigner(KEY_ALIAS);

Finally, configure the session with the message signer and Duo server's public key:

DuoSessionConfig.ts
import { createEcdsaDuoSession } from "@silencelaboratories/silent-shard-sdk";
import { messageSigner } from "./MessageSignerConfig";

export const duoSession = createEcdsaDuoSession({
client: new CloudWebSocketClient("YOUR_CLOUD_NODE_ENDPOINT", false),
cloudVerifyKey: "CLOUD_VERIFY_KEY_HEX",
messageSigner: messageSigner,
});

Check out more details on React Native Store key utility package.