0.1.11 • Published 5 months ago
@covenance/dlc v0.1.11
Covenance DLC
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
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
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
npm installBuilding
npm run buildTesting
# Run tests
npm test
# Run tests with coverage
npm run test:coverageLinting
npm run lint