UNPKG

@covenance/dlc

Version:

Crypto and Bitcoin functions for Covenance DLC implementation

79 lines (78 loc) 3.08 kB
import { Point } from './crypto/secp256k1'; import { Signature, SignatureHex, AdaptorSignature, AdaptorSignatureHex } from './crypto/types'; /** * Converts a hex string to a Uint8Array * @param hex - The hex string to convert * @returns The Uint8Array representation of the hex string */ export declare function hexToBytes(hex: string): Uint8Array; /** * Converts a Uint8Array to a hex string * @param bytes - The Uint8Array to convert * @returns The hex string representation of the Uint8Array */ export declare function bytesToHex(bytes: Uint8Array): string; /** * Converts a Point to a hex string * @param point - The Point to convert * @returns The hex string representation of the Point */ export declare function pointToHex(point: Point): string; /** * Converts a hex string to a Point * @param hex - The hex string to convert * @returns The Point representation of the hex string */ export declare function hexToPoint(hex: string): Point; /** * Converts a Signature to a hex string representation * @param sig - The Signature to convert * @returns The hex string representation of the Signature */ export declare function signatureToHex(sig: Signature): SignatureHex; /** * Converts a hex string representation to a Signature * @param hex - The hex string representation to convert * @returns The Signature representation of the hex string */ export declare function hexToSignature(hex: SignatureHex): Signature; /** * Converts an AdaptorSignature to a hex string representation * @param sig - The AdaptorSignature to convert * @returns The hex string representation of the AdaptorSignature */ export declare function adaptorSignatureToHex(sig: AdaptorSignature): AdaptorSignatureHex; /** * Converts a hex string representation to an AdaptorSignature * @param hex - The hex string representation to convert * @returns The AdaptorSignature representation of the hex string */ export declare function hexToAdaptorSignature(hex: AdaptorSignatureHex): AdaptorSignature; /** * Computes the hash of a message using SHA256 * @param message - The message to hash * @returns The hash of the message */ export declare function sha256(message: Uint8Array): Promise<Uint8Array>; /** * Computes the hash of a message using SHA256 and returns it as a hex string * @param message - The message to hash * @returns The hex string representation of the hash */ export declare function sha256Hex(message: string): Promise<string>; /** * Copies a bigint to a Uint8Array as big-endian * @param dst - The Uint8Array to copy to * @param offset - The offset to copy to * @param n - The bigint to copy */ export declare function be32(dst: Uint8Array, offset: number, n: bigint): void; /** * Convert seconds → BIP68 buffer. * Uses 512-second granularity, sets the type flag (bit 22). * Throws if out of range (> 0xffff * 512 seconds). * @param seconds - The number of seconds to convert * @returns The BIP68 buffer */ export declare function csvTimeDelay(seconds: number): Buffer; export declare function encodeScriptNum(n: number): Buffer;