A three-party transfer method and device
By establishing a tripartite payment channel on the blockchain, the process of tripartite transfer in the Thunderbolt Network is simplified, the cumbersome transfer problems in the existing technology are solved, and a more efficient and secure transfer method is achieved.
Patent Information
- Application Number
- CN202011010339.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-23
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2040-09-23
AI Technical Summary
In the prior art, the three-party transfer process in the lightning network is relatively cumbersome, and multiple payment channels are required to establish and perform complex calculation logic and verification processes.
By establishing a three-party payment channel on the blockchain, the first party sends the transfer data to the second and third parties. As long as the verified signature data is received, the balance information and the transfer serial number can be determined to take effect and the transfer will be completed.
The three-party transfer process is simplified, the number of payment channels and off-chain interactions is reduced, the transfer cost is reduced, and the simplicity and security of the transfer is improved.
Smart Images

Figure CN112053144B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain in the field of financial technology (Fintech), and in particular to a three-party transfer method and device. Background Art
[0002] With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to Fintech. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. At present, based on the immutability of blockchain, transactions are often conducted through blockchain in the field of Fintech. Three-party transfer is a special scenario in the blockchain field. The assets of the three parties are only transferred within the three parties. In the three-party transfer scenario, after the payment channel is established on the blockchain, the intermediate transfer process is completed off-chain. The blockchain only needs to record the initial balance of each of the three parties and the final balance of each of the three parties. In the current solution, three-party transfer is often achieved through Ethereum's Raiden Network.
[0003] The payment channel mechanism in the Raiden Network is established in pairs, but in many cases, the transferor does not transfer money to the receiver frequently. If the transferor and the receiver establish payment channels in pairs for each transfer, the transfer cost will be high. Therefore, the more common scenario is the three-party transfer: A and C have established a payment channel, B and C have also established a payment channel, but A and C have not established a payment channel. When A and C do not want to establish an additional payment channel, they will use B to realize the three-party transfer of A, B and C. However, in this scenario, two payment channels need to be established. The establishment of each payment channel requires interaction with the blockchain. In order to prevent one party from doing evil, in the process of off-chain intermediate transfer, it is also necessary to calculate the balance proof (such as zero-knowledge proof), and negotiate and verify with each other, and the logic is relatively complicated. Therefore, the process of three-party transfer in the Raiden Network is relatively cumbersome, which is a problem to be solved. Summary of the invention
[0004] The present invention provides a three-party transfer method and device, which solves the problem that the process of three-party transfer in the lightning network in the prior art is relatively complicated.
[0005] In a first aspect, the present invention provides a three-party transfer method, comprising: for any transfer within the life cycle of a three-party payment channel shared by three parties, the first party sends first transfer data to the second party and the third party; the first transfer data includes: first balance information, a first transfer sequence number and a first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the first party is the transferor of this transfer; if the first party receives the second transfer data and the third transfer data, it is determined that the first balance information and the first transfer sequence number are effective, thereby completing this transfer; the second transfer data is obtained by the second party after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third party after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0006] Under the above method, the three parties only need to establish a three-party payment channel. For any transfer within the life cycle of the three-party payment channel, after the first party sends the first transfer data to the second party and the third party, as long as the second transfer data and the third transfer data can be received, it can be known that the second party has verified that the first transfer data has passed, and that the third party has verified that the first transfer data and the second transfer data have passed. It can also prevent one party from doing evil, so that it can be determined that the second party and the third party have both recognized the first balance information and the first transfer serial number, that is, the first balance information and the first transfer serial number are effective. In the above three-party transfer process, only a simple signature and verification process is involved, and no complex calculation logic is required. Only one three-party payment channel is required, so the above three-party payment process is more concise.
[0007] Optionally, before the first transfer within the life cycle, each of the three participants writes an initial amount in the blockchain; the first participant writes the initial amount of the first participant into the blockchain in the following manner: the first participant calls the first smart contract of the blockchain according to the three-party payment channel and the initial amount of the first participant; the first smart contract is used to bind the initial amount of the first participant to the three-party payment channel, thereby writing the initial amount of the first participant in the three-party payment channel into the blockchain.
[0008] In the above method, before the first transfer within the life cycle, each of the three participants writes the initial amount in the blockchain, so that the initial amount of the three participants will not be tampered with. In addition, the first participant calls the first smart contract of the blockchain based on the three-party payment channel and the initial amount of the first participant, thereby binding the initial amount of the first participant to the three-party payment channel, and establishing a connection between the three-party payment channel and the initial amount of the first participant.
[0009] Optionally, the three-party payment channel is generated by transmitting the account addresses of the three parties and the preset expiration time of the life cycle to a second smart contract of the blockchain according to a preset function in the second smart contract.
[0010] In the above method, the three-party payment channel is generated by a second smart contract that transmits the account addresses of the three parties and the preset expiration time of the life cycle to the blockchain, making it difficult to crack the three-party payment channel, thereby increasing the security of the three-party payment channel.
[0011] Optionally, when the first participant is the closing party of the three-party payment channel, the first participant transmits the fourth transfer data to the third smart contract of the blockchain and enters the first challenge period; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; if at the end of the first challenge period, the first participant determines that the second balance information recorded in the third smart contract has not been updated, then the first participant determines that the second balance information has taken effect in the blockchain and the life cycle ends; the first participant obtains the assets of the first participant corresponding to the settlement amount in the second balance information from the blockchain.
[0012] Under the above method, the first participant transmits the fourth transfer data to the third smart contract of the blockchain and enters the first challenge period. When the second balance information is not updated at the end of the first challenge period, it is determined that the second balance information has taken effect in the blockchain, thereby giving each participant an opportunity to update the second balance information through the challenge period, and obtaining the assets of the first participant corresponding to the settlement amount in the second balance information, thereby increasing the accuracy of the balance settlement by the first participant.
[0013] Optionally, if during the first challenge period, the first participant determines that the second balance information recorded in the third smart contract is updated to the third balance information, then the first participant determines that the first challenge period is updated to the second challenge period; the third balance information is the settlement balance information declared by the second participant or the third party; if at the end of the second challenge period, the first participant determines that the third balance information recorded in the third smart contract has not been updated, then the first participant determines that the third balance information has taken effect in the blockchain and the life cycle has ended; the first participant obtains the assets of the first participant corresponding to the settlement amount in the third balance information from the blockchain.
[0014] In the above manner, if during the first challenge period, the first participant determines that the second balance information recorded in the third smart contract is updated to the third balance information, it means that the second participant or the third party does not agree with the second balance information, and a new second challenge period is started, thereby increasing the flexibility of transfer settlement.
[0015] Optionally, when the second participant or the third participant is the closing party of the three-party payment channel, and the first participant is the non-closing party, during the third challenge period, the first participant obtains the third balance information recorded in the third smart contract of the blockchain; the third balance information is the settlement balance information declared by the second participant or the third participant; the third transfer sequence number is the settlement transfer sequence number declared by the second participant or the third participant; if the first participant does not agree with the third balance information and / or the third transfer sequence number, then during the third challenge period, the first participant transmits the fourth transfer data to the third smart contract. The fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; the third smart contract is used to update the third balance information recorded in the third smart contract to the second balance information and the third transfer sequence number recorded in the third smart contract to the second transfer sequence number after the fourth transfer data is verified and the second transfer sequence number and the third transfer sequence number meet the preset relationship, and enter the fourth challenge period.
[0016] Under the above method, when the second participant or the third participant is the closing party of the three-party payment channel, and the first participant is the non-closing party, if the first participant does not agree with the third balance information and / or the third transfer sequence number, then during the third challenge period, the first participant transmits the fourth transfer data to the third smart contract. When the second transfer sequence number and the third transfer sequence number meet the preset relationship, the third balance information recorded in the third smart contract can be updated to the second balance information, thereby providing the first participant with an opportunity to appeal the update and improving the error correction capability of the three-party payment settlement.
[0017] In a second aspect, the present invention provides a three-party transfer method, comprising: for any transfer within the life cycle of a three-party payment channel shared by three parties, the second participant obtains first transfer data from the first participant; the first balance information includes the expected balance of each of the three parties after this transfer; the second participant is the recipient of this transfer; after the second participant verifies the first transfer data, the first balance table and the first transfer sequence number are signed to obtain second transfer data; the second participant sends the second transfer data to the first participant and the third party; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; if the second participant receives the third transfer data, it is determined that the first balance information and the first transfer sequence number are effective, thereby completing this transfer; the third transfer data is obtained by the third party after verifying the first transfer data and the second transfer data; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0018] In a third aspect, the present invention provides a three-party transfer method, comprising: for any transfer within the life cycle of a three-party payment channel shared by three parties, the third party obtains first transfer data from the first party and second transfer data from the second party; the first transfer data includes: first balance information, a first transfer sequence number and a first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the second transfer data is obtained by the second party after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; after the third party verifies the first transfer data and the second transfer data, it signs the first balance information and the first transfer sequence number to obtain the third transfer data; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature; the third party sends the third transfer data to the first party and the second party, and determines that the first balance information and the first transfer sequence number are effective, thereby completing this transfer.
[0019] In a fourth aspect, the present invention provides a three-party transfer device, comprising: a data transmission module, used to send first transfer data to a second party and a third party for any transfer within the life cycle of a three-party payment channel shared by three parties; the first transfer data includes: first balance information, a first transfer sequence number and a first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the first party is the transferor of this transfer; a processing module, used to determine that the first balance information and the first transfer sequence number are effective if the data transmission module receives the second transfer data and the third transfer data, thereby completing this transfer; the second transfer data is obtained by the second party after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third party after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0020] Among them, the three parties include a first party, a second party and a third party.
[0021] Optionally, before the first transfer within the life cycle, each of the three participants writes an initial amount in the blockchain; the processing module is also used to: call the first smart contract of the blockchain according to the three-party payment channel and the initial amount of the first participant; the first smart contract is used to bind the initial amount of the first participant to the three-party payment channel, thereby writing the initial amount of the first participant in the three-party payment channel into the blockchain.
[0022] Optionally, the three-party payment channel is generated by transmitting the account addresses of the three parties and the preset expiration time of the life cycle to a second smart contract of the blockchain according to a preset function in the second smart contract.
[0023] Optionally, the processing module is also used to: when the first participant is the closing party of the three-party payment channel, transfer the fourth transfer data to the third smart contract of the blockchain and enter the first challenge period; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; if at the end of the first challenge period, it is determined that the second balance information recorded in the third smart contract has not been updated, then it is determined that the second balance information has taken effect in the blockchain and the life cycle has ended; the data transmission module is also used to: obtain the assets of the first participant corresponding to the settlement amount in the second balance information from the blockchain.
[0024] Optionally, the processing module is also used to: if during the first challenge period, it is determined that the second balance information recorded in the third smart contract is updated to the third balance information, then it is determined that the first challenge period is updated to the second challenge period; the third balance information is the settlement balance information declared by the second participant or the third participant; if at the end of the second challenge period, it is determined that the third balance information recorded in the third smart contract has not been updated, it is determined that the third balance information has taken effect in the blockchain and the life cycle has ended; obtain the assets of the first participant corresponding to the settlement amount in the third balance information from the blockchain.
[0025] Optionally, when the second participant or the third participant is the closing party of the three-party payment channel, the first participant is the non-closing party, and the data transmission module is further used to: obtain the third balance information recorded in the third smart contract of the blockchain during the third challenge period; the third balance information is the settlement balance information declared by the second participant or the third participant; the third transfer sequence number is the settlement transfer sequence number declared by the second participant or the third participant; the processing module is further used to: if the third balance information and / or the third transfer sequence number are not recognized, then during the third challenge period, the fourth transfer data is transmitted to the third smart contract. contract; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; the third smart contract is used to update the third balance information recorded in the third smart contract to the second balance information, and update the third transfer sequence number recorded in the third smart contract to the second transfer sequence number, and enter the fourth challenge period after the fourth transfer data is verified and the second transfer sequence number and the third transfer sequence number meet the preset relationship.
[0026] The beneficial effects of the fourth aspect and each optional device of the fourth aspect can refer to the beneficial effects of the first aspect and each optional method of the first aspect, which will not be repeated here.
[0027] In a fifth aspect, the present invention provides a computer device, including a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect, second aspect, or third aspect and each optional method.
[0028] In a sixth aspect, the present invention provides a storage medium, comprising a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect, second aspect, or third aspect and each optional method.
[0029] These and other aspects of the present invention will become more apparent from the following description of the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0031] Figure 1 This is a schematic diagram of the structure of the blockchain;
[0032] Figure 2 A schematic diagram of a flow chart of a three-party transfer method provided by an embodiment of the present invention;
[0033] Figure 3 A schematic diagram of the structure of a three-party transfer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] The following first explains the terms that appear in the embodiments of the present application.
[0036] Blockchain: Figure 1 As shown in the figure, the blockchain is a chain composed of a series of blocks. In addition to recording the data of the current block, each block also records the hash value of the previous block, forming a chain in this way. There are two core concepts of the blockchain, one is cryptography technology, and the other is decentralization. Based on these two concepts, the historical information on the blockchain cannot be tampered with.
[0037] Node: Every participant in the network is a node, and nodes participate in network formation and data exchange. In a blockchain network, a node refers to a participant with a unique identity, which has a complete copy of the ledger and has the ability to participate in blockchain network consensus and ledger maintenance.
[0038] Smart Contract: A smart contract is a computer protocol designed to disseminate, verify or execute contracts in an information-based manner. Smart contracts allow for trusted transactions without a third party, which are traceable and irreversible. Smart contracts are in the form of code deployed on the blockchain to perform specific functions. For example, Solidity is a mainstream smart contract programming language, and a smart contract written in Solidity is called a Solidity contract. When a smart contract is deployed on the blockchain, a contract address is generated, and users can call this smart contract through the contract address. The functions defined in a smart contract are called contract interfaces. To call a smart contract is to call a contract interface in the contract through the contract address.
[0039] Hash algorithm: An algorithm that maps a digital message to a fixed-length string (also called a message digest, hash value, or fingerprint). If the input message is different, the probability of mapping to the same string is negligible. If the hash value is known, it is not feasible to calculate the original digital message.
[0040] State channel: refers to a virtual channel whose state changes outside the chain.
[0041] Payment channel: Payment channel is a special case of state channel, which refers to a trustless mechanism for transactions between two parties. The intermediate commitment transactions are all off-chain, and only the subsequent settlement transactions are finally on-chain, thereby achieving the effect of improving transaction throughput, low latency and fine granularity.
[0042] Public key: Public key refers to the public key parameters in public key cryptography, which need to be published. It is used for encryption and signature verification. In the blockchain account system, the public key corresponds to an account address.
[0043] Private key: Private key refers to the private key parameter in public key cryptography, which needs to be properly protected. It is used for decryption and signing. In the blockchain account system, the private key controls the ownership and use rights of the account.
[0044] Address: The address is the identifier of the account. For an external account, the address represents the last 20 bytes of the public key of the account (usually starting with 0x, for example, 0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826, the address uses hexadecimal notation).
[0045] In the process of financial institutions (banking institutions, insurance institutions or securities institutions) conducting business (such as bank loan business, deposit business, etc.), based on the immutability of blockchain, transactions are often conducted through blockchain in the field of financial technology. However, with the continuous increase in transaction volume, serial execution of transactions will cause a large number of transactions to be queued for a long time, or transaction errors may occur due to conflicts in shared variables between transactions. Retrying or troubleshooting errors will increase the time to complete the transaction. The current performance of blockchain nodes is increasingly unable to support the huge transaction volume. This situation does not meet the needs of banks and other financial institutions, and cannot guarantee the efficient operation of various businesses of financial institutions. For this reason, Figure 2 As shown, an embodiment of the present invention provides a three-party transfer method.
[0046] Step 201: For any transfer within the life cycle of the three-party payment channel shared by the three parties, the first party sends first transfer data to the second party and the third party.
[0047] Step 202: If the first participant receives the second transfer data and the third transfer data, it is determined that the first balance information and the first transfer sequence number are effective, thereby completing the transfer.
[0048] Among them, the first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three participants after this transfer; the first participant is the transferor of this transfer; the second participant is the recipient of this transfer; the second transfer data is obtained by the second participant after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third party after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0049] It should be noted that the roles of the transferor and the receiver among the three participants mentioned above may be converted. For example, for the three participants A, B and C, the roles of A, B and C can be different for different transfers. For example, A can be the transferor (first participant) in the first transfer in the life cycle, the receiver (second participant) in the second transfer in the life cycle, and the third participant in the third transfer in the life cycle.
[0050] It should be noted that before the first transfer in the life cycle, each of the three participants wrote the initial amount in the blockchain, and it was not until the last transfer in the life cycle that the three parties wrote the settlement amount in the blockchain.
[0051] In an optional implementation manner, the first participant writes the initial amount of the first participant into the blockchain in the following manner:
[0052] The first participant calls the first smart contract of the blockchain according to the three-party payment channel and the initial amount of the first participant; the first smart contract is used to bind the initial amount of the first participant to the three-party payment channel, thereby writing the initial amount of the first participant in the three-party payment channel into the blockchain.
[0053] For example, if the initial amounts of the three participants are all 100, then the first participant can use 100 and the three-party payment channel as the input parameters of the first smart contract, thereby binding the initial amount of the first participant to the three-party payment channel and putting it on the chain; the second and third parties can also refer to the above process to bind the corresponding initial amounts to the three-party payment channel.
[0054] It should be noted that, the first smart contract of the blockchain can also be called by an executor other than the three participants according to the three-party payment channel and the initial amount of the first participant, and the initial amounts of the three participants can be written into the blockchain. In the first smart contract, there is no restriction on the specific input parameters, and the initial amounts of the three participants can be written together, or the initial amount of a certain participant can be written in sequence.
[0055] In an optional implementation, the three-party payment channel is generated by transmitting the account addresses of the three parties and the preset expiration time of the life cycle to a second smart contract of the blockchain according to a preset function in the second smart contract.
[0056] For example, the three-party payment channel can be in the form of a payment channel identifier, which is used as an input parameter in the transfer process within the life cycle, so that each transfer is bound to the three-party payment channel, thereby recording each transfer process within the life cycle. The life cycle can be set with a preset expiration time to indicate the validity of each transfer process within the life cycle.
[0057] For example, the account addresses of the three parties may be Adr1, Adr2, and Adr3, the preset expiration time may be TimeOut, and the preset function in the second smart contract may be the hash function Hash. Then, the three-party payment channel may be Hash(Adr1, Adr2, Adr3, TimeOut).
[0058] It should be noted that, before the end of the life cycle of the three-party payment channel, if one party wishes to exit in advance, it can also initiate a closing request as the closing party of the three-party payment channel.
[0059] In an optional implementation, when the first participant is the closing party of the three-party payment channel, the first participant transmits the fourth transfer data to the third smart contract of the blockchain and enters the first challenge period; if at the end of the first challenge period, the first participant determines that the second balance information recorded in the third smart contract has not been updated, then the first party determines that the second balance information has taken effect in the blockchain and the life cycle ends; the first party obtains the assets of the first participant corresponding to the settlement amount in the second balance information from the blockchain.
[0060] The fourth transfer data includes: second balance information, a second transfer sequence number and a fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant.
[0061] For example, the first challenge period is T1, which is the time period during which the second and third parties can update the second balance information. If they disagree, they can update the second balance information within T1 under certain conditions. If the second balance information recorded in the third smart contract is not updated within T1, it means that the second and third parties agree with the second balance information. At the end of T1, the first party also determines that the second balance information has taken effect in the blockchain.
[0062] In another possible situation, the second party and the third party may not agree with the second balance information. The specific situation is as follows:
[0063] If, during the first challenge period, the first participant determines that the second balance information recorded in the third smart contract is updated to the third balance information, the first participant determines that the first challenge period is updated to the second challenge period; if at the end of the second challenge period, the first participant determines that the third balance information recorded in the third smart contract has not been updated, the first participant determines that the third balance information has taken effect in the blockchain and the life cycle ends; the first party obtains the assets of the first participant corresponding to the settlement amount in the third balance information from the blockchain.
[0064] The third balance information is the settlement balance information declared by the second party or the third party.
[0065] For example, within T1, the first participant determines that the second balance information recorded in the third smart contract is updated to the third balance information, and the first participant determines that T1 is updated to the second challenge period T2. Then T2 is also the period during which the first participant can update the third balance information. If the third balance information continues to be updated in T2, the challenge period will be updated again, and this cycle will be repeated until all three participants agree on the balance information of a certain challenge period.
[0066] In an optional implementation, when the second participant or the third party is the closing party of the three-party payment channel, the first party is the non-closing party, and during the third challenge period, the first party obtains the third balance information recorded in the third smart contract of the blockchain; if the first party does not agree with the third balance information and / or the third transfer sequence number, then during the third challenge period, the first party transmits the fourth transfer data to the third smart contract.
[0067] The third balance information is the settlement balance information declared by the second participant or the third participant; the third transfer sequence number is the settlement transfer sequence number declared by the second participant or the third participant; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; the third smart contract is used to update the third balance information recorded in the third smart contract to the second balance information and the third transfer sequence number recorded in the third smart contract to the second transfer sequence number after the fourth transfer data is verified and the second transfer sequence number and the third transfer sequence number meet the preset relationship, and enter the fourth challenge period.
[0068] For example, when the second participant or the third participant is the closing party of the three-party payment channel, and the first participant is the non-closing party, then within the third challenge period T3, the first participant can obtain the third balance information. If it disagrees, it can transfer the fourth transfer data to the third smart contract within T3, so that when the second transfer sequence number and the third transfer sequence number meet the preset relationship, the third balance information recorded in the third smart contract is updated to the second balance information. For example, the transfer sequence number is incremented in sequence according to the number of transfers. Then, when the second transfer sequence number is greater than the third transfer sequence number, it means that the second transfer sequence number is generated later. After the fourth transfer data is verified, it proves that the transfer corresponding to the second transfer sequence number is once recognized by the three participants, which means that the amount corresponding to the third transfer sequence number is not the final settlement amount, and the third balance information is updated to the second balance information.
[0069] Figure 2 The method shown designs a transfer scheme for a three-party payment channel involving three parties. By designing a new interaction process and payment channel contract, the three-party transfer scenario can perform multi-channel transfers without using the traditional Raiden Network technology, reducing the off-chain interaction process, and making the scheme simpler and easier to operate. Moreover, this scheme does not require an intermediary to assist in the transfer, so it does not require the intermediary to pledge double assets like the traditional Raiden Network technology. No handling fees are required for the entire process, which also reduces the transfer cost of the payment channel.
[0070] It should be noted that Figure 2 The process shown has similar processes for the second and third parties. Specifically, the process for the second party is as follows:
[0071] For any transfer within the life cycle of the three-party payment channel shared by the three parties, the second party obtains the first transfer data from the first party; after the second party verifies the first transfer data, it signs the first balance table and the first transfer sequence number to obtain the second transfer data; the second party sends the second transfer data to the first party and the third party; if the second party receives the third transfer data, it determines that the first balance information and the first transfer sequence number are effective, thereby completing the transfer.
[0072] The first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the second party is the recipient of this transfer; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third party after verifying the first transfer data and the second transfer data; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0073] Specifically, the process for the third party is as follows:
[0074] For any transfer within the life cycle of the three-party payment channel shared by the three parties, the third party obtains the first transfer data from the first party and the second transfer data from the second party; after the third party verifies the first transfer data and the second transfer data, it signs the first balance information and the first transfer sequence number to obtain the third transfer data; the third party sends the third transfer data to the first party and the second party, and determines that the first balance information and the first transfer sequence number are effective, thereby completing the transfer.
[0075] The first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the second transfer data is obtained by the second party after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0076] The following is a detailed description of the embodiments. Figure 2 The process shown.
[0077] If parties A, B, and C want to transfer money through a payment channel, there is no need to build channels for each of them. A three-party payment channel that can accommodate three parties can be implemented through a smart contract.
[0078] The specific steps are as follows:
[0079] (1) Open the channel:
[0080] A, B, and C establish a state channel through negotiation. Specifically, any party can be authorized to call the openChannel function of the deployed payment channel smart contract.
[0081] To open a channel, you only need to pass in the account addresses of A, B, and C and the preset expiration time or preset expiration duration. The openChannel function will calculate the hash value based on the three addresses passed in, calculate the globally unique payment channel identifier channeId of the three-party payment channel, set the preset expiration time of the channel, and set the channel status to open. At this point, the three-party payment channel is successfully established. A, B, and C have all obtained the channeId of the three-party payment channel.
[0082] (2) Deposit of pledged assets:
[0083] After A, B, and C obtain the channel channeId, they call the setTotalDeposit (deposit assets) function respectively to deposit the initial amounts of A, B, and C into the on-chain assets into the smart contract.
[0084] The setTotalDeposit function will verify the channel status and preset expiration time of the three-party payment channel. If it passes, the initial amount of A, B, and C will be recorded. So far, A, B, and C have all deposited assets in the three-party payment channel. Now, enable off-chain transfers. Note that all transfers at this time are executed off-chain, without the need to interact with the blockchain.
[0085] (3) Start off-chain transfer:
[0086] For example, suppose that three parties A, B, and C all deposited an asset amount of 100. Now A wants to transfer 20 to B. The payment process of the three-party payment channel off-chain is as follows:
[0087] Step a): A needs to sign the first balance information (A: 80, B: 120, C: 100) and the transfer sequence number nonce (1 at this time, the transfer sequence number can identify the number of transfers, and each transfer automatically increases by 1) to obtain the first signature. The signature algorithm can use ECDSA.
[0088] Step b): A sends the signed first transfer data to B and C offline through the client.
[0089] Step c): B verifies A's signature and checks the balance information sent by A. After confirmation, he signs the first balance information (A: 80, B: 120, C: 100) and the transfer sequence number (1 at this time), and then sends them to A and C.
[0090] Step d): C receives the balance information and transfer sequence number signatures of A and B, and verifies A (first signature) and B's signature (second signature) respectively. After confirmation, they compare the balance tables and transfer sequence numbers of the two parties to see if they are consistent. They sign the balance table and transfer sequence number in unison to obtain the third signature, and save A, B and their own signatures (first signature, second signature) and the transfer sequence number locally. Then they send the third signature to A and B.
[0091] Step e): After A receives the signatures of C and B, he knows that B and C also approve the transaction. He then saves the signatures of B and C.
[0092] Step f): B also receives the signatures of A and C. Knowing that A and C have approved the transaction, B saves the signatures of A and C.
[0093] At this point, the off-chain transfer is successful. In this way, everyone has the latest balance table and transfer sequence number, and the transfer is complete. If there is an error in the signature verification step, you can communicate with the other party to resend, or go directly to step 4) to close the payment channel.
[0094] 4) Close the payment channel:
[0095] After multiple off-chain transfers in step 3), if any of the three parties wants to exit the three-party payment channel and retrieve the assets in the three-party payment channel, the process of closing the three-party payment channel will begin. Note that it is necessary to interact with the on-chain smart contract at this time.
[0096] For example, after multiple transfers, the latest balance table is A: 50 B: 50 C: 200. The transfer sequence number is 10.
[0097] For example, A is the closing party. A calls the closeChannel function to close the three-party payment channel. The channel channeId and the original text and signature of the latest balance table and transfer sequence number of the three parties must be passed in. The signature is the signature of the latest balance table of A: 50B: 50C: 200 and the transfer sequence number of 10.
[0098] The logic of the closeChannel function is as follows:
[0099] The smart contract sets A as the closed party, and B and C as the non-closed parties; the smart contract verifies whether the signatures of A and the other two non-closed parties (B, C) are correct. If incorrect, resubmit. After the smart contract verifies the signatures of A, B, and C uploaded by A and passes, it records the transfer balance table submitted by A (A: 50B: 50C: 200) and sequence number 10.
[0100] Set the channel status of the three-party payment channel to closed.
[0101] After A successfully calls the closeChannel function, the three-party payment channel enters the challenge period. A waits for B and C to verify whether the balance information and transfer sequence number nonce submitted by A are correct.
[0102] 5) The non-closed party updates the balance table (during the challenge period):
[0103] If B and C execute the transaction initiated by A to close the channel, they will also query the channel status of the three-party payment channel to check whether the balance information and transfer sequence number nonce passed in by A are correct. If correct, they will jump directly to step 6.
[0104] If the balance information and transfer sequence number passed by A are problematic, for example, A only passed in the 9th balance information, which is (A: 100B: 0C: 200), and the transfer sequence number is 9. Obviously, the result of this transfer is favorable to A. Then B and C need to call the contract's updateNonClosingBalanceProof function to update the balance information and transfer sequence number recorded in the channel to prevent A from doing evil.
[0105] updateNonClosingBalanceProof is similar to closeChannel. B passes the balance information and the original text of the transfer sequence number in his hand and the signatures of the three participants stored in B to the updateNonClosingBalanceProof function. The updateNonClosingBalanceProof function verifies whether the signature passed in by the caller is correct, and verifies whether the passed in transfer sequence number is greater than the transfer sequence number passed in by the closing party (A). If it is greater, the payment channel contract will update the recorded balance information and transfer sequence number.
[0106] With this design, it is ensured that even if A does evil and uses the three-party signature that was previously favorable to A to change the on-chain balance, B and C are able to correct the situation.
[0107] 6-channel settlement:
[0108] After B and C check the balance, they wait for the challenge period to end, and A calls the settleChannel function to settle the assets in the three-party payment channel. The payment channel contract will automatically transfer the previously pledged assets to A, B, and C according to the recorded balance information, and set the channel status to unclosed. At this point, the life cycle of the three-party payment channel ends.
[0109] Obviously, under the above steps (1) to (6), the transfer process of the three-party payment channel is different from the traditional two-party transfer channel in that the traditional two-party transfer only requires the initiator to sign the balance and then send it to the receiver. The off-chain process of the three-party channel requires that the transferor and the receiver need to sign the balance information each time and send it to the third party. This process ensures that each role has the balance signatures of the other two parties, which prevents any party from doing evil. Since the three participants A, B, and C are in the same three-party payment channel, A can also transfer money to C directly. In this way, the process of relaying transfers is simpler than that of the Raiden Network.
[0110] like Figure 3 As shown, the present invention provides a three-party transfer device, including: a data transmission module 301, which is used to send first transfer data to a second participant and a third participant for any transfer within the life cycle of a three-party payment channel shared by three participants; the first transfer data includes: first balance information, a first transfer sequence number and a first signature; the first balance information includes the expected balance of each of the three participants after this transfer; the first participant is the transferor of this transfer; a processing module 302, which is used to determine that the first balance information and the first transfer sequence number are effective if the data transmission module 301 receives the second transfer data and the third transfer data, thereby completing this transfer; the second transfer data is obtained by the second participant after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third party after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
[0111] Among them, the three parties include a first party, a second party and a third party.
[0112] Optionally, before the first transfer within the life cycle, each of the three participants writes an initial amount in the blockchain; the processing module 302 is also used to: call the first smart contract of the blockchain according to the three-party payment channel and the initial amount of the first participant; the first smart contract is used to bind the initial amount of the first participant to the three-party payment channel, thereby writing the initial amount of the first participant in the three-party payment channel into the blockchain.
[0113] Optionally, the three-party payment channel is generated by transmitting the account addresses of the three parties and the preset expiration time of the life cycle to a second smart contract of the blockchain according to a preset function in the second smart contract.
[0114] Optionally, the processing module 302 is also used for: when the first participant is the closing party of the three-party payment channel, transferring the fourth transfer data to the third smart contract of the blockchain and entering the first challenge period; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; if at the end of the first challenge period, it is determined that the second balance information recorded in the third smart contract has not been updated, then it is determined that the second balance information has taken effect in the blockchain and the life cycle has ended; the data transmission module 301 is also used for: obtaining the assets of the first participant in the corresponding settlement amount in the second balance information from the blockchain.
[0115] Optionally, the processing module 302 is also used for: if during the first challenge period, it is determined that the second balance information recorded in the third smart contract is updated to the third balance information, then it is determined that the first challenge period is updated to the second challenge period; the third balance information is the settlement balance information declared by the second participant or the third participant; if at the end of the second challenge period, it is determined that the third balance information recorded in the third smart contract has not been updated, it is determined that the third balance information has taken effect in the blockchain and the life cycle has ended; obtain the assets of the first participant corresponding to the settlement amount in the third balance information from the blockchain.
[0116] Optionally, when the second participant or the third party is the closing party of the three-party payment channel, and the first party is the non-closing party, the data transmission module 301 is also used to: obtain the third balance information recorded in the third smart contract of the blockchain during the third challenge period; the third balance information is the settlement balance information declared by the second participant or the third party; the third transfer sequence number is the settlement transfer sequence number declared by the second participant or the third party; the processing module 302 is also used to: if the third balance information and / or the third transfer sequence number are not recognized, then during the third challenge period, the fourth transfer data is transmitted to the third smart contract. three smart contracts; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; the third smart contract is used to update the third balance information recorded in the third smart contract to the second balance information, and update the third transfer sequence number recorded in the third smart contract to the second transfer sequence number after the fourth transfer data is verified and the second transfer sequence number and the third transfer sequence number meet the preset relationship, and enter the fourth challenge period.
[0117] Based on the same inventive concept, an embodiment of the present invention further provides a computer device, including a program or instructions. When the program or instructions are executed, the three-party transfer method provided in the embodiment of the present invention and any optional method are executed.
[0118] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, including a program or instructions. When the program or instructions are executed, the three-party transfer method provided in the embodiment of the present invention and any optional method are executed.
[0119] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0120] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A three-party transfer method, characterized in that: include: For any transfer within the life cycle of the three-party payment channel shared by the three parties, the first party sends the first transfer data to the second party and the third party; the first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three parties after this transfer; the first party is the transferor of this transfer; wherein the three-party payment channel is a second smart contract that transmits the account addresses of the three parties and the preset expiration time of the life cycle to the blockchain, and is generated according to the preset function in the second smart contract; If the first participant receives the second transfer data and the third transfer data, it determines that the first balance information and the first transfer sequence number are effective, thereby completing the transfer; the second transfer data is obtained by the second participant after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third participant after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
2. The method according to claim 1, characterized in that Before the first transfer in the life cycle, each of the three participants writes an initial amount into the blockchain; the first participant writes the initial amount of the first participant into the blockchain in the following manner: The first participant calls the first smart contract of the blockchain according to the three-party payment channel and the initial amount of the first participant; The first smart contract is used to bind the initial amount of the first participant to the three-party payment channel, thereby writing the initial amount of the first participant in the three-party payment channel into the blockchain.
3. The method according to claim 1 or 2, characterized in that Also includes: When the first participant is the closing party of the three-party payment channel, the first participant transmits the fourth transfer data to the third smart contract of the blockchain and enters the first challenge period; The fourth transfer data includes: second balance information, a second transfer sequence number and a fourth signature; the second balance information is the settlement balance information declared by the first participant; the second transfer sequence number is the settlement transfer sequence number declared by the first participant; If, at the end of the first challenge period, the first participant determines that the second balance information recorded in the third smart contract has not been updated, the first participant determines that the second balance information has taken effect in the blockchain, and the life cycle ends; The first participant obtains the assets of the first participant corresponding to the settlement amount in the second balance information from the blockchain.
4. The method according to claim 3, characterized in that Also includes: If, during the first challenge period, the first participant determines that the second balance information recorded in the third smart contract is updated to the third balance information, then the first participant determines that the first challenge period is updated to the second challenge period; the third balance information is the settlement balance information declared by the second participant or the third participant; If, at the end of the second challenge period, the first participant determines that the third balance information recorded in the third smart contract has not been updated, the first participant determines that the third balance information has taken effect in the blockchain, and the life cycle ends; The first participant obtains, from the blockchain, assets of the first participant corresponding to the settlement amount in the third balance information.
5. The method according to claim 1 or 2, characterized in that: Also includes: When the second participant or the third participant is the closing party of the three-party payment channel, and the first participant is the non-closing party, during the third challenge period, the first participant obtains the third balance information recorded in the third smart contract of the blockchain; the third balance information is the settlement balance information declared by the second participant or the third participant; the third transfer sequence number is the settlement transfer sequence number declared by the second participant or the third participant; If the first participant does not agree with the third balance information and / or the third transfer sequence number, then within the third challenge period, the first participant transmits fourth transfer data to the third smart contract; the fourth transfer data includes: second balance information, second transfer sequence number and fourth signature; the second balance information is the settlement balance information declared by the first participant; The second transfer sequence number is the settlement transfer sequence number declared by the first participant; the third smart contract is used to update the third balance information recorded in the third smart contract to the second balance information, and update the third transfer sequence number recorded in the third smart contract to the second transfer sequence number, and enter the fourth challenge period after the fourth transfer data is verified and the second transfer sequence number and the third transfer sequence number satisfy a preset relationship.
6. A three-party transfer method, characterized in that: include: For any transfer within the life cycle of the three-party payment channel shared by the three parties, the second party obtains the first transfer data from the first party; The first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three parties after the transfer; the second party is the recipient of the transfer; wherein the three-party payment channel is a second smart contract that transmits the account addresses of the three parties and the preset expiration time of the life cycle to the blockchain, and is generated according to a preset function in the second smart contract; After the second participant verifies the first transfer data, the second participant signs the first balance table and the first transfer sequence number to obtain second transfer data; the second participant sends the second transfer data to the first participant and the third participant; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; If the second participant receives the third transfer data, it is determined that the first balance information and the first transfer sequence number are effective, thereby completing the transfer; the third transfer data is obtained by the third participant after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
7. A three-party transfer method, characterized in that: include: For any transfer within the life cycle of the three-party payment channel shared by the three participants, the third participant obtains the first transfer data from the first participant and the second transfer data from the second participant; the first transfer data includes: first balance information, first transfer sequence number and first signature; the first balance information includes the expected balance of each of the three participants after this transfer; the second transfer data is obtained by the second participant after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; wherein the three-party payment channel is a second smart contract that transmits the account addresses of the three participants and the preset expiration time of the life cycle to the blockchain, and is generated according to the preset function in the second smart contract; After the third party verifies the first transfer data and the second transfer data, the third party signs the first balance information and the first transfer sequence number to obtain third transfer data; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature; The third party sends the third transfer data to the first party and the second party, and determines that the first balance information and the first transfer sequence number are effective, thereby completing the transfer.
8. A three-party transfer device, characterized in that: include: A data transmission module, for sending first transfer data to a second party and a third party for any transfer within the life cycle of a three-party payment channel shared by three parties; the first transfer data includes: first balance information, a first transfer sequence number and a first signature; the first balance information includes the expected balance of each of the three parties after the current transfer; the first party is the transferor of the current transfer; wherein the three-party payment channel is a second smart contract that transmits the account addresses of the three parties and the preset expiration time of the life cycle to the blockchain, and is generated according to a preset function in the second smart contract; A processing module, for determining that the first balance information and the first transfer sequence number are effective if the second transfer data and the third transfer data are received, thereby completing the transfer; the second transfer data is obtained by the second participant after verifying that the first transfer data is passed; the second transfer data includes: the first balance information, the first transfer sequence number and the second signature; the third transfer data is obtained by the third participant after verifying that the first transfer data and the second transfer data are passed; the third transfer data includes: the first balance information, the first transfer sequence number and the third signature.
9. A computer device, characterized in that: The method comprises a program or an instruction. When the program or the instruction is executed, the method according to any one of claims 1 to 5 or 6 or 7 is executed.
Citation Information
Patent Citations
Multidirectional state channel method and system for blockchain extension, and medium
CN110751468A