# A Traceable and Verifiable Tobacco Products Logistics System with GPS and RFID Technologies
## 3 The Proposed Scheme
### Logistics Phase  
We assumed three roles to operate in this phase: shipper (SHP), logistics (LG), and the recipient (RCP). As per the system architecture shown in Figure 2, we can assume that the shipper is a manufacturer, distributor, or retailer; the recipient is a distributor or retailer; and the logistics is a company that transfers tobacco products between the shipper and recipient. The flowchart of the logistics phase is shown in Figures 9 and 10. The chaincode of logistics is shown in Algorithm 4. 1. When the SHP needs to ship a batch of tobacco products to the RCP, SHP must ship via LG. Initially, SHP selects a random number \(k_{7}\) and generates a message with a list of TID:  
\[M_{7}=(ID_{SHP}||ID_{LG}||List<TID>||T_{13}) \tag{60}\]  
SHP calculates the hash value and executes \"Sign\" in Algorithm 2 to generate signatures \((r_{SHP_{1}},s_{SHP_{1}})\):  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]  
\[(r_{SHP_{1}},s_{SHP_{1}})=Sign(h_{SHP_{1}},k_{7},d_{SHP}) \tag{62}\]  
A message is encrypted by LG's public key:  
\[C_{SHP_{1}}=E_{Puk_{LG}}(M_{7}) \tag{63}\]  
Then, SHP executes the chaincode function \"Shipping\", as shown in Algorithm 4. Next, SHP sends the message \((ID_{SHP},ID_{LG},C_{SHP_{1}},(r_{SHP_{1}},s_{SHP_{1}}))\) to LG. Step '2. LG receives the message at \(T_{14}\), then decrypts the cipher message by its private key:  
\[M_{7}=D_{Prk_{LG}}(C_{SHP_{1}}) \tag{64}\]  
Then, LG checks for the validation of the timestamp:  
\[(T_{14}-T_{13})\stackrel{{?}}{{\leq}}\tau \tag{65}\]  
Next, LG calculates the hash value to validate the signature via \"Verify\" in Algorithm 2:  
\[h_{SHP_{1}}{}^{\prime}=H(M_{7}) \tag{66}\]  
\[Verify(h_{SHP_{1}}{}^{\prime},r_{SHP_{1}},s_{SHP_{1}}) \tag{67}\]  
If the signature is valid, LG using MR triggers a chaincode function \"Receiving\" to scan and check that \(List<TID>\) is equal to the actual tobacco products in the real world, the function of which is shown in Algorithm 4. Then, LG sends a response message to the SHP. LG selects a random number \(k_{8}\) and generates a message:  
\[M_{8}=(ID_{LG}||ID_{SHP}||T_{15}) \tag{68}\]  
Figure 9: The flowchart of the logistics phase from shipper to logistics. Next, LG calculates the hash value to generate the signatures via executing a \"Sign\" function in Algorithm 2:  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]0  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]1  
A response message is encrypted with SHP's public key:  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]2  
Then, LG sends the message \((ID_{LG},ID_{SHP},C_{LG_{1}},(r_{LG_{1}},s_{LG_{1}}))\) to SHP. 1. SHP receives the message from LG, then uses its private key to decrypt the cipher message: \[h_{SHP_{1}}=H(M_{7}) \tag{61}\]3 (72)  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]4 The flowchart of the logistics phase from logistics to the recipient. Then, SHP checks for the validation of the timestamp:  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]5  
If the timestamp is valid, SHP calculates the hash value to validate the signatures via executing a \"Verify\" function in Algorithm 2:  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]6  
\[h_{SHP_{1}}=H(M_{7}) \tag{61}\]7  
If the signature is valid, then SHP starts shipping these tobacco products to the RCP. ```
func Shipping ( ID_SHP string, ID_RCP string, TIDs[]string, GPSLoc string, Signature string) { for i:= 0; i < TIDs_Length; i++ { index:= SearchTID(TIDs[i]); TP[index].TransportRecord.Shipper_ID = ID_SHP TP[index].TransportRecord.Shipper_GPSLocation = GPSLoc TP[index].TransportRecord.Shipper_Datetime = time.Now() TP[index].TransportRecord.Recipient_ID = ID_LG TP[index].TransportRecord.SHP_Signature = Signature } } func Receiving { ID_SHP string, ID_RCP string, TIDs[]string, GPSLoc string, Signature string) { for i:= 0; i < TIDs_Length; i++ { index:= SearchTID(TIDs[i]) TP[index].TransportRecord.Recipient_GPSLocation = GPSLoc TP[index].TransportRecord.Recipient_Datetime = time.Now() TP[index].TransportRecord.RCP_Signature = Signature } }
```  
**Algorithm 4** Chaincode of logistics of the proposed scheme. 1.