# A Traceable and Verifiable Tobacco Products Logistics System with GPS and RFID Technologies
## 3 The Proposed Scheme
### Consumption Phase  
When a consumer goes to purchase tobacco products from a retailer, the processing flow is shown in Figure 11.  
* CS goes into the RT location and selects one or more tobacco products, then proceeds to the checkout process.
* RT starts the checkout process. First, the RT scans the TID of chosen tobacco products from CS. Then, RT selects a random number \(k_{11}\) and generates a message with a list of TID: \[M_{11}=(ID_{RT}||ID_{CA}||List<(TID,Price,DateTime)>||T_{21})\] (92)  
Figure 11: The flowchart of the consumption phase.  
RT calculates the hash value and executes the function \"Sign\" in Algorithm 2 to generate the signatures:  
\[h_{RT_{1}}=H(M_{11}) \tag{93}\]  
\[(r_{RT_{1}},s_{RT_{1}})=Sign(h_{RT_{1}},k_{11},d_{RT}) \tag{94}\]  
A message is encrypted by CA's public key:  
\[C_{RT_{1}}=E_{Pak_{CA}}(M_{11}) \tag{95}\]  
Then, RT sends the message \((ID_{LG},ID_{RCP},C_{LG_{2}},(r_{LG_{2}},s_{LG_{2}}))\) to CA.  
1. CA receives the message at \(T_{22}\), then decrypts the cipher message by its private key:  
\[M_{11}=D_{Prk_{CA}}(C_{RT_{1}}) \tag{96}\]  
Then, CA checks for the validation of the timestamp:  
\[(T_{22}-T_{21})\stackrel{{?}}{{\leq}}\tau \tag{97}\]  
Next, the CA calculates the hash value and executes the function \"Verify\" in Algorithm 2 to validate the signatures:  
\[h_{RT_{1}}{}^{\prime}=H(M_{11}) \tag{98}\]  
\[Verify(h_{RT_{1}}{}^{\prime},r_{RT_{1}},s_{RT_{1}}) \tag{99}\]  
If the signature is valid, CA executes a chaincode \"Purchase\", as shown in Algorithm 5, where a purchasing record is received and updated to the BCC. Then, CA selects a random number \(k_{12}\) and generates a message:  
\[M_{12}=(ID_{CA}||ID_{RT}||List<PID>||T_{23}) \tag{100}\]  
Next, CA calculates the parameters and executes the function \"Sign\" to generate the signatures:  
\[h_{CA_{2}}=H(M_{12}) \tag{101}\]  
\[(r_{CA_{2}},s_{CA_{2}})=Sign(h_{CA_{2}},k_{12},d_{CA}) \tag{102}\]  
A response message is encrypted with RT's public key:  
\[C_{CA_{2}}=E_{Pak_{RT}}(M_{12}) \tag{103}\]  
Then, CA sends the message \((ID_{CA},ID_{RT},C_{CA_{2}},(r_{CA_{2}},s_{CA_{2}}))\) to LG.  
1. RT receives the message, then uses its private key to decrypt the cipher message:  
\[M_{12}=D_{Prk_{RT}}(C_{CA_{2}}) \tag{104}\]  
Then, RT checks for the validation of the timestamp:  
\[(T_{24}-T_{23})\stackrel{{?}}{{\leq}}\tau \tag{105}\]  
If the timestamp is valid, RT calculates the hash value and executes the function \"Verify\" to validate the signatures:  
\[h_{CA_{2}}{}^{\prime}=H(M_{12}) \tag{106}\]  
\[Verify(h_{CA_{2}}{}^{\prime},r_{CA_{2}},s_{CA_{2}}) \tag{107}\]If the signature is valid, then RT prints an invoice with the purchase information \(List<(TID,Price,DateTime,PID,ID_{RT})>\)
* RT gives the printed invoice and tobacco products to the CS, then the transaction is completed.  
```
funcPurchase( ID_RT string, TIDs []string, Price []float, GPSLoc string) (Purchase_ID []string, Payment_DT []time.Time){ for i:= 0; i < TIDs.Length; i++ {  index:= SearchTID(TIDs[i])  TP[index].Retailer_ID = ID_RT  TP[index].Payment_Datetime = time.Now()  TP[index].Payment_GPSLocation = GPSLoc  TP[index].Purchase_ID = GeneratePurchaseID()  TP[index].Payment_Price = Price[i]  Purchase_ID = append(Purchase_ID, TP[index].Purchase_ID)  Payment_Datetime = append(Payment_Datetime, TP[index].Payment_DT) } return Purchase_IDs }
```  
**Algorithm 5** Chaincode of consumption of the proposed scheme.