@covenance/dlc
Version:
Crypto and Bitcoin functions for Covenance DLC implementation
33 lines (32 loc) • 1.85 kB
TypeScript
import { Point } from './secp256k1';
import { PrivKey, PubKey, Signature, AdaptorSignature, Sighash } from './types';
/**
* Counterparty function to create an adaptor signature for a specific event outcome
* @param counterpartyPrivKey - Counterparty's private key
* @param oracleSigPoint - Oracle's signature point for the event outcome
* @param cetSighash - Sighash of the event outcome CET
* @returns Counterparty's adaptor signature
*/
export declare function createAdaptorSig(counterpartyPrivKey: PrivKey, oracleSigPoint: Point, cetSighash: Sighash, tag?: Uint8Array): Promise<AdaptorSignature>;
/**
* Counterparty function to adapt (finalize) an adaptor signature
* @param adaptorSig - The adaptor signature to finalize
* @param s - The oracle's scalar value (s) from their signature or repayment secret
* @returns The final signature
*/
export declare function adaptSig(adaptorSig: AdaptorSignature, s: bigint): Signature;
/**
* Function to verify an adaptor signature
* @param adaptorSig - The adaptor signature to verify
* @param counterpartyPubKey - The counterparty's public key
* @param cetSighash - The sighash of the event outcome CET
* @param oracleSigPoint - The oracle's signature point for the event outcome
* @returns Boolean indicating whether the adaptor signature is valid
*/
export declare function verifyAdaptorSig(adaptorSig: AdaptorSignature, counterpartyPubKey: PubKey, cetSighash: Sighash, oracleSigPoint: Point, tag?: Uint8Array): Promise<boolean>;
/**
* Function to generate a private key which produces a public key with even y.
* This is to avoid doing BIP-340 secret-key parity adjustment (flip if public key has odd Y) each time an adaptor signature is created.
* @returns A private key which produces a public key with even y.
*/
export declare function generateEvenYPrivateKey(): PrivKey;