Discreet Log Contracts (DLC) Specifications
repository·master·Indexed 42 days ago
https://github.com/discreetlogcontracts/dlcspecsSpecifications for Discreet Log Contracts (DLCs), a framework for on-chain/off-chain stateful Bitcoin contracts. Includes technical details on ECDSA adaptor signatures, DLEQ (Discrete Logarithm Equality) proofs, secp256k1 operations, and the role of Oracles in contract execution and funding transactions.
What's inside DLC
- Discreet Log Contracts (DLCs) are oracle smart-contracts compatible with the Bitcoin blockchain. They enable payments to be contingent on specific events that are attested to by oracles. The DLC specification aims to provide a practical framework for Bitcoin and other application developers to implement these contracts.
Learn about Discreet Log Contracts (DLC) via academic and community resources
masterTo understand the theoretical foundations, implementation details, and community discussions surrounding Discreet Log Contracts (DLC), refer to the following curated resources:
Academic Foundation
- Discreet log contracts (2017) by Thaddeus Dryja: The foundational paper for DLC technology.
Community & Discussion
- dlc-dev mailing list: Join the developer mailing list for technical discussions and updates.
- dlc.wiki: A community-driven wiki for DLC information.
Educational Content
- Blog Posts: Detailed series on Medium and Suredbits covering 'What is a DLC?', 'How They Work', 'Security and Trust Models', and practical use cases like crypto hedging and P2P derivatives.
- Video Talks: Presentations by Tadj Dryja at Dev++ 2017, MIT OpenCourseWare, and the MIT Bitcoin Expo 2020.
Review current DLC implementation status
masterAs of the July 2021 meeting, the following implementation statuses were reported for core components:
bitcoin-s
- Most DLC logic is in the specs.
- Missing features: Signed outcomes, off-by-one support.
- Pending PRs: Disjoint Union and Hyperbola/general payout curves.
rust-dlc
- All DLC logic from specs is implemented.
- In-progress: Optimizations, serialization, persistence layer, and network layer.
- Dependencies: Needs an update to
secp256k1-zkpversion. - Testing: Integration tests with
bitcoindare required.
atomic finance components
node-dlc: Handles message serialization/structure and chain monitoring.chainabstractionlayer-finance: Used for wallet building; supports single-oracle and is adding disjoint union support.cfd-dlc: Currently serves as the backend; recently added serial ID support.
How DLC contract negotiation works
masterDiscreet Log Contracts (DLC) are negotiated through a three-step peer-to-peer messaging process between an offerer (initiator) and an accepter (responder):
- Offer: The offerer sends an
offer_dlcmessage containing contract terms and funding details. - Accept: The accepter responds with an
accept_dlcmessage, which includes its signatures for the Contract Execution Transactions (CETs) and the refund transaction. - Sign: The offerer sends a
sign_dlcmessage containing its signatures for all CETs, the refund transaction, and the funding transaction.
Final Step: Once the accepter receives the valid
sign_dlcmessage, it must broadcast the funding transaction to the Bitcoin network.Multiple contracts can run in parallel. They are identified by a
temporary_contract_idduring negotiation, which is replaced by acontract_id(derived from the funding transaction) once the contract is established.+-------+ +-------+ | | | | | |---- (1) offer --->| | | | | | | |<--- (2) accept ----| | | A | | B | | |---- (3) sign --->| | | | | (4) broadcast fund-tx| | | | | +-------+ +-------+ - where node A is 'offerer' and node B is 'accepter'- Offer: The offerer sends an
Understand the `negotiation_fields` type
masterThe
negotiation_fieldstype contains preferences from the DLC accepter used during contract construction.Implementations:
single_negotiation_fields(type 0): Containsrounding_intervals, representing the maximum allowed rounding at any oracle outcome in a numeric DLC.disjoint_negotiation_fields(type 1): Used indlc_acceptmessages responding tocontract_info_v1offers. It containsnum_disjoint_eventsand a list of nestednegotiation_fields(must be version 0 or 1).
Generate Fraud Proofs for Oracle Lying
masterIf an oracle attests to a fraudulent outcome, the combination of their original announcement and the fraudulent attestation serves as a fraud proof.
In scenarios where a user cannot obtain a full individual attestation (e.g., due to multi-oracle aggregation), a fraud proof can still be generated:
- Search through the CET set to find the outcome that corresponds to the observed aggregate attestation.
- Once the outcome for all oracles/digits is known, prove that the attestation corresponds to that outcome using the original announcement(s).
Oracle Specification: Oracle Address and Signing Format
masterAn 'Oracle Address' is defined as a serialized blob that can be copy/pasted, which the oracle signs for each event. To ensure interoperability with P2P messaging, the project uses the TLV (Type-Length-Value) format for these serialized blobs.Message Formats: TLV and Lightning Network (LN) Compatibility
masterThe project distinguishes between general TLV formats and Lightning Network (LN) message formats. To maintain compatibility with Lightning Network BOLT 8 transport specifications, developers should use fragmentation when necessary.How the Oracle functions in a DLC
masterAn Oracle is an entity that signs messages in response to real-world events to decide the outcome of a DLC.
Workflow:
- Pre-event: The oracle advertises a public R-value (a one-time elliptic curve point) and a public key (which can be reused across events).
- Event occurrence: Once the event happens, the oracle releases a signed message over the event outcome using the previously advertised R-value and public key.
Security Note: An oracle cannot equivocate (create two different signatures for two different outcomes of a single event) without revealing its private key. However, the current specification does not protect against a party colluding with an oracle.
How Adaptor Signatures and Signature Points work
masterDLCs use Adaptor Signatures to link the oracle's signature to the contract execution.
- Signature Point (
S): A point computed using only public information (the R-value, public key, and message) prior to the creation of the actual signature. For Schnorr signatures, it is calculated as:S = R + H(R || P || m) * P(wherePis the public key andmis the message). - Adaptor Signature (
s'): An encryption of a signaturesover a messagem. The signaturesis for a given CET and is encrypted using a Signature Point of an oracle. - Decryption: Once the oracle releases its signature, the adaptor signature
s'can be decrypted to reveal the valid signatures, which is then used to create the validly signed CET.
S = R + H(R || P || m) * P- Signature Point (
Understand Numeric Outcome Compression
masterNumeric Outcome Compression is a technique used to reduce the number of adaptor signatures required for a contract when an interval of numeric outcomes
[start, end]results in constant payouts for all parties.Instead of requiring $O(L)$ signatures (where $L$ is the interval length), compression reduces this to $O(\log(L))$. This is achieved by using 'digit prefixes'—arrays of integers representing a base-$B$ number where certain digits are omitted (ignored). An omitted digit in a prefix means that any value in that digit's position is covered by that single adaptor signature.
Key Concepts:
- Intervals: Compression only works on intervals where payouts are constant. The CET calculation algorithm typically splits the domain into such intervals before applying compression.
- Digit Prefixes: A list of digit arrays (in base $B$) where an omitted digit (represented by
_in documentation) acts as a wildcard. - Complexity: The number of signatures required is $O(B \cdot \log_B(L))$.
- Preferred Base: Base 2 (binary) is the preferred base because it minimizes both the number of adaptor signatures and the number of intermediary anticipation points.
What are Discreet Log Contracts (DLCs)?
masterDiscreet Log Contracts (DLCs) are a framework for on-chain/off-chain stateful Bitcoin contracts. They allow two parties to set up contracts directly on the Bitcoin blockchain using an Oracle to determine the contract outcome.
Key characteristics include:
- Privacy: Oracle signatures can be used without an explicit request from contract participants, allowing parties to hide traces of their contracts from the oracle.
- Trust-minimization: Participants do not need to trust each other. The setup and execution ensure that parties can unilaterally close the contract.
- Unilateral Closure: Using Adaptor Signatures, it is impossible for a party to misbehave, and interaction is primarily required during the setup phase.
- Fault Tolerance: A Refund transaction mechanism protects participants against faulty oracles that fail to produce a signature when an event occurs.