<oembed><type>rich</type><version>1.0</version><author_name>npub1snw7t4auupm70ntyeywuzqn80cf6es53ym8rlzymh8ft97qmyq9qrg9vl0</author_name><author_url>https://nostr.ae/npub1snw7t4auupm70ntyeywuzqn80cf6es53ym8rlzymh8ft97qmyq9qrg9vl0</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-01-16&#xA;📝 Original message:&#xA;Hello Takaya,&#xA;        I really liked the idea of data atomic swap mentioned over here. So&#xA;as of now if we consider transfer of a file (may of few KB) then you split&#xA;it into several blocks and use atomic multi path payment whole using the&#xA;blocks for embedding with the preimage inorder to obtain payment. But it&#xA;might be the case you may not have sufficient number of path to transfer&#xA;all the blocks at one go because of preimage size limitation of 256 bit (I&#xA;didn&#39;t get the point that there is no limitation on data size, can anyone&#xA;explain that ?). So may be you need several iteration and I presume thats&#xA;what lightning network will pitch in where we have several such&#xA;microtransactions going on. What happens if it fails in an iteration ? So&#xA;the recipient of the file remains happy with the partial content ? Or will&#xA;the payment be revoked (not sure how) if recipient doesn&#39;t get the full&#xA;content ?&#xA;&#xA;On Mon, Nov 11, 2019 at 6:29 AM Takaya Imai &lt;takaya.imai at frontier-ptnrs.com&gt;&#xA;wrote:&#xA;&#xA;&gt; Hi all,&#xA;&gt;&#xA;&gt; I propose Data Lightning Atomic Swap.&#xA;&gt; Anyone already have the same idea?&#xA;&gt;&#xA;&gt;&#xA;&gt; [Abstract]&#xA;&gt; This proposal is a way to swap data and lightning payment atomically.&#xA;&gt; It has two patterns, one is for a payer to swap data-download with&#xA;&gt; lightning payment to a payee (DLAS-down), the other is for a payer to swap&#xA;&gt; data-upload with lightning payment to a payee (DLAS-up).&#xA;&gt;&#xA;&gt; The data is embedded to preimage so sending and receiving the data need&#xA;&gt; lightning payment at the same time.&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt; [Motivation]&#xA;&gt; Atomic Swaps among crypto currencies has various ways to implement&#xA;&gt; (on-chain to on-chain[1], on-chain to of-chain(Submarine Swap[2])). And&#xA;&gt; Atomic Swaps between data and crypto currencies are also proposed as a part&#xA;&gt; of TumbleBit mechanism[3], Storm mechanism[4] and so on.&#xA;&gt;&#xA;&gt; Recently Joost Jager proposed Instant messages with lightning onion&#xA;&gt; routing, whatsat[5], which use recent sphinx payload change[6]. This is&#xA;&gt; very awesome but not atomic with lightning payment.&#xA;&gt;&#xA;&gt; Atomic lightning mechanism for data is useful in use cases below.&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt; [Pros &amp; Cons]&#xA;&gt;&#xA;&gt; * DLAS-down&#xA;&gt; ** Pros&#xA;&gt; *** Atomic data download exchange with lightning payment&#xA;&gt; ** Cons&#xA;&gt; *** It needs better mechanism to expand data size&#xA;&gt;&#xA;&gt; * DLAS-up&#xA;&gt; ** Pros&#xA;&gt; *** Atomic data upload exchange with lightning payment&#xA;&gt; ** Cons&#xA;&gt; *** OG AMP[7] is needed to implement&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt; [What I describe]&#xA;&gt; * A way to swap data with lightning payment atomically.&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt; [What I do not describe]&#xA;&gt; * A way to detect that data is correct or not, namely zero knowledge proof&#xA;&gt; process.&#xA;&gt;&#xA;&gt; For example, probabilistic checkable proof like TumbleBit[3] proposed.&#xA;&gt; Just message as data is no problem because no need to check the message is&#xA;&gt; correct or not.&#xA;&gt;&#xA;&gt; * A way in case that different preimages are used in a payment route like&#xA;&gt; Multi-hop locks.&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt; [Specification]&#xA;&gt;&#xA;&gt; Lightning Network(LN) has a mechanism about preimage like a brief image&#xA;&gt; below.&#xA;&gt;&#xA;&gt; Payer                             Mediators&#xA;&gt;  Payee&#xA;&gt;&#xA;&gt; =================================================================================&#xA;&gt;&#xA;&gt; Preimage&#xA;&gt; Preimage Hash  &lt;--------------------- invoice ------------------------&#xA;&gt;  Preimage Hash&#xA;&gt; Preimage Hash  ----------------&gt;   Preimage Hash --------------------&gt;&#xA;&gt;  Preimage Hash&#xA;&gt; Preimage       &lt;—-------------—-   Preimage      &lt;--------------------&#xA;&gt;  Preimage&#xA;&gt;&#xA;&gt; As you know, preimage Payer gets can be a proof of payment because Payer&#xA;&gt; can not get it if the payment is executed correctly.&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; 1, Data download &lt;-&gt;  lightning (DLAS-down)&#xA;&gt;&#xA;&gt;&#xA;&gt; Payer sends lightning payment and receives data from Payee atomically.&#xA;&gt;&#xA;&gt;&#xA;&gt; Payer                             Mediators&#xA;&gt;  Payee&#xA;&gt;&#xA;&gt; =================================================================================&#xA;&gt; Payer Channel Pubkey &lt;-----------------------------------------------&gt;&#xA;&gt; Payee Channel Pubkey&#xA;&gt;&#xA;&gt;&#xA;&gt;  data(256bit, padded)&#xA;&gt;&#xA;&gt;  enc_key = (Payee Channel Secret Key * Payer Channel Pubkey).x  (256bit)&#xA;&gt; enc_key = (Payer Channel Secret Key * Payee Channel Pubkey).x  (256bit)&#xA;&gt;&#xA;&gt;  enc_data = data XOR enc_key&#xA;&gt; sha256(enc_data) &lt;--------------------- invoice ----------------------&#xA;&gt; sha256(enc_data)&#xA;&gt; sha256(enc_data) ----------------&gt; sha256(enc_data) -----------------&gt;&#xA;&gt; sha256(enc_data)&#xA;&gt; enc_data         &lt;---------------- enc_data &lt;-------------------------&#xA;&gt; enc_data&#xA;&gt; data = enc_data XOR enc_key&#xA;&gt;&#xA;&gt;&#xA;&gt; * The size of data is restricted to 256 bits. Identically, it should be&#xA;&gt; extended to larger data and the data should be transferred in several&#xA;&gt; payment paths like DLAS-up.&#xA;&gt; * Channel Pubkey is only one for one channel and the data can be decrypted&#xA;&gt; if enc_key is leaked. So enc_key should be generated newly every time by a&#xA;&gt; way like hash chain but the protocol image above is just example for&#xA;&gt; simplicity.&#xA;&gt; * .x means X axis value of points on Elliptic Curve.&#xA;&gt; * If data is less than 256 bits, then 0x00 is padded (I am not sure which&#xA;&gt; of big endian and little endian is better).&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; 2, Data upload &lt;-&gt;  lightning (DLAS-down)&#xA;&gt;&#xA;&gt; Payer sends data and lightning payment from Payee atomically.&#xA;&gt; This is like OG AMP(Atomic Multi-path Payment)[7] system.&#xA;&gt;&#xA;&gt; Payer                             Mediators&#xA;&gt;  Payee&#xA;&gt;&#xA;&gt; =================================================================================&#xA;&gt; data(512bit, padded)&#xA;&gt;&#xA;&gt; share1(256bit)&#xA;&gt; share2(256bit)&#xA;&gt;&#xA;&gt; base_s = share1 XOR share2&#xA;&gt; data1(256bit) ||  data2(256bit) = data(512bit)&#xA;&gt; XOR_d1 = data1 XOR base_s&#xA;&gt; XOR_d2 = data2 XOR base_s&#xA;&gt; PreImg1 = sha256(base_s || data || 1)&#xA;&gt; PreImg2 = sha256(base_s || data || 2)&#xA;&gt;&#xA;&gt; sha256(PreImg1), XOR_d1, share1 -&gt; sha256(PreImg1), XOR_d1, share1  -&gt;&#xA;&gt; sha256(PreImg1), XOR_d1, share1&#xA;&gt; sha256(PreImg2), XOR_d2, share2 -&gt; sha256(PreImg2), XOR_d2, share2  -&gt;&#xA;&gt; sha256(PreImg2), XOR_d2, share1&#xA;&gt;&#xA;&gt;&#xA;&gt;  base s = share1 XOR share2&#xA;&gt;&#xA;&gt;  data = (XOR_d1 XOR base_s) || (XOR_d2 XOR base_s)&#xA;&gt;&#xA;&gt;  PreImg1 = sha256(base_s || data || 1)&#xA;&gt;&#xA;&gt;  PreImg2 = sha256(base_s || data || 2)&#xA;&gt;&#xA;&gt; PreImg1    &lt;-------------------    PreImg1    &lt;---------------------&#xA;&gt; PreImg1&#xA;&gt; PreImg2    &lt;-------------------    PreImg2    &lt;---------------------&#xA;&gt; PreImg2&#xA;&gt;&#xA;&gt;&#xA;&gt; * This protocol example has 512 bits data and they are transferred in two&#xA;&gt; paths. However, it can transfer larger data in several payment paths like&#xA;&gt; [5].&#xA;&gt; * || means string concatenation.&#xA;&gt; * If data is less than 512 bits, then 0x00 is padded(I am not sure which&#xA;&gt; of big endian and little endian is better).&#xA;&gt;&#xA;&gt;&#xA;&gt; ---------&#xA;&gt;&#xA;&gt;&#xA;&gt; [Use Cases]&#xA;&gt;&#xA;&gt; 1, Lightning Network ecosystem&#xA;&gt;&#xA;&gt; * Hosting Incentives like Acai Protocol&#xA;&gt; ** Watchtower Hosting incentive, Backup Hosting incentive&#xA;&gt; *** Commitment tx data sending to Data Host(DLAS-up)&#xA;&gt; **** Commitment tx data is embedded in preimage so that Payer can not send&#xA;&gt; the data without remittance&#xA;&gt; *** Channel backup data receiving from Data Host(DLAS-down)&#xA;&gt; **** Channel backup data is embedded in preimage so that Payer can not&#xA;&gt; receive the data without remittance&#xA;&gt;&#xA;&gt; 2, Crypto currency Problems&#xA;&gt;&#xA;&gt; * Distributed secret key sharing (just come up with an idea though)&#xA;&gt; ** As a key backup, one of secret key shares is distributed with&#xA;&gt; encryption(DLAS-up) to some nodes, which nodes receive lightning payment as&#xA;&gt; key managing fee. And the nodes send a proof for managing the key as&#xA;&gt; response of bloom filter periodically, and exchange encrypted secret key&#xA;&gt; share with lightning payment to asset holder(DLAS-down).&#xA;&gt; ** For example 2 out of 3 multi signature key sharing, asset holder puts&#xA;&gt; the first key, the custodial has the second key, and the third key at the&#xA;&gt; lightning distribution nodes. Asset holders usually spend assets using&#xA;&gt; their key and the key on Distributed Nodes.&#xA;&gt;&#xA;&gt;&#xA;&gt; 3, Problems so far&#xA;&gt;&#xA;&gt; * Prevention email spam and DDoS attack with large data&#xA;&gt; ** Payer can not send email or data without remittance(DLAS-up)&#xA;&gt; ** Payer can not receive reply-email without remittance(DLAS-down)&#xA;&gt;&#xA;&gt; * Incentive of receiving advertisements on browser or desktop/mobile app&#xA;&gt; ** Payer can not send advertisements without remittance(DLAS-up)&#xA;&gt;&#xA;&gt; * Bounty for code bug fixes based on cryptographic proofs or secret&#xA;&gt; computations&#xA;&gt; ** (DLAS-down)&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; [References]&#xA;&gt;&#xA;&gt; [1] https://bitcointalk.org/index.php?topic=321228&#xA;&gt; [2] https://twitter.com/roasbeef/status/964608261830750208&#xA;&gt; [3] https://eprint.iacr.org/2016/575&#xA;&gt; [4] https://github.com/storm-org/storm-spec&#xA;&gt; [5] https://twitter.com/joostjgr/status/1190714028626251779&#xA;&gt; [6] https://github.com/lightningnetwork/lightning-rfc/pull/619&#xA;&gt; [7]&#xA;&gt; https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-February/000993.html&#xA;&gt;&#xA;&gt;&#xA;&gt; document on github:&#xA;&gt; https://github.com/takaya-imai/data_lightning_atomic_swap&#xA;&gt;&#xA;&gt; Best regards,&#xA;&gt; Takaya Imai&#xA;&gt; Email: takaya.imai at frontier-ptnrs.com, takaya.imai at unitedbitcoiners.com&#xA;&gt; _______________________________________________&#xA;&gt; Lightning-dev mailing list&#xA;&gt; Lightning-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev&#xA;&gt;&#xA;&#xA;&#xA;-- &#xA;Yours sincerely,&#xA;Subhra Mazumdar.&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200116/6ea563b8/attachment-0001.html&gt;</html></oembed>