## 4 The Proposed Group Authentication Framework
### Phase 2: Group Authentication
#### 4.2.2 Step 2: Smart Contract Execution for Group Authentication  
Before any IoT device sends data to the group, it will verify the status of the smart contract associated with a particular group ID. If the smart contract is executed, participating IoT devices deduce that group authentication is successful. To authenticate the group and execute the smart contract, the proposed framework will follow procedures given in Algorithm 1.  
```
0: Variable \(var_{ij}\) and Degree \(deg_{ij}\).
0: Smart contract: Executed or Not.
1: Smart Contract: Randomly select one IoT device by \(ID_{puf}\).
2: Smart Contract: Initiate authentication by sending a _hello_ message to the selected IoT device.
3: IoT Device: Generate a large integer var1, compute \(chebyshev\_val=T_{deg_{ij}}(var1)\).
4:for Each remaining IoT devicedo
5: Randomly select one IoT device and send chebyshev_val.
6: Selected IoT Device: \(new\_chebyshev\_val=T_{deg_{ij}}(chebyshev\_val)\).
7: Selected IoT Device: Call smart contract function \(receive\_value\), receive_value (\(new\_chebyshev\_val\)).
8: Smart Contract: chebyshev_val=new\_chebyshev\_val.
9:endfor
10: Smart Contract: \(final\_deg=\prod_{i,j=1,1}^{n,k}deg_{i,j}\)
11: Smart Contract: \(overall\_chebyshev\_val=T_{final_{deg}}(var1)\).
12:if\(overall\_chebyshev\_val\approx chebyshev\_val\)then
13: Execute Smart Contract.
14:EndIf
```  
**Algorithm 1** Group authentication algorithm.  
In order to authenticate the group, the smart contract randomly selects one IoT device and sends a special message, _hello_, to it. Upon receiving the _hello_ message, the IoT device generates a large integer _var1_ and computes the Chebyshev value as \(Chebyshev\_val=T_{deg_{ij}}(var1)\). The IoT device then transfers this Chebyshev value to the smart contract for further processing, using the process shown in Figure 5 to securely send the value. Once the smart contract receives the \(Chebyshev\_val\), it selects another IoT device among the remaining devices and securely transfers the value using the \(receive\_value\) function to catch the \(new\_chebyshev\_val\) sent by Blockchain to the selected IoT device. Upon receiving \(Chebyshev\_val\), the IoT device will compute the new Chebyshev value (\(new\_chebyshev\_val\)) as \(new\_Chebyshev\_val=T_{deg_{ij}}(Chebyshev\_val)\) using its own \(deg_{ij}\). The value of variable \(Chebyshev\_val\) will be replaced by \(new\_Chebyshev\_val\) before it is sent to the smart contract. The smart contract will follow the same steps as all remaining IoT devices and will store the \(Chebyshev\_val\) value received from the last IoT device of the group.  
To authenticate the group, the smart contract will compute the product of all \(deg_{ij}\) of all IoT devices, as shown on line 10 of the algorithm. In this equation, \(n\) is the number of TAs and \(k\) is the number of IoT devices participating in the group. The \(overall\_Chebyshev\_val\) will be computed using \(final_{deg}\) and variable var1 (which is generated by the first IoT device) as shown in line 11 of the algorithm. If the \(overall\_Chebyshev\_val\) is approximately equal to the \(Chebyshev\_val\) shared by the last IoT device, it means all IoT devices used their own \(deg_{ij}\) shared by the smart contract in step 1 of phase 2. In theory, both values should be exactly equal but because we are using the approximation method to compute the Chebyshev value, the exact value may not be yielded. In this scenario, group authentication will be deemed successful and the smart contract will be executed. If any hacker replaces the IoT device with his/her own device, the \(overall\_Chebyshev\_val\) will never be equal to \(Chebyshev\_val\). In case of any change in the group structure, for example, an IoT device is replaced by another IoT device, or any IoT device is removed/added, the whole process needs to be carried out from the start.