UNPKG

@zlattice/lattice-js

Version:

Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)

71 lines 2.53 kB
import { type Curve } from "../common/constants.js"; import { Result } from "neverthrow"; declare const AES_128_CTR = "aes-128-ctr"; declare const KDF_SCRYPT = "scrypt"; declare const SCRYPT_N: number; declare const SCRYPT_P = 1; declare const SCRYPT_R = 8; declare const SCRYPT_KEY_LEN = 32; declare class FileKey { readonly uuid: string; readonly address: string; readonly cipher: Cipher; readonly isGm: boolean; constructor(uuid: string, address: string, cipher: Cipher, isGm: boolean); static fromJson(json: string): Result<FileKey, Error>; } declare class Cipher { readonly aes: Aes; readonly kdf: Kdf; readonly cipherText: string; readonly mac: string; constructor(aes: Aes, kdf: Kdf, cipherText: string, mac: string); } declare class Aes { readonly cipher: string; readonly iv: string; constructor(cipher: string, iv: string); } declare class Kdf { readonly kdf: string; readonly kdfParams: KdfParams; constructor(kdf: string, // 密钥派生函数,scrypt, PBKDF2, bcrypt, HKDF kdfParams: KdfParams); } declare class KdfParams { readonly DkLen: number; readonly n: number; readonly p: number; readonly r: number; readonly salt: string; constructor(DkLen: number, // 生成的密钥长度,单位byte n: number, // CPU/内存成本因子,控制计算和内存的使用量。 p: number, // 并行度因子,控制 scrypt 函数的并行度。 r: number, // 块大小因子,影响内部工作状态和内存占用。 salt: string); } /** * Generate file key * @param privateKey - The private key * @param passphrase - The passphrase * @param curve - The curve * @returns The file key */ declare function generateFileKey(privateKey: string, passphrase: string, curve: Curve): Result<FileKey, Error>; /** * Decrypt file key * @param fileKey - The file key * @param passphrase - The passphrase * @returns The private key */ declare function decryptFileKey(fileKey: FileKey | string, passphrase: string): Result<string, Error>; /** * Generate cipher * @param privateKey - The private key * @param passphrase - The passphrase * @param curve - The curve * @returns The cipher */ declare function generateCipher(privateKey: string, passphrase: string, curve: Curve): Result<Cipher, Error>; export { AES_128_CTR, KDF_SCRYPT, SCRYPT_N, SCRYPT_P, SCRYPT_R, SCRYPT_KEY_LEN, FileKey, Cipher, Aes, Kdf, KdfParams, generateCipher, generateFileKey, decryptFileKey }; //# sourceMappingURL=file_key.d.ts.map