# IoT-Chain and Monitoring-Chain Using Multilevel Blockchain for IoT Security
## 4 Architecture
### Workflow
```
1:procedureprocedure\(Node_{ic}:\)
2:\(Data\gets GenerateSensorData()\)
3:\(Sig\gets CreateSig(Data,Key_{Priv})\)
4:\(Val_{rand}\gets VRF()\)
5:\(TX\gets CreateTX(Data,Sig,Val_{rand})\)
6:\(Block_{last}\gets GetLatestBlock()\)
7:\(Node_{leader}\gets Block_{last}.LeaderNode\)
8:\(SendTX(TX,Node_{leader})\)
9:endprocedure
10:
11:procedureprocedure\(Node_{leader}:\)
12:\(TX\gets ReceiveTX()\)
13:if\(TXs.Length\) is count then
14:\(TXs\gets TX\)
15: Count(\(TXs\)) is not count
16:\(Node_{leader}\gets GetMaxRandomValueNode(TXs)\)
17:\(Block_{ic}\gets CreateBlock(Txs,Node_{leader})\)
18:\(Broadcast(Block_{ic})\)
19:endif
20:endprocedure
```  
**Algorithm 2**\(Network_{ic}\)--\(Block_{ic}/TX\) creation. Algorithm 3 is a lightweight storage process for \(IC\). Nodes in \(Network_{ic}\) proceed with \"export consensus\" to store \(IC\) in \(DFS\). After the export consensus process, \(Block_{exports}\) with the Schnorr signature is delivered to \(Network_{mc}\) through the export node. This process is used to periodically store the IoT chain in a distributed file system and record only metadata for verification in the monitoring chain in order to reduce the capacity of the IoT chain. For verification, it is necessary to start the process of verifying data through the hash value of the last block of the IoT chain. In addition, the final block hash value, which is the verified result, and the signatures of IoT-Chain nodes, must be compressed to generate a Schnorr signature. For operation, the export process of the IoT chain is executed in the Exporter Node. The process of verifying and signing the last block hash value is executed in the nodes of the IoT-Chain. \(Block_{ic}\) is created in \(Network_{ic}\), the size of the \(IC\) increases, and the round exceeds a certain size. Each \(Node_{ic}\) initiates a consensus verifying that \(BH_{last}\) are all the same for embedding into \(Network_{mc}\). Among the nodes, \(Node_{export}\), which is a pre-selected gateway node based on the network and hardware status, is the route of consensus of all nodes through the routing protocol. \(Node_{export}\) creates a \(Sig\) encrypted with \(BH_{last}\) with \(Key_{priv}\), creates \(Block_{export}\) containing \(BH_{last}\) and \(Sig\), and delivers it to the next node on the route. After receiving it, \(Node_{ic}\) sends \(Sig_{schnor}\) to \(Key_{pub}\), which is verified through the \(CA\). If the \(BH_{last}\) returned by creating and decrypting \(Key_{schnor}\) is the same as the \(BH_{last}\) of its own \(IC\), the corresponding \(BH_{last}\) is encrypted with \(Key_{priv}\) to create a \(Sig\), the \(Sig\) is combined with a Schnorr signature method, and the \(Sig\) is added by \(Sig_{schnor}\) to generate the combined \(Sig\). It is created, passed to the next \(Node_{ic}\) in the route, and this is repeated until the next \(Node_{ic}\) does not exist. Every node in the \(Network_{ic}\) repeats this process, the last \(Node_{ic}\) sends a \(Block_{export}\) to \(Node_{export}\), and \(Sig_{schnor}\) sends a \(Block_{export}\) to all nodes in \(CA\). If the same \(BH_{last}\) value is returned after decrypting with \(Key_{schnor}\) created by combining \(Key_{pub}\), the \(IC\) is distributed and stored in the \(DFS\), and subsequently, \(Address_{ic}\) is returned. \(Node_{export}\) transmits \(Block_{export}\) to \(Network_{mc}\). When using the existing multi-signature method, a signature size of about \(O(n)\) and a number of verifications are required, depending on the number of network nodes. The proposed algorithm compresses the signature using the Schnorr signature method. As a result, the number of validations required for group signatures and the storage capacity of the signatures are reduced by \(O(1)\). To create metadata of the IoT-Chain, signatures of all IoT-Chain nodes are required. However, in order to receive the signatures of all nodes, the number of signatures increases as much as the number of nodes, the size of the message also increases, and \(O(n)\) signature verification processes exist.