The Discreet Log Contract (DLC) is a contract execution framework based on an Oracle, proposed by Tadge Dryja of the Massachusetts Institute of Technology in 2018. DLC allows two parties to execute conditional payments based on predefined conditions. The parties determine possible outcomes, pre-sign them, and use these pre-signatures to execute payments when Oracle signs off on the result. Therefore, DLC enables new decentralized financial applications while ensuring the security of Bitcoin deposits.
Compared to the Lightning Network, DLC has the following significant advantages:
Although DLCs hold significant advantages in the Bitcoin ecosystem, there are still some risks and issues, such as:
To address these, this paper proposes several solutions and optimization ideas to mitigate the risks and issues associated with DLCs, thereby enhancing the security of the Bitcoin ecosystem.
Alice and Bob enter into a betting agreement on whether the hash value of the (n+k)-th block is odd or even. If it is odd, Alice wins the game and can withdraw the assets within time t; if it is even, Bob wins the game and can withdraw the assets within time t. Using DLC, the (n+k)-th block information is transmitted through an Oracle to construct a conditional signature, ensuring the correct winner gets all the assets.
Initialization: The generator of the elliptic curve is G, and its order is q.
Key generation: The Oracle, Alice, and Bob independently generate their own private and public keys.
Funding transaction: Alice and Bob create a funding transaction together, locking 1 BTC each in a 2-of-2 multi-signature output (one public key X belongs to Alice, and the other Y to Bob).
Contract Execution Transactions (CET): Alice and Bob create two CETs to spend the funding transaction.
The Oracle computes the commitment
and then calculates S and S′
and broadcasts (R, S, S′).
Alice and Bob each compute the corresponding new public key
Settlement: After the (n+k)-th block appears, the Oracle generates the corresponding s or s′ based on the hash value of that block.
Withdrawal: Either Alice or Bob can withdraw the assets based on the s or s′ broadcasted by the Oracle.
Analysis: The new private key sk^{Alice} calculated by Alice and the new public key PK^{Alice} satisfies the discrete logarithm relationship
Thus, Alice’s withdrawal will be successful.
Similarly, the new private key sk^{Bob} calculated by Bob and the new public key PK^{Bob} satisfy the discrete logarithm relationship
Thus, Bob’s withdrawal will be successful.
Furthermore, if the Oracle broadcasts s, it is useful for Alice, but not for Bob because Bob cannot compute the corresponding new private key sk^{Bob}. Similarly, if the Oracle broadcasts s′, it is useful for Bob, but not for Alice, because Alice cannot compute the corresponding new private key sk^{Alice}. Finally, the description above omits the time lock. A time lock must be added to allow one party to compute the new private key and withdraw within time t. Otherwise, if it exceeds time t, the other party can use the original private key to withdraw the assets.
In the DLC protocol, the Oracle’s private key and the committed nonce are crucial. Leakage or loss of the Oracle’s private key and the committed nonce can lead to the following four security issues:
(1) Oracle Loses Private Key z
If the Oracle loses its private key, the DLC cannot settle, necessitating the execution of a DLC refund contract. Therefore, the DLC protocol includes a refund transaction to prevent the consequences of the Oracle losing its private key.
(2) Oracle’s Private Key z Leakage
If the Oracle’s private key is leaked, all DLCs based on that private key face the risk of fraudulent settlement. An attacker who steals the private key can sign any desired message, gaining complete control over the outcomes of all future contracts. Moreover, the attacker is not limited to issuing a single signed message but can also publish conflicting messages, such as signing that the hash value of the (n+k)-th block is both odd and even.
(3) Oracle’s Leakage or Reuse of Nonce k
If the Oracle leaks the nonce k, then at the settlement phase, regardless of whether the Oracle broadcasts s or s′, an attacker can calculate the Oracle’s private key z as follows:
If the Oracle reuses the nonce k, then after two settlements, an attacker can solve the system of equations based on the Oracle’s broadcast signatures to deduce the Oracle’s private key z in one of four possible scenarios,
case 1:
case 2:
case 3:
case 4:
(4) Oracle Loses Nonce k
If the Oracle loses the nonce k, the corresponding DLC cannot settle, necessitating the execution of a DLC refund contract.
Therefore, to enhance the security of the Oracle’s private key, it is advisable to use BIP32 to derive child or grandchild keys for signing. Additionally, to increase the security of the nonce, the hash value k:=hash(z, counter) should be used as the nonce k, to prevent repetition or loss of the nonce.
In DLC, the role of the Oracle is crucial as it provides key external data that determines the outcome of the contract. To enhance the security of these contracts, decentralized Oracles are required. Unlike centralized Oracles, decentralized Oracles distribute the responsibility of providing accurate and tamper-proof data across multiple independent nodes, reducing the risk associated with a single point of failure and decreasing the likelihood of manipulation or targeted attacks. With a decentralized Oracle, DLCs can achieve a higher degree of trustlessness and reliability, ensuring that contract execution relies entirely on the objectivity of predetermined conditions.
Schnorr threshold signatures can be used to implement decentralized Oracles. Schnorr threshold signatures offer the following advantages:
Therefore, the Schnorr threshold signature protocol has significant advantages in decentralized Oracles in terms of improving security, reliability, flexibility, scalability, and accountability.
In key management technology, an Oracle possesses a complete key z and, using BIP32 along with increments ω, can derive a multitude of child keys z+ω^{(1)} and grandchild keys z+ω^{(1)}+ω^{(2)}. For different events, the Oracle can use various grandchild private keys z+ω^{(1)}+ω^{(2)} to generate corresponding signatures σ for the respective events msg.
In the decentralized Oracle scenario, there are n participants, and a threshold signature requires t+1 participants, where t<n. Each of the n Oracle nodes possesses a private key share z_i,i=1,…,n. These n private key shares z_i correspond to a complete private key z, but the complete private key z never appears. Under the condition that the complete private key z does not appear, t+1 Oracle nodes use their private key shares z_i,i=1,…,t+1 to generate signature shares σ_i′ for the message msg′, and these signature shares σ_i′ combine into a complete signature σ′. Validators using the complete public key Z can verify the correctness of the message-signature pair (msg′,σ′). Since it requires t+1 Oracle nodes to collectively generate the threshold signature, it provides high security.
However, in a decentralized Oracle scenario, the complete private key z does not appear, and therefore direct key derivation using BIP32 is not possible. In other words, decentralized Oracle technology and key management technology cannot be directly integrated.
The paper “Distributed Key Derivation for Multi-Party Management of Blockchain Digital Assets” proposes a distributed key derivation scheme in threshold signature scenarios. The core idea is based on Lagrange interpolation polynomials, where the private key share z_i and the complete private key z satisfy the following interpolation relationship:
Adding the increment ω to both sides of the equation yields:
This equation shows that the private key share z_i plus the increment ω still satisfies the interpolation relationship with the complete private key z plus ω. In other words, the child private key share z_i+ω and the child key z+ω satisfy the interpolation relationship. Therefore, each participant can use their private key share z_i plus the increment ω to derive the child private key share z_i+ω, used to generate child signature shares, and validate them using the corresponding child public key Z+ω⋅G.
However, one must consider hardened and non-hardened BIP32. Hardened BIP32 takes the private key, chain code, and path as input, performs SHA512, and outputs the increment and child chain code. Non-hardened BIP32, on the other hand, takes the public key, chain code, and path as input, performs SHA512, and outputs the increment and child chain code. In a threshold signature scenario, the private key does not exist, so only non-hardened BIP32 can be used. Or, using a homomorphic hash function, hardened BIP32 can be applied. However, a homomorphic hash function differs from SHA512 and is not compatible with the original BIP32.
In the DLC, the contract between Alice and Bob is executed based on the Oracle’s signed result, thus requiring a certain level of trust in the Oracle. Therefore, the correct behavior of the Oracle is a major premise for the operation of DLC.
To reduce trust in the Oracle, research has been conducted on executing DLC based on the results of n Oracles, decreasing reliance on a single Oracle.
Simply increasing the number of Oracles does not achieve de-trust of the Oracles because, after malicious actions by an Oracle, the aggrieved party in the contract has no on-chain recourse.
Therefore, we propose OP-DLC, which incorporates an optimistic challenge mechanism into DLC. Before participating in setting up the DLC, n Oracles need to pledge and build a permissionless on-chain OP game in advance, committing to not act maliciously. If any Oracle acts maliciously, then Alice, Bob, any other honest Oracle, or any other third-party honest observer can initiate a challenge. If the challenger wins the game, the on-chain system penalizes the malicious Oracle by forfeiting its deposit. Additionally, OP-DLC can also adopt the “k-of-n” model for signing, where the k value can even be 1. Therefore, the trust assumption is reduced to just needing one honest participant in the network to initiate an OP challenge and penalize a malicious Oracle node.
When settling OP-DLC based on Layer 2 computation results:
Therefore, OP-DLC facilitates mutual supervision among oracle nodes, minimizing the trust placed in oracles.This mechanism only requires one honest participant and has a 99% fault tolerance, effectively addressing the risk of Oracle collusion.
When DLC is used for cross-chain bridges, fund distribution must occur at the settlement of the DLC contract:
Therefore, to address the aforementioned issue, we propose the OP-DLC + BitVM dual bridge. This solution enables users to deposit and withdraw through BitVM’s permissionless bridge as well as through the OP-DLC mechanism, achieving change at any granularity and enhancing liquidity.
In the OP-DLC, the Oracle is the BitVM federation, with Alice as a regular user and Bob as the BitVM federation. When setting up OP-DLC, the CETs built allow for immediate spending of Alice’s output on Layer 1, while Bob’s output includes a “DLC game Alice can challenge” with a timelock period. When Alice wants to withdraw:
Moreover, if user Alice wants to withdraw from Layer 2 but the preset CETs in the OP-DLC contract do not match the amount, Alice can choose the following methods:
Therefore, the OP-DLC + BitVM dual bridge offers the following advantages:
DLC emerged before the activation of Segwit v1 (Taproot) and has already been integrated with the Lightning Network, allowing the extension of DLC to update and execute continuous contracts within the same DLC channel. With technologies like Taproot and BitVM, more complex off-chain contract verifications and settlements can be implemented within DLC. Additionally, by integrating the OP challenge mechanism, it is possible to minimize trust in Oracles.
This article is reprinted from medium, originally titled “Bitlayer Core Technology: DLC and Its Optimization Considerations”. The copyright belongs to the original author, Bitlayer. If there are any objections to this reprint, please contact the Gate Learn team. The team will handle it according to the relevant procedures as quickly as possible.
Disclaimer: The views and opinions expressed in this article represent only the personal views of the author and do not constitute any investment advice.
Other language versions of the article have been translated by the Gate Learn team. Without mention of Gate.io, the translated articles may not be copied, disseminated, or plagiarized.
The Discreet Log Contract (DLC) is a contract execution framework based on an Oracle, proposed by Tadge Dryja of the Massachusetts Institute of Technology in 2018. DLC allows two parties to execute conditional payments based on predefined conditions. The parties determine possible outcomes, pre-sign them, and use these pre-signatures to execute payments when Oracle signs off on the result. Therefore, DLC enables new decentralized financial applications while ensuring the security of Bitcoin deposits.
Compared to the Lightning Network, DLC has the following significant advantages:
Although DLCs hold significant advantages in the Bitcoin ecosystem, there are still some risks and issues, such as:
To address these, this paper proposes several solutions and optimization ideas to mitigate the risks and issues associated with DLCs, thereby enhancing the security of the Bitcoin ecosystem.
Alice and Bob enter into a betting agreement on whether the hash value of the (n+k)-th block is odd or even. If it is odd, Alice wins the game and can withdraw the assets within time t; if it is even, Bob wins the game and can withdraw the assets within time t. Using DLC, the (n+k)-th block information is transmitted through an Oracle to construct a conditional signature, ensuring the correct winner gets all the assets.
Initialization: The generator of the elliptic curve is G, and its order is q.
Key generation: The Oracle, Alice, and Bob independently generate their own private and public keys.
Funding transaction: Alice and Bob create a funding transaction together, locking 1 BTC each in a 2-of-2 multi-signature output (one public key X belongs to Alice, and the other Y to Bob).
Contract Execution Transactions (CET): Alice and Bob create two CETs to spend the funding transaction.
The Oracle computes the commitment
and then calculates S and S′
and broadcasts (R, S, S′).
Alice and Bob each compute the corresponding new public key
Settlement: After the (n+k)-th block appears, the Oracle generates the corresponding s or s′ based on the hash value of that block.
Withdrawal: Either Alice or Bob can withdraw the assets based on the s or s′ broadcasted by the Oracle.
Analysis: The new private key sk^{Alice} calculated by Alice and the new public key PK^{Alice} satisfies the discrete logarithm relationship
Thus, Alice’s withdrawal will be successful.
Similarly, the new private key sk^{Bob} calculated by Bob and the new public key PK^{Bob} satisfy the discrete logarithm relationship
Thus, Bob’s withdrawal will be successful.
Furthermore, if the Oracle broadcasts s, it is useful for Alice, but not for Bob because Bob cannot compute the corresponding new private key sk^{Bob}. Similarly, if the Oracle broadcasts s′, it is useful for Bob, but not for Alice, because Alice cannot compute the corresponding new private key sk^{Alice}. Finally, the description above omits the time lock. A time lock must be added to allow one party to compute the new private key and withdraw within time t. Otherwise, if it exceeds time t, the other party can use the original private key to withdraw the assets.
In the DLC protocol, the Oracle’s private key and the committed nonce are crucial. Leakage or loss of the Oracle’s private key and the committed nonce can lead to the following four security issues:
(1) Oracle Loses Private Key z
If the Oracle loses its private key, the DLC cannot settle, necessitating the execution of a DLC refund contract. Therefore, the DLC protocol includes a refund transaction to prevent the consequences of the Oracle losing its private key.
(2) Oracle’s Private Key z Leakage
If the Oracle’s private key is leaked, all DLCs based on that private key face the risk of fraudulent settlement. An attacker who steals the private key can sign any desired message, gaining complete control over the outcomes of all future contracts. Moreover, the attacker is not limited to issuing a single signed message but can also publish conflicting messages, such as signing that the hash value of the (n+k)-th block is both odd and even.
(3) Oracle’s Leakage or Reuse of Nonce k
If the Oracle leaks the nonce k, then at the settlement phase, regardless of whether the Oracle broadcasts s or s′, an attacker can calculate the Oracle’s private key z as follows:
If the Oracle reuses the nonce k, then after two settlements, an attacker can solve the system of equations based on the Oracle’s broadcast signatures to deduce the Oracle’s private key z in one of four possible scenarios,
case 1:
case 2:
case 3:
case 4:
(4) Oracle Loses Nonce k
If the Oracle loses the nonce k, the corresponding DLC cannot settle, necessitating the execution of a DLC refund contract.
Therefore, to enhance the security of the Oracle’s private key, it is advisable to use BIP32 to derive child or grandchild keys for signing. Additionally, to increase the security of the nonce, the hash value k:=hash(z, counter) should be used as the nonce k, to prevent repetition or loss of the nonce.
In DLC, the role of the Oracle is crucial as it provides key external data that determines the outcome of the contract. To enhance the security of these contracts, decentralized Oracles are required. Unlike centralized Oracles, decentralized Oracles distribute the responsibility of providing accurate and tamper-proof data across multiple independent nodes, reducing the risk associated with a single point of failure and decreasing the likelihood of manipulation or targeted attacks. With a decentralized Oracle, DLCs can achieve a higher degree of trustlessness and reliability, ensuring that contract execution relies entirely on the objectivity of predetermined conditions.
Schnorr threshold signatures can be used to implement decentralized Oracles. Schnorr threshold signatures offer the following advantages:
Therefore, the Schnorr threshold signature protocol has significant advantages in decentralized Oracles in terms of improving security, reliability, flexibility, scalability, and accountability.
In key management technology, an Oracle possesses a complete key z and, using BIP32 along with increments ω, can derive a multitude of child keys z+ω^{(1)} and grandchild keys z+ω^{(1)}+ω^{(2)}. For different events, the Oracle can use various grandchild private keys z+ω^{(1)}+ω^{(2)} to generate corresponding signatures σ for the respective events msg.
In the decentralized Oracle scenario, there are n participants, and a threshold signature requires t+1 participants, where t<n. Each of the n Oracle nodes possesses a private key share z_i,i=1,…,n. These n private key shares z_i correspond to a complete private key z, but the complete private key z never appears. Under the condition that the complete private key z does not appear, t+1 Oracle nodes use their private key shares z_i,i=1,…,t+1 to generate signature shares σ_i′ for the message msg′, and these signature shares σ_i′ combine into a complete signature σ′. Validators using the complete public key Z can verify the correctness of the message-signature pair (msg′,σ′). Since it requires t+1 Oracle nodes to collectively generate the threshold signature, it provides high security.
However, in a decentralized Oracle scenario, the complete private key z does not appear, and therefore direct key derivation using BIP32 is not possible. In other words, decentralized Oracle technology and key management technology cannot be directly integrated.
The paper “Distributed Key Derivation for Multi-Party Management of Blockchain Digital Assets” proposes a distributed key derivation scheme in threshold signature scenarios. The core idea is based on Lagrange interpolation polynomials, where the private key share z_i and the complete private key z satisfy the following interpolation relationship:
Adding the increment ω to both sides of the equation yields:
This equation shows that the private key share z_i plus the increment ω still satisfies the interpolation relationship with the complete private key z plus ω. In other words, the child private key share z_i+ω and the child key z+ω satisfy the interpolation relationship. Therefore, each participant can use their private key share z_i plus the increment ω to derive the child private key share z_i+ω, used to generate child signature shares, and validate them using the corresponding child public key Z+ω⋅G.
However, one must consider hardened and non-hardened BIP32. Hardened BIP32 takes the private key, chain code, and path as input, performs SHA512, and outputs the increment and child chain code. Non-hardened BIP32, on the other hand, takes the public key, chain code, and path as input, performs SHA512, and outputs the increment and child chain code. In a threshold signature scenario, the private key does not exist, so only non-hardened BIP32 can be used. Or, using a homomorphic hash function, hardened BIP32 can be applied. However, a homomorphic hash function differs from SHA512 and is not compatible with the original BIP32.
In the DLC, the contract between Alice and Bob is executed based on the Oracle’s signed result, thus requiring a certain level of trust in the Oracle. Therefore, the correct behavior of the Oracle is a major premise for the operation of DLC.
To reduce trust in the Oracle, research has been conducted on executing DLC based on the results of n Oracles, decreasing reliance on a single Oracle.
Simply increasing the number of Oracles does not achieve de-trust of the Oracles because, after malicious actions by an Oracle, the aggrieved party in the contract has no on-chain recourse.
Therefore, we propose OP-DLC, which incorporates an optimistic challenge mechanism into DLC. Before participating in setting up the DLC, n Oracles need to pledge and build a permissionless on-chain OP game in advance, committing to not act maliciously. If any Oracle acts maliciously, then Alice, Bob, any other honest Oracle, or any other third-party honest observer can initiate a challenge. If the challenger wins the game, the on-chain system penalizes the malicious Oracle by forfeiting its deposit. Additionally, OP-DLC can also adopt the “k-of-n” model for signing, where the k value can even be 1. Therefore, the trust assumption is reduced to just needing one honest participant in the network to initiate an OP challenge and penalize a malicious Oracle node.
When settling OP-DLC based on Layer 2 computation results:
Therefore, OP-DLC facilitates mutual supervision among oracle nodes, minimizing the trust placed in oracles.This mechanism only requires one honest participant and has a 99% fault tolerance, effectively addressing the risk of Oracle collusion.
When DLC is used for cross-chain bridges, fund distribution must occur at the settlement of the DLC contract:
Therefore, to address the aforementioned issue, we propose the OP-DLC + BitVM dual bridge. This solution enables users to deposit and withdraw through BitVM’s permissionless bridge as well as through the OP-DLC mechanism, achieving change at any granularity and enhancing liquidity.
In the OP-DLC, the Oracle is the BitVM federation, with Alice as a regular user and Bob as the BitVM federation. When setting up OP-DLC, the CETs built allow for immediate spending of Alice’s output on Layer 1, while Bob’s output includes a “DLC game Alice can challenge” with a timelock period. When Alice wants to withdraw:
Moreover, if user Alice wants to withdraw from Layer 2 but the preset CETs in the OP-DLC contract do not match the amount, Alice can choose the following methods:
Therefore, the OP-DLC + BitVM dual bridge offers the following advantages:
DLC emerged before the activation of Segwit v1 (Taproot) and has already been integrated with the Lightning Network, allowing the extension of DLC to update and execute continuous contracts within the same DLC channel. With technologies like Taproot and BitVM, more complex off-chain contract verifications and settlements can be implemented within DLC. Additionally, by integrating the OP challenge mechanism, it is possible to minimize trust in Oracles.
This article is reprinted from medium, originally titled “Bitlayer Core Technology: DLC and Its Optimization Considerations”. The copyright belongs to the original author, Bitlayer. If there are any objections to this reprint, please contact the Gate Learn team. The team will handle it according to the relevant procedures as quickly as possible.
Disclaimer: The views and opinions expressed in this article represent only the personal views of the author and do not constitute any investment advice.
Other language versions of the article have been translated by the Gate Learn team. Without mention of Gate.io, the translated articles may not be copied, disseminated, or plagiarized.