@covenance/dlc
Version:
Crypto and Bitcoin functions for Covenance DLC implementation
42 lines (41 loc) • 2.28 kB
TypeScript
import { Transaction } from '../btc';
import { Point } from '../crypto/secp256k1';
import { PrivKey, AdaptorSignature, Signature, PubKey } from '../crypto/types';
/**
* Creates an adaptor signature for a CET
* @param counterpartyPrivKey - The private key of the counterparty creating the signature
* @param oracleSigPoint - The oracle's signature point for the event outcome
* @param cet - The CET transaction to sign
* @param inputIndex - The index of the input to sign in the CET
* @param tapleafHash - The hash of the tapleaf
* @returns The adaptor signature for the CET
*/
export declare function signCetWithAdaptorSig(counterpartyPrivKey: PrivKey, oracleSigPoint: Point, cet: Transaction, inputIndex: number, tapleafHash: Buffer): Promise<AdaptorSignature>;
/**
* Verifies an adaptor signature for a CET
* @param signature - The adaptor signature to verify
* @param counterpartyPubKey - The counterparty's public key
* @param oracleSigPoint - The oracle's signature point for the event outcome
* @param cet - The CET transaction that was signed
* @param inputIndex - The index of the input that was signed
* @param tapleafHash - The hash of the tapleaf
* @returns True if the signature is valid, false otherwise
*/
export declare function verifyCetAdaptorSig(signature: AdaptorSignature, counterpartyPubKey: PubKey, oracleSigPoint: Point, cet: Transaction, inputIndex: number, tapleafHash: Buffer): Promise<boolean>;
/**
* Verifies a completed signature for a CET
* @param signature - The completed signature to verify
* @param counterpartyPubKey - The counterparty's public key
* @param cet - The CET transaction that was signed
* @param inputIndex - The index of the input that was signed
* @param tapleafHash - The hash of the tapleaf
* @returns True if the signature is valid, false otherwise
*/
export declare function verifyCetSignature(signature: Signature, counterpartyPubKey: PubKey, cet: Transaction, inputIndex: number, tapleafHash: Buffer): Promise<boolean>;
/**
* Taproot/SegWit-v1 Schnorr signature serializer
* @param signature - The signature to serialize
* @param sighash - The sighash to serialize
* @returns The serialized signature
*/
export declare function sigToTaprootBuf({ R, s }: Signature, sighash?: number): Uint8Array;