import type { Hex, HexString, KeyBytes, PublicKeyObject, SchnorrKeyPairObject } from '@did-btcr2/common'; import type { PublicKey } from './public.js'; import { CompressedSecp256k1PublicKey } from './public.js'; import type { SecretKey } from './secret.js'; import { Secp256k1SecretKey } from './secret.js'; import type { HexSchnorrKeyPair, MultibaseKeys, RawSchnorrKeyPair, SchnorrKeyPairParams } from './types.js'; /** * General KeyPair interface used by SchnorrKeyPair class. * @interface KeyPair * @type {KeyPair} */ export interface KeyPair { /** * The public key associated with the SchnorrKeyPair (required). */ readonly publicKey: PublicKey; /** * The secret key associated with the SchnorrKeyPair (optional). */ readonly secretKey?: SecretKey; } /** * Encapsulates paired CompressedSecp256k1PublicKey and Secp256k1SecretKey objects as a single SchnorrKeyPair object. * @class SchnorrKeyPair * @type {SchnorrKeyPair} */ export declare class SchnorrKeyPair implements KeyPair { #private; /** * Creates an instance of Keys. Must provide a at least a secret key. * Can optionally provide both a secret and public key, but must be a valid pair. * @param params The parameters to initialize the Keys object. * @param params.publicKey The public key object or bytes * @param params.secretKey The secret key object or bytes (optional) * @throws KeyPairError If neither a public key or secret key is provided. * @throws KeyPairError If the public key is not a valid pair with the secret key. */ constructor(params?: SchnorrKeyPairParams); /** * Get the Secp256k1SecretKey. * @returns {Secp256k1SecretKey} The Secp256k1SecretKey object * @throws {KeyPairError} If the secret key is not available */ get secretKey(): Secp256k1SecretKey; /** * Set the CompressedSecp256k1PublicKey. * @param {CompressedSecp256k1PublicKey} publicKey The CompressedSecp256k1PublicKey object * @throws {KeyPairError} If the public key is not a valid pair with the secret key. */ set publicKey(publicKey: CompressedSecp256k1PublicKey); /** * Get the CompressedSecp256k1PublicKey. * @returns {CompressedSecp256k1PublicKey} The CompressedSecp256k1PublicKey object */ get publicKey(): CompressedSecp256k1PublicKey; /** * Whether this key pair contains a secret key. * @returns {boolean} True if the secret key is present. */ get hasSecretKey(): boolean; /** * Get the `raw` bytes of each key in the SchnorrKeyPair. * @returns {RawSchnorrKeyPair} JSON object with the SchnorrKeyPair raw bytes. */ get raw(): RawSchnorrKeyPair; /** * Get the Keys in hex format. * @returns {object} The Keys in hex format */ get hex(): HexSchnorrKeyPair; /** * Get the Keys in multibase format. * @returns {MultibaseKeys} The Secp256k1SecretKey in multibase format */ get multibase(): MultibaseKeys; /** * Safe JSON representation. Only includes the public key. * Called implicitly by JSON.stringify(). Use exportJSON() for full serialization. * @returns {{ publicKey: PublicKeyObject }} The JSON representation of the public key */ toJSON(): { publicKey: PublicKeyObject; }; /** * Exports the full key pair as a JSON object. Contains sensitive material. * @returns {SchnorrKeyPairObject} The key pair as a JSON object * @throws {KeyPairError} If the secret key is not available */ exportJSON(): SchnorrKeyPairObject; /** * Static method creates a new Keys from a JSON object. * @param {SchnorrKeyPairObject} keys The JSON object to initialize the Keys. * @returns {SchnorrKeyPair} The initialized Keys object. */ static fromJSON(keys: SchnorrKeyPairObject): SchnorrKeyPair; /** * Static method creates a new SchnorrKeyPair from a Secp256k1SecretKey object or secret key bytes. * @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes * @returns {SchnorrKeyPair} A new SchnorrKeyPair object */ static fromSecret(data: KeyBytes | HexString): SchnorrKeyPair; /** * Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy. * @param {bigint} bint The entropy in bigint form * @returns {SchnorrKeyPair} A new SchnorrKeyPair object */ static fromBigInt(bint: bigint): SchnorrKeyPair; /** * Converts key bytes to a hex string. * @param {KeyBytes} keyBytes The key bytes (secret or public). * @returns {Hex} The key bytes as a hex string. */ static toHex(keyBytes: KeyBytes): Hex; /** * Compares two Keys objects for equality. * @param {SchnorrKeyPair} kp The main keys. * @param {SchnorrKeyPair} otherKp The other keys to compare. * @returns {boolean} True if the public key and secret key are equal, false otherwise. */ static equals(kp: SchnorrKeyPair, otherKp: SchnorrKeyPair): boolean; /** * Static method to generate a new random SchnorrKeyPair instance. * @returns {SchnorrKeyPair} A new Secp256k1SecretKey object. */ static generate(): SchnorrKeyPair; } //# sourceMappingURL=pair.d.ts.map