import { CryptoBackend, XOnlyPointAddTweakResult } from './backend.js'; import { Bytes32, MessageHash, PrivateKey, PublicKey, SchnorrSignature, Signature, XOnlyPublicKey } from './branded.js'; /** * Subset of the `tiny-secp256k1` API consumed by {@link LegacyBackend}. * * Pass an object satisfying this interface to {@link createLegacyBackend} * to bridge an existing `tiny-secp256k1` installation into the * {@link CryptoBackend} contract. */ export interface TinySecp256k1Interface { /** @see {@link CryptoBackend.isPoint} */ isPoint(p: Uint8Array): boolean; /** @see {@link CryptoBackend.pointCompress} */ pointCompress(p: Uint8Array, compressed?: boolean): Uint8Array; /** @see {@link CryptoBackend.isPrivate} */ isPrivate(d: Uint8Array): boolean; /** @see {@link CryptoBackend.pointFromScalar} */ pointFromScalar(d: Uint8Array, compressed?: boolean): Uint8Array | null; /** @see {@link CryptoBackend.isXOnlyPoint} */ isXOnlyPoint(p: Uint8Array): boolean; /** @see {@link CryptoBackend.pointAddScalar} */ pointAddScalar(p: Uint8Array, tweak: Uint8Array, compressed?: boolean): Uint8Array | null; /** @see {@link CryptoBackend.xOnlyPointAddTweak} */ xOnlyPointAddTweak(p: Uint8Array, tweak: Uint8Array): { parity: 1 | 0; xOnlyPubkey: Uint8Array; } | null; /** @see {@link CryptoBackend.privateAdd} */ privateAdd(d: Uint8Array, tweak: Uint8Array): Uint8Array | null; /** @see {@link CryptoBackend.privateNegate} */ privateNegate(d: Uint8Array): Uint8Array; /** @see {@link CryptoBackend.sign} */ sign(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array; /** @see {@link CryptoBackend.signSchnorr} */ signSchnorr?(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array; /** @see {@link CryptoBackend.verify} */ verify(h: Uint8Array, Q: Uint8Array, signature: Uint8Array, strict?: boolean): boolean; /** @see {@link CryptoBackend.verifySchnorr} */ verifySchnorr?(h: Uint8Array, Q: Uint8Array, signature: Uint8Array): boolean; } /** * {@link CryptoBackend} adapter that delegates to a `tiny-secp256k1` * compatible library. * * Prefer {@link createLegacyBackend} for construction. */ export declare class LegacyBackend implements CryptoBackend { #private; /** * @param ecc - Object implementing the {@link TinySecp256k1Interface}. */ constructor(ecc: TinySecp256k1Interface); /** `true` when the underlying library supports Schnorr signing. */ get hasSchnorrSign(): boolean; /** `true` when the underlying library supports Schnorr verification. */ get hasSchnorrVerify(): boolean; /** @inheritDoc */ isPrivate(d: Uint8Array): boolean; /** @inheritDoc */ isPoint(p: Uint8Array): boolean; /** @inheritDoc */ isXOnlyPoint(p: Uint8Array): boolean; /** @inheritDoc */ pointFromScalar(d: PrivateKey, compressed?: boolean): PublicKey | null; /** @inheritDoc */ pointCompress(p: PublicKey, compressed?: boolean): PublicKey; /** @inheritDoc */ pointAddScalar(p: PublicKey, tweak: Bytes32, compressed?: boolean): PublicKey | null; /** @inheritDoc */ xOnlyPointAddTweak(p: XOnlyPublicKey, tweak: Bytes32): XOnlyPointAddTweakResult | null; /** @inheritDoc */ privateAdd(d: PrivateKey, tweak: Bytes32): PrivateKey | null; /** @inheritDoc */ privateNegate(d: PrivateKey): PrivateKey; /** @inheritDoc */ sign(hash: MessageHash, privateKey: PrivateKey, extraEntropy?: Uint8Array): Signature; /** @inheritDoc */ verify(hash: MessageHash, publicKey: PublicKey, signature: Signature): boolean; /** * @inheritDoc * @throws If the underlying `tiny-secp256k1` library lacks `signSchnorr`. */ signSchnorr(hash: MessageHash, privateKey: PrivateKey, extraEntropy?: Uint8Array): SchnorrSignature; /** * @inheritDoc * @throws If the underlying `tiny-secp256k1` library lacks `verifySchnorr`. */ verifySchnorr(hash: MessageHash, publicKey: XOnlyPublicKey, signature: SchnorrSignature): boolean; } /** * Creates a {@link LegacyBackend} wrapping a `tiny-secp256k1` compatible object. * * @param ecc - Object satisfying the {@link TinySecp256k1Interface}. */ export declare function createLegacyBackend(ecc: TinySecp256k1Interface): LegacyBackend; //# sourceMappingURL=legacy.d.ts.map