did-sdk-js
Version:
js sdk for did and vc according to mcps did spec
57 lines (56 loc) • 2.03 kB
TypeScript
import * as bip39 from 'bip39';
/**
* Crypto Utils
* @hidden
*/
export declare class Crypto {
static PRIVKEY_LEN: number;
static MNEMONIC_LEN: number;
static DECODED_ADDRESS_LEN: number;
static COMPRESSED_PUBKEY_LEN: number;
static UNCOMPRESSED_PUBKEY_LEN: number;
static HDPATH: string;
/**
* Generates mnemonic phrase words using random entropy.
*
* @returns Mnemonic
*/
static generateMnemonic(): string;
static generateKey(): {
privateKey: string;
publicKey: string;
};
static generateMnemonicAndKey(): {
mnemonic: string;
privateKey: string;
publicKey: string;
};
/**
* Gets an address from a public key hex.
* @param publicKeyHex The public key hexstring
* @param prefix The address prefix
*
* @returns The address
*/
static getBech32AddressFromPublicKey(publicKeyHex: string, prefix?: string): string;
/**
* Validates mnemonic phrase words.
* @param mnemonic The mnemonic phrase words
* @returns Validation result
*/
static validateMnemonic: typeof bip39.validateMnemonic;
/**
* Gets a private key from mnemonic words.
* @param mnemonic The mnemonic phrase words
* @param derive Derive a private key using the default HD path (default: true)
* @param index The bip44 address index (default: 0)
* @param password A passphrase for generating the salt, according to bip39
* @returns hexstring
*/
static getPrivateKeyFromMnemonic(mnemonic: string, index?: number, derive?: boolean, password?: string): string;
static sign(signMsg: string, privateKeyHex: string): Promise<string>;
static signVerify(signMsg: string, // base64 encode
sigValue: string, publicKeyHex: string): Promise<boolean>;
static encrypt(msg: string, publicKeyHex: string): Promise<string>;
static decrypt(encryptDataHex: string, privateKeyHex: string): Promise<string>;
}