LOADING...
LOADING...
LOADING...
当前位置: 玩币族首页 > 区块链资产 > 解析|《WisdomChain文档知识库》之条件支付

解析|《WisdomChain文档知识库》之条件支付

2020-08-28 WisdomChain中文社区 来源:区块链网络

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

—-

编译者/作者:WisdomChain中文社区

玩币族申明:玩币族作为开放的资讯翻译/分享平台,所提供的所有资讯仅代表作者个人观点,与玩币族平台立场无关,且不构成任何投资理财建议。文章版权归原作者所有。

LOADING...
LOADING...