UNPKG

@opendatalabs/vana-sdk

Version:

A TypeScript library for interacting with Vana Network smart contracts.

44 lines (43 loc) 2.08 kB
/** * Browser implementation of ECIES using @noble/secp256k1 with Uint8Array * * @remarks * Uses native browser crypto APIs and @noble/secp256k1 for elliptic curve operations. * This implementation is polyfill-free and works in all modern browsers. */ import { BaseECIESUint8 } from "./base"; /** * Browser-specific ECIES provider using @noble/secp256k1 * * @remarks * This implementation uses: * - Web Crypto API for AES operations * - @noble/secp256k1 for elliptic curve operations * - @noble/hashes for SHA and HMAC operations * - No Buffer or Node.js dependencies */ export declare class BrowserECIESUint8Provider extends BaseECIESUint8 { 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; }