## 4 ACE and Blockchain-Based IoT Knowledge Sharing Scheme
### Blockchain-Based Authentication and Sanitization Process  
The messages from IoT users need to be sanitized and forwarded to the cloud servers via the edge servers. The problems of trust and synchronization between the edge servers can be solved using blockchain technology. A smart contract is a segment of code scripted on the blockchain, and it can be automatically executed without external interference when meeting the set conditions. The authentication of IoT users, key distribution, and the sanitization of messages are all performed by smart contracts in our solution (Algorithm 1), which ensures the correctness and reliability of the service. The messages received by the edge servers are stored in the blockchain for cross-audit and mutual validation, which is shown in Figure 2. All the edge servers maintain a complete data chain jointly, and the data can be easily recovered if a single point of failure occurs. * **Identity verification and key distribution. ** A user who is interested in participating in the FL task sends a request message, including its ID, public key, security level, FL task name, and timestamp, to the nearest edge server. The edge server first deposits the received request message into the blockchain. Then, the authentication is executed. The edge server calculates the hash value of the ID and the public key of requester and compares it with the hash table from the trusted authority to verify the user  
Figure 2: Multi-level ACE and blockchain-based knowledge sharing process. identity. This verifies that the security level of the requested task matches the identity permissions after confirming the identity of the requester as a registered and legitimate user. Finally, this verifies that the requested task is within the validity period. After the triple confirmation passes the edge server requests the key packet for this user from the trusted authority. The key packet consists of the task encryption key, and the authentication code of the user identity, task name, and timestamp so that its timeliness and correctness can be verifiable. The key packet is encrypted using the user's public key and the edge server cannot know the exact contents of the key packet. The user receives the key packet and decrypts it using its private key to obtain the requested key. * **Message sanitization. ** The edge server sanitizes and broadcasts all the received messages during FL. Smart contracts start by computing the hash value of these messages, which is then stored on the blockchain for retrospect and comparison. All messages are structurally indistinguishable, preventing any inference about the sender's security level, the intended cloud server receiver's identity, or the specific content of the knowledge. The edge server assesses message timeliness via timestamps, and chooses the sanitizer key based on the task name. This performs the ACE algorithm to sanitize each part of the ciphertext with the sanitizer key if the message is timely. The sanitized message is then broadcast to each cloud server. ```
1: Identity \(ID_{i}\), public key \(PK_{i}\), security level \(l_{i}\), task name \(j\), message \(m\), and timestamp \(ts_{1},ts_{2},ts_{2}^{\prime}\). 2: Key results \(R\) and ciphertext \(M\).