Disclosure of Invention
In order to provide a more reliable and efficient tobacco anti-counterfeiting and tracing method, the embodiment of the invention provides a tobacco anti-counterfeiting and tracing method and system based on a block chain. The technical scheme is as follows:
in a first aspect, a tobacco anti-counterfeiting and tracing method based on a block chain is provided, the method comprising:
s1, generating a hash value for each cigarette, respectively generating corresponding first identification codes according to the hash value of each cigarette, printing the first identification codes on the corresponding cigarettes, and writing the hash value of each cigarette into a merkle tree of a block chain;
s2, calculating a first tree root hash value according to the hash value of each cigarette in a cigarette packet, generating a second identification code according to the first tree root hash value, printing the second identification code on a corresponding packaging box of the cigarette packet, and writing the calculated first tree root hash value corresponding to each cigarette packet into a merkle tree of a block chain;
s3, calculating a second tree root hash value according to the hash value of each cigarette pack in one cigarette, generating a third identification code according to the second tree root hash value, printing the third identification code on a packaging box of the one cigarette, and writing the calculated second tree root hash value corresponding to each cigarette into a merkle tree of a block chain;
s4, calculating a third root hash value according to the hash value of each cigarette in a box of cigarettes, generating a fourth identification code according to the third root hash value, printing the fourth identification code on a packaging box of the box of cigarettes, and writing the calculated third root hash value corresponding to each box of cigarettes into a merkle tree of a block chain;
s5, calculating a fourth tree root hash value according to the hash value of each box of cigarettes in a batch, and writing the fourth tree root hash value into a blockchain merkle tree;
s6, in the transportation process of a carrier, by identifying the identification code on each box of tobacco, recording transportation node information and time information, writing the transportation node information and the time information into a block chain, and identifying the authenticity of the tobacco according to the identification code;
and S7, after the retailer and the consumer obtain the tobacco, identifying the authenticity of the tobacco according to the identification code.
With reference to the first aspect, in a first possible implementation manner, the step S2 is executed by writing tobacco information in a blockchain;
the tobacco information comprises manufacturers, production dates, production addresses and production batch numbers.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner, after the retailer and the consumer obtain the tobacco, the identifying the authenticity of the tobacco according to the identification code includes:
after the retailers and consumers acquire the tobacco, acquiring corresponding hash values by identifying the fourth identification code on the packaging box of a box of tobacco, and acquiring corresponding hash values by identifying the third identification code on the packaging box of a cigarette in the box;
calculating a hash value corresponding to the acquired fourth identification code and a hash value corresponding to the third identification code, and determining whether the cigarette belongs to the box; and/or
Acquiring a corresponding hash value by identifying the third identification code on a packing box of a cigarette, and acquiring a corresponding hash value by identifying the second identification code on a packing box of a pack of cigarettes in the cigarette;
calculating a hash value corresponding to the acquired third identification code and a hash value corresponding to the second identification code, and determining whether the cigarette packet belongs to the cigarette; and/or
Acquiring a corresponding hash value by identifying the second identification code on a packaging box of a cigarette, and acquiring a corresponding hash value by identifying the first identification code on one cigarette in the cigarette;
calculating the hash value of the acquired second identification code and the hash value corresponding to the first identification code, and determining whether the cigarette belongs to the cigarette packet;
the tobacco information is written into the block chain and then shared in the block chain, and the tobacco information is acquired by identifying a fourth identification code of a box of cigarettes, a third identification code of a cigarette, a second identification code of a cigarette pack and a first identification code of a cigarette.
With reference to the first aspect, in a third possible implementation manner, during transportation by the carrier, the identifying the authenticity of the tobacco according to the identification code includes:
acquiring a hash value corresponding to a fourth identification code by identifying the fourth identification code on the checked box tobacco;
and calculating according to the obtained hash value and the hash value of the batch of the goods, and determining whether the checked box tobacco belongs to the batch.
With reference to the first aspect, in a fourth possible implementation manner, the identification code includes a two-dimensional code, a barcode, or an RFID code.
In a second aspect, a tobacco anti-counterfeiting and tracing system based on a block chain is provided, the system comprises a first terminal device, an identification device and a second terminal device, wherein,
the first terminal device includes:
the hash value generation module of each cigarette is used for generating a hash value for each cigarette;
the identification code generation module is used for respectively generating corresponding first identification codes according to the hash value of each cigarette;
the printing module is used for printing the first identification code on each corresponding cigarette;
a first writing module, configured to write the hash value of each cigarette into a merkle tree of a block chain;
the first tree root hash value calculating module is used for calculating a first tree root hash value according to the hash value of each cigarette in a pack of cigarettes;
the identification code generation module is further used for generating a second identification code according to the hash value of the first tree root;
the printing module is also used for printing the second identification code on the corresponding packaging box of the cigarette pack;
the first writing module is further used for writing the calculated first tree root hash value corresponding to each cigarette packet into a merkle tree of the block chain;
the second tree root hash value calculation module is used for calculating a second tree root hash value according to the hash value of each cigarette pack in one cigarette;
the identification code generation module is further used for generating a third identification code according to the hash value of the second tree root;
the printing module is also used for printing the third identification code on the packaging box of the cigarette;
the first writing module is further configured to write the calculated second tree root hash value corresponding to each cigarette into the merkle tree of the block chain;
the third root hash value generation module is used for calculating a third root hash value according to the hash value of each cigarette in a box of cigarettes;
the identification code generation module is further used for generating a fourth identification code according to the hash value of the third root;
the printing module is also used for printing the fourth identification code on the packaging box of the box of cigarettes;
the first writing module is further used for writing the calculated third root hash value corresponding to each box of cigarettes into the merkle tree of the block chain;
the fourth tree root hash value calculating module is used for calculating a fourth tree root hash value according to the hash value of each box of cigarettes in a batch;
the first writing module is further configured to write the fourth tree root hash value into a blockchain merkle tree;
the identification device includes:
the first identification code recognition module is used for recognizing the identification code on each box of tobacco in the transportation process of a transport provider;
the recording module is used for recording the transport node information and the time information by identifying the identification code on each box of tobacco;
the second writing module is used for writing the transport node information and the time information into a block chain;
the first identifying module is used for identifying the authenticity of the tobacco according to the identification code;
the second terminal device includes:
and the second identification module is used for identifying the authenticity of the tobacco according to the identification code after the retailer and the consumer obtain the tobacco.
With reference to the second aspect, in a first possible implementation manner, the first writing module is further configured to write tobacco information in a blockchain;
the tobacco information comprises manufacturers, production dates, production addresses and production batch numbers.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner, the second authentication module includes:
the second identification code recognition unit is used for recognizing the fourth identification code on the packaging box of the box of tobacco after the retailer and the consumer obtain the tobacco;
the first hash value acquisition unit is used for acquiring a corresponding hash value by identifying the fourth identification code on the packaging box of the box of tobacco;
the second identification code recognition unit is also used for recognizing the third identification code on the packaging box of one cigarette in the box;
the first hash value acquisition unit is further used for acquiring a corresponding hash value by identifying the third identification code on the packaging box of one cigarette in the box;
a first determining unit, configured to calculate a hash value corresponding to the acquired fourth identification code and a hash value corresponding to the third identification code, and determine whether the cigarette belongs to the bin; and/or
The first hash value acquisition unit is further used for acquiring a corresponding hash value by identifying the third identification code on the packaging box of one cigarette;
the second identification code recognition unit is also used for recognizing the second identification code on a packing box of a cigarette in the cigarette;
the first hash value acquisition unit is further used for acquiring a corresponding hash value by identifying the second identification code on the packaging box of one cigarette in the one cigarette;
the first determining unit is further configured to calculate a hash value corresponding to the acquired third identification code and a hash value corresponding to the second identification code, and determine whether the cigarette packet belongs to the cigarette; and/or
The first hash value acquisition unit is further used for acquiring a corresponding hash value by identifying the second identification code on the packaging box of a cigarette;
the second identification code identification unit is also used for identifying a first identification code on one cigarette in the cigarette pack;
the first hash value acquisition unit is further used for acquiring a corresponding hash value by identifying a first identification code on one cigarette in the pack of cigarettes;
the first determining unit is further configured to calculate a hash value of the acquired second identification code and a hash value corresponding to the first identification code, and determine whether the cigarette belongs to the cigarette packet;
the first writing module writes tobacco information into the block chain and shares the tobacco information in the block chain, and the second identification code recognition unit obtains the tobacco information through a fourth identification code for recognizing a box cigarette, a third identification code for a cigarette, a second identification code for a cigarette pack and a first identification code for a cigarette.
With reference to the second aspect, in a third possible implementation manner, the first authentication module includes:
the second hash value acquisition unit is used for acquiring a hash value corresponding to a fourth identification code by identifying the fourth identification code on the checked box tobacco;
and the second determining unit is used for calculating according to the obtained hash value and the hash value of the batch of the goods, and determining whether the checked box tobacco belongs to the batch.
With reference to the second aspect, in a fourth possible implementation manner, the identification code includes a two-dimensional code, a barcode, or an RFID code.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
the embodiment of the invention provides a tobacco anti-counterfeiting and tracing method and a system based on a block chain, wherein a hash value is generated for each cigarette, the hash value of each cigarette respectively generates a corresponding first identification code to be printed on each corresponding cigarette, a first root hash value is calculated according to the hash value of each cigarette in a cigarette pack, and a second identification code is generated to be printed on a corresponding cigarette pack box; calculating the hash value of a second tree root according to the hash value of each cigarette pack in one cigarette, generating a third identification code and printing the third identification code on a packaging box of one cigarette; calculating a hash value of a third root according to the hash value of each cigarette in a box of cigarettes, generating a fourth identification code and printing the fourth identification code on a packaging box of the box of cigarettes; calculating the hash value of the fourth tree root according to the hash value of each box of cigarettes in a batch; writing the hash value of tobacco from each branch to each packet, strip, box and batch into a block chain merkle tree; so that the tobacco has a unique corresponding hash value from the batch to all the cases of tobacco contained in the batch, to each pack of tobacco contained in each case, and finally to each piece of tobacco contained in each pack of tobacco, the hash value of each pack of tobacco is calculated from the hash value of each pack of tobacco contained therein, the hash value of each box of tobacco is calculated from the hash value of each box of tobacco contained therein, the hash values of a batch of tobacco are calculated from the hash values of each box of tobacco contained therein, in this way, the management of the tobacco from branch, pack, strip to box and batch is realized by the stacked merkle trees, which are stored in the block chain, each cigarette is bound with a cigarette packet, each cigarette packet is bound with a cigarette carton package, and each cigarette carton package is bound with a case package, so that the authenticity and traceability of tobacco in a block chain can be guaranteed; meanwhile, in the transportation process of a transport provider, the transport node information and the time information are recorded by identifying the identification code on each box of tobacco, the transport node information and the time information are written into a block chain, and the authenticity of the tobacco is identified according to the identification code; after the retailers and consumers acquire the tobacco, identifying the authenticity of the tobacco according to the identification codes; when the transport company or other departments check the tobacco, the corresponding hash value is obtained by identifying the identification code on the box package, the hash value is calculated by matching with the hash value of the batch of tobacco, and the box tobacco is determined to belong to the batch, so that the authenticity of the box of tobacco is ensured; after a retailer acquires tobacco, the retailer can identify an identification code or a corresponding hash value on a strip package, calculate the hash value of the tobacco in the box through the hash value and determine that the strip package tobacco belongs to the box if the hash value is matched with the hash value, so that the retailer can determine the authenticity of the tobacco, after a consumer acquires a packet of tobacco, identify the identification code on a cigarette to acquire the hash value, calculate the hash value of the tobacco through the hash value and determine that the branch tobacco belongs to the packet if the hash value is matched with the hash value, so that each link can verify the authenticity of the tobacco and inquire tobacco information such as production place, production time and the like, and each node of a supply chain can also verify the authenticity of the product, so that the tobacco anti-counterfeiting and tracing method provided by the embodiment of the invention improves the recognition degree of the verification, and is convenient to recognize and efficient; in addition, the generated identification code only needs to be printed on the package, and compared with the three-dimensional holographic mold, the fluorescent code anti-counterfeiting, the variable frequency ink anti-counterfeiting, the light variable ink anti-counterfeiting and the like in the prior art, the cost is low, the printing process is convenient, and other cost or anti-counterfeiting materials are not needed.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, 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 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.
Example one
The embodiment of the invention provides a tobacco anti-counterfeiting and tracing method based on a block chain, which is shown in figure 1 and comprises the following steps:
s1, generating a hash value for each cigarette, respectively generating corresponding first identification codes according to the hash value of each cigarette, printing the first identification codes on each corresponding cigarette, and writing the hash value of each cigarette into the merkle tree of the block chain.
The identification code comprises a two-dimensional code, a bar code or an RFID code, and can also be other identification codes suitable for being printed or attached on tobacco or other commodities.
Specifically, the process of generating a hash value for each cigarette may include:
a. assigning a marker code to each cigarette;
the marker code includes using an ASCII code arrangement as the marker code.
For example, each cigarette is marked with an ASCII code, and the 7-bit ASCII code may not be repeated in the mark 1287Smoke is detected; other numbers, symbols or letters can also be used as the mark code of each cigarette, which is not limited in the embodiment of the present invention.
b. Generating a hash value corresponding to each cigarette according to the mark code of each cigarette;
specifically, according to the mark code allocated to each cigarette, a corresponding hash value is calculated through a hash algorithm.
If the first identification code is a two-dimensional code, the hash value of each cigarette is respectively generated into a corresponding two-dimensional code, then the two-dimensional code of each cigarette is printed on the outer packaging paper of the cigarette, and the hash value of each cigarette is written into a merkle tree (a tree in a data structure) of the block chain for recording.
The method comprises the steps of distributing a mark code for each cigarette to generate a corresponding hash value, generating an identification code according to the hash value of each cigarette, printing the identification code on each corresponding cigarette, writing the hash value of each cigarette into a merkle tree of a block chain, recording each cigarette through the block chain, and if the cigarette is fake, not obtaining the corresponding hash value in the block chain, so that each cigarette is guaranteed not to be fake and can be traced to the source.
S2, calculating a first tree root hash value according to the hash value of each cigarette in a cigarette packet, generating a second identification code according to the first tree root hash value, printing the second identification code on a corresponding cigarette packet packaging box, and writing the calculated first tree root hash value corresponding to each cigarette packet into the merkle tree of the block chain.
Wherein, also include writing into the tobacco information in the block chain;
the tobacco information comprises manufacturers, production dates, production addresses and production batch numbers; besides, other tobacco information, such as the tobacco producing area, the content of each component of the tobacco, etc., may also be included, and the embodiment of the present invention does not limit the specific written tobacco information.
Specifically, when the first root hash value corresponding to each cigarette packet is written into merkle of the block chain, the tobacco information is written into the block chain along with each cigarette packet, so as to share the tobacco information in the block chain.
Through writing into tobacco information into the block chain along with every packet of cigarette, made things convenient for other people to acquire tobacco information, simultaneously, because the tobacco information of writing into the block chain can share to when other people discernment cigarette, a packet of cigarette or a cigarette etc. all can obtain tobacco information, made things convenient for the user to look over in order to realize tracing to the source to the tobacco.
S3, calculating a second tree root hash value according to the hash value of each cigarette pack in one cigarette, generating a third identification code according to the second tree root hash value, printing the third identification code on a packaging box of one cigarette, and writing the calculated second tree root hash value corresponding to each cigarette into the merkle tree of the block chain.
S4, calculating a hash value of a third tree root according to the hash value of each cigarette in one box of cigarettes, generating a fourth identification code according to the hash value of the third tree root, printing the fourth identification code on a packaging box of one box of cigarettes, and writing the calculated hash value of the third tree root corresponding to each box of cigarettes into the merkle tree of the block chain.
And S5, calculating a fourth tree root hash value according to the hash value of each box of cigarettes in a batch, and writing the fourth tree root hash value into the blockchain merkle tree.
Specifically, still include:
writing the corresponding fourth root hash value for each batch of tobacco to the merkle tree of the blockchain.
S6, during transportation by a carrier, the transport node information and the time information are recorded by identifying the identification code on each box of tobacco, the transport node information and the time information are written into the block chain, and the authenticity of the tobacco is identified according to the identification code.
Specifically, in the transportation process of the carrier, the process of identifying the authenticity of the tobacco according to the identification code may include:
acquiring a hash value corresponding to a fourth identification code by identifying the fourth identification code on the checked box tobacco;
and calculating according to the obtained hash value and the hash value of the batch of the goods, and determining whether the box tobacco subjected to the drawing test belongs to the batch.
And S7, after the retailers and the consumers acquire the tobacco, identifying the authenticity of the tobacco according to the identification codes.
The retailer and the consumer may obtain the case-packed tobacco, the strip-packed tobacco, the packet-packed tobacco and each piece of tobacco in each packet, and can verify the authenticity of the tobacco from each piece, packet, strip to packet, the preferred retailer verifies the authenticity of the tobacco by verifying whether each piece of tobacco belongs to the packet and whether each packet of tobacco belongs to the strip, and the consumer preferably verifies the authenticity of the tobacco by verifying whether each piece of tobacco belongs to the packet;
specifically, the process may include:
after the retailers and consumers acquire the tobacco, acquiring corresponding hash values by identifying the fourth identification code on the packaging box of a box of tobacco, and acquiring corresponding hash values by identifying the third identification code on the packaging box of a cigarette in the box;
calculating a hash value corresponding to the acquired fourth identification code and a hash value corresponding to the third identification code to determine whether a cigarette belongs to a box; and/or
Acquiring a corresponding hash value by identifying a third identification code on a packaging box of a cigarette, and acquiring a corresponding hash value by identifying a second identification code on a packaging box of a pack of cigarettes in the cigarette;
calculating a hash value corresponding to the acquired third identification code and a hash value corresponding to the second identification code to determine whether a packet of cigarettes belongs to a cigarette; and/or
Acquiring a corresponding hash value by identifying a second identification code on a packaging box of a cigarette, and acquiring a corresponding hash value by identifying a first identification code on one cigarette in the cigarette;
calculating the hash value of the acquired second identification code and the hash value corresponding to the first identification code to determine whether a cigarette belongs to a pack of cigarettes;
the tobacco information is written into the block chain and then shared in the block chain, and the tobacco information is acquired by identifying a fourth identification code of a box of cigarettes, a third identification code of a cigarette, a second identification code of a cigarette pack and a first identification code of a cigarette.
Optionally, the method provided by the embodiment of the invention can also be applied to anti-counterfeiting and tracing in the fields of medicines, foods, vaccines, branded goods, luxury goods and the like, and if the anti-counterfeiting and tracing method adopted in the fields and the anti-counterfeiting and tracing method related to tobacco belong to the same idea, the method is within the protection scope of the invention.
Optionally, the method provided by the embodiment of the present invention can be applied to any one of a common chain, a federation chain, and a private chain in a block chain.
The embodiment of the invention provides a tobacco anti-counterfeiting and tracing method based on a block chain, which comprises the steps of generating a hash value for each cigarette, respectively generating a corresponding first identification code for each cigarette, printing the corresponding first identification code on each cigarette, calculating a first root hash value according to the hash value of each cigarette in a cigarette packet, and generating a second identification code, and printing the second identification code on a corresponding cigarette packet packaging box; calculating the hash value of a second tree root according to the hash value of each cigarette pack in one cigarette, generating a third identification code and printing the third identification code on a packaging box of one cigarette; calculating a hash value of a third root according to the hash value of each cigarette in a box of cigarettes, generating a fourth identification code and printing the fourth identification code on a packaging box of the box of cigarettes; calculating the hash value of the fourth tree root according to the hash value of each box of cigarettes in a batch; writing the hash value of tobacco from each branch to each packet, strip, box and batch into a block chain merkle tree; so that the tobacco has a unique corresponding hash value from the batch to all the cases of tobacco contained in the batch, to each pack of tobacco contained in each case, and finally to each piece of tobacco contained in each pack of tobacco, the hash value of each pack of tobacco is calculated from the hash value of each pack of tobacco contained therein, the hash value of each box of tobacco is calculated from the hash value of each box of tobacco contained therein, the hash values of a batch of tobacco are calculated from the hash values of each box of tobacco contained therein, in this way, the management of the tobacco from branch, pack, strip to box and batch is realized by the stacked merkle trees, which are stored in the block chain, each cigarette is bound with a cigarette packet, each cigarette packet is bound with a cigarette carton package, and each cigarette carton package is bound with a case package, so that the authenticity and traceability of tobacco in a block chain can be guaranteed; meanwhile, in the transportation process of a carrier, the transportation node information and the time information are recorded by identifying the identification code on each box of tobacco, the transportation node information and the time information are written into a block chain, and the authenticity of the tobacco is identified according to the identification code; after the retailers and consumers acquire the tobacco, identifying the authenticity of the tobacco according to the identification codes; when the transport company or other departments check the tobacco, the corresponding hash value is obtained by identifying the identification code on the box package, the hash value is calculated by matching with the hash value of the batch of tobacco, and the box tobacco is determined to belong to the batch, so that the authenticity of the box of tobacco is ensured; after a retailer acquires tobacco, the retailer can identify an identification code or a corresponding hash value on a strip package, calculate the hash value of the tobacco in the box through the hash value and determine that the strip package tobacco belongs to the box if the hash value is matched with the hash value, so that the retailer can determine the authenticity of the tobacco, after a consumer acquires a packet of tobacco, identify the identification code on a cigarette to acquire the hash value, calculate the hash value of the tobacco through the hash value and determine that the branch tobacco belongs to the packet if the hash value is matched with the hash value, so that each link can verify the authenticity of the tobacco and inquire tobacco information such as production place, production time and the like, and each node of a supply chain can also verify the authenticity of the product, so that the tobacco anti-counterfeiting and tracing method provided by the embodiment of the invention improves the recognition degree of the verification, and is convenient to recognize and efficient; in addition, the generated identification code only needs to be printed on the package, and compared with the three-dimensional holographic mold, the fluorescent code anti-counterfeiting, the variable frequency ink anti-counterfeiting, the light variable ink anti-counterfeiting and the like in the prior art, the cost is low, the printing process is convenient, and other cost or anti-counterfeiting materials are not needed.
Example two
An embodiment of the present invention provides a tobacco anti-counterfeiting and tracing system based on a block chain, and as shown in fig. 2, the system 2 includes a first terminal device 21, an identification device 22, and a second terminal device 23, wherein,
the first terminal device 21 includes:
a hash value generation module 211 for each cigarette, configured to generate a hash value for each cigarette;
the identification code generating module 212 is used for respectively generating corresponding first identification codes according to the hash value of each cigarette;
a printing module 213, configured to print the first identification code on each corresponding cigarette;
a first writing module 214, configured to write the hash value of each cigarette into a merkle tree of the blockchain;
a first tree root hash value calculation module 215, configured to calculate a first tree root hash value according to a hash value of each cigarette in a pack of cigarettes;
the identification code generating module 212 is further configured to generate a second identification code according to the hash value of the first tree root;
the printing module 213 is further configured to print the second identification code on a corresponding cigarette packing box;
the first writing module 214 is further configured to write the calculated first root hash value corresponding to each cigarette packet into the merkle tree of the blockchain;
a second root hash value calculation module 216, configured to calculate a second root hash value according to a hash value of each cigarette pack in a cigarette;
the identification code generating module 212 is further configured to generate a third identification code according to the hash value of the second tree root;
the printing module 213 is further configured to print a third identification code on the packaging box of a cigarette;
the first writing module 214 is further configured to write the calculated second root hash value corresponding to each cigarette into the merkle tree of the blockchain;
a third root hash value generation module 217, configured to calculate a third root hash value according to the hash value of each cigarette in a box of cigarettes;
the identification code generating module 212 is further configured to generate a fourth identification code according to the hash value of the third root;
the printing module 213 is further configured to print a fourth identification code on a packing box of a box of cigarettes;
the first writing module 214 is further configured to write the calculated third root hash value corresponding to each box of smoke into the merkle tree of the blockchain;
a fourth root hash value calculation module 218, configured to calculate a fourth root hash value according to the hash value of each box of cigarettes in a batch;
the first writing module 214 is further configured to write the fourth tree root hash value into the blockchain merkle tree;
the identification device 22 includes:
the first identification code recognition module 221 is used for recognizing the identification code on each box of tobacco in the transportation process of a carrier;
a recording module 222, configured to record transportation node information and time information by identifying an identification code on each box of tobacco;
a second writing module 223, configured to write the transportation node information and the time information into the block chain;
the first identifying module 224 is used for identifying the authenticity of the tobacco according to the identification code;
the second terminal device 23 includes:
and the second identification module 231 is used for identifying the authenticity of the tobacco according to the identification code after the retailer and the consumer acquire the tobacco.
Optionally, the first writing module 214 is further configured to write tobacco information in the blockchain;
the tobacco information comprises manufacturers, production dates, production addresses and production batch numbers.
Optionally, the second authentication module 231 includes:
a second identification code recognition unit 2311 for recognizing a fourth identification code on a package of a pack of tobacco after the retailer and the consumer have acquired the tobacco;
a first hash value obtaining unit 2312, configured to obtain a corresponding hash value by identifying a fourth identification code on a packing box of a box of tobacco;
the second identification code recognition unit 2311 is also used for recognizing a third identification code on a packing box of a cigarette in the box;
the first hash value obtaining unit 2312 is further configured to obtain a corresponding hash value by identifying a third identification code on a packing box of a cigarette in the carton;
a first determining unit 2313, configured to calculate a hash value corresponding to the acquired fourth identifier and a hash value corresponding to the third identifier, and determine whether a cigarette belongs to a carton; and/or
The first hash value obtaining unit 2312 is further configured to obtain a corresponding hash value by identifying a third identification code on a packing box of a cigarette;
the second identification code recognition unit 2311 is also used for recognizing a second identification code on a pack of a cigarette in a strip of cigarettes;
the first hash value obtaining unit 2312 is further configured to obtain a corresponding hash value by identifying a second identification code on a packing box of a pack of cigarettes in a cigarette;
the first determining unit 2313 is further configured to calculate a hash value corresponding to the acquired third identification code and a hash value corresponding to the second identification code, and determine whether a packet of cigarettes belongs to a cigarette; and/or
The first hash value obtaining unit 2312 is further configured to obtain a corresponding hash value by recognizing a second identification code on a packing box of a pack of cigarettes;
the second identification code recognition unit 2311 is also used for recognizing the first identification code on one cigarette in one pack of cigarettes;
the first hash value obtaining unit 2312 is further configured to obtain a corresponding hash value by identifying a first identification code on one cigarette in a pack of cigarettes;
the first determining unit 2313 is further configured to calculate a hash value of the obtained second identification code and a hash value corresponding to the first identification code, and determine whether a cigarette belongs to a pack of cigarettes;
after the first writing module 214 writes the tobacco information into the blockchain, the tobacco information is shared in the blockchain, and the second identification code recognition unit 2311 acquires the tobacco information by recognizing the fourth identification code of a cigarette carton, the third identification code of a cigarette, the second identification code of a cigarette pack and the first identification code of a cigarette.
Optionally, the first authentication module 224 includes:
a second hash value obtaining unit 2241, configured to obtain a hash value corresponding to the fourth identification code by identifying the fourth identification code on the checked box tobacco;
and the second determining unit 2242 is configured to calculate according to the obtained hash value and the hash value of the batch of the goods, and determine whether the checked box tobacco belongs to the batch.
Optionally, the identification code comprises a two-dimensional code, a barcode or an RFID code.
The embodiment of the invention provides a tobacco anti-counterfeiting and tracing system based on a block chain, which generates a hash value for each cigarette, respectively generates a corresponding first identification code for each cigarette, prints the corresponding first identification code on each cigarette, calculates a first root hash value according to the hash value of each cigarette in a cigarette pack, generates a second identification code, and prints the second identification code on a corresponding cigarette pack box; calculating the hash value of a second tree root according to the hash value of each cigarette pack in one cigarette, generating a third identification code and printing the third identification code on a packaging box of one cigarette; calculating a hash value of a third root according to the hash value of each cigarette in a box of cigarettes, and generating a fourth identification code printed on a packaging box of the box of cigarettes; calculating the hash value of the fourth tree root according to the hash value of each box of cigarettes in a batch; writing the hash value of tobacco from each branch to each packet, strip, box and batch into a block chain merkle tree; so that the tobacco has a unique corresponding hash value from the batch to all the cases of tobacco contained in the batch, to each pack of tobacco contained in each case, and finally to each piece of tobacco contained in each pack of tobacco, and the hash value of each package of tobacco is calculated from the hash value of each package of tobacco contained therein, the hash value of each box of tobacco is calculated from the hash value of each package of tobacco contained therein, the hash values of a batch of tobacco are calculated from the hash values of each box of tobacco contained therein, in this way, the management of the tobacco from branch, pack, strip to box and batch is realized by the stacked merkle trees, which are stored in the block chain, each cigarette is bound with a cigarette packet, each cigarette packet is bound with a cigarette carton package, and each cigarette carton package is bound with a case package, so that the authenticity and traceability of tobacco in a block chain can be guaranteed; meanwhile, in the transportation process of a carrier, the transportation node information and the time information are recorded by identifying the identification code on each box of tobacco, the transportation node information and the time information are written into a block chain, and the authenticity of the tobacco is identified according to the identification code; after the retailers and consumers acquire the tobacco, identifying the authenticity of the tobacco according to the identification codes; when the transport company or other departments check the tobacco, the corresponding hash value is obtained by identifying the identification code on the box package, the hash value is calculated by matching with the hash value of the batch of tobacco, and the box tobacco is determined to belong to the batch, so that the authenticity of the box of tobacco is ensured; after a retailer acquires tobacco, the retailer can identify an identification code or a corresponding hash value on a strip package, calculate the hash value of the tobacco in the box through the hash value and determine that the strip package tobacco belongs to the box if the hash value is matched with the hash value, so that the retailer can determine the authenticity of the tobacco, after a consumer acquires a packet of tobacco, identify the identification code on a cigarette to acquire the hash value, calculate the hash value of the tobacco through the hash value and determine that the branch tobacco belongs to the packet if the hash value is matched with the hash value, so that each link can verify the authenticity of the tobacco and inquire tobacco information such as production place, production time and the like, and each node of a supply chain can also verify the authenticity of the product, so that the tobacco anti-counterfeiting and tracing method provided by the embodiment of the invention improves the recognition degree of the verification, and is convenient to recognize and efficient; in addition, the generated identification code only needs to be printed on the package, and compared with the three-dimensional holographic mold, the fluorescent code anti-counterfeiting, the variable frequency ink anti-counterfeiting, the light variable ink anti-counterfeiting and the like in the prior art, the cost is low, the printing process is convenient, and other cost or anti-counterfeiting materials are not needed.
All the above-mentioned optional technical solutions can be combined arbitrarily to form the optional embodiments of the present invention, and are not described herein again.
It should be noted that: in the tobacco anti-counterfeiting and tracing system based on the block chain provided by the embodiment, when the tobacco anti-counterfeiting and tracing method based on the block chain is executed, only the division of the functional modules is taken as an example, and in practical application, the function distribution can be completed by different functional modules according to needs, that is, the internal structure of the system is divided into different functional modules so as to complete all or part of the functions described above. In addition, the block chain-based tobacco anti-counterfeiting and tracing system provided by the embodiment and the block chain-based tobacco anti-counterfeiting and tracing method embodiment belong to the same concept, and the specific implementation process thereof is detailed in the method embodiment and is not repeated herein.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.