|
@@ -29,9 +29,9 @@ The proposal here is to introduce "Hash Locked" accounts such that when used wit
|
|
|
|
|
|
Suppose Alice has 100 PASC and Bob has 1 BTC, and they wish to perform an Atomic Swap between themselves. The below workflow can be employed:
|
|
|
|
|
|
-1. Alice creates picks a very large number and is known as ***SECRET***
|
|
|
+1. Alice picks a very large random number known as **SECRET**
|
|
|
|
|
|
-2. Alice calculates **CODE** = HASH(***SECRET***)
|
|
|
+2. Alice calculates **CODE** = HASH(**SECRET**)
|
|
|
|
|
|
3. Bob gives Alice his public key **B**
|
|
|
|
|
@@ -44,10 +44,7 @@ Suppose Alice has 100 PASC and Bob has 1 BTC, and they wish to perform an Atomic
|
|
|
- X.Price = **0**
|
|
|
|
|
|
----
|
|
|
-_**NOTE** At this point Bob has the ability to acquire account X containing 100 PASC for free. Except, there is an additional consensus rule applied since the account is typed "Hash Locked". Hash Locked accounts requires that the purchasing operation include the pre-image that when hashed matches the account data. In other words, Bob needs to include SECRET in the Payload since it hashes to CODE. If the Payload does not Hash to the account data, the purchase operation is invalid. Specifically,_
|
|
|
-```
|
|
|
-X.Data = HASH(PurchaseOperation.Payload)
|
|
|
-```
|
|
|
+_**NOTE** At this point Bob has the ability to acquire account X containing 100 PASC at no cost. However, there is now an additional requirement now that he must supply SECRET in the payload of the purchasing operation. This new consensus rule is only applied for accounts typed "Hash Locked". When purchasing Hash Locked accounts, the purchasing operations Payload must hash to the target accounts data field. In other words, Bob needs to include SECRET in the Payload since it hashes to CODE. If the Payload does not Hash to the account data, the purchase operation is invalid._
|
|
|
|
|
|
_This rule forces Bob to know SECRET before buying this account for nothing. If he does not know SECRET, he cannot buy X._
|
|
|
|
|
@@ -72,16 +69,16 @@ _The swap has still not occured yet but is setup bi-directionally._
|
|
|
|
|
|
---
|
|
|
|
|
|
-7. Once Alice detects **TXN1** on BTC chain, she immediately spends the outputs of **TXN1** to her own wallet and takes possesion of the 1 BTC. She does this with by publishing **TXN2** on BTC.
|
|
|
+7. Once Alice detects **TXN1** on the BTC chain, she immediately spends it's outputs via a **TXN2** to her own wallet. She thus takes possesion of the 1 BTC, revealing **SECRET** in the process.
|
|
|
|
|
|
----
|
|
|
-_**NOTE** In the process of spending TXN1, Alice reveals the SECRET inside TXN2, which was a necessary condition of the smart-contract defined in **TXN1**, in particular the ```x for H(x) = CODE``` portion._
|
|
|
+_**NOTE** In the process of spending TXN1, Alice reveals the SECRET inside of TXN2, which was a necessary condition of the smart-contract defined in **TXN1**, in particular the ```x for H(x) = CODE``` portion._
|
|
|
|
|
|
----
|
|
|
|
|
|
8. Bob detects the transaction **TXN2** and extracts **SECRET** from **TXN2**.
|
|
|
|
|
|
-9. Bob immediately includes **SECRET** inside the Payload of his Purchase Account operation and takes posession of account **X**, containing **100 PASC**.
|
|
|
+9. Bob createas a Purchase Account operation for **X** and includes **SECRET** inside the Payload, thus taking possession of **X** containing the **100 PASC**.
|
|
|
|
|
|
10. **Atomic Swap Completed**
|
|
|
|
|
@@ -89,7 +86,7 @@ _**NOTE** In the process of spending TXN1, Alice reveals the SECRET inside TXN2,
|
|
|
_**IMPORTANT**_
|
|
|
|
|
|
_Notice that Alice's offer to Bob was locked for 3 weeks, yet Bob's offer to Alice was locked for only 2 weeks._
|
|
|
-* _A Time-Lock differential is necessary to avoid the scenario where Alice takes both the 1 BTC and account X containing 100 PASC by revealing the SECRET at the moment the time-lock of X to Bob expires._
|
|
|
+* _A time-lock differential is necessary to avoid the scenario where Alice takes both the 1 BTC and account X containing 100 PASC by revealing the SECRET at the moment the time-lock of X to Bob expires._
|
|
|
* _With this time difference, if after 2 weeks Alice has not revealed SECRET, Bob can determine Alice is acting in bad faith (or has abandoned the contract) giving him 1 week to safely cancel the swap and reclaim his 1 BTC._
|
|
|
* _In this eventuality, Alice does not lose her PASC since she never revealed SECRET. She can safely reclaim her PASC after account X's time-lock to Bob expires in 3 weeks_.
|
|
|
|