Invention content
The present invention provides a kind of distributed commodity data storage system, circulation and source tracing method based on block chain, for
The above technical deficiency introduces the thought of block chain and Distributed Storage, is assisted by organic combination supervision department, industry
Meeting, manufacturing enterprise, circulation enterprise data resource, establish block chain alliance retrospect system, expect that retailer's is entire from former material
The each side of supply chain participates in data input and the maintenance of block chain jointly, ensures data in real time, orderly, can not really forge.
Realize it is forward traceable, can inversely trace to the source, risk can management and control, occur quality security problem when product can recall, reason can be investigated thoroughly,
Responsibility can be investigated, implements quality safety main body responsibility conscientiously, structure trusted, transparent, the distributed industry alliance that efficiently cooperates with
Ecology.
To achieve the goals above, the present invention proposes a kind of distributed commodity data storage system based on block chain, packet
Include multiple super nodes and multiple ordinary nodes;
The super node:Transaction is submitted in addition qualification and verification member for examining block Lian Zhong alliance newcomers
Legitimacy, what the basic data of ordinary node and ordinary node reported in memory block chain gives birth to according to critical control link information
At Hash codes, and safeguard one for generating the unencryption account book of chain of tracing to the source;
When trace to the source request when, be additionally operable to the Hash codes of verification storage and ordinary node reports at this time critical control link
Information corresponds to the consistency of Hash codes, and critical control link information and chain of tracing to the source, which are formed complete commodity, traces to the source information;
The ordinary node:The data information for having permission acquisition and the entire block chain of verification, itself is checked by secret key
Transaction record, new transaction data is added into block chain after super node verifies, also according to laws and regulations requirement record produce
Critical control link information in intermediate links generates Hash codes and reports in super node;
When trace to the source request when, by the critical control link information reporting of record to super node.
Preferably, the super node, corresponding to member include at least government regulator and employer's organization;Institute
The ordinary node stated, corresponding to member include at least manufacturing enterprise, material supplier, dealer and retailer.
Preferably, the super node, including:
Approval module:The qualification that is added for examining block Lian Zhong alliance newcomers submits the legal of transaction with member is verified
Property;
Account book module:It for generating encryption account book according to the transaction record of ordinary node, and broadcasts into block chain, simultaneously
Safeguard a unencryption account book for generating chain of tracing to the source;
Memory module:What basic data and ordinary node for ordinary node in memory block chain reported controls according to key
The Hash codes that link information processed generates;
Trace back block:Request of tracing to the source for receiving retrospect person, splices in the transaction record of account book according to time order and function
At chain of tracing to the source, the one of the Hash codes Hash codes corresponding with the critical control link information that ordinary node at this time reports of storage is verified
Critical control link information and chain of tracing to the source are formed complete commodity information of tracing to the source and are sent to retrospect person by cause property.
Preferably, the ordinary node, including:
Data acquisition module:For obtaining and verifying the data information in entire block chain;
Data reporting module:For new block data to be added into block chain after super node verifies;
Memory module:For storing critical control link information;
Hash codes generation module:For generating Hash codes according to critical control link information and reporting to super node.
Preferably, the ordinary node further includes:
Ciphering signature module:For being encrypted and signing to transaction record;
Traceability code and case code generation module:The case code of traceability code and packing case for generating commodity;
Binding module:For according to commodity case situation, by the corresponding case code of packing case and the commodity pair in babinet
The traceability code answered carries out barcode scanning binding.
Preferably, the critical control link information includes at least raw material examining report, the finished product detection of each batch
Report and use raw material batch number.
The present invention also proposes a kind of distributed commodity circulation method based on block chain, includes the following steps:
S10, block Lian Nei manufacturing enterprise's ordinary nodes generate Hash codes according to critical control link information, separately generate commodity
Traceability code and packing case case code;
Super node preserves Hash codes and verifies traceability code and case code in S20, block chain;
S30, situation of being cased according to commodity, by the corresponding case code of packing case and the corresponding traceability code of commodity in babinet
Barcode scanning binding is carried out, and the incidence relation of case code and traceability code is stored in super node in block chain;
S40, block Lian Nei manufacturing enterprises ordinary node are encrypted and sign to transaction record, super node verification verification
Legitimacy;
S50, the ordinary node scanning case code determination of block Lian Nei circulation enterprises are stocked up, and newly-increased one of super node is encrypted
Transaction record is simultaneously broadcasted;
Retailer's ordinary node scans sold commodity tracing code and generates order, consumer payment in S60, block chain
When, it is associated with payment accounts and commodity tracing code and preserves to super node in block chain.
The present invention also proposes a kind of distributed commodity source tracing method based on block chain, includes the following steps:
The traceability code of S100, retrospect person's items scanning initiate retrospect request to super node;
S200, traceability code case code affiliated in intermediate links is inquired in record;
S300, the corresponding intermediate links transaction record of case code is searched in transaction record;
S400, super node are spliced into chain of tracing to the source in intermediate links transaction record according to time order and function;
S500, the manufacturing enterprise that the commodity are inquired by traceability code, and initiate crucial control to manufacturing enterprise's ordinary node
Link information inquiry request;
S600, by the critical control link information reporting of record to super node, super node verifies the Kazakhstan for reporting information
Whether uncommon value is consistent with what is recorded before;
S700, production critical control link information is merged with chain of tracing to the source, forms complete commodity and traces to the source information,
Return to retrospect person.
A kind of distributed commodity data storage system, circulation and source tracing method based on block chain provided by the invention,
Include three key contents, i.e.,:Block chain, distributed storage, retroactive method;Block chain solves current commodity production, stream
The opaque problem of transaction data, the characteristic that can not be distorted by block chain ensure that confidence level and the authority of data in logical chain
Property, reduce the trust friction between enterprise and enterprise, between enterprise and supervision department;Distributed storage solves centralization and chases after
The platform that traces back stores the big problem of pressure, and the details for producing intermediate links dispersion is stored in the database of each enterprise's node
In, while ensureing that these data will not without authorization be distorted by enterprise by Hash codes;Finally, retroactive method proposed by the present invention solves
The problem of supply chain trace back data is not complete, and responsibility difficulty positions, this method is using traceability code as core, in conjunction with case code association, mobile
The means such as payment, whole relevant informations of the record commodity in from raw material to consumer's whole life cycle, when there are quality problems
When can position responsible party rapidly, and send out recall notice to relevant enterprise and consumer.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiment is only a part of the embodiment of the present invention, instead of all the embodiments.Base
Embodiment in the present invention, those of ordinary skill in the art obtained without creative efforts it is all its
His embodiment, shall fall within the protection scope of the present invention.
If it is to be appreciated that related in the embodiment of the present invention directionality instruction (such as up, down, left, right, before and after ...),
Then directionality instruction be only used for explaining relative position relation under a certain particular pose (as shown in the picture) between each component,
Motion conditions etc., if the particular pose changes, directionality instruction also correspondingly changes correspondingly.
If in addition, relating to the description of " first ", " second " etc. in the embodiment of the present invention, it is somebody's turn to do " first ", " second " etc.
Description be used for description purposes only, be not understood to indicate or imply its relative importance or implicitly indicate indicated skill
The quantity of art feature." first " is defined as a result, the feature of " second " can explicitly or implicitly include at least one spy
Sign.In addition, the technical solution between each embodiment can be combined with each other, but must be with those of ordinary skill in the art's energy
It is enough realize based on, when the knot that conflicting or cannot achieve when will be understood that this technical solution occurs in the combination of technical solution
Conjunction is not present, also not the present invention claims protection domain within.
The present invention provides a kind of distributed commodity data storage system based on block chain;The present invention uses the side of alliance's chain
Formula is disposed, and government regulator (Department of Qulity Supervision, food Bureau of Drugs Supervision, industrial and commercial bureau, bureau of commerce etc.) and employer's organization are block chains
Super node, there is the power of examination and approval, alliance's chain is often included in a new node and is required for agreeing unanimously by super node.
The access node of mandate is known as ordinary node, can add new information block data of tracing to the source, and newly-increased data need super node
It can just be become a full member of into chain after verifying its legitimacy, data can never be changed once cochain.Data on block chain
It is disclosed to full allied member, but since data have passed through the encryption of enterprise's secret key, each enterprise can only be checked certainly by secret key
Oneself transaction data, to ensure the safety of business privacy.
In first preferred embodiment of the invention, which includes multiple super nodes (government regulator and employer's organization)
With multiple ordinary nodes (manufacturing enterprise, material supplier, dealer and retailer);
The super node:Transaction is submitted in addition qualification and verification member for examining block Lian Zhong alliance newcomers
Legitimacy, what the basic data of ordinary node and ordinary node reported in memory block chain gives birth to according to critical control link information
At Hash codes, and safeguard one for generating the unencryption account book of chain of tracing to the source;When trace to the source request when, be additionally operable to verification deposit
The consistency of the Hash codes of storage Hash codes corresponding with the critical control link information that ordinary node at this time reports, by crucial control ring
Section information and chain of tracing to the source form complete commodity and trace to the source information;
In the embodiment of the present invention, super node is responsible for examining the friendship that qualification is added and verifies member's submission of alliance newcomer
It is easily whether legal.Essential information, commodity category information, commodity tracing code and the case of the in store alliance enterprise of each super node
The basic datas such as the related information of code.Other than the encryption account book on open chain, also maintain on super node there are one not plus
Close account book can generate chain of tracing to the source when the public, supervisor trace to the source by this account book.In order to save super node
Memory space, produce intermediate links in critical control link information, in raw material batch, survey report, transportational process
Environmental monitoring data etc. are stored in the server of enterprise itself, and super node only preserves the Hash codes generated by information, if enterprise
Industry changes these information without authorization, and Hash codes will change.
The ordinary node:For obtaining and verifying the data information in entire block chain, after super node verifies
New block data is added into block chain, and the critical control link in production intermediate links is recorded according to laws and regulations requirement and is believed
Breath generates Hash codes and reports in super node;When trace to the source request when, by the critical control link information of record and generated
Hash codes report in super node.
In the embodiment of the present invention, ordinary node is the manufacturing enterprise to coalize, material supplier, dealer, retailer
Etc. belonging to ordinary node.Ordinary node has permission the data information of acquisition and the entire block chain of verification, but can only pass through enterprise
Secret key checks that the transaction record of itself, ordinary node can add new block data into chain block, and new data is super by confirming
Grade node becomes a full member of after confirming in block chain.Ordinary node needs to record the pass in production intermediate links according to laws and regulations requirement
Key control link information, and generate Hash codes and report to super node.
In second preferred embodiment of the invention, as shown in Figure 1, the super node, including:
Approval module:The qualification that is added for examining block Lian Zhong alliance newcomers submits the legal of transaction with member is verified
Property;
Account book module:It for generating encryption account book according to the transaction record of ordinary node, and broadcasts into block chain, and ties up
Unencryption account book of the shield one for generating chain of tracing to the source;
Memory module:What basic data and ordinary node for ordinary node in memory block chain reported controls according to key
The Hash codes that link information processed generates;
Trace back block:Request of tracing to the source for receiving retrospect person, splices in the transaction record of account book according to time order and function
At chain of tracing to the source, the one of the Hash codes Hash codes corresponding with the critical control link information that ordinary node at this time reports of storage is verified
Critical control link information and chain of tracing to the source are formed complete commodity information of tracing to the source and are sent to retrospect person by cause property.
The ordinary node, including:
Data acquisition module:For obtaining and verifying the data information in entire block chain;
Data reporting module:For new block data to be added into block chain after super node verifies;
Memory module:For storing critical control link information;
Hash codes generation module:For generating Hash codes according to critical control link information and reporting to super node.
In third preferred embodiment of the invention, as shown in Fig. 2, the ordinary node, further includes:
Ciphering signature module:For being encrypted and signing to transaction record;
Traceability code and case code generation module:The case code of traceability code and packing case for generating commodity;
Binding module:For according to commodity case situation, by the corresponding case code of packing case and the commodity pair in babinet
The traceability code answered carries out barcode scanning binding.
The present invention also proposes a kind of distributed commodity circulation method based on block chain;
In four preferred embodiment of the invention, as shown in Figure 3 and Figure 4, include the following steps:
S10, block Lian Nei manufacturing enterprise's ordinary nodes generate Hash codes according to critical control link information, separately generate commodity
Traceability code and packing case case code;
In the embodiment of the present invention, manufacturing enterprise formulates the production schedule, and produces commodity according to batch, records each batch
Raw material examining report, finished product detection are reported, using the critical control links information such as raw material batch number, will be given birth to after these message linkages
At a Hash codes, super node preserves the incidence relation of Hash codes and production batch;Manufacturing enterprise generates according to batch output
The template of a certain number of traceability codes and case code, raw code can be custom-configured by enterprise;
Super node preserves Hash codes and verifies traceability code and case code in S20, block chain;
In the embodiment of the present invention, the incidence relation of Hash codes and production batch is preserved, and verifies traceability code and case code only
One property and legitimacy;
S30, situation of being cased according to commodity, by the corresponding case code of packing case and the corresponding traceability code of commodity in babinet
Barcode scanning binding is carried out, and the incidence relation of case code and traceability code is stored in super node in block chain;
In the embodiment of the present invention, manufacturing enterprise will be attached on commodity and packing case respectively by the traceability code of verification, case code,
It is worth mentioning that case code can not also be associated with batch, but packing case is imprinted on well with regard to Mass production directly before scheduled production
On.
Manufacturing enterprise cases to commodity, and operating procedure when vanning is as follows:
1. the commodity amount that setting is put into per case, such as 6;
2. first scanning the traceability code of 6 commodity, system automatically switches to case code scan pattern later;
3. scanning case code, bindings are completed;
4. system automatically switches back into traceability code scan pattern, lower 6 traceability codes are continued to scan on.
Whole process need not carry out any clicking operation, only need continuous barcode scanning that binding can be completed.Case code and traceability code
Incidence relation can preserve to super node.
S40, block Lian Nei manufacturing enterprises ordinary node are encrypted and sign to transaction record, super node verification verification
Legitimacy.
In the embodiment of the present invention, sales slip, the letters such as typing customer name, trade name, quantity, the amount of money are filled in by manufacturing enterprise
Breath, and the corresponding commodity case code of the barcode scanning typing sales slip, are encrypted and sign to transaction record finally by enterprise's private key,
Super node first verifies the legitimacy of transaction.
S50, the ordinary node scanning case code determination of block Lian Nei circulation enterprises are stocked up, and newly-increased one of super node is encrypted
Transaction record is simultaneously broadcasted;
In the embodiment of the present invention, receiving tally is filled in by circulation enterprise, and scanning case code completes confirmation of stocking up, and both parties complete true
After recognizing, super node increases an encrypted transaction record newly on disclosed block chain, and broadcasts to whole network.Note:It is attached
The multistage distribution relationship of intermediate links is omitted in figure, and in practical applications, intermediate flow is also required to fill in when having trade relations shipment to downstream
Sales slip and scanning case code, detailed process are consistent with manufacturing enterprise's sales.
Retailer's ordinary node scans sold commodity tracing code and generates order, consumer payment in S60, block chain
When, it is associated with payment accounts and commodity tracing code and preserves to super node in block chain.
In the embodiment of the present invention, simultaneously post sales, retailer scans what consumer selected to commodity incoming terminal retailer for restocking
The traceability code of commodity forms order, if consumer is paid by mobile terminal, system can payment accounts and commodity tracing code
Incidence relation, and be stored in super node, if quality problems occur in commodity when needing to recall, supervision department can be according to these
Record finds the consumer for having purchased problem batch and sends out prompting.
The present invention also proposes a kind of distributed commodity source tracing method based on block chain,
In fifth preferred embodiment of the invention, as shown in Figure 5 and Figure 6, include the following steps:
The traceability code of S100, retrospect person (consumer) items scanning initiate retrospect request to super node;
S200, traceability code case code affiliated in intermediate links is inquired in record;
In the embodiment of the present invention, request of tracing to the source can first be sent to super node, and super node is in the retrospect recorded before this
Traceability code case code affiliated in intermediate links is found in code-case code incidence relation table;
S300, the corresponding intermediate links transaction record of case code is searched in transaction record;
S400, super node are spliced into chain of tracing to the source in intermediate links transaction record according to time order and function;
S500, the manufacturing enterprise that the commodity are inquired by traceability code initiate crucial control ring to manufacturing enterprise's ordinary node
Save information inquiring request;
S600, the critical control link information of record and the Hash codes generated are reported in super node and is tested
Whether the cryptographic Hash of card, verification manufacturing enterprise return information is consistent with what is recorded before;
S700, production critical control link information is merged with chain of tracing to the source, forms complete commodity and traces to the source information,
Return to consumer.
For the present invention as shown in fig. 7, block chain organizes organization data as unit of block, block is a kind of data knot of record transaction
Structure.Each block is made of block head and block main body, and the block head of each block in addition to creating generation block contains previous
The Hash codes of block, the timestamp that block generates, and Merkel's root by transaction data generation in block body.
Merkel's root is the root node of Merkel tree, it is assumed that has 8 transaction records, the construction side of Merkel's root in block body
Formula is as follows:
1, Hash operation is done to transaction record 1-1~1-8;
2, two adjacent transaction records are connected, then does Hash operation, obtains 2-1~2-4;
3, second step is repeated, 3-1,3-2 are obtained;
4, second step is repeated, 4-1, as Merkel's root are obtained.
Block body includes field and the transaction record list of number of transaction.The data field of transaction record designs
It is as follows:
The present invention has carried out the transformation experiment of block chain on the basis of Guangdong Province's foodstuff traceability platform, is obtained in real time by API
It takes the transaction data for platform of tracing to the source to re-encrypt preservation to block chain, has been built up the food for having 8 nodes at present
It traces to the source block chain, realizes that receiving tally, sales slip, returning note inquiry and commodity are traced to the source function, in the feelings of 10,000,000 areas Ge Kuai height
Under condition, block chain APIs supports number of concurrent > 100, response time to be less than 1 second, it is sufficient to meet the trading frequency of bussiness class.
In conclusion being disclosed to whole allied members after transaction record write-in block chain of the present invention, each node in alliance
The all in store complete account book of portion, the entry in account book can only increase newly, can not distort and delete.Data in disclosed account book
By encryption, enterprise may only check the transaction record of itself by secret key;Produce the crucial control ring in the process of circulation
Section information dispersion is stored in enterprise's node, and super node only preserves Hash codes to verify whether it is tampered;Traceability code, case code
Generation needs to verify its uniqueness and legitimacy by super node;The incidence relation of case code and traceability code is established when vanning, is flowed
The i.e. recordable disengaging goods situation of case code need to be only scanned during logical.Incidence relation table is first passed through when items scanning traceability code finds this
Traceability code case code affiliated in intermediate links, then the corresponding intermediate links transaction of case code is searched in the transaction record of block chain
Record, chain of tracing to the source is spliced into according to time order and function;Improve case code and the associated operating process of traceability code, entire binning process
Any clicking operation is not needed, boxing efficiency greatly improved;When consumer buys commodity by mobile payment, record commodity chase after
Trace back the incidence relation of code and consumer payment account, can be sent to recall notice when quality problems occurs in some batch of goods
Corresponding consumer.
The foregoing is merely the preferred embodiment of the present invention, are not intended to limit the scope of the invention, every at this
Under the inventive concept of invention, using equivalent structure transformation made by description of the invention and accompanying drawing content, or directly/use indirectly
In the scope of patent protection that other related technical areas are included in the present invention.