UNPKG

@covenance/dlc

Version:

Crypto and Bitcoin functions for Covenance DLC implementation

85 lines (60 loc) 1.39 kB
# Covenance DLC [![CI](https://github.com/covenance-io/dlc/actions/workflows/ci.yml/badge.svg)](https://github.com/covenance-io/dlc/actions/workflows/ci.yml) A TypeScript library implementing cryptographic primitives for Discreet Log Contracts (DLCs) in the Covenance project. ## Installation TODO: Configure private NPM repo on GitHub. ## Usage ### Oracle Functions ```typescript import { commitToEvent, attestEventOutcome } from 'covenance-dlc'; // Oracle commits to an event const { signaturePoints, nonce } = commitToEvent( eventOutcomeHashes, oraclePubKey ); // Oracle attests to an event outcome const oracleSig = attestEventOutcome( oraclePrivKey, nonce, eventOutcomeHash ); ``` ### Counterparty Functions ```typescript import { createAdaptorSig, adaptSig, verifyAdaptorSig } from 'covenance-dlc'; // Create an adaptor signature const adaptorSig = createAdaptorSig( counterpartyPrivKey, oracleSigPoint, cetSighash ); // Verify an adaptor signature const isValid = verifyAdaptorSig( adaptorSig, counterpartyPubKey, cetSighash, oracleSigPoint ); // Adapt a signature const finalSig = adaptSig(adaptorSig, oracleSig); ``` ## Development ### Setup ```bash npm install ``` ### Building ```bash npm run build ``` ### Testing ```bash # Run tests npm test # Run tests with coverage npm run test:coverage ``` ### Linting ```bash npm run lint ```