| The problem of food security affects the health of the nation.As is known to all,fake and shoddy products not only cause market turmoil,but also harm people physically and mentally.Therefore,more and more consumers’ dietary needs have shifted their focus to quality assurance.In order to ensure food quality and safety,food traceability is an important means to solve food safety problems.Traditional QR code traceability technology stores data in the central database of enterprises or organizations for management,which is highly centralized and difficult to guarantee the authenticity of data.Information through encryption technology,two-dimensional code technology and cryptography to encrypt important plaintext data to achieve the purpose of safe transmission of information.Blockchain technology is used to solve the trust problem of traditional database centralized unified management.Blockchain technology is applied to the food traceability system to ensure the authenticity and validity of traceability information.This paper combines the cryptographic two-dimensional code technology with blockchain technology,and proposes a cryptographic two-dimensional code traceability and anti-counterfeiting technology based on blockchain.The main work contents are as follows:(1)An improved RSA algorithm for three prime parameter replacement is presented.Using three prime factors p,q and r can reduce the number of prime factors when producing keys with the same number of digits.Parameter replacement is to use a new N value to replace the n in the public key of the traditional algorithm to increase the security of the key through number theory.Montgomery algorithm is used to convert modular multiplication and modular redundancy operations into bitwise operations,so as to improve the efficiency of the algorithm.(2)A two-dimensional code encryption system based on improved RSA algorithm is proposed and implemented.According to the requirements of the traceability system,the snowflake algorithm is used to design the traceability ID,and the applet,two-dimensional code and encryption technology are combined,and the management side and the client side are divided.The management side uses the improved RSA algorithm to generate the key,the public key is used to generate the encrypted two-dimensional code of the traceability ID,the private key is stored in the cloud database,and the consumer uses the applet to scan and decrypt the code to obtain the traceability ID and verify the authenticity.(3)A rice supply chain traceability model was built,and the application of blockchain technology in food and agricultural products supply chain traceability was analyzed.From the perspective of the quality of food and agricultural products,the data structure is extracted and the corresponding smart contract is designed.At the same time,the smart contract is used to record whether the quality of food and agricultural products is qualified.During the data entry,each node will automatically trigger the smart contract to realize the purpose of quality monitoring.According to the rice supply chain,the roles that need to be involved in the traceability link are designed,each role is certified,the business functions of each enterprise node are analyzed,and the overall traceability architecture of the food and agricultural products supply chain is constructed.(4)Implementation of Blockchain Traceability system based on Hyperledger Fabric.The implementation of blockchain network construction,smart contract deployment,client-side and consumer-side traceability query operations.The dual storage data hash mode of local plus blockchain is designed.When consumers conduct traceability query,data hash comparison is carried out to realize data verification.Two traceability query modes of Web side and small program are designed to query all relevant information in the process of production and circulation,and a food quality traceability system based on blockchain is realized.The results show that the system can realize various expected functions normally.The cryptographic Two-dimensional code traceability system designed in this paper based on blockchain proposes to build a modular,pluggable and configurable food circulation traceability hierarchical system based on blockchain technology,which can effectively enhance the credibility of data in all links of the food chain and the whole life cycle,promote the open sharing of data,and reduce the cost of food circulation. |