1 | import type { EncryptedJsonEncoding, KeypairType } from '@polkadot/util-crypto/types';
|
2 | import type { KeyringPair, KeyringPair$Meta } from '../types.js';
|
3 | import type { PairInfo } from './types.js';
|
4 | interface Setup {
|
5 | toSS58: (publicKey: Uint8Array) => string;
|
6 | type: KeypairType;
|
7 | }
|
8 | /**
|
9 | * @name createPair
|
10 | * @summary Creates a keyring pair object
|
11 | * @description Creates a keyring pair object with provided account public key, metadata, and encoded arguments.
|
12 | * The keyring pair stores the account state including the encoded address and associated metadata.
|
13 | *
|
14 | * It has properties whose values are functions that may be called to perform account actions:
|
15 | *
|
16 | * - `address` function retrieves the address associated with the account.
|
17 | * - `decodedPkcs8` function is called with the account passphrase and account encoded public key.
|
18 | * It decodes the encoded public key using the passphrase provided to obtain the decoded account public key
|
19 | * and associated secret key that are then available in memory, and changes the account address stored in the
|
20 | * state of the pair to correspond to the address of the decoded public key.
|
21 | * - `encodePkcs8` function when provided with the correct passphrase associated with the account pair
|
22 | * and when the secret key is in memory (when the account pair is not locked) it returns an encoded
|
23 | * public key of the account.
|
24 | * - `meta` is the metadata that is stored in the state of the pair, either when it was originally
|
25 | * created or set via `setMeta`.
|
26 | * - `publicKey` returns the public key stored in memory for the pair.
|
27 | * - `sign` may be used to return a signature by signing a provided message with the secret
|
28 | * key (if it is in memory) using Nacl.
|
29 | * - `toJson` calls another `toJson` function and provides the state of the pair,
|
30 | * it generates arguments to be passed to the other `toJson` function including an encoded public key of the account
|
31 | * that it generates using the secret key from memory (if it has been made available in memory)
|
32 | * and the optionally provided passphrase argument. It passes a third boolean argument to `toJson`
|
33 | * indicating whether the public key has been encoded or not (if a passphrase argument was provided then it is encoded).
|
34 | * The `toJson` function that it calls returns a JSON object with properties including the `address`
|
35 | * and `meta` that are assigned with the values stored in the corresponding state variables of the account pair,
|
36 | * an `encoded` property that is assigned with the encoded public key in hex format, and an `encoding`
|
37 | * property that indicates whether the public key value of the `encoded` property is encoded or not.
|
38 | */
|
39 | export declare function createPair({ toSS58, type }: Setup, { publicKey, secretKey }: PairInfo, meta?: KeyringPair$Meta, encoded?: Uint8Array | null, encTypes?: EncryptedJsonEncoding[]): KeyringPair;
|
40 | export {};
|