FoodSQRBlock: Digitizing food production & supply chain with blockchain & QR code in the cloud

—Food safety is an important issue in today’s world. Traditional agri-food production system doesn’t offer easy trace-ability of the produce at any point of the supply chain, and hence, during a food-borne outbreak, it is very difﬁcult to sift through food production data to track produce and origin of the outbreak. In recent years, blockchain based food production system has resolved this challenge, however, none of the proposed methodologies makes the food production data easily accessible, traceable and veriﬁable by consumers or producers using mobile/edge devices. In this paper, we propose FoodSQRBlock (Food Safety Quick Response Block), a blockchain technology based framework, which digitizes the food production information, and makes it easily accessible, traceable and veriﬁable by the consumers and producers by using QR codes. We also propose a large scale integration of FoodSQRBlock in the cloud to show the feasibility and scalability of the framework, and experimental evaluation to prove that.


I. INTRODUCTION
Over the decades the food production system -the way to get food from farm to the table in the household -has evolved to a complex network.Today's food production system provides the consumers more variety, convenient, economical and healthier source of food, however, such a system comes with its own challenges, such as the case where ingredients produced by one producer could end up in thousands of other products distributed in many different shops [1], [2].This challenge is an issue of food safety, which is detrimental to consumers' health and seriously damages the consumer's trust on the food market.For example, some immoral food producer could use trench oil to produce cooking oil, which is then distributed to thousands of shops, which is retrospectively bought and consumed by the consumer, making them sick in the process.Several cases of such accidents or food safety This work is supported by Nosh Technologies [nosh/agri-tech-000002]. scandals such as "horsemeat scandal" "Sudan red", "clenbuterol", "Sanlu toxic milk powder" and "trench oil" [3] have happened all over the world.These scandals not just harm the economy of the food market, but at the same time threatens the safety and stability of the society as well.Although there is no standard on how each segment of the food production system (farmer, processor, distributor, retailer, etc.) tracks and records data for food traceability purposes, in order to deal with such a challenge related to food safety, Blockchain Technology (BT) [4], [5] plays a vital role in the traceability of food ingredients in recent times such that the consumers can trace the source of the food ingredients that they are buying/consuming.
Traditionally many producers still record data of their production on papers, whereas, some producers digitize the production data, which doesn't enable interaction with other parties in the food system.Moreover, traditional food production system is centralized in nature, could result in the trust problem, such as fraud, corruption, tampering and falsifying information.During a food-borne outbreak sifting through thousands of documents (digital or paper) to trace food ingredients could be slow and complicated.In recent times, several methodologies [2], [3], [6], [7] based on BT have been proposed to solve the challenge of food traceability for food safety purposes.The key strengths of utilizing BT is its decentralized, distributed and trusted nature, which could be advantageously used for food traceability and transparency for consumers at any point of the food production system.However, all the proposed BT frameworks [2], [3], [6], [7] only deal with effective traceability of food supply chain, but not with: how to make the food traceability more accessible to consumers such that they can verify and track their bought food items, may be with an easy-to-access device such as a mobile phone.
On the other hand, a popular way to store food data digitally is by using 2D barcodes (Universal Product Code barcode) [9].The Universal Product Code (UPC) barcode consists of 12 numeric digits that are uniquely assigned to each trade/food item.Every region or country maintains a database which holds the record of these trade/food items along with the UPC unique code, which are capable of storing the following data: the type of product, size, manufacturer and the country of origin of the food item.Therefore, if a consumer wants to know more about the bought food item, they have to use a barcode reader (using mobile phone application), which will fetch the unique UPC from the barcode and then fetch the information from an online database using the UPC.Although the information are fetched from an online database, the amount of information available on the item is limited to the type of product, size, manufacturer and the country of origin based on the type of the database.Therefore, no accurate traceability of the item throughout the supply chain is available for the consumer to verify.For example, Fig. 1.(a) represents a typical 2D barcode, which accompanies the Tropicana juice's product label [8], and only reflects the following information (see Fig. It should be kept in mind that the 2D barcode in Fig. 1.(a) only allows to store 12 digit UPC and no other information, therefore, if the correct database is not used to fetch the information on the product using UPC then the information might not get retrieved at all.Moreover, if the consumer is not connected to the Internet, s/he might not even retrieve any information based on the UPC by scanning traditional 2D barcode since a lookup on the online database using UPC is necessary.
Another issue is that many food products have shorter shelf life such as fresh vegetables and fruits should be consumed within few weeks of being produced and the expiry/best before date is printed on the label of the food item during the packaging and hence, is not available in the UPC barcode information.Many food management applications [10], [11] are now being offered to remind the consumer of the expiry/best before dates of the food products to reduce food waste in the household.In these applications (apps), a consumer can record the bought food items along with their expiry/best before dates, to create a reminder to consume the items before they expire.These applications offer barcode scanning to automatically enter the bought food items in to the apps, however, given the lack of information stored in the barcode, the consumer still has to enter the expiry/best before date of each items individually.Therefore, this calls for a technology which enables the consumer not just to be able to verify the source of the bought food items throughout the supply chain for food traceability purposes, but also automatically fetch the respective expiry/best before date.
To resolve these challenges we propose FoodSQRBlock (Food Safety Quick Response Block), a BT based framework, which digitizes the food production information such that the consumer and producers can trace the food produce at any point of the food production system, and make the information easily accessible using Quick Response code (QR code) such that the information can be retrieved and verified easily by the consumers and producers.To the best of our knowledge, this is the first work to propose a traceability system utilizing blockchain and QR code together.In this paper, we also provide a large scale integration of FoodSQRBlock in the cloud such that the framework could be adopted easily given the improvement and accessibility of cloud technology.To this extent the main contributions of this paper are as follows: 1) Propose FoodSQRBlock, a BT and QR code based framework to digitize food production information and retrieval.2) Large scale integration of FoodSQRBlock in the cloud and related experimental evaluational in Google Cloud Platform.

3) Analysis and limitations of large scale integration of
FoodSQRBlock in the cloud.

A. Blockchain Technology
When Satoshi Nakamoto [5] released the technology named Bitcoin, he revolutionised the industry not because he has invented a new currency system, which do not require intervention of institutional mediator while transferring money from one entity to another, but because he has gifted one of the most disruptive technology, which has come to life in decades.With the introduction of Bitcoin, Blockchain got introduced to the world, which is a digital ledger in which all transactions are recorded chronologically and publicly.But the application of blockchain is not just limited to crypto-currencies [12], [13] such as Bitcoin and have proved to be useful in tracking ownership, provenance of documents, digital assets, physical assets, voting rights, etc. Blockchain network is traditionally of three types as follows: 1) Public: In this network, everyone can check and verify the transaction made.The network is also open to anyone who wants to participate in the consensus process.2) Private: In this type of network, strict restrictions are applied on data access and the nodes (user/entity) have restricted access to specific block chains, which are monitored by a governing body.3) Consortium: Nodes in this type of network can form partnership with businesses or other authorities.This type of network may be public or private and hence, this could be seen as a hybrid approach as partly decentralized.
Blockchain Technology is popular because of its design features, which are composed of six key elements as follows: 1) Decentralized: Blockchain data could be recorded, stored, updated and distributed without depending on a central authority or node.2) Transparency: Data recorded and stored are transparent and are visible.Therefore, leveraging trust among its users.3) Open Source: The source code as well as the most of the blockchain dependent systems are open to view, free to use and provide the ease of extension for other applications.4) Autonomous: Blockchain updates are consensus based and thus data could be updated securely from a single user to the whole system.This feature provides autonomy to the system to update data securely.5) Immutability: All data in the blockchain are reserved forever.6) Anonymity: Blockchain also provides anonymity to its users and make the system more trust worthy by only using the users' blockchain addresses instead of their personal information.

B. QR Code
QR code [14]- [16] is an effective information transmission medium, which is widely used in product traceability, advertising, mobile payment, passport verification and other fields.QR code is defined into 40 symbol versions (to carry various data payloads) and 4 user-selectable error correction level (ECL): L, M, Q and H, which can correct up to 7%, 15%, 25% and 30% error codewords respectively when attacked by defacement.The larger QR version can offer higher data payload where the QR code can hold a maximum capacity of 2,956 bytes for a version 40 code.The error correction capability of QR code is one of the key features of this type of barcode introduced by QR code standard and allows the barcode reader to retrieve the data correctly if portions of the barcode are damaged.QR code utilizes Reed-Solomon error correction algorithm to realize this fault tolerance, where the error correction codewords would be generated by Reed-Solomon algorithm and added in the tail of QR code data codewords [17]- [20].Usually two error correction codewords could be used to correct codeword data error.Obviously, the larger the QR code version and the error correction level, it can offer higher data payload and reliability.Fig. 2 represents a QR code in which a simple, "Hello, World!" message is embedded.

C. Cloud Computing
Cloud computing (cloud) [21], [22] is a model to enable ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources such as networks, servers, storage, applications, and services, which can be rapidly provisioned and released with minimal management effort or service provider interaction [23].The essential characteristics of Cloud computing are summarized as follows: 1) On-demand self-service: For cloud computing, capabilities can be provided automatically when needed, without requiring any human interaction between the consumer and the service provider.2) Broad network access: In this type of service, computing capabilities are available over the network and accessible through several mechanisms disposable for a wide range of consumer platforms such as workstations, laptops, and smartphones.3) Resource pooling: In cloud, computing resources are pooled to accommodate multiple consumers, and hence, dynamically allocating and deallocating them according to consumer's demand.Moreover, the provider resources are location independent, i.e. the consumer does not have any knowledge or control of their exact location.4) Rapid elasticity: In cloud, computing capabilities can be provided flexibly and released to scale in and out according to the consumer's demand.Therefore, the consumer has the perception of unlimited, and always adequate, computing capabilities.5) Measured service: In cloud, resource usage can be monitored and reported according to the type of service being offered.This is particularly relevant in pay-peruse, or pay-per-user services because it grants a great transparency between the provider and the consumer of such services.
Cloud services can be provided to consumers in a variety of ways, and one such service is Software as a service (SaaS) [24], where the software and its related data are centrally hosted in the cloud computing environment such that the software could be provided to numerous consumers.

III. RELATED WORK
Agri-food production and supply chains [2], [3], [6], [7] have been studied extensively.Li et al. [25] developed a dynamic planning method for agri-food supply chain.This methodology minimizes the losses of agri-food products while simultaneously maximizing the profits for agri-food supply chain members.In 2015, Foroglou et al. [26] produced a study on applications of blockchain, which included electronic cash system.In the same study, Foroglou et al. also showed applications of blockchain in different domains in the future such as contracts, voting, intellectual property rights, smart property and finance.In 2016, Tian [3] proposed an agri-food blockchain framework using RFID technology to implement data acquisition, circulation and sharing in production, processing, warehousing, distribution and sales links of agri-food supply chain.In [2], Zhao et al. foresaw the storage capacity of BT being one of the most pressing challenges for applying BT in agri-food supply chain.Another challenge on implementing BT pointed out in [2] was the demanding computational power of utilizing such framework.In [6], Astill et al. mentioned the use of Internet-of-Things (IoT) (by using sensors embedded in different stages of food production) for data acquisition of food production and supply chain, and utilizing BT to create transparency of such data.From the published aforementioned studies two important challenges arise from using BT in food production system: 1) Improving the storage capacity of blockchain data while not increasing the computational power requirement.2) Making BT based food production framework more accessible to consumers such that the food items could be verified easily at any point in the supply chain.In this paper, we propose, FoodSQRBlock, BT based framework to make food production data more traceable and then make it available/accessible to the consumers using QR code.Since, the whole framework is implemented on a large scale in the cloud, which offers flexible scalability as per consumer's demand, the challenge faced due to storage capacity is not an issue.In this section, we introduce our FoodSQRBlock framework to digitize the food production data at any point of the supply chain and make the data available and accessible to consumers for verification purposes using QR code.Fig. 3 shows the conceptual FoodSQRBlock framework of an agri-food supply chain traceability system.In Fig. 3, the food item is produced in a farm, where the relevant information are digitized and stored in block (genesis block/block 0) and then the item is transported to a warehouse/distribution center, from where the item is finally transported to a shop for consumers to by.In each step of this supply chain, a new block is created which stores the hash of the previous block such that at any point the item (produce) could be tracked and traced.We utilize SHA256 algorithm [27], which is very popular in BT nowadays, for the hash function to generate the hash of the previous block.The FoodSQRBlock has two modules: Encoding & Decoding.The Encoding module digitizes the produce information, generates the blocks and also generates the QR code holding the information.The Decode module, which is an open source software (algorithm), enables the consumers to fetch and verify the information about the produce.The program source code for Encoding and Decoding modules are provided in Sec.VII.

IV. PROPOSED FRAMEWORK: FOODSQRBLOCK
Encoding Module: If we consider f i as the i th instance of the food item being produced at a farm or manufacturing plant, then the following information (inf o(f i )) about the produce: produce name (p i ), type (t i ), farm/manufacturing plant id (f arm i ), size of produce (s i ), production date (pdate i ), expiry/best before date (edate i ), could be digitized such that these information could be passed along with the block for traceability and verification purposes by the consumer.Therefore, the digitized information could be represented as follows: In inf o(f i ), the unique farm id (f arm i ) is stored, which correlates with the farm data (farm name, Geo-location of the farm), stored in a database maintaining records of all the farms/manufacturing plants.Here, the unique farm id is also generated using the hash function on the stored details of the farm/manufacturing plant, and hence, ensuring that the farm id is unique for each farm.In the genesis block (block 0), inf o(f i ) is stored.Whenever the produce is transported or processed by an entity in the supply chain a new block is generated, which holds the original inf o(f i ) as well as the hash of the previous block.QR code could be generated at any point in the supply chain and it holds the information passed in the block (inf o(f i ) and hash of previous block).Decoding Module: In this module, the information (inf o(f i )) and the hash of the previous block are fetched using a QR code scanner (smartphone) from the QR code.Since, the information of the previous block is made available online for the consumers to verify, the Decode module performs a hash function on the information from the previous block and compares the value with the hash value fetched from the QR code.If the hash values match then it means the information about the produce is authentic (leveraging immutability characteristic of BT).A reverse search on the unique farm id fetched from the QR code is performed to fetch the details of the farm/manufacturing plant where the produce originated and the information is displayed to the consumer along with other information about the produce (p i , t i , s i , pdate i , edate i ).Since, the details of the farm/manufacturing plant is stored in a database, the reverse search on the database could be performed using the unique farm id.Note: Given the storage capacity of QR codes, more information could be stored/embedded in the QR code in the Encoding module.As a proof of concept and to test run FoodSQRBlock framework, we found inf o(f i ) embedding p i , t i , f arm i , s i , pdate i , edate i are most suitable for the purpose.

V. LARGE SCALE INTEGRATION OF FOODSQRBLOCK IN THE CLOUD
In order to implement the FoodSQRBlock in the cloud, we chose Google Cloud Platform (GCP)'s [28] Compute Engine service, which is a virtual machine consisting of 8 vCPUs, 16 GB RAM memory and 500 GB disk memory space, to setup our cloud server.The Compute Engine was running on Debian GNU OS (Linux) version 10 (code name "buster").We chose the following two food items to test run our implementation: milk & pumpkin.Milk is sourced from a local farm (Boydells Dairy Farm in Essex, UK) and pumpkin is also sourced locally (Foxes Farm Produce in Essex, UK).The milk is sourced from the farm and then sold directly in the farmer's market, whereas, the pumpkins are moved to a warehouse distributing facility after being sourced from the farm and then were sold in the farmer's market.We implemented the FoodSQRBlock as a webservice (SaaS) on the GCP Compute Engine server to process the blocks and generate QR code, containing all the relevant information, for individual produce.We simulated the production in the aforementioned farms (Boydells Dairy Farm & Foxes Farm Produce) in the cloud platform to replicate the scenario of a real world food production system.For a batch of milk being sourced around the same time, are all accumulated into the same block and blockchain consisting of two blocks (genesis block and hash of genesis block) are generated for each individual batch.Whereas, for pumpkins, every one hundred pumpkins are accumulated into the same block and since, each batch of pumpkin made it to farmer's market (shop) via distribution center, each batch was processed to consist of 3 blocks in the chain (genesis block, hash of genesis block when it went to distribution center and hash of the block from distribution center after making it to the farmer's market).In the GCP's Compute Engine, the webservice of FoodSQR-Block processed (generate hash of block along with stored information as mentioned in the Encoding module in Sec.IV) different numbers of produce to see the time taken for processing such information.Fig. 5 shows the processing time in seconds for 1, 10, 100, 1000, 10000, 100000 number of produces on the GCP's Compute Engine.

B. Analysis & Discussion
From Sec.V-A it is evident that given the resources of GCP's Compute Engine, 10,000 items could be processed easily under 80 minutes.However, if a farm or manufacturing plant produces more than 10,000 items in a day then a more computationally powerful cloud server is required to be able to process the items within a reasonable time.Because GCP allows flexible ad-hoc computation resources for its Compute Engine, it is easy for us to scale up or down based on the numbers of items to be processed, therefore, solving the storage capacity issue of BT as mentioned in Sec.III.

VI. CONCLUSION
In this paper, we proposed FoodSQRBlock, a blockchain technology based framework, which digitizes the food production information, and makes it easily accessible, traceable and verifiable by the consumers and producers by using QR codes to embed the information.We also implemented Food-SQRBlock in Google Cloud Platform to replicate a real life food production scenario using milk & pumpkins as produce examples.Experimental evaluation proves the feasibility and scalability of FoodSQRBlock implementation in the cloud.

Fig. 3 .
Fig. 3. Conceptual FoodSQRBlock framework of an agri-food supply chain traceability system based on QR code & blockchain technology Fig. 4. QR code holding information of a dairy product, which is produced at Boydells Dairy Farm in the UK, generated by FoodSQRBlock

Fig. 4 .
(a)  shows the QR code generated at the shop when the produced milk is transported to the shop (from farm to warehouse/distribution center to shop).

Fig. 4 .
(b) shows the decoded information about the dairy product, fetched from the QR code in Fig. 4.(a).

Fig. 5 .
Fig. 5. Time taken to process different number of items (using FoodSQR-Block) in Google Cloud Platform's Compute Engine