市值: $2.2278T 1.13%
體積(24小時): $56.4286B 56.31%
  • 市值: $2.2278T 1.13%
  • 體積(24小時): $56.4286B 56.31%
  • 恐懼與貪婪指數:
  • 市值: $2.2278T 1.13%
加密
主題
加密植物
資訊
加密術
影片
頭號新聞
加密
主題
加密植物
資訊
加密術
影片
bitcoin
bitcoin

$87959.907984 USD

1.34%

ethereum
ethereum

$2920.497338 USD

3.04%

tether
tether

$0.999775 USD

0.00%

xrp
xrp

$2.237324 USD

8.12%

bnb
bnb

$860.243768 USD

0.90%

solana
solana

$138.089498 USD

5.43%

usd-coin
usd-coin

$0.999807 USD

0.01%

tron
tron

$0.272801 USD

-1.53%

dogecoin
dogecoin

$0.150904 USD

2.96%

cardano
cardano

$0.421635 USD

1.97%

hyperliquid
hyperliquid

$32.152445 USD

2.23%

bitcoin-cash
bitcoin-cash

$533.301069 USD

-1.94%

chainlink
chainlink

$12.953417 USD

2.68%

unus-sed-leo
unus-sed-leo

$9.535951 USD

0.73%

zcash
zcash

$521.483386 USD

-2.87%

加密貨幣新聞文章

使用 OP_CAT 建構和驗證 Merkle 樹

2024/06/25 13:00

在我們的系列#1 之後,我們示範如何使用 OP_CAT 建立和驗證 Merkle 樹。在比特幣中,梅克爾樹被用作資料結構,用於驗證資料、同步以及有效地將區塊鏈的交易和區塊連結在一起。

使用 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),我們將及時刪除。

2026年07月28日 其他文章發表於