did-sdk-js
Version:
js sdk for did and vc according to mcps did spec
39 lines (38 loc) • 1.58 kB
TypeScript
import { Crypto } from "./crypto";
export declare class Sm2 extends Crypto {
static PRIVKEY_LEN: number;
static KEY_TYPE: string;
static generateMnemonicAndKey(): {
mnemonic: string;
privateKey: string;
publicKey: string;
};
/**
* Calculates the public key from a given private key.
* @param privateKeyHex The private key hexstring
* @param mode Pubkey Type 'compress' or ''
* @returns Public key {type:type, value:hexstring}
*/
static getPublicKeyFromPrivateKey(privateKeyHex: string, mode?: string): string;
static generateKey(): {
privateKey: string;
publicKey: string;
};
/**
* Generates a signature (base64 string) for a signDocSerialize based on given private key.
* @param signMsg from protobuf and tx.
* @param privateKeyHex The private key.
* @returns Signature. Does not include tx.
*/
static sign(signMsg: string, privateKeyHex: string): Promise<string>;
/**
* Verifies a signature (64 byte <r,s>) given the sign bytes and public key.
* @param sigValue The signature base64 string.
* @param signMsg Unsigned transaction sign msg string.
* @param publicKeyHex The public key.
* @returns Signature. Does not include tx.
*/
static signVerify(signMsg: string, sigValue: string, publicKeyHex: string): Promise<any>;
static encrypt(msg: string, publicKeyHex: string): Promise<string>;
static decrypt(encryptDataHex: string, privateKeyHex: string): Promise<any>;
}