Food safety trace back method and system based on block chain
Technical field
The disclosure belongs to the technical field of food safety, more specifically belongs to a kind of food based on block chain design philosophy
Safety tracing method and system.
Background technique
Food safety is the serious problem of society today that current year China is faced, since food quality is unqualified or even toxic
Problem caused by nocuousness emerges one after another, so that the confidence of consumer has received and seriously affects, or even loses faith in domestic food
And turn to the approach such as buy on behalf.In order to solve this problem, if can record faithfully one by one the parameter in food production simultaneously
And provided on the internet in such a way that consumer is easy to detect, will be beneficial to consumer's reconstruction for the confidence of food hygiene
's.Although currently having had various inspection and quarantine mechanisms and process to be monitored to the important node in food production,
But cause confidence level lower by multi-party distort first is that data are easy, second is that consumer can not easily touch such data,
Third is that the information record format of each main body is difficult to be compatible with during Food circulation, it is difficult to cover fourth is that the data of governability are limited
The whole cycle of lid Food circulation, therefore act on limited.Food safety trace back should accomplish to understand the source of food and whereabouts,
Indices meet the requirements, and with more believable safety and have the convenience for being easy to ordinary populace and using.Block chain technology
Because its can not tamper, dispersibility, the transparency and open, be suitable for being subject to it is suitably modified, using its design philosophy come into
The retrospect of row food safety, and be possible to the efficiency of original time-consuming food security information verification process with a low credibility significantly
It is promoted.
Summary of the invention
The first purpose of the disclosure is to solve the problems, such as in the prior art at least some, and provides a kind of based on block chain
The food safety trace back method and system of design philosophy will avoid recorded food safety from believing using this method and system
Breath is artificially distorted, and ordinary consumer can also be allowed to check recorded food security information in a manner of more convenient.
Disclose a kind of food safety trace back method based on block chain in one embodiment, including from detection terminal to testing
Demonstrate,prove the operator message that terminal sends detection terminal public key and the identity for verification operation person;Terminal is verified in good authentication
Detection terminal is sent by verifying terminal public key when the identity of operator, and will test terminal public key and verifying terminal secret key transmission
To reception terminal;It will be deposited using verifying terminal public key, detection terminal secret key and fixed storage private key encryption by detection terminal
Storage information is sent to reception terminal, which includes the identity of operator, timestamp and by detection terminal included
The food parameter that multiple sensors are sensed;It is whole using fixed storage public key, verifying terminal secret key and detection by reception terminal
It holds the public key decryptions storage information and sends the notice for saving and completing to verifying terminal saving the rear of storage information;And verifying
Terminal receive save complete notice after by by the combination of current authentication terminal secret key and random information in hash function
Middle iteration is greater than primary mode to update verifying terminal secret key.
Another embodiment discloses a kind of food safety trace back system based on block chain, including detection terminal, verifying
Terminal and reception terminal, detection terminal are configured to send detection terminal public key to verifying terminal and for the body of verification operation person
The operator message of part;Verifying terminal is configured to send detection for verifying terminal public key in the identity of good authentication operator
Terminal, and will test terminal public key and verify terminal secret key and be sent to reception terminal;Detection terminal is configured to will be using verifying
The storage information of terminal public key, detection terminal secret key and fixed storage private key encryption is sent to reception terminal, the storage information
Identity, timestamp including operator and the food parameter sensed by multiple sensors that detection terminal is included;It receives
Terminal is configured with fixed storage public key, verifying terminal secret key and detection terminal public key and decrypts the storage information and saving
It stores the rear of information and sends the notice for saving and completing to verifying terminal;And verifying terminal is configured to receiving preservation completion
Notice after by by the combination of current authentication terminal secret key and random information in hash function iteration be greater than primary mode
To update verifying terminal secret key.
In one embodiment, the food parameter sensed includes humidity, temperature and GPS location.
In one embodiment, operator message includes user name, password and biological information and biological information includes referring to
One of line, facial characteristics and sound characteristic.
In one embodiment, updated verifying terminal secret key is stored and deletes old verifying end by verifying terminal
The step of holding private key.
In one embodiment, verifying terminal and detection terminal storage has account information relevant to detection terminal, and connects
It receives terminal and does not have account information relevant to detection terminal.
Embodiment of the disclosure is carried out between any two by three terminals, i.e. detection terminal, verifying terminal and reception terminal
Interaction will realize higher safety, avoid eating to complete the message transmission of encryption when being applied to food safety trace back
Other main bodys distort information in product flowchart process, and ordinary consumer can also ensure its food checked from principle
The confidence level of secure data, so that providing that one kind has can not tamper, dispersibility, the transparency and open new food safety
Tracking mechanism.
Detailed description of the invention
Attached drawing of the invention will diagrammatically illustrate embodiment, rather than in order to limit embodiment, in which:
Fig. 1 is the block diagram of food safety trace back system according to an embodiment of the present invention.
Fig. 2 is the flow chart of food safety trace back method according to an embodiment of the present invention.
Specific embodiment
It will be appreciated by those skilled in the art that term first, second etc. can be used to describe various elements herein and without
The limitation of sequence or priority.Wherein the first element can be referred to as second element, and similarly, and second element can be referred to as
One element.Understand that the function action pointed out in block diagrams can be detached from the sequence pointed out in operational illustration yet and occur.For example, even
Continuous two frames shown actually can be executed substantially concurrently or be executed with reverse order, this depends on the functionality being related to.Letter
Breath transmitting can occur on the direction opposite with the arrow of description.Fig. 1 is food safety trace back system according to an embodiment of the present invention
The block diagram of system.The food safety trace back system includes at least one detection terminal 101, at least one verifying terminal 102 and at least
One reception terminal 103.Terminal 101 is detected, verifying terminal 102 and reception terminal 103 can be any execution computing function
Fixed equipment or portable equipment, such as desktop computer, notebook computer, smart phone, tablet computer, server, hand
Hold any computing device that can store and handle data such as PC, base station.Wherein detection terminal 101 is for during food safety
Coordinates collection of data in each detection process, detection terminal 101 may include that multiple sensors 105 are used to detect food ginseng
Number.Food parameter may include the source area of GPS position information food for confirmation.Food parameter may include transport and storage
Whether temperature and humidity information food for confirmation in the process has rotten danger.Food parameter can be temporal information so as to true
Recognize correct date of manufacture and transportational process.Food parameter can also be intensity of sunshine, air pollution data, soil data, water
Information collected by various other sensors such as matter situation.Verifying terminal 102 is for verifying the detection number detected of terminal 101
According to, and the decision mechanism cryptographically transmitted.Rule defined in verifying terminal 102 can store in long-range rule
Then accordingly modify in database 106 and by operator.Rule may include priority when being verified, such as first
One of operator message is first verified, and in obstructed out-of-date other types for starting verification operation person information, and it is wrong in verifying
Alarm etc. accidentally occurs.Verify the operator that verifying detection terminal 101 is transmitted when sending the data of its detection of terminal 102
Information, the operator message are not limited to the information that username and password etc. is relatively easily tampered or usurps, and should also include operation
The biological informations such as fingerprint, facial characteristics and the sound characteristic of person information for confirmation is uploaded by correct operator.It receives
Terminal 103 is the terminal for receiving and storing encryption information, with detection terminal 101 and verifying terminal 102 pass through network into
Row communication.Receiving terminal 103 can be the server or computing terminal that consumer can access, and can also can access with consumer
Server or computing terminal communicate to consumer can from receive terminal 103 obtain food security information without with inspection
It surveys terminal 101 and verifying terminal 102 is communicated.For example, consumer can hold mobile terminal 104 will pass through wireless network
It is communicated with terminal 103 is received.Meanwhile consumer will not carry out any lead to detection terminal 101 or verifying terminal 102
Letter.
Fig. 2 is the flow chart of food safety trace back method according to an embodiment of the present invention.In step s 201, first by examining
It surveys terminal 101 and sends detection terminal public key and operator's letter of the identity for verifying the operator to verifying terminal 102
Breath.The key pair of public key and private key described herein can for example be provided by well-known RSA asymmetric encryption, with
Coded communication is realized between the terminals.Detection terminal 101 is having detected the food ginseng including humidity, temperature, time and GPS location
It will be automatically or manually by the food parameter and the biological informations such as fingerprint, facial characteristics and sound characteristic that include operator after number
Operator message be sent collectively to verifying terminal 102.
In step S203, verifying terminal 102 may have access to the history identity information of pre-stored operator, go through in basis
After detection terminal 101 verifying terminal public key will be sent to when the identity information of history identity information good authentication operator to be used for
Continuous tripartite's encrypted transmission step, and will test terminal public key and verify terminal secret key and be sent to the reception end communicated
End 103.Verifying terminal 102 may be coupled to rule database 106.In addition to storing corresponding regular number in rule database 106
It is outer accordingly, it may also include above-mentioned history identity information, passing Message Record and other authentication datas etc..
In step S205, detection terminal 101 will be private using verifying terminal public key, detection terminal secret key and fixed storage
The storage information of key encryption, which is sent to, receives terminal 103.The storage information include the identity of institute verification operation person, timestamp and
The food parameter that detection terminal 101 had previously been sensed.Storage information can use verifying terminal public key, detection terminal secret key and consolidate
Determine storage successively to be signed with private key three, and is successively decrypted in decryption using another of cipher key pair.Storage
Information also can use verifying terminal public key, detection terminal secret key and fixed storage private key three and generate a new key pair
Carry out encrypted transmission.It may insure the safety of data in this way.Verifying terminal 102 neither saves storage information, can not also decrypt
Information is stored, therefore data can be prevented to be tampered and store and process the ability that high-volume stores information.
In step S207, by reception terminal 103 to be deposited with verifying terminal public key, detection terminal secret key and fixation before
Storage private key corresponding fixed storage public key, verifying terminal secret key and detection terminal public key in order carry out storage information
Decryption.The notice for saving and completing is sent to verifying terminal receiving the rear of the decrypted storage information of the preservation of terminal 103.Consumer
Hereafter the mobile terminal 104 held can will check the food security information of preservation by receiving the database in terminal 103,
And it is not communicated with other terminals during entirely checking.
In step S209, verifying terminal 102. is after receiving the notice for saving and completing by the way that current authentication terminal is private
The combination of key and random information iteration in hash function is greater than primary mode to update verifying terminal secret key.Hash function can
To be the SHA256 function in secure hash algorithm SHA, the function by logical operation is repeated after message piecemeal by holding
Row circulation encryption, finally obtains the summary info of 256 bits, i.e. cryptographic Hash.And obtained cryptographic Hash will be as new verifying
Terminal secret key, to protect verifying terminal 102 and detect the message transmission between terminal 101.In this way, being not only able to achieve three terminals
Between safety information transmitting, and can ensure that key transmission be also encryption, can greatly improve and steal data or usurp
Change the difficulty of data.
Herein described specific embodiment is not to be for limiting the scope of the invention, but the scope of the present invention will be covered
Cover the various substitutions or change of the embodiment being discussed herein.Protection scope of the present invention is limited only by the appended claims, and unlimited
The design parameter described in any embodiment or step.