UNPKG

@opendatalabs/vana-sdk

Version:

A TypeScript library for interacting with Vana Network smart contracts.

46 lines (45 loc) 2.18 kB
/** * Node.js implementation of ECIES using native secp256k1 for performance * * @remarks * Uses native secp256k1 bindings for all elliptic curve operations. * Uses Node.js crypto module for hashing and AES operations. * Provides Uint8Array-only interface with no Buffer exposure. */ import { BaseECIESUint8 } from "./base"; /** * Node.js-specific ECIES provider using native secp256k1 * * @remarks * This implementation: * - Uses native secp256k1 for all EC operations (optimal performance) * - Uses Node.js crypto for SHA-512, HMAC, and AES operations * - Internally works with Uint8Array * - Only uses Buffer at crypto API boundaries */ export declare class NodeECIESUint8Provider extends BaseECIESUint8 { private readonly identityHashFn; protected generateRandomBytes(length: number): Uint8Array; protected verifyPrivateKey(privateKey: Uint8Array): boolean; protected createPublicKey(privateKey: Uint8Array, compressed: boolean): Uint8Array | null; protected validatePublicKey(publicKey: Uint8Array): boolean; protected decompressPublicKey(publicKey: Uint8Array): Uint8Array | null; protected performECDH(publicKey: Uint8Array, privateKey: Uint8Array): Uint8Array; protected sha512(data: Uint8Array): Uint8Array; protected hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array; protected aesEncrypt(key: Uint8Array, iv: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>; protected aesDecrypt(key: Uint8Array, iv: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>; /** * Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix). * Handles compressed (33 bytes) and uncompressed (65 bytes) formats only. * * @remarks * Strict policy: Does not accept 64-byte raw coordinates to avoid masking * malformed data. Callers must provide properly formatted keys. * * @param publicKey - The public key to normalize (33 or 65 bytes) * @returns The normalized uncompressed public key (65 bytes) * @throws {Error} When public key format is invalid or decompression fails */ normalizeToUncompressed(publicKey: Uint8Array): Uint8Array; }