The invention discloses a tobacco anti-counterfeiting and tracing method and
system based on a block chain, which belongs to the technical field of anti-counterfeiting and tracing. The method includesthe following steps: S1, generating a hash value for each cigarette, generating a first identification code according to the hash value of each cigarette, and printing the first identification code on each cigarette; S2, calculating a first root hash value according to the hash value of each cigarette in a pack of cigarettes, generating a second identification code and printing the second identification code on the
package box of the corresponding pack of cigarettes; S3, calculating a second root hash value according to the hash value of each pack of cigarettes in a
carton of cigarettes, generating a third identification code and printing the third identification code on the
package box of the corresponding
carton of cigarettes; S4, calculating a third root hash value according to the hash value of each
carton of cigarettes in a box of cigarettes, generating a fourth identification code and printing the fourth identification code on the
package box of the corresponding box of cigarettes; and S5, calculating a fourth root hash value according to the hash value of each box of cigarettes in a batch, and writing the hash values of each cigarette, each pack of cigarettes, each carton of cigarettes, each box of cigarettes and each batch into a
Merkle tree of a block chain. Thus, each cigarette, each pack of cigarettes, each carton of cigarettes, each box of cigarettes and each batchare managed in a stacked
Merkle tree mode, and tobacco anti-counterfeiting and tracing is realized based on the irreversible and tamper-resistant hash values of the block chain.