Disclosure of Invention
The invention aims to provide a system for acquiring environment data in real time and writing the environment data into a block chain, which can ensure the authenticity of the environment data.
In order to achieve the purpose, the invention provides the following scheme:
a system for acquiring and writing environmental data to a blockchain in real time, comprising: a blockchain terminal proxy node and a blockchain server;
the block chain terminal proxy node includes:
the environment sensing module is used for acquiring environment data;
the micro control unit is used for storing a digital encryption and signature program, a data automatic sending program and a private key and a public key of the block chain terminal proxy node, and is also used for executing the digital encryption and signature program and the data automatic sending program; and
the wireless radio frequency module is connected with the micro control unit and used for transmitting the environment data to the block chain server;
the blockchain server is a node in a blockchain network and is used for storing the received environment data and executing a blockchain application program to write the environment data into the blockchain network.
Optionally, a flash memory is integrated in the micro control unit, and the digital encryption and signature program, the automatic data transmission program, and the private key and the public key of the blockchain terminal proxy node are stored in the flash memory.
Optionally, the radio frequency module includes one or more of a bluetooth module, a WIFI module, and a mobile communication network terminal module.
Optionally, the block chain terminal proxy node further includes a substrate, a data bus and a connection pin interface of the environment sensing module, the micro control unit and the radio frequency module are disposed on the substrate, and the environment sensing module, the micro control unit and the radio frequency module are integrated on the substrate.
Optionally, the blockchain terminal proxy node further includes a power module, and the power module includes a battery.
Optionally, the environment sensing module includes an embeddable microsensor and/or a positioning chip.
Optionally, the digital encryption and signature program includes:
generating a random positive integer k, wherein k < q;
calculating r ═ gkmod p)mod q;
Calculating s ═ k-1(h (m) + xr) mod q, outputting (r, s) as the signature of m;
whereinQ, p, g are global public keys, p ═ kq +1, g ═ h(p-1)/qmod p, h are randomly generated integers, 1<h<(p-1),g>1, m is the environment data, x is the private key of the blockchain terminal proxy node, and h (m) is the hash of m generated using the SHA-1 hash function.
Optionally, the blockchain application includes:
verifying the digital signature;
and after the verification is passed, packaging, broadcasting and updating the distributed data account book on the environment data.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects: the invention provides a system block chain terminal agent node and a block chain server which can obtain environmental data in real time and write the environmental data into a block chain; wherein, the block chain terminal proxy node comprises: the system comprises an environment sensing module, a micro control unit and a wireless radio frequency module; the micro control unit stores a digital encryption and signature program and a data automatic sending program, executes the programs to sign the environmental data acquired by the environmental sensing module and automatically transmit the environmental data to the block chain network, so that the function of transmitting the acquired environmental data to the block chain network in real time is realized, the intervention of human factors is avoided, and the authenticity and the credibility of the uplink data are guaranteed.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious 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 invention aims to provide a system for acquiring environment data in real time and writing the environment data into a block chain, which can ensure the authenticity of the environment data.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1, the system for acquiring and writing environmental data into a blockchain in real time provided by the present invention includes: a block chain terminal agent node 1 and a block chain server 2;
wherein, the block chain terminal proxy node 1 comprises: the system comprises an environment sensing module 11, a micro control unit 12 and a wireless radio frequency module 13, wherein the environment sensing module 11 is used for acquiring environment data; the micro control unit 12 stores a digital encryption and signature program, an automatic data transmission program and a private key and a public key of the block chain terminal proxy node 1, and the micro control unit 12 is further configured to execute the digital encryption and signature program and the automatic data transmission program; the wireless radio frequency module 13 is connected to the micro control unit 12, and the wireless radio frequency module 13 is configured to transmit the environment data to the blockchain server 2.
The blockchain server 2 is a node in the blockchain network, and can perform standard work of blockchain packaging, broadcasting, and shared data book update, and store blockchain data (received environment data).
The digital encryption and signature program, the automatic data transmission program, and the private key and public key of the blockchain terminal proxy node 1 are stored in the flash memory of the micro control unit 12.
The wireless rf module 13 may adopt communication frequencies and protocols of a standardized local area network such as bluetooth and WiFi, and be implemented by a bluetooth or WiFi (or dual-mode) system on chip (SoC), or adopt a customized mode to design the system on chip (SoC) by selecting a higher frequency band such as 5.8GHz or 28 GHz. The radio frequency module 13 can also be implemented by using a public mobile communication network (such as 4G, 3G, GPRS, etc.) terminal module such as a SIM card and a card reader. The wireless network includes public mobile communication networks (such as 4G, 3G, GPRS, etc.) and wireless local area networks (WiFi, bluetooth, etc.), and the infrastructure includes base stations, antennas, wireless network cards, routers, etc. according to different categories.
The blockchain terminal proxy node 1 further includes a substrate, where the substrate is an integrated motherboard of the device (integrated with the environment sensing module 11, the micro control unit 12, the radio frequency module 13, and the like), and includes a data bus and a connection pin interface of each module.
The micro control unit 12 is an important control module of the device, also called a single chip, and can be analogized to a chip-level computer integrating a central processing unit, a memory, a nonvolatile memory (such as a flash memory), a counter, a digital-to-analog conversion module, and the like.
The environment sensing module 11 can be implemented by using an embeddable micro sensor (such as a temperature sensor, a humidity sensor, a pH value sensor, an acceleration sensor, a three-axis gyroscope, a compound detection sensor, and the like) or a GPS/Beidou positioning chip according to application requirements.
The blockchain terminal proxy node 1 further includes a battery module, which can select a suitable battery according to the device power consumption evaluation and the use requirement.
The parameter determination process in the digital encryption and signature of the invention is as follows:
randomly generating L-bit prime numbers as a global public key p, wherein L needs to satisfy the requirement that the size is between 512 and 1024 and is a multiple of 64;
the global public key q is a 160-bit prime factor of p-1, i.e. the q bit length is 160, which satisfies 2159< q <2160, and p is kq +1, where k is a randomly or pseudo-randomly generated positive integer;
the global public key g is h (p-1)/qmod p, wherein h is a randomly generated integer and needs to satisfy 1<h<(p-1),g>1,gq≡1(mod p);
The user private key x is a positive integer generated randomly or pseudo-randomly, and x < q;
user public key y ═ gxmod(p)。
After the user private key and the user public key are determined, the micro-control unit (102) and the compiler are connected by using the development board, and the private key and the public key of the blockchain terminal proxy node device (i.e. the user private key and the user public key generated in step zero) and the digital encryption and signature program and the customized logic control program (where the customized logic control program includes a program for acquiring data of the environment sensing module, an automatic data transmission program, and control programs of other modules, etc.) are written into a nonvolatile memory (such as a flash memory) in the micro-control unit.
The environment sensing module collects environment data according to the frequency set by the micro control unit and transmits the data to the micro control unit.
The micro control unit runs a Digital Signature Algorithm (DSA) on the received environment data according to the set Digital Signature frequency. The method comprises the following specific steps:
generating a random positive integer k, wherein k < q;
calculating r ═ gkmod p)mod q;
Calculating s ═ k-1(h (m) + xr) mod q, where m is a signature object message, that is, newly added environment data in a period corresponding to a specified digital signature frequency, and h (m) is a hash of m generated by using an SHA-1 hash function;
output (r, s) as a signature of m.
And transmitting the digital signature and (or) corresponding original data to the outside through a wireless radio frequency module according to the frequency set by the micro control unit, and receiving the digital signature and (or) corresponding original data by a connectable block chain server.
After receiving the data, the block chain server firstly verifies the digital signature, and the specific steps are as follows:
receiving a data set (public key (g, p, q, y), original message M, signature (r, s));
calculating w ═ s-1mod q;
Calculating u1=[H(M)w]mod q,u2=rwmod q;
Calculating v ═ [ (g ^ u1y ^ u2) mod p ] mod q;
judging that if v is equal to r, the verification is passed; otherwise, the verification fails and the process terminates.
After the verification is passed, the block chain server cooperates with the terminal agent node to run a block chain application program, and performs block chain network tasks such as data packaging, broadcasting, distributed data account book updating and the like according to the set frequency/data volume. The specific steps are described as follows:
the block chain server feeds back a verification passing message to the terminal proxy node;
a block chain terminal agent node sends a data packing, broadcasting and distributed data book updating request (Proposal) to a certain (generally a plurality of) endorsement nodes (Endorers) in a block chain network;
carrying out data packing on an endorsement node (Endorser) simulation account chain code (Chaincode), and signing and returning an endorsement result (endorsement);
after the number of the received endorsements (Endorsession) reaches a certain threshold value, the block chain terminal agent node sends the packed data subjected to endorsement to a sequencing node (Orders);
the sequencing node (Orders) sequences the read-write sets, constructs a Block (Block), and sends the Block to the confirmation node (Committer);
and the confirmation node (Committer) verifies the Block (Block), the packed data read-write set, the endorsement strategy and the like according to a set rule, writes the verified packed data into a Block chain and broadcasts the Block chain all over the network, and updates the distributed account book database (World State DB) of each place.
The system for acquiring the environmental data in real time and writing the environmental data into the block chain can realize real-time and automatic acquisition of the environmental data, carries out digital signature on the data by the block chain terminal proxy node, and sends the signature and/or the data to the block chain server to be written into the block chain network, thereby avoiding the intervention of human factors in the whole process and ensuring the trueness and credibility of the uplink data. In addition, the invention divides the data chaining process into two parts, sets the digital signature part with lower requirements on calculation and storage at the block chain terminal proxy node for completion, and sets the block packing, verification and broadcasting parts with higher requirements on calculation and storage at the block chain server terminal for completion, thereby realizing cost effectiveness while realizing functionality.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The principles and embodiments of the present invention have been described herein using specific examples, which are provided only to help understand the method and the core concept of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed. In view of the above, the present disclosure should not be construed as limiting the invention.