主頁 > 區塊鏈 > 決議 |《Wisdom Chain檔案知識庫》之條件支付

決議 |《Wisdom Chain檔案知識庫》之條件支付

2020-09-11 20:27:57 區塊鏈

English

Conditional payment of Wisdom Chain document knowledge base

This article comes from the official Twitter of Wisdom Chain
URL:
https://twitter.com/Wisdom_Chain/status/1298458216725176328?s=20

If we want to make a transaction now, I want to sell my data to you. what is the safest way of transaction?



Obviously, there are two problems:

Because what I sell is the data, certainly cannot give you directly, otherwise how can I do if you get the data and then directly run away?
But I certainly can't take your money first, because the data I gave you may not meet your requirements, or I took the money and ran away.

To solve the above problem, we need a perfect and accurate "one hand pay, one hand delivery" solution. Zero knowledge proof and blockchain can be used at this time.

Today we try to explain this interesting solution in the language that ordinary people can understand: the conditional payment of Wisdom Chain.

What does this concept mean?

To put it simply, it is to reach a perfect and fair "one hand pay, one hand delivery" scheme without trusting a third party.

Imagine a transaction scenario in which neither party is willing to make payment / delivery to the other party without the presence of a trusted third party, otherwise the other party will run away. One hand payment and one hand delivery means that the payment / delivery action must be atomic.

The so-called perfect fairness means that neither side can take more advantage. However, this concept is an old topic. As early as the 1980s, many scholars have been studying how to achieve a perfect fair trade. But for a long time, it has been agreed that a trusted third party is essential. Later, when Bitcoin was born, we found that it could be done by using the characteristics of blockchain.

How is conditional payment realized in Wisdom Chain?

According to official disclosure, conditional payment in Wisdom Chain is mainly composed of "hash time locking", "hash height locking" and other factors. Here, only hash time locking and hash height locking are discussed.

What is hash time locking?

Hash lock, full name of hash time lock contract, is a new technology implementation form proposed in lightning network.

Hash lock mode is a mechanism that users guess the original value of hash value to pay in a specified period of time. In short, on the basis of the smart contract, both parties lock the assets first. If both parties input the original value of the correct hash value in a limited time, the transaction can be completed.

In this mechanism, we can realize the rapid confirmation of micro payment, that is to say, to achieve the goal of rapid confirmation of lightning network. Next, the author will take the asset exchange of the application scenario of hash locking as an example to explain how hash locking is realized.

How to implement hash time locking? In order to facilitate the understanding of how hash time locking is locked, here we compare two locks, one is hash lock and the other is time lock.
 
1. Hash lock

Through hash value locking, after locking, only the original value of the hash value is used to unlock. Assuming that the number is 123, the value after hash is a03a. Through a03a locking, without considering hash collision, it can only be unlocked by 123.

2. Time lock

The time lock requires the password for the hash lock to be entered within a specified time. If the time of the time lock is 1 hour, the user is required to enter the password of the hash lock within 1 hour. If the password of the hash lock is input after 1 hour, the time lock will not be opened.

In other words, the condition for opening the two locks at the same time is to input the original value of the hash value within the specified time. In the above example, if "123" is input within one hour, both locks will be in the open state.

Now A will use hash time locking mechanism to exchange its WDC in B for Ethernet currency. The specific steps are as follows:

A first generates random number S, and then give hash value H (S) of random number to B through the network, assuming that the random number is 123, and the hash value is a03a.

At the same time, A locks time and locks Hash, assuming that the time lock time is 1 hour, and the Hash value of Hash lock is a03a. After locking, the WDC to be converted is locked on chain 1.



After B receives the hash value "a03a" given by A, B deploys the smart contract on the Ethernet site based on this hash value and stores the same value of ETH in the contract. B's smart contract requires A to provide the password "123" within the specified time to take away the ETH in the smart contract.

This process is equivalent to that B itself has two locks. The hash lock is the same as the hash lock of A. it needs the same password to open it. If the time lock is half an hour.
 


A uses the smart contract of B, and enters its own password "123" within half an hour, then it can open B's hash lock on chain B, and take away the ETH in B smart contract (equivalent to B's ETH, because the smart contract is created by B, and the ETH in the contract is also transferred by B).
Because A entered the password when calling the smart contract of B, so B also knew that the password was "123". As long as he opened the hash lock on the chain A in one hour, the WDC of A would be transferred to B.



Through the above process, we can see that A can realize the exchange from WDC to ETH through hash time locking.

Through the above description, we understand the hash time locking, and the following hash height locking will be very simple to understand, and the principle is roughly the same as hash time locking. So let's briefly describe hash height locking.

Hash height lock

A and B can reach an agreement to lock A's 10WDC. Before the arrival of time T (T is expressed in terms of a block chain height in the future), if B can show a suitable R to A so that the hash value of R is equal to the predetermined value H, B can obtain the 10WDC; if B still fails to provide A correct R until time T has passed, the WDC will automatically unfreeze and return it to A. This process produces random numbers and verifies them.

When you understand hash time lock and hash height lock, you understand the technical principle of conditional payment for WisdomChain.

簡體中文
本文來自Wisdom Chain官方Twitter
URL:
https://twitter.com/Wisdom_Chain/status/1298458216725176328?s=20


假如我們現在要做一筆交易,我想把自己的資料賣給你,怎樣交易才是最安全的?



顯然這里會有兩個問題:

因為我賣的是資料,肯定不能直接給你,否則你得到資料后直接跑了怎么辦?
但我肯定也不能先拿你的錢,因為可能我給你的資料是不符合你要求的,或者我拿了錢之后也跑了。

要解決上面這個問題,我們就需要一個完美精準的「一手交錢、一手交貨」方案,零知識證明和區塊鏈這時就可以派上用場了。

今天我們盡可能用普通人能聽懂的語言,完整講解了這樣一個有趣的解決方案:Wisdom Chain的條件支付。

這個概念意味著什么呢?簡單點講,就是在沒有_信任第三方_的場合下達成_完美公平地「_一手交錢一手交貨」的方案。

想象一個交易場景,如果交易雙方在沒有信任第三方在場的情況下,誰也不愿意先出手付款 / 交貨給對方,否則對方會跑路。一手交錢一手交貨就意味著:付款 / 交貨動作必須具備原子性(大白話:要么交換完成,要么不交換,不給任何一方賴賬的空間)。

所謂完美公平是指任何一方都沒辦法占更多的小便宜。不過這個概念是一個古老的話題,早在 80 年代起就有很多學者在研究如何做到完美公平交易。但是長期以來,大家一致認為一個受信任的第三方是必不可少的。后來等到位元幣誕生,大家發現利用區塊鏈的特性就可以做到。

那么什么Widom Chain中的條件支付是如何實作的呢?

據官方透露在Widom Chain中的條件支付主要是由“哈希時間鎖定”、“哈希高度鎖定”與其他因素構成,這里暫只討論哈希時間鎖定與哈希高度鎖定。

什么是哈希時間鎖定

哈希鎖定,全稱哈希時間鎖定合約(HashTimeLockContract),是閃電網路中提出的一種新的技術實作形式。

哈希鎖定模式是指用戶在規定的時間段對于哈希值的原值進行猜測來支付的一種機制。簡單講,就是在智能合約的基礎上,雙方先鎖定資產,如果都在有限的時間內輸入正確哈希值的原值,即可完成交易。

 在這樣的機制下可以實作小額支付的快速確認,也就是說實作閃電網路快速確認的目標。接下來筆者將通過哈希鎖定的應用場景之資產兌換為例來為大家科普哈希鎖定是怎么實作的。
 
怎么實作哈希時間鎖定?為了方便理解哈希時間鎖定到底是如何鎖定的,這里給大家類比了兩個鎖,一個是哈希鎖,一個是時間鎖。
 
1、哈希鎖

通過哈希值上鎖,上鎖之后只有用產生這個哈希值的原本值進行開鎖,假設數123,哈希之后的值為a03a,通過a03a上鎖,不考慮哈希碰撞的情況下,只能由123解鎖。

2、時間鎖

時間鎖要求在規定時間內輸入哈希鎖的密碼。如果時間鎖的時間是1個小時,那么就要求用戶需要在1個小時內輸入哈希鎖的密碼,如果在1個小時后輸入哈希鎖的密碼,時間鎖仍然不會開啟。

也就是說同時打開這兩個鎖的條件是,在規定的時間內輸入哈希值原本的值,上面的例子就是在1個小時內,輸入“123”,兩把鎖才會都處于開啟狀態。
現在A將利用哈希時間鎖定的機制把自己的WDC在B那里兌換以太幣,具體的操作步驟如下:

A先生成亂數S,再把亂數的哈希值H(S)通過網路給B,假設亂數是123,哈希值是a03a。 

同時,A進行時間上鎖和哈希上鎖,假設時間鎖的時間為1小時,哈希鎖上鎖的哈希值是a03a。上完鎖后,待轉換的WDC就被鎖定在鏈1上。



B收到A給的哈希值“a03a”后,B根據這個哈希值在以太坊上部署智能合約,并往合約中存同等價值的以太幣。B的智能合約要求A在規定時間內提供密碼“123”才可以取走智能合約中的以太幣。

這個程序相當于,B自己也上了兩把鎖,其中哈希鎖和A的那把哈希鎖一樣,需要用同樣的密碼才可以打開,時間鎖假如為半個小時。
 


A使用B的這個智能合約,并在半個小時內輸入自己的密碼“123”,就能打開B在鏈B上的哈希鎖,就能取走B智能合約里的以太幣(相當于B的以太幣,因為智能合約是B創建的,合約里的以太幣也是B轉進去的)。

因為A在呼叫了B的智能合約時輸入了密碼,因此B也就知道了密碼是“123”,他只要在一個小時內通過這個密碼打開鏈A上的哈希鎖,A的WDC就會轉給B。



通過上面的程序,可以看到,A可以通過哈希時間鎖定這種方式,實作了WDC到以太幣的兌換。

通過上面的說明我們了解了哈希時間鎖定,下面的哈希高度鎖定就會很簡單的明白,原理與哈希時間鎖定大致相同。所以我們簡單的描述下哈希高度鎖定。

哈希高度鎖定

A和B可以達成協議,協議將鎖定A的10WDC,在時刻T到來之前(T以未來的某個區塊鏈高度表述),如果B能夠向A出示一個適當的R,使得R的哈希值等于事先約定的值H,B就能獲得這10WDC;如果直到時刻T過去了,B仍然未能提供一個正確的R,這WDC將自動解凍并歸還A。這個程序產生亂數和驗證亂數的程序。

當明白了哈希時間鎖定與哈希高度鎖定后,你就明白了WisdomChain的條件支付的技術原理。



關注Wisdom Chain動態
Twitter:@Wisdom_Chain
微博:WisdomChain
知乎:智慧鏈技術社區
Facebook:WisdomChain
Telegram:@WisdomPublicChain


相關資源
WIsdom Chain公鏈檔案知識庫:
https://docs.wisdchain.com/#/
Wisdom Chain官網:
https://wisdchain.io/
Wisdom Chain技術論壇:
http://tech.wisdchain.io/
Wisdom Chain開源代碼庫:
https://github.com/WisedomChainGroup
Wisdom Chain區塊瀏覽器:
https://scan.wisdchain.com

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/7288.html

標籤:區塊鏈技術

上一篇:公鏈轉賬錯誤的方法

下一篇:區塊鏈的在于工業,生產環節的應用。

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • JAVA使用 web3j 進行token轉賬

    最近新學習了下區塊鏈這方面的知識,所學不多,給大家分享下。 # 1. 關于web3j web3j是一個高度模塊化,反應性,型別安全的Java和Android庫,用于與智能合約配合并與以太坊網路上的客戶端(節點)集成。 # 2. 準備作業 jdk版本1.8 引入maven <dependency> < ......

    uj5u.com 2020-09-10 03:03:06 more
  • 以太坊智能合約開發框架Truffle

    前言 部署智能合約有多種方式,命令列的瀏覽器的渠道都有,但往往跟我們程式員的風格不太相符,因為我們習慣了在IDE里寫了代碼然后打包運行看效果。 雖然現在IDE中已經存在了Solidity插件,可以撰寫智能合約,但是部署智能合約卻要另走他路,沒辦法進行一個快捷的部署與測驗。 如果團隊管理的區塊節點多、 ......

    uj5u.com 2020-09-10 03:03:12 more
  • 谷歌二次驗證碼成為區塊鏈專用安全碼,你怎么看?

    前言 谷歌身份驗證器,前些年大家都比較陌生,但隨著國內互聯網安全的加強,它越來越多地出現在大家的視野中。 比較廣泛接觸的人群是國際3A游戲愛好者,游戲盜號現象嚴重+國外賬號安全應用廣泛,這類游戲一般都會要求用戶系結名為“兩步驗證”、“雙重驗證”等,平臺一般都推薦用谷歌身份驗證器。 后來區塊鏈業務風靡 ......

    uj5u.com 2020-09-10 03:03:17 more
  • 密碼學DAY1

    目錄 ##1.1 密碼學基本概念 密碼在我們的生活中有著重要的作用,那么密碼究竟來自何方,為何會產生呢? 密碼學是網路安全、資訊安全、區塊鏈等產品的基礎,常見的非對稱加密、對稱加密、散列函式等,都屬于密碼學范疇。 密碼學有數千年的歷史,從最開始的替換法到如今的非對稱加密演算法,經歷了古典密碼學,近代密 ......

    uj5u.com 2020-09-10 03:03:50 more
  • 密碼學DAY1_02

    目錄 ##1.1 ASCII編碼 ASCII(American Standard Code for Information Interchange,美國資訊交換標準代碼)是基于拉丁字母的一套電腦編碼系統,主要用于顯示現代英語和其他西歐語言。它是現今最通用的單位元組編碼系統,并等同于國際標準ISO/IE ......

    uj5u.com 2020-09-10 03:04:50 more
  • 密碼學DAY2

    ##1.1 加密模式 加密模式:https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html ECB ECB : Electronic codebook, 電子密碼本. 需要加密的訊息按照塊密碼的塊大小被分為數個塊,并對每個塊進 ......

    uj5u.com 2020-09-10 03:05:42 more
  • NTP時鐘服務器的特點(京準電子)

    NTP時鐘服務器的特點(京準電子) NTP時鐘服務器的特點(京準電子) 京準電子官V——ahjzsz 首先對時間同步進行了背景介紹,然后討論了不同的時間同步網路技術,最后指出了建立全球或區域時間同步網存在的問題。 一、概 述 在通信領域,“同步”概念是指頻率的同步,即網路各個節點的時鐘頻率和相位同步 ......

    uj5u.com 2020-09-10 03:05:47 more
  • 標準化考場時鐘同步系統推進智能化校園建設

    標準化考場時鐘同步系統推進智能化校園建設 標準化考場時鐘同步系統推進智能化校園建設 安徽京準電子科技官微——ahjzsz 一、背景概述隨著教育事業的快速發展,學校建設如雨后春筍,隨之而來的學校教育、管理、安全方面的問題成了學校管理人員面臨的最大的挑戰,這些問題同時也是學生家長所擔心的。為了讓學生有更 ......

    uj5u.com 2020-09-10 03:05:51 more
  • 位元幣入門

    引言 位元幣基本結構 位元幣基礎知識 1)哈希演算法 2)非對稱加密技術 3)數字簽名 4)MerkleTree 5)哪有位元幣,有的是UTXO 6)位元幣挖礦與共識 7)區塊驗證(共識) 總結 引言 上一篇我們已經知道了什么是區塊鏈,此篇說一下區塊鏈的第一個應用——位元幣。其實先有位元幣,后有的區塊 ......

    uj5u.com 2020-09-10 03:06:15 more
  • 北斗對時服務器(北斗對時設備)電力系統應用

    北斗對時服務器(北斗對時設備)電力系統應用 北斗對時服務器(北斗對時設備)電力系統應用 京準電子科技官微(ahjzsz) 中國北斗衛星導航系統(英文名稱:BeiDou Navigation Satellite System,簡稱BDS),因為是目前世界范圍內唯一可以大面積提供免費定位服務的系統,所以 ......

    uj5u.com 2020-09-10 03:06:20 more
最新发布
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:46:47 more
  • Hyperledger Fabric 使用 CouchDB 和復雜智能合約開發

    在上個實驗中,我們已經實作了簡單智能合約實作及客戶端開發,但該實驗中智能合約只有基礎的增刪改查功能,且其中的資料管理功能與傳統 MySQL 比相差甚遠。本文將在前面實驗的基礎上,將 Hyperledger Fabric 的默認資料庫支持 LevelDB 改為 CouchDB 模式,以實作更復雜的資料... ......

    uj5u.com 2023-04-16 07:28:31 more
  • .NET Core 波場鏈離線簽名、廣播交易(發送 TRX和USDT)筆記

    Get Started NuGet You can run the following command to install the Tron.Wallet.Net in your project. PM> Install-Package Tron.Wallet.Net 配置 public reco ......

    uj5u.com 2023-04-14 08:08:00 more
  • DKP 黑客分析——不正確的代幣對比率計算

    概述: 2023 年 2 月 8 日,針對 DKP 協議的閃電貸攻擊導致該協議的用戶損失了 8 萬美元,因為 execute() 函式取決于 USDT-DKP 對中兩種代幣的余額比率。 智能合約黑客概述: 攻擊者的交易:0x0c850f,0x2d31 攻擊者地址:0xF38 利用合同:0xf34ad ......

    uj5u.com 2023-04-07 07:46:09 more
  • Defi開發簡介

    Defi開發簡介 介紹 Defi是去中心化金融的縮寫, 是一項旨在利用區塊鏈技術和智能合約創建更加開放,可訪問和透明的金融體系的運動. 這與傳統金融形成鮮明對比,傳統金融通常由少數大型銀行和金融機構控制 在Defi的世界里,用戶可以直接從他們的電腦或移動設備上訪問廣泛的金融服務,而不需要像銀行或者信 ......

    uj5u.com 2023-04-05 08:01:34 more
  • solidity簡單的ERC20代幣實作

    // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; //ERC20 同質化代幣,每個代幣的本質或性質都是相同 //ETH 是原生代幣,它不是ERC20代幣, ......

    uj5u.com 2023-03-21 07:56:29 more
  • solidity 參考型別修飾符memory、calldata與storage 常量修飾符C

    在solidity語言中 參考型別修飾符(參考型別為存盤空間不固定的數值型別) memory、calldata與storage,它們只能修飾參考型別變數,比如字串、陣列、位元組等... memory 適用于方法傳參、返參或在方法體內使用,使用完就會清除掉,釋放記憶體 calldata 僅適用于方法傳參 ......

    uj5u.com 2023-03-08 07:57:54 more
  • solidity注解標簽

    在solidity語言中 注釋符為// 注解符為/* 內容*/ 或者 是 ///內容 注解中含有這幾個標簽給予我們使用 @title 一個應該描述合約/介面的標題 contract, library, interface @author 作者的名字 contract, library, interf ......

    uj5u.com 2023-03-08 07:57:49 more
  • 評價指標:相似度、GAS消耗

    【代碼注釋自動生成方法綜述】 這些評測指標主要來自機器翻譯和文本總結等研究領域,可以評估候選文本(即基于代碼注釋自動方法而生成)和參考文本(即基于手工方式而生成)的相似度. BLEU指標^[^?88^^?^]^:其全稱是bilingual evaluation understudy.該指標是最早用于 ......

    uj5u.com 2023-02-23 07:27:39 more
  • 基于NOSTR協議的“公有制”版本的Twitter,去中心化社交軟體Damus

    最近,一個幽靈,Web3的幽靈,在網路游蕩,它叫Damus,這玩意詮釋了什么叫做病毒式營銷,滑稽的是,一個Web3產品卻在Web2的產品鏈上瘋狂傳銷,各方大佬紛紛為其背書,到底發生了什么?Damus的葫蘆里,賣的是什么藥? 注冊和簡單實用 很少有什么產品在用戶注冊環節會有什么噱頭,但Damus確實出 ......

    uj5u.com 2023-02-05 06:48:39 more