Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The intelligent agent creates an unprecedented digital currency form, namely the bitcoin, is unique in solving the problem of data consistency among a plurality of dynamic nodes under the condition of no central coordination, and shows the great value of the block chain technology. The block chain is used as a unique distributed database and has natural advantages of distributed safety, non-tampering, uniqueness, non-reversibility and the like. The characteristics of blockchain technology make more and more fields focus on the application of blockchains. In the field of internet of things, the block chain technology can be applied to ensuring the accuracy of data sources and the safe transmission and storage of data. Specific examples include, but are not limited to, the following application scenarios: the environmental data such as temperature, humidity, PM2.5 concentration and the like acquired by the environmental sensor in public places are transmitted and stored through the block chain, so that the data acquired by the meteorological bureau are safer and more reliable. Water meters, electric meters, gas meters and the like in the home are connected into a block chain network, and automatic payment of life resource consumption can be realized. The door lock of the house is accessed into the block chain network, the transfer of the door lock control right and the sharing of the house can be realized through the intelligent contract of the block chain, the delivery of rent is realized through the block chain network, and wider sharing economy is realized. Aiming at the application scenes, how to safely and efficiently realize the access of the Internet of things equipment with limited hardware resources to the blockchain network is a key problem.
Most of the internet of things edge devices are thin terminals with limited resources, and currently, the popular internet of things devices and data access modes are internet of things management platforms based on a cloud server and connected to centralized management, such as an aricloud internet of things platform and a Baidu cloud internet of things platform. In such a centralized management architecture model, the internet of things application lacks functions of auditing and auditable and also lacks a mechanism for independently verifying data integrity, privacy conditions, or reliability. This approach leads to problems of insecurity of data, easy tampering, data opacity, etc.
In order to solve the above problems, with the development of a block chain technology and the advantages of distributed security, inflexibility, traceability and the like, researchers provide that the internet of things equipment and data are directly accessed to a block chain network. At present, the mode of accessing the Internet of things equipment to a block chain is mainly a light node mode, and in the light node mode, the light node mode is realized by deploying light nodes at the Internet of things terminal. In the mode, the Internet of things equipment can be directly accessed to the block chain network service, and the method has good safety, but has the defect that the Internet of things equipment is required to have at least hardware conditions such as raspberry pi (Raspberry Pi), can not support a very common singlechip in the Internet of things terminal, and has great limitation.
The first embodiment:
in order to solve the problem that the application limitation is large due to the fact that a block chain access mode provided in the related art requires that an internet of things terminal has a strong hardware condition, the present embodiment provides a block chain service access method applied to a block chain service access system, as shown in fig. 1, the block chain service access system is a system architecture diagram of the block chain service access system provided in the present embodiment, and includes three major parts: the system comprises an internet of things terminal, a block chain proxy node service and a block chain network, wherein the internet of things terminal is provided with a Message construction client, the client can be preferably realized by adopting an MQTT (Message queue Telemetry Transport protocol) client, the block chain proxy node service comprises a plurality of SDK (Software Development Kit) proxy nodes, each SDK proxy node is provided with a Message proxy server and an SDK rear end, correspondingly, the Message proxy server can be preferably realized by adopting the MQTT server, and the block chain network is provided with a plurality of different block chain nodes.
As shown in fig. 2, which is a basic flowchart of the block chain service access method provided in this embodiment, the block chain service access method provided in this embodiment includes the following steps:
step 201, the terminal of the internet of things sends a block chain message to the target block chain agent node through a preset network protocol.
Specifically, the network protocol of this embodiment may be preferably implemented by using an MQTT protocol, which is a lightweight communication protocol based on a Publish/Subscribe (Publish/Subscribe) mode, and the protocol is constructed on a TCP/IP protocol. MQTT has the advantage of providing real-time reliable messaging services to remote devices with minimal code and limited bandwidth. As an instant messaging protocol with low cost and low bandwidth occupation, the MQTT is more suitable for the Internet of things thin terminal with limited hardware conditions.
In this embodiment, the hash algorithm and the digital signature verification algorithm of the corresponding blockchain system are implemented at the terminal node of the internet of things, a blockchain message can be directly constructed at a message construction client deployed at the terminal of the internet of things, and then the blockchain message is sent to the blockchain agent node through a network request.
Step 202, the target block chain proxy node calls the block chain SDK client, and forwards the block chain message received through the message proxy server to the block chain network.
Specifically, the blockchain network provides SDKs in various languages, including Go, Java, JavaScript, and the like, and the client needs to interact with the blockchain network service through the SDKs. The SDK operation needs certain hardware resource support, and general Internet of things equipment is difficult to meet requirements. In the system architecture design, the problem of the connection block chain service of the Internet of things thin terminal with limited hardware resources is solved by introducing a block chain SDK proxy node.
In this embodiment, the message proxy server may be an MQTT server, the block chain SDK proxy node deploys the MQTT server and a block chain SDK back end, the MQTT server may receive a block chain message sent by the internet of things terminal, and the block chain SDK back end sends the message to the block chain network, so that the block chain SDK proxy node serves as a bridge between the internet of things terminal and the block chain network.
Step 203, the blockchain network performs a service response corresponding to the blockchain message.
Specifically, the internet of things terminal interacts with the blockchain network through the SDK proxy node to obtain blockchain services, and similarly, response data of the blockchain network is forwarded to the internet of things terminal through the blockchain proxy node.
As shown in fig. 3, which is a schematic flow chart of a method for allocating a blockchain proxy node provided in this embodiment, in an optional implementation manner of this embodiment, before the step of sending a blockchain message to the blockchain proxy node by using a preset network protocol, the internet of things terminal specifically includes the following flows:
301, the terminal of the internet of things sends a node allocation request to a blockchain network through an initial blockchain agent node;
step 302, the blockchain network inquires and registers an intelligent contract based on the node allocation request, and determines a target blockchain agent node;
and step 303, the blockchain network returns the node information of the target blockchain agent node to the internet of things terminal through the initial blockchain agent node.
Specifically, the registration intelligence contract of the present embodiment includes a plurality of legally registered blockchain proxy nodes. In practical applications, a device with limited terminal resources may connect to the blockchain SDK proxy service node to obtain information on the blockchain. The connection mode enables the IOT equipment to trust the proxy nodes to a certain extent, and if the proxy nodes are attacked by security, the proxy nodes can provide false blockchain information for the IOT equipment.
Therefore, the embodiment provides a dynamic selection mechanism for the block chain SDK proxy service node, which allows the internet of things device to obtain the block chain SDK proxy service node list instead of relying on a single trusted node. In a blockchain network, a system will deploy a registration contract for blockchain SDK proxy nodes, and any node that provides blockchain SDK proxy services will need to register through the registration of the intelligent contract (chain code). The whole communication will include the following stages: firstly, a service provider of any operation block chain SDK proxy node needs to register in a block chain SDK proxy node registration contract; secondly, the terminal node of the Internet of things interacts with the registration contract of the SDK proxy node of the block chain through the SDK proxy node of the initial block chain for the first time, and the contract selects one service node from the node list to return; and finally, the terminal of the Internet of things interacts with the block chain network through the newly acquired SDK proxy node to acquire the block chain service.
In this embodiment, a specific procedure for dynamically and securely selecting the proxy node is introduced as follows: a. the terminal of the Internet of things requests dynamic allocation of the agent nodes through the initial agent nodes and is used for interacting with the block chain network in subsequent services; b. the initial agent node requests to register an intelligent contract (chain code); c. registering contract dynamic allocation block chain SDK proxy nodes and returning the SDK proxy nodes to the initial proxy nodes; d. the initial proxy node transfers the distributed proxy node information to the Internet of things terminal; e. the terminal of the Internet of things requests block chain service through the newly distributed agent nodes; f. and connecting the newly distributed agent nodes with the block chain network to provide block chain transfer service for the terminal of the Internet of things.
With the increase of terminals of the internet of things which want to access the blockchain network, the blockchain SDK proxy node is used as an important transfer node, and the security and the performance of the blockchain SDK proxy node directly influence the security and the performance of the blockchain network accessed by the internet of things. The embodiment dynamically and safely selects the block chain agent node, avoids single-point faults and potential safety hazards of the fixed node, and can effectively improve the overall safety and performance of the system.
In addition, the present embodiment further describes an implementation algorithm of the above-mentioned registered intelligent contract, where the inputs of the algorithm are: without input, the output is: dynamically selecting a proxy node connection information; a. declaring a proxy node list chain code structure body, wherein the structure body attribute comprises a node name and a node connection address, the node name is used as the key value of the map, and the node connection address is used as the value of the map; b. compiling a node registration Register () method for registering qualified proxy nodes; writing a getRandomNode () method, and randomly returning to an agent node; c. the method comprises the following steps of realizing an Init () function and an Invoke () function of a chain code, wherein the Init () function is an interface which must be realized by the chain code, the processing logic when the chain code is initialized or upgraded is realized by the Init () function, and the logic which is processed when the chain code is called or inquired in operation is realized by the Invoke () function, namely, the Register () function and the getRandomNode () function are called; d. main () main function is implemented, and the shim.start () method is called in the main function.
Further, in an optional implementation manner of this embodiment, the method for acquiring a blockchain proxy node further includes: periodically counting performance parameters of a plurality of legally registered block chain agent nodes by a block chain network; and the blockchain network correspondingly records the security levels aiming at a plurality of legally registered blockchain agent nodes in the registered intelligent contract according to the performance parameters.
Correspondingly, the step of querying and registering the intelligent contract based on the node allocation request and determining the target blockchain proxy node in the blockchain network specifically includes: the block chain network inquires and registers an intelligent contract based on the node distribution request; and the blockchain network determines the blockchain agent node with the highest security level in the registered intelligent contract as the target blockchain agent node.
Specifically, in this embodiment, the dynamic allocation manner of the target blockchain agent nodes may be random allocation or regular allocation, and in order to ensure the security and performance of the allocated agent nodes to the maximum extent, the intelligent registration contract of this embodiment may track the historical performance of each agent node, and then give a certain security incentive to each agent node according to the performance, where the performance is positively correlated with the security level, and then allocate the agent node with the highest security level in the registration contract to the internet of things terminal according to the node allocation request.
Further, in another optional implementation manner of this embodiment, the step of determining the target blockchain proxy node by querying the registration intelligent contract based on the node allocation request in the blockchain network specifically includes: the method comprises the steps that a block chain network obtains a terminal attribute or a target request service attribute of an Internet of things terminal; the blockchain network inquires a registration intelligent contract based on the node allocation request, and determines a blockchain proxy node corresponding to the terminal attribute or the target request service attribute as a target blockchain proxy node. In other implementations, the blockchain proxy nodes may also be adaptively allocated according to the difference between the terminals of the internet of things requesting access to the blockchain service or the difference between services requested by the terminals of the internet of things, so as to meet the adaptability between the terminals or services and the nodes, and further ensure the performance of the blockchain service.
As shown in fig. 4, which is a flowchart illustrating a method for creating a blockchain SDK client provided in this embodiment, in an optional implementation manner of this embodiment, before the step of invoking the blockchain SDK client by the target blockchain proxy node and forwarding a blockchain message received by the message proxy server to a blockchain network, the method specifically includes the following steps:
step 401, a target block chain agent node creates a Fabric-SDK object and configures a config.yaml file;
step 402, the target blockchain agent node creates a blockchain channel and adds channel information;
step 403, the target blockchain agent node initializes the SDK, instantiates a blockchain channel, and implements various APIs to obtain the created blockchain SDK client.
Specifically, in this embodiment, the proxy node interacts with the blockchain network through the Fabric-SDK application interface, and the configuration content of the config.yaml file includes: client, passageway, node, sequencing node, the passageway information includes: channel name, channel configuration, sequencing organization name and resource management terminal instance.
In addition, the embodiment also takes a super account book block chain network as an example, provides a specific block chain service access implementation, and details of a communication method and a process of interaction between an internet of things terminal and the super account book network through a block chain SDK proxy service node will be described. Fig. 5 is a specific flowchart of the method for interacting the internet of things terminal and the super ledger block-chain network provided in this embodiment, and the detailed steps are as follows:
1. the terminal of the Internet of things constructs a transaction proposal and carries out signature, and the transaction proposal is sent to a block chain SDK proxy service node through an MQTT protocol;
2. after receiving the proxy service node, the MQTT service transaction end of the block chain SDK proxy service node transfers the data to the block chain node P1 through the block chain SDK client;
3. the block link node P1 executes a response to acquire the proposal of the transaction by the link code S1;
4. the response generated in the chain code S1 is read into the book reading set as a simulation proposal;
5. returning the transaction proposal endorsed by the P1 node to the block chain SDK proxy service node;
6. the block chain SDK proxy service node transmits the endorsement transaction proposal to the Internet of things client through the MQTT protocol;
7. the Internet of things client signs the complete transaction and sends the signature to the agent node;
8. the agent node sends the signed and endorsed transaction to the sorting node O1;
9. after packaged transaction through a sequencing node in O1, an Order node in O1 broadcasts the transaction to P1, the P1 verifies the transaction before submitting the transaction to ledger L1, and then a P1 node confirms the transaction and writes the transaction into the ledger;
10. and the new transaction is successfully updated into the blockchain account book, the latest state of the account book is written into the database for storage, and the latest state becomes the world state.
It should be noted that some relevant components are disposed on the block link points of the present embodiment, wherein the components of O1 are described as follows: ordering the nodes of the packed transaction, the components of P1 are described as: the Peer node in the organization, the component of S1, is described as: chain code on the P1 node, the element of L1 is described as: ledger on P1 node.
According to the block chain service access method provided by the embodiment of the invention, an Internet of things terminal sends a block chain message to a target block chain agent node through a preset network protocol; the target block chain agent node calls a block chain SDK client and forwards the block chain message received by the message agent server to a block chain network; the blockchain network performs a service response corresponding to the blockchain message. By implementing the method, the device and the system, the blockchain message is directly constructed at the Internet of things terminal, the blockchain message is sent to the blockchain agent node through the network request and is transferred to the blockchain network from the blockchain agent node, so that the lightweight connection between the Internet of things terminal and the blockchain network is realized, the Internet of things thin terminal access blockchain service with limited hardware conditions can be more widely supported, and the application scene of blockchain service access is expanded.
Second embodiment:
in order to solve the problem that the application limitation is large due to the fact that the block link access method provided in the related art requires that the terminal of the internet of things has a strong hardware condition, this embodiment shows a block link service access device, and referring to fig. 6 specifically, the block link service access device of this embodiment includes:
a sending module 601, configured to send a blockchain message to a target blockchain proxy node through a preset network protocol by an internet of things terminal;
a forwarding module 602, configured to invoke the blockchain SDK client by the target blockchain proxy node, and forward the blockchain message received by the message proxy server to the blockchain network;
a response module 603 for the blockchain network to perform a service response corresponding to the blockchain message.
In some embodiments of this embodiment, the block chain service access device further includes: and (5) a query module. Specifically, the sending module is further configured to: the terminal of the Internet of things sends a node allocation request to a block chain network through an initial block chain agent node; the query module is configured to: the block chain network inquires and registers an intelligent contract based on the node allocation request, and determines a target block chain agent node; wherein the registration intelligent contract comprises a plurality of legally registered blockchain agent nodes; the response module is further configured to: and the block chain network returns the node information of the target block chain agent node to the terminal of the Internet of things through the initial block chain agent node.
Further, in some embodiments of this embodiment, the block chain service access device further includes: a statistic module and a recording module. Specifically, the statistical module is configured to: periodically counting performance parameters of a plurality of legally registered block chain agent nodes by a block chain network; the recording module is configured to: the block chain network correspondingly records the security levels aiming at a plurality of legally registered block chain agent nodes in a registered intelligent contract according to the performance parameters; the query module is specifically configured to: the block chain network inquires and registers an intelligent contract based on the node distribution request; and the blockchain network determines the blockchain agent node with the highest security level in the registered intelligent contract as the target blockchain agent node.
In some embodiments of this embodiment, the block chain service access device further includes: a creation module to: the target block chain agent node creates a Fabric-SDK object and configures a config.yaml file; the target block chain agent node creates a block chain channel and adds channel information; the target block chain agent node initializes the SDK, instantiates a block chain channel and realizes various APIs to obtain a block chain SDK client end after the creation; the configuration content of the config.yaml file comprises: client, channel, node and sequencing node; the channel information includes: channel name, channel configuration, sequencing organization name and resource management terminal instance.
It should be noted that, the block chain service access method in the foregoing embodiment can be implemented based on the block chain service access device provided in this embodiment, and it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the block chain service access device described in this embodiment may refer to the corresponding process in the foregoing method embodiment, and details are not described here again.
By adopting the block chain service access device provided by the embodiment, the terminal of the internet of things sends a block chain message to the target block chain agent node through a preset network protocol; the target block chain agent node calls a block chain SDK client and forwards the block chain message received by the message agent server to a block chain network; the blockchain network performs a service response corresponding to the blockchain message. By implementing the method, the device and the system, the blockchain message is directly constructed at the Internet of things terminal, the blockchain message is sent to the blockchain agent node through the network request and is transferred to the blockchain network from the blockchain agent node, so that the lightweight connection between the Internet of things terminal and the blockchain network is realized, the Internet of things thin terminal access blockchain service with limited hardware conditions can be more widely supported, and the application scene of blockchain service access is expanded.
The third embodiment:
the present embodiment provides an electronic apparatus, as shown in fig. 7, which includes a processor 701, a memory 702, and a communication bus 703, wherein: the communication bus 703 is used for realizing connection communication between the processor 701 and the memory 702; the processor 701 is configured to execute one or more computer programs stored in the memory 702 to implement at least one step of the block chain service access method in the first embodiment.
The present embodiments also provide a computer-readable storage medium including volatile or non-volatile, removable or non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, computer program modules or other data. Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash Memory or other Memory technology, CD-ROM (Compact disk Read-Only Memory), Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer.
The computer-readable storage medium in this embodiment may be used for storing one or more computer programs, and the stored one or more computer programs may be executed by a processor to implement at least one step of the method in the first embodiment.
The present embodiment also provides a computer program, which can be distributed on a computer readable medium and executed by a computing device to implement at least one step of the method in the first embodiment; and in some cases at least one of the steps shown or described may be performed in an order different than that described in the embodiments above.
The present embodiments also provide a computer program product comprising a computer readable means on which a computer program as shown above is stored. The computer readable means in this embodiment may include a computer readable storage medium as shown above.
It will be apparent to those skilled in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software (which may be implemented in computer program code executable by a computing device), firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit.
In addition, communication media typically embodies computer readable instructions, data structures, computer program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to one of ordinary skill in the art. Thus, the present invention is not limited to any specific combination of hardware and software.
The foregoing is a more detailed description of embodiments of the present invention, and the present invention is not to be considered limited to such descriptions. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.