|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
在我们的系列#1 之后,我们演示了如何使用 OP_CAT 构建和验证 Merkle 树。在比特币中,默克尔树被用作数据结构,用于验证数据、同步以及有效地将区块链的交易和区块链接在一起。

This post was first published on Medium.
这篇文章首先发表在 Medium 上。
Following our series #1, we demonstrate how to construct and verify Merkle trees using OP_CAT.
在我们的系列#1 之后,我们演示了如何使用 OP_CAT 构建和验证 Merkle 树。
In Bitcoin, Merkle trees are used as the data structure for verifying data, synchronizing the blockchain, and efficiently linking transactions and blocks together. The OP_CAT opcode, which allows for the concatenation of two stack variables, can be used with SHA256 hashes of public keys to streamline the Merkle tree verification process within Bitcoin Script. OP_CAT uniquely allows for the creation and opening of entries in Merkle trees, as the fundamental operation for building and verifying Merkle trees involves concatenating two values and then hashing them.
在比特币中,默克尔树被用作验证数据、同步区块链以及有效地将交易和区块链接在一起的数据结构。 OP_CAT 操作码允许连接两个堆栈变量,可与公钥的 SHA256 哈希值一起使用,以简化比特币脚本中的 Merkle 树验证过程。 OP_CAT 独特地允许在 Merkle 树中创建和打开条目,因为构建和验证 Merkle 树的基本操作涉及连接两个值,然后对它们进行哈希处理。
There are many applications for Merkle trees. Here are a few prominent examples:
Merkle 树有很多应用。以下是一些突出的例子:
Merkle proof
默克尔证明
A Merkle proof is a cryptographic method used to verify that a particular transaction is included in a Merkle tree without having to download the entire blockchain. This is especially useful for lightweight clients and improving the efficiency of data verification.
Merkle 证明是一种加密方法,用于验证特定交易是否包含在 Merkle 树中,而无需下载整个区块链。这对于轻量级客户端特别有用,可以提高数据验证的效率。
Tree signature
树签名
A tree signature is a cryptographic method that improves the security and efficiency of digital signatures using tree structures, especially Merkle trees. This approach is used to generate a more compact and private proof that a message or set of messages has been signed by a particular key, compared to regular Multisig.
树签名是一种利用树结构(尤其是 Merkle 树)提高数字签名安全性和效率的密码学方法。与常规多重签名相比,此方法用于生成更紧凑和私密的证据,证明一条消息或一组消息已由特定密钥签名。
Zero-Knowledge Proof
零知识证明
STARK (Succinct Transparent Arguments of Knowledge) is a type of zero-knowledge proof system. STARKs are designed to allow a prover to prove the validity of a computation to a verifier without revealing any sensitive information about the computation itself. If OP_CAT were to be added to Bitcoin, it could potentially enable the implementation of a STARK verifier in Bitcoin Script, with work already underway on this. This would allow for secure and private transactions on the Bitcoin network. Compared to pairing-based proof systems like SNARK, STARK is considered to be more Bitcoin-friendly.
STARK(简洁透明的知识论证)是一种零知识证明系统。 STARK 旨在允许证明者向验证者证明计算的有效性,而无需透露有关计算本身的任何敏感信息。如果将 OP_CAT 添加到比特币中,它可能会在比特币脚本中实现 STARK 验证器,这方面的工作已经在进行中。这将允许在比特币网络上进行安全和私密的交易。与 SNARK 等基于配对的证明系统相比,STARK 被认为对比特币更加友好。
Implementation
执行
The implementation of the Merkle tree using sCrypt is straightforward. The following code calculates the root hash of a merkle tree, given a leaf and its merkle path, typically used in verifying a merkle proof.
使用 sCrypt 实现 Merkle 树非常简单。以下代码计算默克尔树的根哈希,给定叶子及其默克尔路径,通常用于验证默克尔证明。
Full code is at https://github.com/sCrypt-Inc/scrypt-btc-merkle.
完整代码位于 https://github.com/sCrypt-Inc/scrypt-btc-merkle。
A single run results in the following transactions:
单次运行会产生以下事务:
Check the transaction on Mempool
查看 Mempool 上的交易
Check the transaction on Mempool
查看 Mempool 上的交易
Script versions
脚本版本
There are alternative implementations in bare scripts, like the one below. One major benefit of using sCrypt for implementing merkle trees is its readability and maintainability. Scripts are often very difficult to read and work on.
裸脚本中有其他替代实现,如下所示。使用 sCrypt 实现默克尔树的一大好处是其可读性和可维护性。脚本通常很难阅读和处理。
OP_EXISTS
OP_EXISTS
Plz tell me you had a compiler to generate that
请告诉我你有一个编译器来生成它
— Jerry – Bitcoin Bay (@Lightswarm) March 1, 2024
— Jerry – 比特币湾 (@Lightswarm) 2024 年 3 月 1 日
Stay tuned for more OP_CAT use cases.
请继续关注更多 OP_CAT 用例。
Watch: sCrypt Hackathon students realize there’s more to blockchain
观看:sCrypt 黑客马拉松学生意识到区块链还有更多用途
New to blockchain? Visit CoinGeek’s Blockchain for Beginners section, the ultimate resource guide to learn more about blockchain technology.
区块链新手?访问 CoinGeek 的区块链初学者部分,这是了解更多有关区块链技术的终极资源指南。
免责声明:info@kdj.com
所提供的信息并非交易建议。根据本文提供的信息进行的任何投资,kdj.com不承担任何责任。加密货币具有高波动性,强烈建议您深入研究后,谨慎投资!
如您认为本网站上使用的内容侵犯了您的版权,请立即联系我们(info@kdj.com),我们将及时删除。
-
- 比特币、eCash 分叉和空投动态:深入探讨加密货币的最新争议
- 2026-05-03 00:52:02
- 探索最近的 eCash 分叉、其作为高风险空投的分类,以及对比特币和加密生态系统的更广泛影响。
-
-
- 美联储维持利率稳定,地缘政治紧张局势引发比特币价格下跌
- 2026-05-01 04:04:38
- 美联储维持利率的决定,加上中东冲突,影响了比特币的价格。分析近期趋势和市场反应。
-
-
-
-
-
-

































