Application of blockchain technology for beverage safety in intelligent ready-made beverage machines

In recent years, beverage machines are popular and have a wide market, but the current beverage machines have insecurity factors such as low efficiency of source control, the possibility of data being tampered with, lack of intelligent warning and forced termination


Introduction
Ready-made beverages have been the hottest food industry in the past two years. The development of the ready-made beverage market has benefited from the concentrated explosion of "Netflix", which has rapidly become popular with the power of capital (Mostafa, 2022). According to the increasing number of beverage shops, the size of the ready-made beverage market is expanding, and this growth is mainly due to the replacement of conventional beverages by consumers and the demand of consumer groups for "healthy ready-made beverages" (Pinto et al., 2022;Ma et al., 2023). At the same time, along with the gradual sinking of consumption upgrades, the future of ready-made beverages in second and third-tier cities also has a huge market development space.
However, in recent years, there have been numerous beverage safety incidents, with varying magnitude occurring every year (Nelson et al., 2022). For example, in July 2022, a customer drank a foreign substance from a cap of ready-made beverage purchased at a well-known beverage shop, so it is urgent to solve the problems in the field of beverage safety. As an important means of ensuring beverage safety, beverage safety traceability is becoming a hot topic of research. The so-called beverage safety traceability is the effective management of information on the source of raw materials, beverage production, and key aspects of beverage production, through the monitoring and management of such information to achieve early warning and traceability, to prevent and reduce the emergence of problems, once problems can be quickly traced back to the source (Putson et al., 2022).
Although the current beverage machine doesn't need a lot of manual support but also faces the same drink safety problems. One of them is malicious poisoning, and it cannot be traced back to the source, which seriously affects the safety of people's livelihood; the other is that the product expiry cannot be reminded in time, which is a safety hazard; the third is that the product drink making fails and the reason cannot be traced; the fourth is that the lack of material cannot be notified in time and can only be checked manually. Thus, the market urgently needs beverage machines with safe traceability, good information consistency, and non-tamperable information.
The current construction of a quality and safety traceability system for beverages mainly considers the application of RFID technology, using RFID systems to track food in real time and trace the parties involved in each node (Tanner, 2016;Samsami & Yasrebi, 2020). However, the use of RFID technology alone can't solve the problem of information security and consistency, as its use of a centralized database as the data storage medium has the potential to be tampered with and lost due to attacks or unforeseen circumstances. Blockchain technology can solve the problem of low data security of the traceability system due to its decentralization advantage.

Introduction to blockchain technology
Blockchain technology has grown rapidly in recent years and is emerging as a leader in many fields (Yli-Huumo et al., 2016;Sikorski et al., 2017). It is a distributed database based on the Bitcoin protocol that does not require a license. It can maintain a continuously growing list of data records that can't be tampered with or modified, even for the operators of the database nodes. In short, a blockchain is a chain of blocks organized in some way.
Blockchain technology's information can't be tampered with, traceable characteristics make blockchain technology in the beverage machine great advantages, the quality and rigor of information are very important to the beverage machine, one is the source of food and beverage can be traced, can ensure the safety of the source of the drink, the second is the customer to the drink can be real-time clear drink all information so that customers have no worries.

Hash consistency
The most important technique for maintaining consistency in blockchain technology is the hash algorithm, which is also the most utilized algorithm in the design of blockchains (Deng et al., 2009). The hash algorithm is the process of computing a unique and fixed-length binary value for the input information, which is the hash value (Yang & Yang, 2022). No changes can be made to the data in the hashing algorithm, and even small changes to the input data will result in a completely different hash value (Basak et al., 2021). Anyone can therefore enter the same plaintext in the same hashing algorithm and the input data can be hashed to give the same hash value. By comparing the hashes of the data it is possible to verify that the input data has not been tampered with.
The hash algorithm has the following security features: 1) Unidirectionality: It is easy to compute H(x) for a given data x but having to find the x corresponding to H(x) is computationally irreversible.
2) Weak collision resistance: For a given data x 1 , it is infeasible to find another data x 2 such that both satisfy H(x 1 ) = H(x 2 ).
3) Strong collision resistance: It is infeasible to find arbitrarily different data x 1 and x 2 such that both satisfy H(x 1 ) = H(x 2 ).

Application of blockchain technology in beverage machines
Blockchain technology applied to the beverage machine system consists of four main parts as shown in Figure 1. The back ends as the core of the management system can coordinate the other three parts. Disposable cartridges can only be re-bound once the random label has been bound and can't be changed.
The main function of the chip information reading is to batch bind the material box with chip ID to prepare for the identification, the APP upper computer can complete the identification of the material box information and update the remaining material of the material box, and the operation and maintenance personnel can handle the remaining quantity of the material powder, the expiry warning or alarm from the back-end feedback.

Working principle and process
As can be seen in Figure 2, the packaging is pre-processed first, then the material box is installed on the machine, the data is read and written and recorded by RFID, the RFID control board and the upper computer APP interchange information between each other, the cloud server and the upper computer APP communicate, and finally the upper computer APP output information, and then judge whether the powder is expired, if it is expired then the relevant drinks are taken off the shelf and the operation and maintenance staff are notified, if it is not expired then it is used normally.

Pre-packaged
The back-end generates the disposable material box according to the batch, after the box is generated the status is "generated", the chip generates the manufacturer information, gets the chip id through the "get chip id by batch" interface, and writes the information to the chip through the read/write device. After successful writing, the backend updates the status of the cassette to "verified", at this time the electronic label will be bound to the disposable cassette.

Installation of the cassette on the machine
Once the disposable cartridge has been fitted to the equipment, the cartridge status in the background is updated to 'used' . The shelf life will be calculated according to the opened shelf life, the expiry time after opening must be less than the unopened warranty expiry time, otherwise, the warranty expiry time will be calculated according to the unopened warranty expiry time. The background supports manual entry of the chip id (the main purpose of this is to facilitate temporary testing), after the official use of human factors is not allowed to modify the coding rules.

Determination of the status of the cassette
The host APP reads the identity ID of the disposable material box on the RFID control board through the RS232 serial port and matches the identity ID through the background. Expiry scenario: When the ingredients of the disposable cassette expire, the user cannot view the related drinks by clicking on the product category interface. Insufficient stock scenario: After each drink is made, the beverage dispenser updates the stock API and thus updates the stock box stock. When the remaining quantity is too low to make a drink, the user cannot view the relevant drink by clicking on the product category screen.

Alarm handling of the cassette
There are two types of expiry notifications: one is a 3-day warning for material change, and the other is an alarm notification when the material has expired. The backend detects that the raw material is less than 3 days old and pushes the warning to the mobile phone of the operation and maintenance staff. Notification of insufficient stock: A warning message is pushed to the public number when powder stock reaches the warning value. When an alarm occurs, the product category screen will also not be able to view the relevant drinks.

Chip id reading solution
Operations and maintenance staff open the raw material management page, which will open the box enable and implement the following logic: APP that is, every 5 seconds cycle to the motherboard to send the box to enable open command and then send a scan box RFID command. the motherboard began to scan the RFID tag on the box, if the identification is to the new disposable box, it will be based on the box number to the background to obtain information on the box. the number is valid to update the raw material management if the number is valid, the page will be updated, if the number is invalid, the data will not be written into the material management data, invalid situation: the number is not registered, and the box has expired. If the operator exits the material management page, the cassette is switched off and the main board stops scanning the cassette.

Operation and maintenance process
Operation and maintenance personnel first open the beverage dispenser door then open the operation and maintenance mode, then open the silo door, through the raw material management interface to view the remaining situation of raw materials, complete the replacement of the cassette, at this time through the raw material management interface to view the replacement results, if the replacement fails, re-check whether the cassette position is installed in place; if the replacement is completed to close the silo door to close the operation and maintenance mode, operation and maintenance are over (Figure 3).

Experimental verification
Experiment 1: the device RFID single-point reading test: prepare 10000 copies of bound tags and 10000 copies of tags (including 95% for bound tags set, 5% non-bound tags) for reading test. After the actual test, the bound tag reading correct rate of 100%. Non-bound tags, the device suggests a total of 500 illegal tags. Therefore, the equipment RFID single point reading test is fully qualified. Experiment 2: using bound and unbound labels for drink making tests: 10,000 bound labels and 10,000 labels (including 95% bound and 5% unbound labels) were used for drink making tests. The bound label device was tested to be able to label bound recipes for drink production.
The unbound labels were prompted as illegal labels. The equipment did not carry out drink making for a total of 500 times. Therefore, the bound label device was able to read correctly and make drinks according to the recipe, while the unbound label device was unable to make drinks.
Experiment 3: the bound label in the food after the expiry of the drink production test: using 10,000 has been bound label (including 95% for the warranty period, 5% to exceed the expiry date) for drink production. A total of 9,500 beverages could be made from the bound labels within the warranty period. Expired tags were prompted with an expiry message and no drinks could be made.
Experiment 4: bound labels with insufficient spare capacity: 10,000 bound labels (95% with sufficient spare capacity and 5% with insufficient spare capacity) were used for drink production. The bound labels with sufficient spare capacity were tested to produce a total of 9500 drinks. The equipment with insufficient spare capacity indicated that there was insufficient spare capacity and could not make a total of 500 drinks. Therefore, drinks could not be made when there was insufficient spare capacity.
The results of these experiments show that blockchain technology is very effective in achieving consistency and tamperevident information in beverage machines.