UNPKG

3.98 kBTypeScriptView Raw
1import type { HexString } from '@polkadot/util/types';
2import type { EncryptedJson, Keypair, KeypairType, Prefix } from '@polkadot/util-crypto/types';
3export interface KeyringOptions {
4 /**
5 * @description The ss58Format to use for address encoding (defaults to 42)
6 */
7 ss58Format?: Prefix;
8 /**
9 * @description The type of keyring to create (defaults to ed25519)
10 */
11 type?: KeypairType;
12}
13export declare type KeyringPair$Meta = Record<string, unknown>;
14export interface KeyringPair$Json extends EncryptedJson {
15 address: string | HexString;
16 meta: KeyringPair$Meta;
17}
18export interface SignOptions {
19 /**
20 * @description Create a MultiSignature-compatible output with an indicator type
21 **/
22 withType?: boolean;
23}
24export interface KeyringPair {
25 readonly address: string;
26 readonly addressRaw: Uint8Array;
27 readonly meta: KeyringPair$Meta;
28 readonly isLocked: boolean;
29 readonly publicKey: Uint8Array;
30 readonly type: KeypairType;
31 decodePkcs8(passphrase?: string, encoded?: Uint8Array): void;
32 derive(suri: string, meta?: KeyringPair$Meta): KeyringPair;
33 encodePkcs8(passphrase?: string): Uint8Array;
34 lock(): void;
35 setMeta(meta: KeyringPair$Meta): void;
36 sign(message: HexString | string | Uint8Array, options?: SignOptions): Uint8Array;
37 toJson(passphrase?: string): KeyringPair$Json;
38 unlock(passphrase?: string): void;
39 encryptMessage(message: HexString | string | Uint8Array, recipientPublicKey: HexString | string | Uint8Array, nonce?: Uint8Array): Uint8Array;
40 decryptMessage(encryptedMessageWithNonce: HexString | string | Uint8Array, senderPublicKey: HexString | string | Uint8Array): Uint8Array | null;
41 verify(message: HexString | string | Uint8Array, signature: Uint8Array, signerPublic: HexString | string | Uint8Array): boolean;
42 vrfSign(message: HexString | string | Uint8Array, context?: HexString | string | Uint8Array, extra?: HexString | string | Uint8Array): Uint8Array;
43 vrfVerify(message: HexString | string | Uint8Array, vrfResult: Uint8Array, signerPublic: HexString | Uint8Array | string, context?: HexString | string | Uint8Array, extra?: HexString | string | Uint8Array): boolean;
44}
45export interface KeyringPairs {
46 add: (pair: KeyringPair) => KeyringPair;
47 all: () => KeyringPair[];
48 get: (address: string | Uint8Array) => KeyringPair;
49 remove: (address: string | Uint8Array) => void;
50}
51export interface KeyringInstance {
52 readonly pairs: KeyringPair[];
53 readonly publicKeys: Uint8Array[];
54 readonly type: KeypairType;
55 decodeAddress(encoded: string | Uint8Array, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
56 encodeAddress(key: Uint8Array | string, ss58Format?: Prefix): string;
57 setSS58Format(ss58Format: Prefix): void;
58 addPair(pair: KeyringPair): KeyringPair;
59 addFromAddress(address: string | Uint8Array, meta?: KeyringPair$Meta, encoded?: Uint8Array | null, type?: KeypairType, ignoreChecksum?: boolean): KeyringPair;
60 addFromJson(pair: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair;
61 addFromMnemonic(mnemonic: string, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
62 addFromPair(pair: Keypair, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
63 addFromSeed(seed: Uint8Array, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
64 addFromUri(suri: string, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
65 createFromJson(json: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair;
66 createFromPair(pair: Keypair, meta: KeyringPair$Meta, type: KeypairType): KeyringPair;
67 createFromUri(suri: string, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
68 getPair(address: string | Uint8Array): KeyringPair;
69 getPairs(): KeyringPair[];
70 getPublicKeys(): Uint8Array[];
71 removePair(address: string | Uint8Array): void;
72 toJson(address: string | Uint8Array, passphrase?: string): KeyringPair$Json;
73}