import { IHDPath } from './hdpath'; import { AddrDerivation } from './wallet'; export interface ICryptoBytes { value: Uint8Array; toHex(): string; toPrefixedHex(): string; toBase64(): string; toBigInt(): bigint; toNumber(): number; toBech32(prefix: string, limit?: number): string; slice(start?: number, end?: number): ICryptoBytes; concat(key: ICryptoBytes): ICryptoBytes; } export interface IAlgo { name: string; makeKeypair(privateKey: Uint8Array): { privkey: Uint8Array; pubkey: Uint8Array; }; compress(pubkey: Uint8Array): Uint8Array; uncompress(pubkey: Uint8Array): Uint8Array; sign(message: Uint8Array, privateKey: Uint8Array): Promise; verify(signature: Uint8Array, message: Uint8Array, pubkey: Uint8Array): Promise; } export type HashFunction = (data: Uint8Array) => Uint8Array; export interface IPrivateKeyConfig { algo: IAlgo | string; passphrase?: string; } export interface IPublicKeyConfig { compressed?: boolean; } export interface IAddressConfig { strategy: IAddressStrategy | string; } export interface IWalletConfig { privateKeyConfig?: IPrivateKeyConfig; publicKeyConfig?: IPublicKeyConfig; addressConfig?: IAddressConfig; derivations: AddrDerivation[]; } export interface IAddressStrategy { name: string; preprocessPublicKey?(pubKeyBytes: Uint8Array, compressed: boolean, algo: IAlgo): Uint8Array; hash(bytes: Uint8Array): Uint8Array; encode(hashedBytes: Uint8Array, prefix?: string): string; decode(address: string): { bytes: Uint8Array; prefix?: string; }; checksum?(address: string): string; validateChecksum?(address: string): boolean; extractPrefix(address: string): string | undefined; } export interface IPrivateKey { readonly value: ICryptoBytes; readonly hdPath?: IHDPath; readonly config: IPrivateKeyConfig; toPublicKey(config?: IPublicKeyConfig): IPublicKey; sign(data: Uint8Array): Promise; toHex(): string; toBase64(): string; } export interface IPublicKey { readonly value: ICryptoBytes; readonly algo: IAlgo | string; readonly compressed: boolean; toAddress?(config: IAddressConfig, prefix?: string): IAddress; verify(data: Uint8Array, signature: ICryptoBytes): Promise; toHex(): string; toBase64(): string; } export interface IAddress { readonly value: string; readonly prefix?: string; readonly config: IAddressConfig; toBytes(): ICryptoBytes; isValid(): boolean; } export interface IWallet { readonly privateKeys: IPrivateKey[]; readonly config: IWalletConfig; getAccounts(): Promise; getAccountByIndex(index: number): Promise; signByIndex(data: Uint8Array, index?: number): Promise; } export declare function isIWallet(obj: any): obj is IWallet; export interface IAccount { getPublicKey(isCompressed?: boolean): IPublicKey; readonly address?: string; readonly hdPath?: IHDPath; readonly algo: string; }