LocalSigner

The LocalSigner in the Chorus One SDK is a specialized implementation of the Signer interface that utilizes a BIP39 mnemonic for signing operations.

This signer is ideal for local environments where you need a straightforward and secure method to generate and manage cryptographic keys from mnemonic phrases.

Table of contents

Constructors

Methods

Constructors

constructor

โ€ข new LocalSigner(params): LocalSigner

Constructs a new LocalSigner.

Parameters

Name
Type
Description

params

Object

The parameters required to initialize the LocalSigner

params.mnemonic

string

A string containing your BIP39 mnemonic phrase

params.accounts

[{ hdPath: string }]

An array of account objects, each containing an HD path

params.keyType

KeyType

An enum specifying the signing key type (e.g. SECP256K1, ED25519)

params.addressDerivationFn

AddressDerivationFn

A function that derives the address from the public key

params.mnemonicToSeedFn?

MnemonicToSeedFn

-

params.seedToKeypairFn?

SeedToKeypairFn

-

params.logger?

Logger

(Optional) A logger to use for logging messages, i.e console

Returns

LocalSigner

A new instance of LocalSigner.

Methods

init

โ–ธ init(): Promise<void>

Initializes the signer, performing any necessary setup or configuration.

Returns

Promise<void>

A promise that resolves once the initialization is complete.


sign

โ–ธ sign(signerAddress, signerData): Promise<{ sig: Signature ; pk: Uint8Array }>

Signs the provided data using the private key associated with the signer's address.

Parameters

Name
Type
Description

signerAddress

string

The address of the signer

signerData

SignerData

The data to be signed, which can be a raw message or custom data

Returns

Promise<{ sig: Signature ; pk: Uint8Array }>

A promise that resolves to an object containing the signature and public key.


getPublicKey

โ–ธ getPublicKey(address): Promise<Uint8Array>

Retrieves the public key associated with the signer's address.

Parameters

Name
Type
Description

address

string

The address of the signer

Returns

Promise<Uint8Array>

A promise that resolves to a Uint8Array representing the public key.

Last updated

Was this helpful?