A payment-based off-chain transaction method
By building payment settlements in the payment channel network, selecting high stability user sets for transactions, and dynamically adjusting the reputation of the payment channel, the problems of high deposits and frequent transactions in the payment channel network are solved, and the effect of reducing deposits and transactions is achieved. Improve transaction efficiency and success rate.
Patent Information
- Application Number
- CN202210261343.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-03-16
AI Technical Summary
The existing payment channel network has high user deposits and many on-chain transactions, resulting in high transaction costs and low efficiency, and it is difficult to widely popularize.
Using off-chain transaction method based on payment settlement, the payment settlement is constructed by selecting the set of users with the greatest stability, allocating transaction fees, dynamically adjusting the reputation of the payment channel to reduce the dissolution rate, reducing blockchain transactions, and using the deposit in the payment settlement for direct use trade.
It reduces user deposits, reduces the number of on-chain transactions, increases transaction volume and success rate, and reduces system costs and transaction number submitted to the blockchain.
Smart Images

Figure CN114677218B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain and payment channel network, and specifically relates to an off-chain transaction method based on payment knots between multiple users in a payment channel network. Background Art
[0002] Bitcoin has become increasingly popular and has attracted many applications due to its ability to transfer funds through a trustless, distributed, and global financial network. Bitcoin's adoption has experienced rapid growth, resulting in a rapid increase in the number of Bitcoin transactions per day. The core of blockchain lies in decentralization, and all transaction information is confirmed by the entire network, which makes it highly secure. However, it is this full-network confirmation mechanism that makes its information processing inefficient. Due to the limitations of the blockchain consensus mechanism, the maximum transaction rate of Bitcoin is only 7 transactions per second. Such a throughput is much lower than that of centralized payment systems such as VISA or Papal. Payment channel networks provide off-chain settlement of transactions and are one of the most promising solutions to the blockchain scalability problem. Since payment channels reduce the number of transactions that otherwise require blockchain authentication, payment channels can significantly increase transaction rates, which actually only depends on the network bandwidth between users, rather than the blockchain consensus mechanism. In addition, transactions in payment channels do not require the direct services of blockchain miners. Therefore, payment channel networks can conduct transactions at low transaction costs and economically implement small payments.
[0003] However, some fundamental issues of the payment channel network remain unresolved. Creating or dissolving a payment channel requires submitting a transaction to the blockchain. The number of on-chain transactions increases as the number of channels increases, so how to reduce the number of on-chain transactions? The user's deposit in the payment channel determines the ability of its payment channel to transfer funds. Therefore, it is very important for users to deposit sufficient deposits in each of their payment channels. However, if users deposit a large amount of deposits in the payment channel, the financial burden will also increase accordingly. These financial pressures also hinder the widespread establishment of payment channels. Therefore, how to reduce users' deposits is also a question of practical significance.
[0004] The invention with patent number CN112995298A mentions a communication method and storage medium based on blockchain, which increases the robustness of the communication system through a decentralized and competitive node system, reduces the operating costs of the system, realizes the reuse of infrastructure, and uses multiple communication channels to effectively avoid interception of information. However, the patent does not involve the technical issues of reducing user deposits and reducing the number of transactions on the chain.
[0005] The invention with patent number CN112258171A mentions a blockchain-based off-chain payment center routing method, system, medium, and equipment. In view of the current problems of low transaction performance of blockchain payment channel network, unbalanced channel capital flow, and channel capacity limiting the transaction amount, the routing scheme of the payment channel center in the blockchain payment channel network and the channel capital flow rate control technology are studied to achieve large-amount transactions in low-capacity channels and achieve high transaction throughput without breaking the channel balance. The patent also does not involve the technical issues of reducing user deposits and reducing the number of on-chain transactions.
[0006] The invention with patent number CN113763163A mentions a blockchain payment channel network transaction fee allocation method and system, which allocates funds according to the degree of interest in the path node, and reasonably allocates the fees of each intermediate path node under the condition of the transaction path and fee of the given payment channel transaction, thereby attracting more path nodes to join, making the overall network more robust, and achieving the purpose of improving the transaction efficiency of the blockchain network. Similarly, the patent does not involve the technical issues of reducing user deposits and reducing the number of transactions on the chain. Summary of the invention
[0007] Technical problems to be solved: How to reduce user deposits, reduce the number of on-chain transactions, and effectively increase transaction volume.
[0008] Technical solution:
[0009] An off-chain transaction method based on payment knot, the off-chain transaction method comprising the following steps:
[0010] S1, input the user set U that requests to establish a payment knot, select n users from the set U to form a payment knot with maximum stability as the constraint, regard the formed payment knot as a node in the payment channel, and distribute transaction fees according to the user's contribution to the payment knot;
[0011] Among them, all users in the same payment knot trade directly with each other, and users in the payment knot are allowed to use all deposits in the payment knot to trade with other users in the same payment knot; n is a positive integer greater than or equal to 3, and the contribution of users in the payment knot is greater than 0;
[0012] S2, with the optimization goal of minimizing the sum of the length and weight of the transaction path, selects nodes one by one to build payment channels for transactions; the weight of each payment channel is inversely proportional to the reputation of the channel;
[0013] S3, with minimizing the dissolution rate of payment knots as the optimization goal, dynamically adjusts the reputation of the payment channel according to the number of transaction rounds and transaction results to reduce the motivation of users to exit the payment knot, reduce the maintenance cost of the payment knot, increase the stability of the payment knot, and reduce the number of transactions submitted to the blockchain due to the opening and closing of the payment knot.
[0014] Furthermore, in step S1, taking maximum stability as the optimization goal, the process of selecting n users from the set U to form a payment settlement includes the following steps:
[0015] S11, for a payment settlement with n users k , S k ={v1,v2,...v n},v i Is the payment settlement k The stability of the i-th user in , i = 1, 2, ... n, is defined as: Among them, ε1, ε2, α, β are positive constants, c k (n) is a payment system with n users. k The cost function of
[0016] S12, initialize the final selected user set
[0017] S13, find all subsets of the user set U, and the number of elements in each subset is not less than 3;
[0018] S14, according to the stability formula defined in step S11, calculate the stability of all subsets obtained in step S13, and record the set with the greatest stability as S k ;
[0019] S15, output the final user set S k .
[0020] Furthermore, in step S1, if user v i The deposit in the payment settlement is a i,k , the deposit outside the payment settlement is b i,k , user v i The contribution of min(a i,k ,b i,k ), min(a i,k ,b i,k )>0.
[0021] Furthermore, in step S1, the process of allocating transaction fees according to the user's contribution to the payment settlement includes the following steps:
[0022] For each transaction fee F, let the number of people participating in the transaction in the payment process be m, and user vi The income obtained through distribution is Wherein, m is less than or equal to n.
[0023] Furthermore, the topological structure of the payment channel network is assumed to be a directed graph G = (V, E); where V represents the set of users, E represents the set of payment channels; each 1000 transactions is defined as a round; any payment channel e i,j The reputation in round r is and The greater the reputation, the higher the possibility that the channel will be selected by the route. The reputation of a payment channel is 0 when it is just established. The method for changing and updating the reputation of any payment channel is as follows:
[0024] (1) Starting from the third round, when a payment channel does not execute any transactions after a round of transactions, the reputation of the payment channel is changed to:
[0025] (2) If a payment channel is selected during routing and the payment channel refuses to execute a transaction or does not execute a transaction for other reasons, the reputation of the payment channel is changed to: Where ζ is the success rate of transactions executed by the channel;
[0026] (3) If a payment channel successfully executes a transaction, the reputation of the payment channel changes to: Where d is the path length of the transaction.
[0027] Furthermore, in the payment channel network G = (V, E), where V represents the set of users and E represents the set of payment channels; define user v i To user v j The weight of the payment channel between them in round r is In the formula, is the reputation of the channel, θ is a positive constant; For user v i The weight table saved locally records the number of user v after h hops. i To user v j The minimum weight of For user v i The routing table saved locally records the user v i To user v j The next hop user on the path; N(v i ) indicates user v i A set of neighbor nodes;
[0028] With the optimization goal of minimizing the length and weight of the transaction path, the process of selecting nodes one by one to build a payment channel for transactions includes the following steps:
[0029] S21, input payment channel network G and transaction request transaction = (v s ,v t ,a),v s is the sender of the transaction, v r is the recipient of the transaction, and a is the transaction amount;
[0030] S22, for each user in the payment channel network, execute the initialization algorithm and set the user v i For any user v j ∈V weight table Broadcast to N(v i );
[0031] S23, when the user's update distance h<|V|-1, execute the update algorithm for each user in the payment channel network until h=|V|-1; update the updated user v i For any user v j ∈V weight table Broadcast to N(v i ); |V| is the number of all nodes in the payment channel network;
[0032] S24, yes The value of is judged: if The value of is infinite, that is, no suitable path is found to complete the transaction, the algorithm ends and returns an empty path; if Execute step S25;
[0033] S25, according to v s Routing table in Take out the next hop user, and then according to the next hop user v i Routing table Take out the user at the next hop, and repeat this process until the user at the next hop is v t , add these extracted users to the final path;
[0034] S26, output the final selected path.
[0035] Furthermore, in step S22, for each user in the payment channel network, the process of executing the initialization algorithm includes the following steps:
[0036] S221, input payment channel network G and any user v i ;
[0037] S222, initializing the value of the update distance h to 1;
[0038] S223, for all v j ∈V, if edge e i,j Existence, will Assignment, the assignment method is as follows: when v i =v j When , the user overlaps with himself, When v j ∈N(v i )season At the same time If it is not the case, the two users are unreachable.
[0039] S224, user v i For any user v j ∈V weight table Broadcast to N(v i ).
[0040] Furthermore, in step S23, when the user's update distance h<|V|-1, the process of executing the update algorithm for each user in the payment channel network includes the following steps:
[0041] S231, input user v i and weight table where v j ∈V,v k ∈N(v i );
[0042] S232, for all users v j ∈V, record if And b i,j ≥a, then let if or b i,j <a, then let
[0043] S233, set h=h+1;
[0044] S234, weight table Broadcast to N(v i ), where v j ∈V.
[0045] Furthermore, for a payment settlement with n users, k , the cost of establishment and dissolution is c k (n) = γ × (32 × (n + 1) + 64 × 2) = γ × (32 × n + 160), where γ is the conversion factor for converting bytes to money; user v i The cost is
[0046] The present invention proposes a method for improving off-chain transactions through payment knots. In the present invention, the payment knot method is formalized. The present invention proposes detailed methods for creating, trading, dissolving, and routing payment knots. In the payment knot, the present invention proposes the concept of user contribution to distribute profits and calculate the stability of the payment knot. The present invention also proposes a reputation system to describe the reputation of the payment channel in the payment channel network system. In the payment knot, if a user does not execute a transaction for a long time, the user cannot obtain benefits, and the user's motivation to exit the payment knot will continue to increase. In order to reduce the motivation of users to exit the payment knot, according to the reputation system, the present invention designs a routing algorithm with an incentive mechanism, so that users who are relatively marginal in the payment knot also have a greater probability of executing transactions. Using the payment knot method of the present invention, in the payment channel network of the blockchain, the transaction success rate can be improved, the total deposit of users in the payment channel network can be reduced, and the number of transactions published on the blockchain due to the dissolution of the payment channel can be reduced. In addition, the payment knot can increase the transaction volume without an additional channel balancing mechanism.
[0047] Beneficial effects:
[0048] First, reduce user deposit: In the payment channel network, if user v i Want to use the same amount τ i To trade directly with other n-1 users, you must establish a channel with other users, and the deposit required for each channel is at least τ i Therefore, the total deposit of the user in the payment channel network is (n-1)τ i In the payment process, since a user can use his internal deposit to trade directly with any other n-1 users, the required deposit is τ i Therefore, compared with the payment channel, the deposit saved is (n-2)τ i .
[0049] Second, increase user transaction volume: In the payment channel, if user v i A channel is established with n-1 other users, and the deposit in each channel is τ i , then the total deposit is (n-1)τ i If the total deposit is deposited into the payment node, the internal deposit that can be used is (n-1)τ i Compared with the original payment channel, the deposit amount that can be used for transfer in the payment knot is significantly larger than that in the payment channel. Therefore, in the payment knot, users can obtain more transaction volume than in the original payment channel.
[0050] Third, reduce user costs: According to the calculation formula of user costs: As the number of people in the payment process increases, the cost to users becomes lower and lower.
[0051] Fourth, reduce the number of transactions submitted to the blockchain: In the payment channel network, when n users decide to create and dissolve a payment knot, only two transactions are submitted to the blockchain, including the creation of the payment knot and the dissolution of the payment knot. On the other hand, if these n users want to trade directly without a payment knot, they need to establish n(n-1) / 2 channels, and then n(n-1) transactions will be submitted to the blockchain. Therefore, the payment knot can significantly reduce the number of transactions submitted to the blockchain. Compared with the original payment channel, the number of transactions submitted to the blockchain is reduced by n(n-1)-2. As the number of users increases, more transactions can be avoided from being submitted to the blockchain.
[0052] Fifth, routing advantage: When any route passes through the payment knot, no matter what the exact path inside the payment knot is, only two users' internal deposits will change: the user who transferred funds into the payment knot and the user who transferred funds out of the payment knot. Therefore, in the payment knot, no additional channel balancing work is required to balance the deposits of the intermediate nodes, which can reduce the system overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 Flow chart of the user selection algorithm in the payment settlement of the present invention.
[0054] Figure 2 This is the process of creating a payment settlement in the present invention.
[0055] Figure 3 This is a diagram showing a situation where a payment settlement cannot be created.
[0056] Figure 4 This is the flow chart of the routing algorithm.
[0057] Figure 5 This is the initialization algorithm flow chart.
[0058] Figure 6 To update the algorithm flow chart.
[0059] Figure 7 The flowchart of the off-chain transaction method based on payment knot of the present invention. DETAILED DESCRIPTION
[0060] The following examples will enable those skilled in the art to more fully understand the present invention, but are not intended to limit the present invention in any way.
[0061] Figure 7 This is a flow chart of the off-chain transaction method based on payment knot of the present invention. Figure 7 , the off-chain transaction method includes the following steps:
[0062] S1, input the user set U that requests to establish a payment knot, take maximum stability as the optimization goal, select n users from the set U to form a payment knot, regard the constructed payment knot as a node in the payment channel, and distribute transaction fees according to the user's contribution to the payment knot.
[0063] Among them, all users in the same payment knot trade directly with each other, and users in the payment knot are allowed to use all deposits in the payment knot to trade with other users in the same payment knot; n is a positive integer greater than or equal to 3, and the contribution of users in the payment knot is greater than 0.
[0064] S2, with the optimization goal of minimizing the sum of the length and weight of the transaction path, selects nodes one by one to build payment channels for transactions; the weight of each payment channel is inversely proportional to the reputation of the channel.
[0065] S3, with minimizing the dissolution rate of payment knots as the optimization goal, dynamically adjusts the reputation of the payment channel according to the number of transaction rounds and transaction results to reduce the motivation of users to exit the payment knot, reduce the maintenance cost of the payment knot, increase the stability of the payment knot, and reduce the number of transactions submitted to the blockchain due to the opening and closing of the payment knot.
[0066] In this embodiment, the payment knot is part of the payment channel network and follows special deposit usage rules. All users in the same payment knot can trade directly with each other without the need for additional routing, and a user can use all his deposits in the payment knot to perform a transaction. This embodiment defines the stability of the payment knot to describe the state of the payment knot. At the same time, a user selection algorithm is designed based on the stability to calculate the user set when the payment knot has the maximum stability. Let the set of users who request to establish a payment knot be U. Using the user selection algorithm, n users are selected from the set U to form a payment knot. The user set of the kth payment knot created by n users in the payment channel network is S k ={v1,v2,...v n}. For S k Any user v i , where i = 1, 2, ... n, the deposit in the payment is a i,k , the deposit outside the payment settlement is b i,k The amount of funds that a user can transfer in a payment settlement depends on a i,k and b i,k The minimum value of . Define user v i The contribution of min(a i,k ,b i,k ). This embodiment requires that when creating a payment settlement k Afterwards, user v i ∈S kThe contribution of i,k ,b i,k )>0. If the contribution requirement is not met, the creation process will fail.
[0067] The specific steps of the user selection algorithm include:
[0068] Step 1.1: For a payment settlement with n users k , stability is defined as: Among them, ε1, ε2, α, β are positive constants, c k (n) is the cost function of establishing a payment network with n users.
[0069] Step 1.2: Initialize the final selected user set Let the set of users who participate in creating the payment settlement be U.
[0070] Step 1.3: Find all subsets of set U, and the number of elements in the subset must be no less than 3.
[0071] Step 1.4: According to the stability formula defined in step 1.1, calculate the stability of all subsets found in step 1.3, and record the set with the greatest stability as S k .
[0072] Step 1.5: Output the final user set S k .
[0073] When a transaction passes through the payment settlement, that is, when the user in the payment settlement receives the transaction fee, this embodiment distributes the transaction fee according to the user's contribution to the payment settlement. This embodiment only distributes the income (transaction fee) to the users who participated in the transaction. According to the defined user contribution, for each transaction fee F, assuming that the number of people participating in the transaction in the payment settlement is m, then user v i The income obtained through distribution is
[0074] In the payment settlement, this embodiment proposes the concept of user contribution to distribute profits and calculate the stability of the payment settlement. Using the payment settlement method of this embodiment, in the payment channel network of the blockchain, the transaction success rate can be improved, the total deposit of users in the payment channel network can be reduced, and the number of transactions published on the blockchain due to the dissolution of the payment channel can be reduced. In addition, the payment settlement can increase the transaction volume without an additional channel balancing mechanism.
[0075] In the payment process, if a user does not execute a transaction for a long time, the user will not be able to obtain benefits, and the user's motivation to exit the payment process will continue to increase.
[0076] When a user in a payment knot exits, the payment knot will be dissolved. This embodiment estimates the cost of creation and dissolution, i.e., the user's cost, based on the number of bytes occupied by transactions published to the blockchain for creation and dissolution. When a user creates a payment knot, a 64-byte total signature is required; when dissolving a payment knot, a 64-byte total signature, a 32-byte user public key, and a 32-byte fund transaction public key are required. Therefore, the total number of bytes of the settlement transaction is 32×(n+1)+64 bytes. For a payment knot with n users, k , the cost of establishment and dissolution is c k (n) = γ × (32 × (n + 1) + 64 × 2) = γ × (32 × n + 160), where γ is the conversion factor for converting bytes to money. User v i The cost is
[0077] In order to reduce the motivation of users to exit the payment knot, according to the defined concept of reputation, this embodiment designs a routing algorithm with an incentive mechanism, so that users who are relatively marginal in the payment knot also have a greater probability of executing transactions, reducing the motivation of users to exit the payment knot, reducing the maintenance cost of the payment knot, increasing the stability of the payment knot, and reducing the number of transactions submitted to the blockchain due to the opening and closing of the payment knot.
[0078] Assume that the topological structure of the payment channel network is a directed graph G = (V, E); where V represents the set of users and E represents the set of payment channels; define each 1000 transactions as a round; any payment channel e i,j The reputation in round r is and The greater the reputation, the higher the possibility that the channel will be selected by the route. The reputation of a payment channel is 0 when it is just established. The method of changing and updating reputation is as follows:
[0079] (1) After a round of transactions, if the channel does not execute any transactions, we determine that the channel is a relatively marginal channel and need to improve the reputation of the channel to increase the possibility of the channel being selected by the route. Therefore, the reputation of the channel will increase with the increase of the number of transaction rounds: The increase starts from the third round.
[0080] (2) If the channel is selected during routing and the channel refuses to execute the transaction or does not execute the transaction for other reasons, the reputation of the payment channel will be reduced as a penalty. When reducing the reputation, the success rate of transactions executed by the channel is used as a reference. The reputation of the channel changes as follows: Where ζ is the success rate of transactions executed by the channel.
[0081] (3) If the channel successfully executes a transaction, the channel’s reputation will increase as a reward: Where d is the path length of the transaction.
[0082] In the payment channel network G, user v i In the payment channel i,j The deposit in is b i,j ; Define the weight of each payment channel as Where θ is a positive constant; For user v i The weight table saved locally records the number of user v after h hops. i To user v j The minimum weight of For user v i The routing table saved locally records the user v i To user v j The next hop user on the path is used to track the transaction path; N(v i ) indicates user v i A collection of neighbor nodes.
[0083] The goal of the routing algorithm with incentive mechanism is to minimize the sum of the length and weight of the transaction path; given a transaction request transaction = (v s ,v t ,a),v s is the sender of the transaction, v t is the recipient of the transaction, a is the transaction amount, and the specific steps of the routing algorithm with incentive mechanism are as follows:
[0084] Step 2.1: Input the payment channel network G and the transaction request transaction = (v s ,v t ,a).
[0085] Step 2.2: For each user in the payment channel network, execute the initialization algorithm.
[0086] Step 2.3: When the user's update distance h<|V|-1, execute the update algorithm for each user in the payment channel network.
[0087] Step 2.4: If The value of is infinite, that is, no suitable path is found to complete the transaction, the algorithm ends and returns an empty path; if Perform step 2.5.
[0088] Step 2.5: According to v s Routing table in Take out the next hop user, and then according to the next hop user v i Routing table Take out the user at the next hop, and repeat this process until the user at the next hop is v t , add these extracted users to the final path.
[0089] Step 2.6: Output the final selected path.
[0090] In step 2.2, the specific steps of the initialization algorithm are as follows:
[0091] Step 3.1: Input the payment channel network G and any user v i .
[0092] Step 3.2: Initialize the value of the update distance h to 1.
[0093] Step 3.3: For all v j ∈V, if edge e i,j exists, then it will Assignment, the assignment method is as follows: when v i =v j , the user overlaps with himself, so When v j ∈N(v i )season At the same time If it is neither of the above two cases, the two users are unreachable, so
[0094] Step 3.4: Set user v i For any user v j ∈V weight table Broadcast to N(v i ).
[0095] In step 2.3, the specific steps of the update algorithm are as follows:
[0096] Step 4.1: Enter user v i and weight table where v j ∈V,v k ∈N(v i ).
[0097] Step 4.2: For all users v j ∈V, record if And b i,j ≥a, then let if or b i,j <a, then let
[0098] Step 4.3: Let h=h+1.
[0099] Step 4.4: Add the weight table Broadcast to N(v i ), where v j ∈V.
[0100] Examples
[0101] 1: Creation of payment knot.
[0102] Assume that users v1, v2, v3, v4, and v9 want to create a payment solution. The selection steps are as follows: Figure 1 As shown, the creation process is as follows Figure 2 As shown, the final selected users are v1, v2, v3, and v4. Therefore, the set of users of the first payment node created in the payment channel network is S1 = {v1, v2, v3, v4}; for any user v in S i , the deposits for i=1,2,3,4 are: a 1,1 =5,b 1,1 =4, a 2,1 =6,b 2,1 =8,a 3,1 =7,b 3,1 =5, a 4,1 =5,b 4,1 = 5. The contribution value of each user in the payment is: v1: min(5,4) = 4, v2: min(6,8) = 6, v3: min(7,5) = 5, v4: min(5,5) = 5.
[0103] For user v1, if the traditional payment channel is used, v1 may want to complete a transaction with one of v2, v3, and v4 with a transaction amount of 5. In order to meet v1's needs, user v1 needs to deposit a deposit of 5 in the payment channels (v1, v2), (v1, v3), and (v1, v4) respectively. Then the total deposit deposited by user v1 in the payment channel network is 15. If the payment knot is used, the user needs to deposit a deposit of 5, and can complete the transaction with v2, v3, and v4. Therefore, the deposit that user v1 can save is 10.
[0104] like Figure 3 As shown, after the payment knot is created, the contribution of v2 is 0. In this case, the payment knot is not allowed to be created.
[0105] In the above transaction, assume that the handling fee charged to each user is 1. The users involved in this transaction are v1 and v3. According to the contribution of users v1 and v3 in step 1.1, and the profit calculation formula: It can be calculated that the benefit of user v1 is: The benefits of user v3 are:
[0106] When creating a payment settlement, the specific steps for the user to select the algorithm are as follows:
[0107] Step 1.1: For a payment settlement with n users k , whose stability is defined as: Let ε1, ε2, α, β be positive constants, and their values are 1, 1, 1, 0.7 respectively. k (n) is the cost function of establishing a payment network with n users.
[0108] Step 1.2: Initialize the final selected user set Suppose the set of users who participate in creating a payment settlement is U = {v1, v2, v3, v4, v9}, where a 1,1 =5,b 1,1 =4, a 2,1 =6,b 2,1 =8,a 3,1 =7,b 3,1 =5, a 4,1 =5,b 4,1 =5, a 9,1 =1,b 9,1 =1.
[0109] Step 1.3: The number of elements in all subsets of set U is not less than 3. The subsets are: {v1,v2,v3},{v1,v2,v4},{v1,v2,v9},{v1,v3,v4},{v1,v3,v9},{v1,v4,v9},{v2,v3,v4},{v2,v3,v9},{v2,v4,v9},{v3,v4,v9},{v1,v2,v3,v4},{v1,v3,v4,v9},{v1,v2,v4,v9},{v1,v2,v3,v9},{v2,v3,v4,v9},{v1,v2,v3,v4,v9}.
[0110] Step 1.4: According to the stability calculation formula in step 1.1, calculate the stability of all subsets in step 1.3: 178.3, 178.3, 174.3, 178.3, 173.3, 173.3, 179.3, 175.3, 175.3, 174.3, 181.6, 176.6, 177.6, 177.6, 178.6, 179.5. Therefore, the set with the greatest stability is {v1, v2, v3, v4}.
[0111] Step 1.5: Output the final user set S k ={v1,v2,v3,v4}.
[0112] The total cost function of the payment knot is c k (n) = γ × (32 × n + 160), where γ = 0.1. Figure 2 , when the payment structure S1 of the four users is dissolved, according to the cost function of a single user It can be seen that the cost per user is If a traditional payment channel is established, the cost per user is Therefore, by using payment gateway, users can save 4.
[0113] In addition, when the payment channel of these four users is dissolved, only two transactions will be published on the blockchain. On the other hand, if these four users want to trade directly without payment settlement, they need to establish 6 channels, and 12 transactions will be submitted to the blockchain. Compared with the original payment channel, the number of transactions submitted to the blockchain has been reduced by 10.
[0114] 2: Reputation system.
[0115] like Figure 2 As shown in the figure, it is assumed that the payment settlement is established in the third cycle, and no transactions have passed through the payment channel. After the payment settlement is established, Figure 2 The reputation of each payment channel in is as follows: The reputation of the payment channel in the payment knot is 0. If a transaction transaction=(v5,v7,1) is successful, and the transaction path is (v5,v1), (v1,v3), (v3,v7), then the reputation of the payment channel on the path changes as follows: After this, if a transaction transaction=(v5,v7,1) fails, and the transaction path is (v5,v1), (v1,v3), (v3,v7), then the payment channel transaction success rate on the path is 50%, and their reputation changes are as follows:
[0116] The network topology of the payment channel is as follows: Figure 2 As shown. Let θ = 1, then the weights of each payment channel are as follows: The weights of the remaining payment channels are all 1. Now given a payment request transaction = (v5, v8, 1), the flow chart of the routing algorithm is as follows Figure 4 , the specific steps are as follows:
[0117] Step 2.1: Input the payment channel network G = (V, E) and the transaction request transaction = (v5, v8, 1).
[0118] Step 2.2: For each user in the payment channel network, execute the initialization algorithm, which requires calling steps 3.1-3.5. After the execution, the user's local weight table is shown in Table 1, and the routing table is shown in Table 2.
[0119] Step 2.3: When the user's update distance h is less than 7, the update algorithm is executed for each user in the payment channel network. Step 4.14.4 needs to be called to update the weight table and routing table. After the update, the final results of the two tables are shown in Tables 3 and 4.
[0120] Step 2.4: According to Table 3, the path is reachable, so proceed to step 2.5.
[0121] Step 2.5: According to Table 4, the values taken out are v5, v1, v4, and v8.
[0122] Step 2.6: Output the path (v5,v1), (v1,v4), (v4,v8).
[0123] Table 1: Initialization weight table
[0124]
[0125] Table 2: Initialization routing table
[0126]
[0127]
[0128] Table 3: Final weight table
[0129]
[0130] Table 4: Final routing table
[0131]
[0132]
[0133] The initialization algorithm in step 2.2 will be executed once for each user. The flowchart of the initialization algorithm is as follows: Figure 5 As shown, we take user v1 as an example. The specific steps are as follows:
[0134] Step 3.1: Input the payment channel network G = (V, E) and user v1.
[0135] Step 3.2: Initialize the traversal distance h to 1, and the set of v1’s neighbor nodes is: {v5,v2,v3,v4}.
[0136] Step 3.3: For all users, the weight value must be calculated. Here, user v2 is taken as an example.1,2 exists, and the two users are not the same, so W1 3 (1,2)=1+1=2; the final assignment results of the weight table and routing table of user v1 are shown in Table 1 and Table 2.
[0137] Step 3.4: Broadcast the weight table to users v2, v3, v4, and v5.
[0138] The update algorithm in step 2.3 will be executed multiple times in the loop. The flowchart of the algorithm is as follows: Figure 6 As shown, we take user v1 when h = 2 as an example, the specific steps of the algorithm are as follows:
[0139] Step 4.1: Input user v1 and weight table W2 3 (v k ,v j ), where v j ∈V,v k ∈N(v1).
[0140] Step 4.2: For all users, the weight value and routing table must be calculated. Let's take user v6 as an example. When the traversal distance from v1 to v6 is 2, the deposit in the channel meets the capacity constraint, and the two users become reachable from being unreachable. Therefore, the weights from v1 to v6 in the weight table of user v1 are updated to
[0141] Step 4.3: Let h=3.
[0142] Step 4.4: Set the weight table W3 3 (v k ,v j ) is broadcast to users v2, v3, v4, and v5, where v j ∈V,v k ∈N(v1).
[0143] According to the above content, the present invention can also be modified in different ways; the subject matter disclosed in the present invention can be implemented in different forms and examples, and the present application can be applied to a large number of applications; all applications, modifications and changes claimed in the claims belong to the scope of the present application.
Claims
1. A payment-based off-chain transaction method, characterized in that: The off-chain transaction method The following steps are involved: S1, input the user set U that requests to establish a payment knot, take maximum stability as the optimization goal, select n users from the set U to form a payment knot, regard the formed payment knot as a node in the payment channel, and distribute transaction fees according to the user's contribution to the payment knot; Among them, all users in the same payment knot trade directly with each other, and users in the payment knot are allowed to use all the deposits in the payment knot to trade with other users in the same payment knot; n is a positive integer greater than or equal to 3, and the contribution of users in the payment knot is greater than 0; S2, with the optimization goal of minimizing the sum of the length and weight of the transaction path, selects nodes one by one to build payment channels for transactions; the weight of each payment channel is inversely proportional to the reputation of the channel; S3, with the optimization goal of minimizing the dissolution rate of payment knots, dynamically adjusts the reputation of the payment channel according to the number of transaction rounds and transaction results; Assume that the topological structure of the payment channel network is a directed graph G = (V, E); where V represents the set of users and E represents the set of payment channels; define each 1000 transactions as a round; any payment channel e i,j The reputation in round r is and The greater the reputation, the higher the possibility that the channel will be selected by the route. The reputation of a payment channel is 0 when it is just established. The method for changing and updating the reputation of any payment channel is as follows: (1) Starting from the third round, when a payment channel does not execute any transactions after a round of transactions, the reputation of the payment channel is changed to: (2) If a payment channel is selected during routing and the payment channel refuses to execute a transaction or does not execute a transaction for other reasons, the reputation of the payment channel is changed to: Where ζ is the success rate of transactions executed by the channel; (3) If a payment channel successfully executes a transaction, the reputation of the payment channel changes to: Where d is the path length of the transaction; In the payment channel network G = (V, E), where V represents the set of users and E represents the set of payment channels; define user v i To user v j The weight of the payment channel between them in round r is In the formula, is the reputation of the channel, θ is a positive constant; For user v i The weight table saved locally records the number of user v after h hops. i To user v j The minimum weight of For user v i The routing table saved locally records the user v i To user v j The next hop user on the path; N(v i ) indicates user v i A set of neighbor nodes; With the optimization goal of minimizing the length and weight of the transaction path, the process of selecting nodes one by one to build a payment channel for transactions includes the following steps: S21, input payment channel network G and transaction request transaction = (v s ,v t ,a),v s is the sender of the transaction, v r is the recipient of the transaction, and a is the transaction amount; S22, for each user in the payment channel network, execute the initialization algorithm and set the user v i For any user v j ∈V weight table Broadcast to N(v i ); S23, when the user's update distance h<|V|-1, execute the update algorithm for each user in the payment channel network until h=|V|-1; update the updated user v i For any user v j ∈V weight table Broadcast to N(v i ); |V| is the number of all nodes in the payment channel network; S24, yes The value of is judged: if The value of is infinite, that is, no suitable path is found to complete the transaction, the algorithm ends and returns an empty path; if Execute step S25; S25, according to v s Routing table in Take out the next hop user, and then according to the next hop user v i Routing table Take out the user at the next hop, and repeat this process until the user at the next hop is v t , add these extracted users to the final path; S26, output the final selected path.
2. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: In step S1, the process of selecting n users from the set U to form a payment settlement with maximum stability as the optimization goal includes the following steps: S11, for a payment settlement with n users k , S k ={v1,v2,...v n },v i Is the payment settlement k The stability of the i-th user in , i = 1, 2, ... n, is defined as: Among them, ε1, ε2, α, β are positive constants, c k (n) is a payment structure with n users. k The cost function of S12, initialize the final selected user set S13, find all subsets of the user set U, and the number of elements in each subset is not less than 3; S14, according to the stability formula defined in step S11, calculate the stability of all subsets obtained in step S13, and record the set with the greatest stability as S k ; S15, output the final user set S k .
3. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: In step S1, if user v i The deposit in the payment settlement is a i,k , the deposit outside the payment settlement is b i,k , user v i The contribution of min(a i,k ,b i,k ), min(a i,k ,b i,k )>0.
4. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: In step S1, the process of allocating transaction fees according to the user's contribution to the payment settlement includes the following steps: For each transaction fee F, let the number of people participating in the transaction in the payment process be m, and user v i The income obtained through distribution is Wherein, m is less than or equal to n.
5. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: In step S22, for each user in the payment channel network, the process of executing the initialization algorithm includes the following steps: S221, input payment channel network G and any user v i ; S222, initializing the value of the update distance h to 1; S223, for all v j ∈V, if edge e i,j Existence, will The assignment is as follows: when v i =v j When , the user overlaps with himself, When v j ∈N(v i )season At the same time If it is not the case, the two users are unreachable. S224, user v i For any user v j ∈V weight table Broadcast to N(v i ).
6. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: In step S23, when the user's update distance h<|V|-1, the process of executing the update algorithm for each user in the payment channel network includes the following steps: S231, input user v i and weight table where v j ∈V,v k ∈N(v i ); S232, for all users v j ∈V, record if And b i,j ≥a, then let if or b i,j <a, then let S233, set h=h+1; S234, weight table Broadcast to N(v i ), where v j ∈V.
7. The off-chain transaction method based on payment knot according to claim 1 is characterized in that: For a payment settlement with n users k , the cost of establishment and dissolution is c k (n) = γ × (32 × (n + 1) + 64 × 2) = γ × (32 × n + 160), where γ is the conversion factor for converting bytes to money; user v i The cost is
