Discreet Log Contracts (DLC) Specifications

repository·master·Indexed 42 days ago

https://github.com/discreetlogcontracts/dlcspecs

Specifications 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.

Tokens
26.8K
Snippets
20
Records
124
Agent score
54%

What's inside DLC

  1. What are Discreet Log Contracts (DLCs)?

    master
    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.
  2. Learn about Discreet Log Contracts (DLC) via academic and community resources

    master

    To 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.
  3. Review current DLC implementation status

    master

    As 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-zkp version.
    • Testing: Integration tests with bitcoind are 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.
  4. How DLC contract negotiation works

    master

    Discreet Log Contracts (DLC) are negotiated through a three-step peer-to-peer messaging process between an offerer (initiator) and an accepter (responder):

    1. Offer: The offerer sends an offer_dlc message containing contract terms and funding details.
    2. Accept: The accepter responds with an accept_dlc message, which includes its signatures for the Contract Execution Transactions (CETs) and the refund transaction.
    3. Sign: The offerer sends a sign_dlc message containing its signatures for all CETs, the refund transaction, and the funding transaction.

    Final Step: Once the accepter receives the valid sign_dlc message, it must broadcast the funding transaction to the Bitcoin network.

    Multiple contracts can run in parallel. They are identified by a temporary_contract_id during negotiation, which is replaced by a contract_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'
  5. Understand the `negotiation_fields` type

    master

    The negotiation_fields type contains preferences from the DLC accepter used during contract construction.

    Implementations:

    • single_negotiation_fields (type 0): Contains rounding_intervals, representing the maximum allowed rounding at any oracle outcome in a numeric DLC.
    • disjoint_negotiation_fields (type 1): Used in dlc_accept messages responding to contract_info_v1 offers. It contains num_disjoint_events and a list of nested negotiation_fields (must be version 0 or 1).
  6. Generate Fraud Proofs for Oracle Lying

    master

    If 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:

    1. Search through the CET set to find the outcome that corresponds to the observed aggregate attestation.
    2. Once the outcome for all oracles/digits is known, prove that the attestation corresponds to that outcome using the original announcement(s).
  7. How the Oracle functions in a DLC

    master

    An Oracle is an entity that signs messages in response to real-world events to decide the outcome of a DLC.

    Workflow:

    1. 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).
    2. 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.

  8. How Adaptor Signatures and Signature Points work

    master

    DLCs use Adaptor Signatures to link the oracle's signature to the contract execution.

    1. 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 (where P is the public key and m is the message).
    2. Adaptor Signature (s'): An encryption of a signature s over a message m. The signature s is for a given CET and is encrypted using a Signature Point of an oracle.
    3. Decryption: Once the oracle releases its signature, the adaptor signature s' can be decrypted to reveal the valid signature s, which is then used to create the validly signed CET.
    S = R + H(R || P || m) * P
  9. Understand Numeric Outcome Compression

    master

    Numeric 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.
  10. What are Discreet Log Contracts (DLCs)?

    master

    Discreet 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.