import type { Bytes, Hex, HexString, KeyBytes, SecretKeyObject, SignatureBytes } from '@did-btcr2/common'; import { CompressedSecp256k1PublicKey } from './public.js'; import type { CryptoOptions } from './types.js'; /** * General SecretKey interface for the Secp256k1SecretKey class. * @interface SecretKey * @type {SecretKey} */ export interface SecretKey { /** * Get the secret key bytes. * @readonly @type {KeyBytes} The secret key bytes. */ bytes: KeyBytes; /** * Getter returns the secret key bytes in bigint format. * Setter allows alternative method of using a bigint seed for the entropy. * @type {bigint} The secret key seed. */ seed: bigint; /** * Get the secret key as a hex string. * @readonly @type {Hex} The secret key as a hex string. */ hex: Hex; /** * Checks if this secret key is equal to another secret key. * @param {SecretKey} other The other secret key to compare. * @returns {boolean} True if the private keys are equal. */ equals(other: SecretKey): boolean; /** * Uses the secret key to compute the corresponding public key. * @returns {CompressedSecp256k1PublicKey} The computed public key bytes. */ computePublicKey(): CompressedSecp256k1PublicKey; /** * Checks if the secret key is valid. * @returns {boolean} Whether the secret key is valid. */ isValid(): boolean; } /** * Encapsulates a secp256k1 secret key * Provides get methods for different formats (raw, secret, point). * Provides helpers methods for comparison, serialization and publicKey generation. * @class Secp256k1SecretKey * @type {Secp256k1SecretKey} * @implements {SecretKey} */ export declare class Secp256k1SecretKey implements SecretKey { #private; /** * Instantiates an instance of Secp256k1SecretKey. * @param {Bytes | bigint} entropy bytes (Uint8Array) or secret (bigint) * @throws {SecretKeyError} If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed */ constructor(entropy: Bytes | bigint); /** * Zeros out secret key material from memory. * The instance should not be used after calling this method. */ destroy(): void; /** * Get the secret key entropy as a byte array. * @returns {KeyBytes} The secret key bytes as a Uint8Array */ get bytes(): Uint8Array; /** * Get the secret key entropy as a bigint. * @returns {bigint} The secret key as a bigint */ get seed(): bigint; /** * Returns the raw secret key as a hex string. * @returns {HexString} The secret key as a hex string */ get hex(): HexString; /** * Encode the secret key bytes as a secretKeyMultibase string. * @returns {string} The secret key in base58btc multibase format */ get multibase(): string; /** * Encodes the secret key bytes to BIP340 multibase format. * @returns {string} The secret key in BIP340 multibase format. */ encode(): string; /** * Checks if this secret key is equal to another. * @param {SecretKey} other The other secret key * @returns {boolean} True if the private keys are equal, false otherwise */ equals(other: SecretKey): boolean; /** * Computes the public key from the secret key bytes. * @returns {CompressedSecp256k1PublicKey} The computed public key */ computePublicKey(): CompressedSecp256k1PublicKey; /** * Safe JSON representation. Does not expose secret material. * Called implicitly by JSON.stringify(). Use exportJSON() for full serialization. */ toJSON(): { type: string; }; /** * Exports the secret key as a JSON object. Contains sensitive material. * @returns {SecretKeyObject} The secret key as a JSON object */ exportJSON(): SecretKeyObject; /** @override Prevents secret material from appearing in console.log */ toString(): string; /** * Checks if the secret key is valid. * @returns {boolean} True if the secret key is valid, false otherwise */ isValid(): boolean; /** * Checks if the public key is a valid secp256k1 point. * @returns {boolean} True if the public key is valid, false otherwise */ hasValidPublicKey(): boolean; /** * Produce a signature over arbitrary data using schnorr or ecdsa. * @param {MessageBytes} data Data to be signed. * @param {CryptoOptions} opts Options for signing. * @param {('ecdsa' | 'schnorr')} opts.scheme The signature scheme to use. Default is 'schnorr'. * @returns {SignatureBytes} Signature byte array. * @throws {SecretKeyError} if no private key is provided. */ sign(data: Bytes, opts?: CryptoOptions): SignatureBytes; /** * Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key). * @param {string} multibase The multibase string to decode * @returns {Bytes} The decoded secret key. */ static decode(multibase: string): Bytes; /** * Creates a Secp256k1SecretKey object from a JSON object. * @param {SecretKeyObject} json The JSON object containing the secret key bytes * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object */ static fromJSON(json: SecretKeyObject): Secp256k1SecretKey; /** * Convert a bigint secret to secret key bytes. * @param {KeyBytes} bytes The secret key bytes * @returns {bigint} The secret key bytes as a bigint secret */ static toSecret(bytes: KeyBytes): bigint; /** * Convert a secret key bytes to a bigint secret. * @param {bigint} secret The secret key secret. * @returns {KeyBytes} The secret key secret as secret key bytes. */ static toBytes(secret: bigint): KeyBytes; /** * Creates a new Secp256k1SecretKey object from a bigint secret. * @param {bigint} bint The secret bigint * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object */ static fromBigInt(bint: bigint): Secp256k1SecretKey; /** * Generates random secret key bytes. * @returns {KeyBytes} Uint8Array of 32 random bytes. */ static random(): KeyBytes; /** * Creates a new Secp256k1SecretKey from random secret key bytes. * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object */ static generate(): Secp256k1SecretKey; /** * Generates a public key from the given secret key bytes. * @param {KeyBytes} bytes The secret key bytes * @returns {CompressedSecp256k1PublicKey} The computed public key bytes */ static getPublicKey(bytes: KeyBytes): CompressedSecp256k1PublicKey; } //# sourceMappingURL=secret.d.ts.map