Skip to main content

Keyshare

Keyshare class represents a ECDSA Keyshare from the Native Module. This class hold memory pointer to the keyshare in the native module and handle various useful operations on the keyshare.

Note: Most methods in this class are asynchronous and return a promise. Due to React-Native native module bridge.


Import

import * as dkls from '@silencelaboratories/dkls-sdk';

// Then you can use it as
dkls.Keyshare

Usage

// Get public key and key id from keyshare
const publicKey = await keyshare.publicKeyBase64;
const publicKeyHex = await keyshare.publicKeyHex;
const keyId = await keyshare.keyId;

// Derive child public key from keyshare
const derivedPublicKey = await keyshare.deriveChildPublicKey('m');

// Get keyshare in base64 format for persistence
const keyshareBase64 = keyshare.toBase64();
// Recreate keyshare from keyshare base64 string
const keyshareFromBase64 = await dkls.Keyshare.fromBase64(keyshareBase64);

// After all operation free up memory
await keyshare.free();

Accessors

handle

Get Signature

get handle(): number

Returns

number


keyIdBase64

Get Signature

get keyIdBase64(): string

Get the keyId of the keyshare in Base64 format

Returns

string

Base64 encoded string of the keyId


keyIdBase64Url

Get Signature

get keyIdBase64Url(): string

Get the keyId of the keyshare in Base64Url format

Returns

string

Base64Url encoded string of the keyId


keyIdHex

Get Signature

get keyIdHex(): string

Get the keyId of the keyshare in Hex format

Returns

string

Hex encoded string of the keyId


publicKeyBase64

Get Signature

get publicKeyBase64(): string

Get the public key of the keyshare in Base64 format

Returns

string

Base64 encoded string of the public key


publicKeyHex

Get Signature

get publicKeyHex(): string

Get the public key of the keyshare in Hex format

Returns

string

Hex encoded string of the public key

Methods

deriveChildPublicKey()

deriveChildPublicKey(derivationPath): Promise<string>

Derive child public key from keyshare

Parameters

derivationPath

string

BIP 32 derivation path

Returns

Promise<string>

A promise contain derived public key (string base64 encode)


free()

free(): Promise<boolean>

Free up the native memory allocated for the keyshare

Returns

Promise<boolean>

A promise containing the success status of the operation


toBase64()

toBase64(): Promise<string>

Get the keyshare in base64 format

Returns

Promise<string>

A promise containing the base64 encoded string of the keyshare


fromBase64()

static fromBase64(keyshareBase64): Promise<Keyshare>

Create a Keyshare instance from a base64 encoded string

Parameters

keyshareBase64

string

base64 encoded string of the keyshare

Returns

Promise<Keyshare>

A promise containing the Keyshare instance