## 5 Construction
Then, the system public parameters are set as \(PK=\left(\mathbb{G},g,\ h=g^{\beta},f=g^{1/\beta},\ e(g,g)^{\alpha},\mathbb{U}_{ mix},\ H_{1}\right)\), and the master key for \(AA_{i}\) is defined as \(MK_{i}=\left(\alpha,\ \beta,u_{i}\right)\). 2. Key Generation: \(AA.KeyGen(PK,MK_{i},\mathbb{U}_{mix})\longmapsto\left(SK_{CR_{j}}\right)\)  
The AA runs a KeyGen algorithm to generate an attribute key for each CR in a group. In this phase, AA\({}_{j}\) selects a random number \(r_{j}\in\mathbb{Z}_{p}\) for \(CR_{j}\) and a random number \(r_{k}\in\mathbb{Z}_{p}\) for each attribute \(k\) in the attribute set \(\mathbb{U}_{k}\), where \(\mathbb{U}_{k}\subseteq\mathbb{U}_{mix}\) for \(CR_{j}\). Then, the attribute key \(SK_{CR_{j}}\) is generated as follows:  
\[SK_{CR_{j}}=\left(D=g^{(\alpha+r_{j})\beta},\ \forall k\in\mathbb{U}_{k}:\ D_{k}=g^{r_{j}}H_{1}(k)^{r_{k}},\ D_{k} ^{\prime}=g^{r_{k}}\right).\]  
3. First Stage of Encryption: \(CR.Encryption\left(PK,M,\mathcal{T},SK_{CR_{j}}\right)\longmapsto\left(CT_{1}\right)\) The transmitting controller \(CR_{t}\) performs the following operations:  
* Access Policy Setup: An access policy \(\mathcal{T}\) is established, and a polynomial \(q_{x}\) is assigned to each node \(x\) (including leaf nodes) in the tree. Starting from the root node \(R\), these polynomials are set in a top-down manner. The degree of each polynomial \(q_{x}\) is defined as \(d_{x}=k_{x}-1\), where \(k_{x}\) is the threshold value for node \(x\). Figure 2: Sequence diagram of setup process. * Polynomial Definition: The value of the root node is initialised to a random number \(s\in\mathbb{Z}_{p}\), so that \(q_{R}(0)=s\). Additional points are then selected at random to fully define each polynomial \(q_{x}\) within the tree. For non-root nodes \(x\), the value \(q_{x}(0)\) is set to \(q_{parent(x)}(index(x))\). In the access policy \(\mathcal{T}\), let \(Y\) represent the set of leaf nodes, denoted by \(\big{\{}q_{y}(0)\big{\}}_{y\in Y}\). * Ciphertext Generation: \(CR_{t}\) selects an encryption key \(key\in G_{T}\) and encrypts the plaintext \(M\), resulting in \(\widetilde{C}=Enc(M,\;key)\). Subsequently, it computes \(C_{1}=key\cdot e(g,g)^{\text{ss}}\), hashes the \(key\) and \(\widetilde{C}\) as \(\sigma=HMAC\Big{(}key,\;\widetilde{C}||timestamp\Big{)}\), and calculates \(C_{2}=f^{s}=g^{s/\beta}\). The initial ciphertext is thus constructed as follows: \[CT_{1}=\bigg{(}\mathcal{T},\;\widetilde{C}=Enc(M,\;key),C_{1}=key\cdot e(g,g) ^{\text{ss}},\;C_{2}=f^{s},\;\big{\{}q_{y}(0)\big{\}}_{y\in Y},\;\sigma,\;timestamp \bigg{)}.\]
* Transmission to Compute Node: Finally, \(CT_{1}\) is transmitted to the \(CN_{t}\) in the group for the second stage of encryption. * Second Stage of Encryption: \(CN.Encryption(PK,CT_{1})\longmapsto(CT_{2})\) In this phase, \(CN_{t}\) receives \(CT_{1}\) from \(CR_{t}\). It then computes \(C_{y}=g^{q_{y}(0)}\) and \(C_{y}^{\prime}=H(att(y))^{q_{y}(0)}\) for each \(y\in Y\). The second stage of ciphertext \(CT_{2}\) is generated as follows: \[CT_{2}=\bigg{(}\mathcal{T},\widetilde{C},\;C_{1},\;C_{2},\;\forall y\in Y:C_{y} =g^{q_{y}(0)},\;C_{y}^{\prime}=H(att(y))^{q_{y}(0)},\;\sigma,\;timestamp \bigg{)}\] In this format, \(CT_{2}\) is fully encrypted and ready for secure transmission to the receiving \(CR_{r}\) or for storage in a data base. * Verification of Message Source First, \(CN_{r}\) selects a random number \(b\in\mathbb{Z}_{p}\) and retrieves the group public key \(gpk_{t}\) of the transmitting group. It then computes \(B=(gpk_{t})^{b}=g^{butz}\) and sends \(B\) to \(AA_{t}\). Next, \(AA_{t}\) verifies whether a message has been sent to \(CN_{r}\). If the verification is successful, \(AA_{t}\) computes \(C^{\prime}=B^{1/u_{t}}\) and returns \(C^{\prime}\) to the \(CN_{r}\). Upon receiving \(C^{\prime}\), \(CN_{r}\) calculates \(C=g^{b}\) and verifies whether \(C\doteq C^{\prime}\). If \(C=C^{\prime}\), the message is confirmed to originate from \(AA_{t}\), and the decryption process proceeds. Otherwise, the message is rejected as \(\bot\).