import type { Bytes, Hex, KeyBytes, MultibaseObject, PublicKeyObject } from '@did-btcr2/common'; import type { CryptoOptions } from './types.js'; export declare const BIP340_PUBLIC_KEY_MULTIBASE_PREFIX: Bytes; /** * Point Interface representing an (x, y) coordinate on the secp256k1 curve. * @interface Point * @type {Point} */ export interface Point { x: KeyBytes; y: KeyBytes; } /** * General PublicKey Interface used by CompressedSecp256k1PublicKey. * @interface PublicKey * @type {PublicKey} */ export interface PublicKey { /** * Compressed public key getter. * @readonly @type {KeyBytes} The 33 byte compressed public key [parity, x-coord]. */ compressed: KeyBytes; /** * Uncompressed public key getter. * @readonly @type {KeyBytes} The 65 byte uncompressed public key [0x04, x-coord, y-coord]. */ uncompressed: KeyBytes; /** * X-only public key getter. * @readonly @type {KeyBytes} The 32 byte x-only public key [x-coord]. */ xOnly: KeyBytes; /** * CompressedSecp256k1PublicKey parity getter. * @readonly @type {number} The 1 byte parity (0x02 if even, 0x03 if odd). */ parity: number; /** * CompressedSecp256k1PublicKey isEven getter. * @readonly @type {boolean} True if the public key is even, false if odd. */ isEven: boolean; /** * CompressedSecp256k1PublicKey x-coordinate getter. * @readonly @type {KeyBytes} The 32 byte x-coordinate of the public key. */ x: KeyBytes; /** * CompressedSecp256k1PublicKey y-coordinate getter. * @readonly @type {KeyBytes} The 32 byte y-coordinate of the public key. */ y: KeyBytes; /** * CompressedSecp256k1PublicKey multibase getter. * @readonly @returns {MultibaseObject} The public key as MultibaseObject as a address string, key and prefix bytes. */ multibase: MultibaseObject; /** * CompressedSecp256k1PublicKey hex string getter. * @readonly @type {Hex} The public key as a hex string. */ hex: Hex; /** * CompressedSecp256k1PublicKey point getter. * @readonly @type {Point} The public key as a point (x, y). */ point: Point; /** * Decode the base58btc multibase string to the compressed public key prefixed with 0x02. * @returns {KeyBytes} The public key as a 33-byte compressed public key with header. */ decode(): KeyBytes; /** * Encode the CompressedSecp256k1PublicKey as an x-only base58btc multibase public key. * @returns {string} The public key formatted a base58btc multibase string. */ encode(): string; /** * Public key equality check. * @param {PublicKey} other The public key to compare. * @returns {boolean} True if the public keys are equal. */ equals(other: PublicKey): boolean; } /** * Encapsulates a secp256k1 public key compliant to BIP-340 BIP schnorr signature scheme. * Provides get methods for different formats (compressed, x-only, multibase). * Provides helpers methods for comparison and serialization. * @class CompressedSecp256k1PublicKey * @type {CompressedSecp256k1PublicKey} */ export declare class CompressedSecp256k1PublicKey implements PublicKey { #private; /** * Creates a CompressedSecp256k1PublicKey instance. * @param {Hex} initialBytes The public key byte array. * @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed) */ constructor(initialBytes: Hex); /** * Get the compressed public key. * @returns {KeyBytes} The 33-byte compressed public key (0x02 or 0x03, x). */ get compressed(): KeyBytes; /** * Get the uncompressed public key. * @returns {Uint8Array} The 65-byte uncompressed public key (0x04, x, y). */ get uncompressed(): KeyBytes; /** * X-only (32-byte) view of the public key per BIP-340. */ get xOnly(): KeyBytes; /** * Parity of the SEC compressed public key. * @returns {0x02 | 0x03} The parity byte (0x02 if even, 0x03 if odd). * @throws {PublicKeyError} If the parity byte is not 0x02 or 0x03. */ get parity(): 0x02 | 0x03; /** * Whether the SEC compressed public key has even Y. * @returns {boolean} True if the public key has even Y. */ get isEven(): boolean; /** * Get the x-coordinate of the public key. * @returns {Uint8Array} The 32-byte x-coordinate of the public key. */ get x(): KeyBytes; /** * Get the y-coordinate of the public key. * @returns {Uint8Array} The 32-byte y-coordinate of the public key. */ get y(): KeyBytes; /** * Get the multibase public key. * @returns {MultibaseObject} An object containing the multibase bytes, address and prefix. */ get multibase(): MultibaseObject; /** * Returns the raw public key as a hex string. * @returns {string} The public key as a hex string. */ get hex(): string; /** * Return the public key point. * @returns {Point} The public key point. */ get point(): Point; /** * Returns the BIP-340 (x-only) representation of this key. * @returns {KeyBytes} The BIP-340 (x-only) representation of the public key. */ bip340(): KeyBytes; /** * Decodes the multibase string to the 35-byte corresponding public key (2 byte prefix + 32 byte public key). * @returns {KeyBytes} The decoded public key: prefix and public key bytes */ decode(): KeyBytes; /** * Encodes compressed secp256k1 public key from bytes to BIP340 multibase format. * @returns {string} The public key encoded in base-58-btc multibase format. */ encode(): string; /** * Verify a signature using schnorr or ecdsa. * @param {SignatureBytes} signature Signature for verification. * @param {string} data Data for verification. * @param {CryptoOptions} opts Options for signing. * @param {('ecdsa' | 'schnorr')} opts.scheme The signature scheme to use. Default is 'schnorr'. * @returns {boolean} If the signature is valid against the public key. */ verify(signature: Bytes, data: Bytes, opts?: CryptoOptions): boolean; /** * Compares this public key to another public key. * @param {PublicKey} other The other public key to compare * @returns {boolean} True if the public keys are equal, false otherwise. */ equals(other: PublicKey): boolean; /** * JSON representation of a CompressedSecp256k1PublicKey object. * @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object. */ toJSON(): PublicKeyObject; /** * Static method to validate a public key. * @param {Hex} pk The public key in hex (Uint8Array or string) format. * @returns {boolean} True if the public key is valid, false otherwise. */ static isValid(pk: Hex): boolean; /** * Creates a CompressedSecp256k1PublicKey object from a JSON representation. * @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey. * @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object. */ static fromJSON(json: PublicKeyObject): CompressedSecp256k1PublicKey; } //# sourceMappingURL=public.d.ts.map