Skip to main content

Class: Secp256r1Keypair

An Secp256r1 Keypair used for signing transactions.

Extends

Constructors

Constructor

new Secp256r1Keypair(keypair?): Secp256r1Keypair;

Create a new keypair instance. Generate random keypair if no Secp256r1Keypair is provided.

Parameters

ParameterTypeDescription
keypair?Secp256r1KeypairDataSecp256r1 keypair

Returns

Secp256r1Keypair

Overrides

Keypair.constructor

Methods

signingDigest()

static signingDigest(bytes, intent): Uint8Array;

Sign messages with a specific intent. By combining the message bytes with the intent before hashing. Returns the digest.

Parameters

ParameterType
bytesUint8Array
intentIntentScope

Returns

Uint8Array

Inherited from

Keypair.signingDigest


signWithIntent()

signWithIntent(bytes, intent): Promise<SignatureWithBytes>;

Sign messages with a specific intent. By combining the message bytes with the intent before hashing and signing, it ensures that a signed message is tied to a specific purpose and domain separator is provided

Parameters

ParameterType
bytesUint8Array
intentIntentScope

Returns

Promise<SignatureWithBytes>

Inherited from

Keypair.signWithIntent


signTransaction()

signTransaction(bytes): Promise<SignatureWithBytes>;

Signs provided transaction by calling signWithIntent() with a TransactionData provided as intent scope

Parameters

ParameterType
bytesUint8Array

Returns

Promise<SignatureWithBytes>

Inherited from

Keypair.signTransaction


signPersonalMessage()

signPersonalMessage(bytes): Promise<{
bytes: string;
signature: string;
}>;

Signs provided personal message by calling signWithIntent() with a PersonalMessage provided as intent scope

Parameters

ParameterType
bytesUint8Array

Returns

Promise<{ bytes: string; signature: string; }>

Inherited from

Keypair.signPersonalMessage


toIotaAddress()

toIotaAddress(): string;

Returns

string

Inherited from

Keypair.toIotaAddress


getKeyScheme()

getKeyScheme(): SignatureScheme;

Get the key scheme of the keypair Secp256r1

Returns

SignatureScheme

Overrides

Keypair.getKeyScheme


generate()

static generate(): Secp256r1Keypair;

Generate a new random keypair

Returns

Secp256r1Keypair


fromSecretKey()

static fromSecretKey(secretKey, options?): Secp256r1Keypair;

Create a keypair from a raw secret key byte array.

This method should only be used to recreate a keypair from a previously generated secret key. Generating keypairs from a random seed should be done with the Keypair.fromSeed method.

Parameters

ParameterTypeDescription
secretKeystring | Uint8Arraysecret key byte array or Bech32 secret key string*
options?{ skipValidation?: boolean; }-
options.skipValidation?boolean-

Returns

Secp256r1Keypair

Throws

error if the provided secret key is invalid and validation is not skipped.


fromSeed()

static fromSeed(seed): Secp256r1Keypair;

Generate a keypair from a 32 byte seed.

Parameters

ParameterTypeDescription
seedUint8Arrayseed byte array

Returns

Secp256r1Keypair


getPublicKey()

getPublicKey(): PublicKey;

The public key for this keypair

Returns

PublicKey

Overrides

Keypair.getPublicKey


getSecretKey()

getSecretKey(): string;

The Bech32 secret key string for this Secp256r1 keypair

Returns

string

Overrides

Keypair.getSecretKey


sign()

sign(data): Promise<Uint8Array>;

Return the signature for the provided data.

Parameters

ParameterType
dataUint8Array

Returns

Promise<Uint8Array>

Overrides

Keypair.sign


deriveKeypair()

static deriveKeypair(mnemonics, path?): Secp256r1Keypair;

Derive Secp256r1 keypair from mnemonics and path. The mnemonics must be normalized and validated against the english wordlist.

If path is none, it will default to m/74'/4218'/0'/0/0, otherwise the path must be compliant to BIP-32 in form m/74'/4218'/{account_index}'/{change_index}/{address_index}.

Parameters

ParameterType
mnemonicsstring
path?string

Returns

Secp256r1Keypair