Background
In recent years, with the proposal and smooth operation of bitcoin systems, blockchain technology, which is the underlying technology of bitcoin, has received attention, and more blockchain-based product disputes have appeared, wherein the appearance of an etherhouse is yet another milestone event of blockchain development, and the most essential difference of the etherhouse from the previously-appearing blockchain system is that the etherhouse supports the operation of intelligent contracts. I.e., in the ether house's cryptocurrency system, allows complex transactions to be conducted via smart contracts. The intelligent contract is a set of digital commitments, which control digital assets and contain the right and obligation agreed by contract participants and is automatically executed by a computer system. The intelligent contract program is not only a computer program capable of being automatically executed, but also a system participant, responds to the received information, and can receive and store the value and send the information and the value to the outside. This program, like a trusted person, can temporarily keep the assets in custody, always operating according to a priori rules.
Currently, the ethernet transactions are account-based, requiring that each transaction be recorded in sequence, and the recorded transaction sequence is characterized by a nonce (number once) value, thereby achieving the purpose of preventing replay attacks. The nonce will be incremented each time the account initiates a transaction. And the rules used by the nonces are as follows:
(1) too little nonce, the transaction may be directly rejected;
(2) too much nonces, transactions will always be in queue;
(3) when a larger nonce value is sent, then the previous nonce is filled in, the transaction will be executed;
(4) the transaction queue only stores a maximum of 64 transactions issued from the same account;
(5) when there are transactions in a certain node queue, but the Etherhouse node is stopped at the moment, the transactions in the queue can be removed;
(6) when the current nonce is proper and the account balance is insufficient, the current nonce is rejected by the Ether house;
(7) if a transaction is initiated but not mined because gas (the unit of measure of computational work, the reward for the ether house miner's packaging block) is low or the network is busy, the previous transaction can be "covered" by using the same nonce and a higher gas fee.
In the ethernet encrypted currency system, the concurrency performance of smart contract transactions is limited by the transactional nature of the ethernet. Generally, the Etherhouse intelligent contracts are mainly used for meeting concurrency requirements in certain scenes by setting multiple accounts (or allocating the same authority to the multiple accounts).
The method is characterized in that multiple account numbers are configured in the intelligent contract to meet concurrent requirements, a series of individual accounts are authorized substantially in a mode of presetting roles and permissions, for the intelligent contract, the accounts are not directly related and cannot represent a specific account, the intelligent contract is greatly immersed, and the intelligent contract needs to be modified so as to adapt to the concurrent requirements under the framework. However, real-world environments generally assume that one account represents one user, and thus the solution is more difficult to promote.
Disclosure of Invention
The invention aims to: aiming at the existing problems, the Etheng intelligent contract method can solve the concurrency problem of the intelligent contract and does not need to change the existing intelligent contract authority framework.
The invention relates to an Ethernet intelligent contract implementation method based on a multi-sign technology, which comprises the following steps:
acquiring an Ether house address of a specified account;
and carrying out multi-sign configuration on the Ethernet house addresses of the specified accounts to obtain a multi-sign contract, wherein the multi-sign configuration is as follows: taking the Ether house addresses of the multiple designated accounts as multiple Ether house addresses and configuring the unlocking private key numbers corresponding to the multiple Ether house addresses; recording the mapping relation between the multi-sign contract and each appointed account;
configuring service invocation permission of the multi-sign contract: assigning the associated rights of the business contract to the multi-sign contract;
the method comprises the following steps of (1) Ethernet shop transaction service calling processing based on a multi-sign contract:
and the multiple appointed accounts send service requests to corresponding multiple contracts, the multiple contracts call the matched service contracts based on the received service requests, and the Ethernet trading industry is completed based on the execution of the service contracts.
Further, the specific steps for assigning the related authority of the service contract to the multi-sign contract are as follows: and searching the business contract of which the Ethernet shop address is matched with the Ethernet shop address included in the multi-sign contract, and replacing the Ethernet shop address in the searched business contract with the multi-sign contract.
Further, when the unlocking private key number corresponding to the multiple ether house addresses is configured, the unlocking private key number and the ether house address number included in the multiple contract are configured according to a proportion equivalent to 1/3, 2/5 or 2/7.
In addition, when the unlocking private key number corresponding to the multi-sign ether house address is configured, the unlocking private key number and the ether house address number included in the multi-sign contract satisfy:
wherein m (m is more than or equal to 1) represents the number of unlocking private keys, and n (n is more than 1) represents the number of Ether house addresses included in the multi-sign contract.
In summary, due to the adoption of the technical scheme, the invention has the beneficial effects that:
the invention manages and uses the service contract by using the multi-sign contract instead of the common account, thereby avoiding the problem of concurrency limit caused by the reason of the Ether house nonce and effectively improving the concurrency performance of the Ether house intelligent contract. And the authority framework of the existing Ether house intelligent contract does not need to be changed, and the concurrency performance requirement of the user on the Ether house intelligent contract is met.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the following embodiments and accompanying drawings.
Referring to fig. 1, when the etherhouse intelligent contract of the present invention is implemented, a three-layer architecture is adopted, and the three-layer architecture sequentially comprises: an account layer, a multi-label layer and a service layer; wherein the content of the first and second substances,
the first layer of account layer is the Ether house address (i.e. common Ether house address) and the private key of the account; the generation process of the ether house address can adopt the following mode:
first, a 256-bit random number is generated as a private key, and then the private key is converted into secp256k1 (specific elliptic curve: y)2=x3+7) the public key in the non-compressed format, that is, the 512-bit public key, then the hash value of the public key is calculated by using a hash algorithm Keccak256, the hash value is converted into a hexadecimal character string, finally, the last 40 letters of the hexadecimal character string are taken, and 0x is added to the beginning of the hexadecimal character string to serve as the ether house address.
The second layer is a multi-sign layer, namely multi-sign contracts, and common Etheng addresses of aggregated accounts are provided; the method comprises the steps of obtaining a corresponding multi-sign contract based on a multi-sign technology (multiple signature technology), and recording the mapping relation between the multi-sign contract and a plurality of specified accounts.
The multiple signature technology is that in the process of generating an address, n private keys are adopted to generate a multiple signature address, and m (m is less than or equal to n) private keys in the multiple signature address are required to be used for using coins in the multiple signature address. The multiple signature address can customize the necessary combination according to the requirement, such as 2/3, that is, a multiple signature address is generated by 3 different private keys, 2 private keys (unlocking private key number) are needed to use the coins in the multiple signature address.
In the specific embodiment, common ether house addresses of a plurality of designated accounts are selected from all accounts to serve as multi-sign ether house addresses, and the number m of unlocking private keys of the multi-sign ether house addresses is configured, so that multi-sign contracts are obtained; and recording the mapping relation between the multi-sign contract and the specified multiple accounts. And when the number of the unlocking private keys is configured, the unlocking private keys can be selected according to
Or
Is set, or is based on
Or
Where n represents the number of accounts. Of course, it can also be based on
And configuring the number m of unlocking private keys.
The third layer of service layer, i.e. service contracts, is responsible for recording and executing specific services.
The three-layer calling relation is as follows: the account layer calls a multi-sign layer, and the multi-sign layer calls a service layer. The account layer calls the multi-sign contracts of the designated accounts obtained by the multi-sign layer; and then, based on the calling of the multi-sign layer to the service layer, the concurrent execution of the corresponding services of the multiple specified accounts corresponding to the multi-sign contract is realized.
Referring to fig. 2, the setting of the account authority based on the multi-sign technology specifically includes:
firstly, configuring a multi-sign contract, adding Ethernet house addresses of a plurality of specified accounts into the multi-sign contract, wherein each Ethernet house address corresponds to one account, and thus adding n accounts to the multi-sign contract; and configures the number of unlocking private keys of the multi-sign contract.
And secondly, distributing the related authority of the service contract (namely the execution authority of a certain service of the service contract) to the multi-sign contract, namely replacing the common Ethernet house address corresponding to the service contract by the multi-sign contract.
Namely, the invention has no invasive behavior to the original intelligent contract, and the original contract does not need any upgrading operation.
Referring to fig. 3, the service invocation processing procedure of the present invention specifically includes:
firstly, a multi-account simultaneously initiates a service request to a multi-sign contract, namely, the multi-account concurrently calls the multi-sign contract to execute a service;
and secondly, calling a service contract according to the request of the account by the multi-sign contract to complete the service.
Because the problem of nonce conflict does not exist among the accounts, when multiple accounts are used in a concurrent mode, if calling of one account fails, execution of other accounts cannot be affected, and therefore concurrence performance of the intelligent contracts of the etherhouses is improved.
Examples
Taking the application of a coupon contract based on ERC-721 (Non-homogeneous Token (Non-fluent Token)) as an example, it is assumed that a service provider sends a coupon to a system account at a coupon issuing stage, and when a customer meets a certain condition, the system can send the coupon to the customer, and for this application scenario, when the method for implementing the concurrent intelligent agreement of the ether house based on the multi-sign technology of the present invention is applied, the system account can be set as multiple accounts, and by using the method for implementing the intelligent agreement of the ether house of the present invention, the system account can send the coupon to multiple customers concurrently without performing serialization, thereby improving the concurrent performance of the coupon contract, and the specific implementation process is as follows:
step 1: configuring customer conditions under which coupons can be obtained;
step 2: inquiring accounts meeting the configured customer conditions to obtain a coupon dispatching account set;
and step 3: setting the system account as a multi-sign account related to the coupon delivery account set, namely obtaining the multi-sign Ethernet shop address of the system account based on the Ethernet shop address of each account in the coupon delivery account set; configuring the number of unlocking private keys of the multi-sign ether house address to obtain a multi-sign contract of a corresponding system account, namely, taking an account meeting a preset account screening condition as a specified account, thereby configuring the corresponding multi-sign contract based on a plurality of specified accounts;
and 4, step 4: assigning the associated rights to the business contract to the multi-sign contract;
and 5: the system account initiates a service request about coupon delivery based on the multi-sign contract, and the service contract realizes the service of coupon delivery based on the multi-sign contract.
While the invention has been described with reference to specific embodiments, any feature disclosed in this specification may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise; all of the disclosed features, or all of the method or process steps, may be combined in any combination, except mutually exclusive features and/or steps.