A blockchain account operation method, node device and storage medium
By using smart contracts to perform permission detection in blockchain networks, the problem of low permission detection efficiency is solved, and more efficient and diverse permission management is achieved.
Patent Information
- Application Number
- CN201911149892.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-21
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2039-11-21
AI Technical Summary
In the prior art, when permission detection is performed by calling the blockchain underlying permission control module, the compilation process takes a long time, resulting in low permission detection efficiency.
By writing permission management-related contracts into smart contracts in advance in the blockchain network, and calling the smart contract directly for permission detection during the permission detection process, the diversity of permission detection methods is increased and compilation time is saved.
It improves the efficiency of permission detection, increases the diversity of permission detection methods, and improves the flexibility and security of permission management.
Smart Images

Figure CN111222109B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain account operation method, a node device, and a storage medium. Background Art
[0002] Blockchain technology has the characteristics of decentralization, block data is basically tamper-proof, and trustlessness, and is considered to be a subversion of the computer model after the Internet.
[0003] Permission management is the core content of blockchain. Currently, it is mainly detected by calling the permission control module at the bottom of the blockchain to determine whether a terminal has operation permissions. However, in the process of calling the permission control module for permission detection, the permission control module needs to be compiled. The compilation process will consume a long time, resulting in low permission detection efficiency. Summary of the Invention
[0004] The embodiments of the present invention provide a blockchain account operation method, a node device, and a storage medium, which can not only improve the efficiency of authority detection, but also increase the diversity of authority detection methods.
[0005] In one aspect, an embodiment of the present invention provides a method for operating a blockchain account, the method comprising:
[0006] Receive an operation request for a target account in the blockchain network sent by a client, wherein the operation request carries the requested target operation;
[0007] Calling a first smart contract related to the target account in the blockchain network to detect whether the client has operation authority for the target account, and obtaining a detection result;
[0008] If the detection result indicates that the client has the operation permission for the target account, the target operation is performed on the target account.
[0009] In one embodiment, the method further includes: if the detection result indicates that the client does not have the operation authority for the target account, broadcasting a message to the nodes in the blockchain network that the operation request does not have the authority; and / or, adding an unauthorized identifier to the operation request in the blockchain network.
[0010] In one embodiment, the calling of the first smart contract related to the target account in the blockchain network to detect whether the client has the operation authority for the target account, and obtaining the detection result, includes:
[0011] Invoking a first smart contract related to the target account in the blockchain network to obtain an authorization list of the target account, the authorization list including multiple authorization identifiers that have operation permissions for the target account;
[0012] Invoking a first smart contract related to the target account in the blockchain network to detect whether the identifier of the client is an authorized identifier in the authorization list;
[0013] If so, a detection result is obtained indicating that the client has the operation authority for the target account; if not, a detection result is obtained indicating that the client does not have the operation authority for the target account.
[0014] In one embodiment, the method further comprises: adding an execution completed flag to the first smart contract related to the target account in the blockchain network after calling the first smart contract related to the target account in the blockchain network to detect whether the client has the operation authority for the target account.
[0015] In one embodiment, the method further includes: when the authorization list of the target account changes, publishing a second smart contract related to the changed target account in the blockchain network.
[0016] In one embodiment, the method further includes: when receiving an operation request for the changed target account sent by the client, calling the second smart contract to detect whether the client has the operation authority for the changed target account, and obtaining a detection result.
[0017] In one embodiment, the change in the authorization list of the target account includes adding an authorization identifier to the authorization list, or removing an authorization identifier from the authorization list. In one embodiment, the target operation includes any one of the following: reading resource data from the target account, transferring resource data to the target account, or transferring resource data from the target blockchain account.
[0018] On the other hand, an embodiment of the present invention provides a blockchain account operation device, including a unit for executing the above-mentioned blockchain account operation method. Specifically, the device includes:
[0019] A transceiver unit, configured to receive an operation request sent by a client for a target account in a blockchain network, wherein the operation request carries the requested target operation;
[0020] A detection unit, configured to call a first smart contract related to the target account in the blockchain network to detect whether the client has operation authority over the target account, and obtain a detection result;
[0021] A processing unit is configured to perform the target operation on the target account if the detection result indicates that the client has the operation permission on the target account.
[0022] On the other hand, an embodiment of the present invention provides a node device, including: a processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are interconnected, wherein the memory stores an executable program code, and the processor is used to call the executable program code to execute the above-mentioned blockchain account operation method.
[0023] Accordingly, an embodiment of the present invention further provides a storage medium, which stores instructions that, when executed on a computer, enable the computer to execute the above-mentioned blockchain account operation method.
[0024] The embodiment of the present invention, upon receiving an operation request for a target account in the blockchain network sent by a client, calls a first smart contract in the blockchain network to detect whether the client has the operation authority for the target account, and if the client has the operation authority for the target account, performs the target operation requested by the operation request on the target account, thereby realizing permission detection using smart contracts, which can not only improve the efficiency of permission detection, but also increase the diversity of permission detection methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.
[0026] Figure 1 This is a schematic diagram of the architecture of a blockchain network provided by an embodiment of the present invention;
[0027] Figure 2 This is a schematic diagram of the architecture of a distributed system provided by an embodiment of the present invention;
[0028] Figure 3 This is a schematic diagram of the structure of a blockchain block provided by an embodiment of the present invention;
[0029] Figure 4 This is a flowchart of a method for operating a blockchain account provided by an embodiment of the present invention;
[0030] Figure 5 This is a flowchart of a permission detection method provided by an embodiment of the present invention;
[0031] Figure 6 This is a schematic diagram of the structure of a blockchain account operating device provided by an embodiment of the present invention;
[0032] Figure 7 It is a structural diagram of a node device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0034] With the advent of the technological age and the development of mobile internet, the pace of network transformation is accelerating. The process of achieving information integration within or across multiple fields and providing clients with comprehensive information solutions also faces new challenges, such as architectural improvements and a shift in support priorities. Therefore, blockchain technology, as a specific implementation of distributed ledgers, has gradually become the preferred method for storing and transacting data in various fields, leveraging its inherent advantages in data storage and management.
[0035] by Figure 1 The following is an example of the blockchain network architecture diagram shown in Figure 1. Figure 1 As shown, the node devices in the blockchain network may include banks, insurance companies, government buildings, shops, schools, and hospitals. Banks, insurance companies, government buildings, shops, schools, and hospitals all participate in the management and processing of the same blockchain network, and can also participate in supervising the legality of transactions to achieve fairness in the blockchain network's processing or storage of transaction data. At the same time, the above-mentioned banks, insurance companies, government buildings, shops, schools, and hospitals all belong to different fields. The fusion and interaction of information from different fields can better improve the quality and efficiency of social work. Any node device in the blockchain network can verify the acquired transaction data. When the verification result is successful, a block can be generated based on the transaction data (such as Figure 1 The block shown in the figure is published to the blockchain so that other node devices in the blockchain network can perform distributed storage of the block. Figure 1 As shown, the node devices in the blockchain network may include banks, insurance companies, government buildings, shops, schools and hospitals, and banks, insurance companies, government buildings, shops, schools and hospitals can store the identity information of the same user A in a distributed manner, so the user A can query his or her identity information at any institution.
[0036] The embodiment of the present invention provides a distributed system, which can be formed by connecting a client and multiple node devices (any form of computing devices in the access network, such as servers and user terminals) through network communication. Taking the distributed system as a blockchain system as an example, see Figure 2 , Figure 2 This is an optional architectural diagram of a distributed system provided by an embodiment of the present invention applied to a blockchain system (or blockchain network), consisting of a client and multiple node devices. The node devices form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP). In a distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer. The client can also be a node device in the blockchain network.
[0037] See also Figure 2 The functions of each node in the blockchain system shown include:
[0038] 1) Routing: A basic function of a node, used to support communication between nodes.
[0039] In addition to the routing function, nodes can also have the following functions:
[0040] 2) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.
[0041] See also Figure 3 , Figure 3 This is an optional schematic diagram of the block structure provided by an embodiment of the present invention. Each block includes the hash value of the data stored in the block (the hash value of the current block) and the hash value of the previous block. The blocks are connected by hash values to form a blockchain. In addition, the block may also include information such as the timestamp when the block was generated. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0042] 3) Applications are deployed in the blockchain to implement specific services based on actual business needs. They record data related to the implementation of the functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they will add the record data to a temporary block.
[0043] For example, the services implemented by the application include:
[0044] 3.1) Wallet: This is used to provide the functionality for conducting electronic resource transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. Upon successful verification by other nodes, the transaction record data is stored in a temporary block of the blockchain as a response to acknowledge the transaction validity). The wallet also supports querying the remaining electronic resources in the electronic resource address.
[0045] 3.2) Shared ledgers are used to store, query, and modify account data. Records of operations on account data are sent to other nodes in the blockchain system. After verification, other nodes acknowledge the validity of the account data by storing the recorded data in a temporary block. They can also send a confirmation to the node that initiated the operation.
[0046] 3.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that is executed when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of a buyer's purchased goods and transferring the buyer's electronic resources to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts that process received information.
[0047] Furthermore, rights management is a core aspect of blockchain technology. Currently, the primary method for checking whether a client has permission to operate a blockchain account is to call the underlying rights control module of the blockchain. However, calling the rights control module to perform rights checks on the client requires compiling the rights control module, which consumes considerable time and results in inefficient rights checking. Based on this, an embodiment of the present invention provides a method for operating a blockchain account, comprising the following steps: receiving an operation request from a client for a target account in a blockchain network, the operation request carrying a requested target operation, such as reading resource data from the target account, transferring resource data to the target account, or transferring resource data from the target blockchain account; calling a first smart contract associated with the target account in the blockchain network to check whether the client has permission to operate the target account; and, if the client has permission to operate the target account, executing the target operation on the target account. This method increases the diversity of rights checking methods by pre-programming rights management contracts into the smart contract and directly calling the smart contract for rights checking during the subsequent rights checking process. Furthermore, it saves compilation time and improves rights checking efficiency, as described in detail below.
[0048] See also Figure 4 , Figure 4The flowchart of the method for operating a blockchain account provided by an embodiment of the present invention is as follows. The method for operating a blockchain account described in the embodiment of the present invention can be applied to a node device, which can be Figure 2 Any node device of the blockchain network in the distributed system shown. In other embodiments, the node device is an optimal node device determined based on the load status, response time, and distance between each node device in the blockchain network and the client. The operation method of the blockchain account described in the embodiment of the present invention includes:
[0049] S401: Receive an operation request for a target account in a blockchain network sent by a client, where the operation request carries a requested target operation.
[0050] In this embodiment of the present invention, the target account is a blockchain account in a blockchain network; the target operation requested by the operation request may be operations such as reading resource data from the target account, transferring resource data into the target account, or transferring resource data out of the target blockchain account. Upon receiving an operation request for the target account from a client, the node device may immediately obtain the requested target operation contained in the operation request; or it may subsequently obtain the requested target operation from the operation request upon detecting that the client has permission to operate the target account.
[0051] S402: Call a first smart contract related to the target account in the blockchain network to detect whether the client has operation authority for the target account, and obtain a detection result.
[0052] In an embodiment of the present invention, the first smart contract is a permissions management contract previously published in the blockchain network and associated with the target account, which can be used for permission detection. In one embodiment, a node device invokes the first smart contract associated with the target account in the blockchain network to obtain the target account's authorization list, which contains multiple authorization identifiers that grant operation permissions to the target account. The authorization identifier is the identifier of a terminal that grants operation permissions to the target account; the identifier can be a string that uniquely identifies the terminal, such as the terminal's IP address or MAC address, or the identifier can be obtained by processing the string through encryption, hashing, and signing. The terminal can be a node device in the blockchain network.
[0053] Furthermore, the node device calls the first smart contract to detect whether the identifier of the client that initiates the operation request is an authorization identifier in the authorization list. The identifier of the client can be a character string that can uniquely identify the client, such as the client's IP address or MAC address, or the character string obtained after encryption, hash algorithm, signature, etc. The calculation method of the client identifier is consistent with the above-mentioned authorization identifier. If it is detected that the identifier of the client is an authorization identifier in the authorization list, a detection result indicating that the client has the operation authority for the target account is obtained, and step S403 is executed. If it is detected that the identifier of the client is not an authorization identifier in the authorization list, a detection result indicating that the client does not have the operation authority for the target account is obtained.
[0054] In one embodiment, if the detection result indicates that the client does not have permission to operate the target account, the node device will publish the operation request to the blockchain and broadcast a message to the nodes in the blockchain network indicating that the operation request does not have permission, and / or add an unauthorized identifier to the operation request in the blockchain network. This method is conducive to the subsequent rapid verification of whether the target operation requested by the operation request has been executed. In other embodiments, if the detection result indicates that the client does not have permission to operate the target account, the node device can reject the client's operation request for the target account and send a prompt message to the client indicating that the operation failed.
[0055] In another embodiment, after receiving an operation request for a target account from a client, the node device publishes the operation request to the blockchain. After the publication is complete, the node device calls the first smart contract to detect whether the client has the operation permission for the target account and obtains the detection result. This method can achieve on-chain permission detection, which has higher credibility than off-chain permission detection, thereby improving the security of blockchain accounts.
[0056] In one embodiment, the node device calls the first smart contract to detect whether the client has the authority to operate the target account. After obtaining the detection result, the node device adds an execution completion mark to the first smart contract related to the target account in the blockchain network. Alternatively, when the detection result indicates that the client has the authority to operate the target account, the node device adds an execution completion mark to the first smart contract related to the target account in the blockchain network. After the first smart contract is marked as executed, it will not be executed again. In this way, the permission management contract is made time-sensitive, which can prevent the permission management contract from being tampered with to a certain extent, thereby further improving the security of the blockchain account.
[0057] S403: If the detection result indicates that the client has the operation permission for the target account, perform the target operation on the target account.
[0058] For example, the target operation is to read the resource balance in the target account, the node device reads the resource balance in the target account, and sends the acquired resource balance to the client. For another example, the target operation is to transfer a first amount of resources into the target account, the node device adds the first amount to the resource balance in the target account, and sends the updated resource balance to the client. For another example, the target operation is to transfer a second amount of resources from the target account, the node device subtracts the second amount from the resource balance in the target account, and sends the updated resource balance to the client. Wherein, the node device can read the resource balance in the target account before transferring resources from the target account, and detect whether the resource balance is greater than or equal to the second amount; when the resource balance is greater than or equal to the second amount, the node device subtracts the second amount from the resource balance in the target account. When the resource balance is less than the second amount, the node device rejects the operation request to transfer resources from the target account, and sends a prompt message to the client indicating that the operation failed. In other embodiments, after a node device rejects a request to transfer resources from a target account, it publishes the request to transfer resources from the target account to the blockchain, broadcasts a message indicating that the request was not responded to to all nodes in the blockchain network, and / or adds an unresponsive flag to the request in the blockchain network. This facilitates subsequent rapid verification of whether the requested resource transfer was executed.
[0059] The embodiment of the present invention increases the diversity of permission detection methods by writing the contracts related to permission management into the smart contract in advance, and directly calling the smart contract to perform permission detection in the subsequent permission detection process; in addition, the smart contract runs on a virtual machine, which can save compilation time to a certain extent, thereby improving the efficiency of permission detection.
[0060] In other embodiments, a node device receives an operation request sent by a client for a target account in a blockchain network, the operation request carrying the requested target operation; calls a first smart contract related to the target account in the blockchain network to detect whether the client has permission to operate the target account, and obtains a detection result; if the detection result indicates that the client has permission to operate the target account, calls the first smart contract to detect whether the client has permission to perform the target operation on the target account; if so, performs the target operation on the target account. Otherwise, refuses to perform the target operation on the target account.
[0061] In one embodiment, when a client does not have permission to operate a target account, or does not have permission to perform a target operation on the target account, the node device receives a permission granting request from the client, requesting permission to perform the target operation on the target account. The node device then invokes the first smart energy contract to grant the client permission to perform the target operation on the target account. Specifically, the node device may add the client's identifier to the target account's authorization list. In other embodiments, before invoking the first smart energy contract to grant the client permission to perform the target operation on the target account, the node device checks whether the client's identifier is in a target list, which includes the identifiers of multiple terminals that cannot be granted permission to operate the target account. If the client's identifier is not in the target list, the node device determines, based on a preset permission group, whether the permission to perform the target operation on the target account is in the preset permission group; permissions in the preset permission group are permissions that can be automatically granted to operate the target account. If the permission to perform the target operation on the target account is in the preset permission group, the node device invokes the first smart energy contract to grant the client permission to perform the target operation on the target account. Through the above method, the permission management contract written into the smart contract can also realize the permission granting function.
[0062] In another embodiment, when a client has permission to perform a target operation on a target account, a node device receives a permission revocation request from the client, requesting the revocation of the client's permission to perform the target operation on the target account, or revoking the client's permission to operate the target account. In response to the permission revocation request, the node device invokes the first smart contract to revoke the client's permission to perform the target operation on the target blockchain account, or revoke the client's permission to operate the target account. Revoking the client's permission to operate the target account may specifically involve removing the client's identifier from the target account's authorization list. In other embodiments, if the node device detects that the client poses a security risk, it automatically invokes the first smart contract to revoke the client's permission to operate the target blockchain account. The node device may detect whether the client poses a security risk based on client-related data in the blockchain network, or it may determine that the client poses a security risk upon receiving a message broadcast by another node device indicating that the client poses a security risk. In this manner, the permission management contract embedded in the smart contract can also implement permission revocation.
[0063] In other embodiments, the method for operating a blockchain account in the embodiment of the present invention may also include: Figure 5 The following steps are shown:
[0064] S501. When the authorization list of the target account changes, publish a second smart contract related to the changed target account in the blockchain network.
[0065] In an embodiment of the present invention, a change in the authorization list of the target account includes adding a new authorization identifier to the authorization list, or reducing an authorization identifier in the authorization list; the changed authorization list contains one or more authorization identifiers that have operation permissions for the target account; the second smart contract is related to the changed target account and is a permission management contract that can be used for permission detection, permission granting, and permission revocation.
[0066] In one embodiment, before or after publishing a second smart contract associated with the changed target account on the blockchain network, a node device checks whether the first smart contract has been marked as executed. If the first smart contract has not been marked as executed, an invalidation flag is added to the first smart contract. After the invalidation flag is added to the first smart contract, it will no longer be executed. This approach can avoid selection conflicts between smart contracts.
[0067] S502: When receiving an operation request for the changed target account from the client, calling the second smart contract to detect whether the client has the operation authority for the changed target account, and obtaining a detection result.
[0068] In an embodiment of the present invention, the node device calls the second smart contract to obtain the changed authorization list of the target account, and calls the second smart contract to detect whether the identifier of the client that initiates the operation request is the authorization identifier in the changed authorization list. If it is detected that the identifier of the client is the authorization identifier in the changed authorization list, a detection result indicating that the client has the operation authority for the changed target account is obtained, and the operation requested by the operation request is performed on the changed target account. If it is detected that the identifier of the client is not the authorization identifier in the changed authorization list, a detection result indicating that the client does not have the operation authority for the changed target account is obtained, and the client's operation request for the changed target account is rejected, and a prompt message indicating that the operation failed is sent to the client.
[0069] By adopting the above method, when the authorization list of the target account changes, a new permission management contract can be reissued, and the new permission management contract can be used to respond to new operation requests. In this way, the permission management contract related to the target account in the blockchain network can be updated when the update conditions are met, making the permission management contract timely and more in line with actual needs. It can also prevent the permission management contract from being tampered with to a certain extent, thereby further improving the security of the blockchain account.
[0070] The embodiment of the present invention, upon receiving an operation request for a target account in the blockchain network sent by a client, calls a smart contract in the blockchain network to detect whether the client has the operation authority for the target account, and if the client has the operation authority for the target account, performs the target operation requested by the operation request on the target account, thereby realizing permission detection using smart contracts, which can not only improve the efficiency of permission detection, but also increase the diversity of permission detection methods.
[0071] See also Figure 6 , Figure 6 A schematic diagram of the structure of a blockchain account operation device provided in an embodiment of the present invention. The blockchain account operation device described in the embodiment of the present invention is applied to the node device in the above method embodiment, and the device includes:
[0072] The transceiver unit 601 is configured to receive an operation request for a target account in the blockchain network sent by a client, wherein the operation request carries the requested target operation;
[0073] A detection unit 602 is configured to call a first smart contract related to the target account in the blockchain network to detect whether the client has operation authority over the target account, and obtain a detection result;
[0074] The processing unit 603 is configured to perform the target operation on the target account if the detection result indicates that the client has the operation permission on the target account.
[0075] In one embodiment, the transceiver unit 601 is further configured to broadcast a message indicating that the operation request does not have permission to the nodes in the blockchain network if the detection result indicates that the client does not have permission to operate the target account;
[0076] The processing unit 603 is further configured to add an unauthorized identifier to the operation request in the blockchain network.
[0077] In one embodiment, the detection unit 602 is specifically configured to:
[0078] Invoking a first smart contract related to the target account in the blockchain network to obtain an authorization list of the target account, where the authorization list includes multiple authorization identifiers that have operation permissions for the target account; invoking the first smart contract related to the target account in the blockchain network to detect whether the identifier of the client is an authorization identifier in the authorization list; if so, obtaining a detection result indicating that the client has the operation permission for the target account; if not, obtaining a detection result indicating that the client does not have the operation permission for the target account.
[0079] In one embodiment, the processing unit 603 is further configured to add an execution completion flag to the first smart contract related to the target account in the blockchain network.
[0080] In one embodiment, the processing unit 603 is further configured to:
[0081] When the authorization list of the target account changes, a second smart contract related to the changed target account is published in the blockchain network.
[0082] In one embodiment, the detection unit 602 is further configured to:
[0083] When the transceiver unit 601 receives the operation request for the changed target account sent by the client, it calls the second smart contract to detect whether the client has the operation authority for the changed target account, and obtains the detection result.
[0084] In one embodiment, the change in the authorization list of the target account includes adding an authorization identifier to the authorization list, or reducing an authorization identifier in the authorization list.
[0085] In one embodiment, the target operation includes any one of the following:
[0086] Read resource data from the target account, transfer resource data into the target account, and transfer resource data out of the target blockchain account.
[0087] It can be understood that the functions of each functional unit of the operating device of the blockchain account in the embodiment of the present invention can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0088] The embodiment of the present invention, upon receiving an operation request for a target account in the blockchain network sent by a client, calls a smart contract in the blockchain network to detect whether the client has the operation authority for the target account, and if the client has the operation authority for the target account, performs the target operation requested by the operation request on the target account, thereby realizing permission detection using smart contracts, which can not only improve the efficiency of permission detection, but also increase the diversity of permission detection methods.
[0089] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of a node device provided in an embodiment of the present invention. The node device described in this embodiment of the present invention includes: a processor 701, a communication interface 702, and a memory 703. The processor 701, communication interface 702, and memory 703 can be connected via a bus or other means. This embodiment of the present invention uses a bus connection as an example.
[0090] Among them, the processor 701 (or CPU (Central Processing Unit)) is the computing core and control core of the node device, which can parse various instructions in the node device and process various data of the node device. For example, the CPU can transmit various interactive data between the internal structures of the node device, and so on. The communication interface 702 may optionally include a standard wired interface, a wireless interface (such as Wi-Fi, mobile communication interface, etc.), which is controlled by the processor 701 to send and receive data. The memory 703 (Memory) is a memory device in the node device, which is used to store programs and data. It can be understood that the memory 703 here can include the built-in memory of the node device, and of course it can also include the extended memory supported by the node device. The memory 703 provides storage space, which stores the operating system of the node device, which may include but is not limited to: Android system, iOS system, Windows Phone system, etc., and the present invention is not limited to this.
[0091] In the embodiment of the present invention, the processor 701 performs the following operations by running the executable program code in the memory 703:
[0092] An operation request for a target account in a blockchain network sent by a client is received through the communication interface 702, wherein the operation request carries the requested target operation; a first smart contract related to the target account in the blockchain network is called to detect whether the client has the operation permission for the target account, and obtain a detection result; if the detection result indicates that the client has the operation permission for the target account, the target operation is performed on the target account.
[0093] In one embodiment, the processor 701 is further configured to: if the detection result indicates that the client does not have the authority to operate the target account, broadcast a message indicating that the operation request does not have the authority to operate to the nodes in the blockchain network through the communication interface 702; and / or, add an identifier indicating that the operation request does not have the authority to operate in the blockchain network.
[0094] In one embodiment, the processor 701 calls the first smart contract related to the target account in the blockchain network to detect whether the client has the operation permission for the target account. When the detection result is obtained, it is specifically used to: call the first smart contract related to the target account in the blockchain network to obtain the authorization list of the target account, where the authorization list contains multiple authorization identifiers that have the operation permission for the target account; call the first smart contract related to the target account in the blockchain network to detect whether the identifier of the client is an authorization identifier in the authorization list; if so, obtain a detection result indicating that the client has the operation permission for the target account; if not, obtain a detection result indicating that the client does not have the operation permission for the target account.
[0095] In another embodiment, the processor 701 calls the first smart contract related to the target account in the blockchain network to detect whether the client has the operation authority for the target account. After obtaining the detection result, it is also used to: add an execution completion mark to the first smart contract related to the target account in the blockchain network.
[0096] In one embodiment, the processor 701 is further configured to:
[0097] When the authorization list of the target account changes, a second smart contract related to the changed target account is published in the blockchain network.
[0098] In one embodiment, the processor 701 is further configured to:
[0099] When an operation request for the changed target account sent by the client is received through the communication interface 702, the second smart contract is called to detect whether the client has the operation authority for the changed target account, and obtain a detection result.
[0100] In one embodiment, the change in the authorization list of the target account includes adding an authorization identifier to the authorization list, or removing an authorization identifier from the authorization list. In one embodiment, the target operation includes any one of the following: reading resource data from the target account, transferring resource data to the target account, or transferring resource data from the target blockchain account.
[0101] In a specific implementation, the processor 701, communication interface 702, and memory 703 described in the embodiment of the present invention can execute the implementation of the node device described in the method for operating a blockchain account provided in an embodiment of the present invention, and can also execute the implementation described in the device for operating a blockchain account provided in an embodiment of the present invention, which will not be repeated here.
[0102] The embodiment of the present invention, upon receiving an operation request for a target account in the blockchain network sent by a client, calls a smart contract in the blockchain network to detect whether the client has the operation authority for the target account, and if the client has the operation authority for the target account, performs the target operation requested by the operation request on the target account, thereby realizing permission detection using smart contracts, which can not only improve the efficiency of permission detection, but also increase the diversity of permission detection methods.
[0103] An embodiment of the present invention also provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the blockchain account operation method as described in the embodiment of the present invention.
[0104] An embodiment of the present invention also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method for operating a blockchain account as described in an embodiment of the present invention.
[0105] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0106] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0107] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the rights of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A method for operating a blockchain account, characterized in that: The method comprises: Receive an operation request from a client for a target account in a blockchain network, the operation request carrying the requested target operation; and publish the operation request to the blockchain; Invoking a first smart contract related to the target account in the blockchain network to perform an on-chain permission check to detect whether the client has the operation permission for the target account, and obtaining a detection result; the first smart contract runs on a virtual machine; If the detection result indicates that the client has the permission to operate the target account, the first smart contract is called to perform an on-chain permission check. If it is detected that the client has the permission to perform the target operation on the target account, the target operation is performed on the target account. If the on-chain permission check determines that the client has an abnormality, the first smart contract is called to revoke the client's permission to operate the target account. If the detection result indicates that the client does not have the permission to operate the target account, or the client does not have the permission to perform the target operation on the target account, then Broadcasting a message indicating that the operation request does not have the authority to the nodes in the blockchain network; adding an unauthorized identifier to the operation request in the blockchain network; If a permission granting request is received from the client, the permission granting request is used to request that the client be granted permission to perform the target operation on the target account, and the identifier of the client is not in the target list, and the permission to perform the target operation on the target account is a permission in a preset permission group, then the first smart contract is called to grant the client permission to perform the target operation on the target account, the target list includes identifiers of terminals that cannot be granted permission to operate the target account, and the permissions in the preset permission group are permission to operate the target account that can be automatically granted; an execution completed mark is added to the first smart contract related to the target account in the blockchain network; the first smart contract with the execution completed mark will not be executed again subsequently; When the authorization list of the target account changes, a second smart contract related to the changed target account is published in the blockchain network; before or after publishing the second smart contract, if it is detected that the first smart contract has not been marked as executed, an invalid flag is added to the first smart contract; when the second smart contract receives an operation request for the changed target account from the client, it is used to detect whether the client has the operation permission for the changed target account through on-chain permission detection, and obtain a detection result.
2. The method according to claim 1, wherein The calling of the first smart contract related to the target account in the blockchain network to detect whether the client has the operation authority for the target account, and obtaining the detection result includes: Invoking a first smart contract related to the target account in the blockchain network to obtain an authorization list of the target account, the authorization list including multiple authorization identifiers that have operation permissions for the target account; Invoking a first smart contract related to the target account in the blockchain network to detect whether the identifier of the client is an authorized identifier in the authorization list; If so, a detection result is obtained indicating that the client has the operation authority for the target account; if not, a detection result is obtained indicating that the client does not have the operation authority for the target account.
3. The method according to claim 1 or 2, wherein: The change in the authorization list of the target account includes adding an authorization identifier to the authorization list, or reducing an authorization identifier from the authorization list.
4. The method according to claim 1, wherein The target operation includes any one of the following: reading resource data in the target account, transferring resource data into the target account, and transferring resource data out of the target account.
5. A blockchain account operating device, characterized in that: The device comprises: A transceiver unit, configured to receive an operation request sent by a client for a target account in a blockchain network, the operation request carrying the requested target operation; and publish the operation request to the blockchain; a detection unit, configured to call a first smart contract related to the target account in the blockchain network to perform an on-chain permission check to detect whether the client has the operation permission for the target account, and obtain a detection result; the first smart contract runs on a virtual machine; a processing unit configured to, if the detection result indicates that the client has the permission to operate the target account, call the first smart contract to perform an on-chain permission check; and when it is detected that the client has the permission to perform the target operation on the target account, perform the target operation on the target account; and when it is determined through the on-chain permission check that the client has an abnormality, call the first smart contract to revoke the client's permission to operate the target account; The transceiver unit is further configured to, if the detection result indicates that the client does not have the operation authority for the target account, or the client does not have the authority to perform the target operation on the target account, broadcast a message to the nodes in the blockchain network indicating that the operation request does not have the authority; The processing unit is further configured to add an identifier of not having authority to the operation request in the blockchain network; if a permission granting request sent by the client is received, the permission granting request is used to request that the client be granted authority to perform the target operation on the target account, and the identifier of the client is not in the target list, and the authority to perform the target operation on the target account is a permission in a preset permission group, then calling the first smart contract to grant the client authority to perform the target operation on the target account, the target list includes identifiers of terminals that cannot be granted operation permissions on the target account, and the permissions in the preset permission group are operation permissions on the target account that can be automatically granted; adding an execution completed identifier to the first smart contract related to the target account in the blockchain network; the first smart contract with the execution completed identifier added will not be executed again subsequently; when the authorization list of the target account changes, publishing a second smart contract related to the changed target account in the blockchain network; before or after publishing the second smart contract, if it is detected that the first smart contract does not have an execution completed identifier added, adding an invalid identifier to the first smart contract; The detection unit is further configured to, upon receiving an operation request for the changed target account sent by the client, detect whether the client has the operation authority for the changed target account through on-chain authority detection, and obtain a detection result.
6. The blockchain account operating device according to claim 5, characterized in that: The detection unit is further configured to call a first smart contract related to the target account in the blockchain network to obtain an authorization list of the target account, wherein the authorization list includes multiple authorization identifiers that have operation permissions for the target account; A first smart contract related to the target account in the blockchain network is called to detect whether the identifier of the client is an authorization identifier in the authorization list; if so, a detection result indicating that the client has the operation authority for the target account is obtained; if not, a detection result indicating that the client does not have the operation authority for the target account is obtained.
7. The blockchain account operating device according to claim 5 or 6, characterized in that: The change in the authorization list of the target account includes adding an authorization identifier to the authorization list, or reducing an authorization identifier from the authorization list.
8. The blockchain account operating device according to claim 5, characterized in that: The target operation includes any one of the following: reading resource data in the target account, transferring resource data into the target account, and transferring resource data out of the target account.
9. A node device, characterized in that: include: A processor, a communication interface, and a memory, wherein the processor, the communication interface, and the memory are interconnected, wherein the memory stores an executable program code, and the processor is used to call the executable program code to execute the blockchain account operation method according to any one of claims 1 to 4.
10. A storage medium, characterized in that: The storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method for operating a blockchain account according to any one of claims 1 to 4.
11. A computer program product comprising instructions, characterized in that When the method is run on a computer, the computer is enabled to execute the method for operating a blockchain account as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Service request responding method, device and system
CN104301140A
Resource value transfer method and device, storage medium and server
CN107862526A
Access authentication method and device
CN108537549A
Data reading and writing method and device and electronic equipment
CN110020542A
Permissions using blockchain
US20180248880A1