@zlattice/lattice-js
Version:
Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)
71 lines • 2.18 kB
TypeScript
import type { ProjPointType } from '@noble/curves/abstract/weierstrass';
export * from "./utils.js";
export { initRNGPool } from './rng.js';
export { calculateSharedKey } from './kx.js';
export declare const EmptyArray: Uint8Array<ArrayBuffer>;
/**
* 加密
*/
export declare function doEncrypt(msg: string | Uint8Array, publicKey: string | ProjPointType<bigint>, cipherMode?: number, options?: {
asn1?: boolean;
}): string;
/**
* 解密
*/
export declare function doDecrypt(encryptData: string, privateKey: string, cipherMode?: number, options?: {
output: 'array';
asn1?: boolean;
}): Uint8Array;
export declare function doDecrypt(encryptData: string, privateKey: string, cipherMode?: number, options?: {
output?: 'string';
asn1?: boolean;
}): string;
export interface SignaturePoint {
k: bigint;
x1: bigint;
}
/**
* 签名
*/
export declare function doSignature(msg: Uint8Array | string, privateKey: string, options?: {
pointPool?: SignaturePoint[];
der?: boolean;
hash?: boolean;
publicKey?: string;
userId?: string;
}): string;
/**
* 验签
*/
export declare function doVerifySignature(msg: string | Uint8Array, signHex: string, publicKey: string | ProjPointType<bigint>, options?: {
der?: boolean;
hash?: boolean;
userId?: string;
}): boolean;
export declare function getZ(publicKey: string, userId?: string): Uint8Array<ArrayBufferLike>;
/**
* sm3杂凑算法
*/
export declare function getHash(hashHex: string | Uint8Array, publicKey: string, userId?: string): string;
/**
* 预计算公钥点,可用于提升加密性能
* @export
* @param {string} publicKey 公钥
* @param windowSize 计算窗口大小,默认为 8
* @returns {ProjPointType<bigint>} 预计算的点
*/
export declare function precomputePublicKey(publicKey: string, windowSize?: number): ProjPointType<bigint>;
/**
* 计算公钥
*/
export declare function getPublicKeyFromPrivateKey(privateKey: string, compressed?: boolean): string;
/**
* 获取椭圆曲线点
*/
export declare function getPoint(): {
k: bigint;
x1: bigint;
privateKey: string;
publicKey: string;
};
//# sourceMappingURL=index.d.ts.map