# Unified Ciphertext-Policy Weighted Attribute-Based Encryption for Sharing Data in Cloud Computing
## 5 Proposed Unified Ciphertext-Policy Weighted Attribute-Based Encryption
### The Design of UCP-WABE
1: Create \(\Gamma_{c}\) according to the mutual sub-policy of \(\Gamma_{1}\) and \(\Gamma_{2}\)
2: Select a random \(s\in\mathbb{Z}_{p}\); set \(f_{c}(0)=s\); and randomly choose other \(d_{c}\) points to determine \(f_{c}(x)\)
3:for\(\forall\) non-root node \(N_{q}\)do
4: Calculate \(f_{q}(0)\), and randomly choose other \(d_{q}\) points to determine \(f_{q}(x)\)
5:if\(a_{i}\in\gamma_{c}\)then
6: Calculate \(C_{(i,0),1},C_{(i,0),2}\)
7:for\(j=1\) to \(\omega_{i}\)do
8:if\(j\
eq\omega_{i}\)then
9: Calculate \(C_{(i,j),1},C_{(i,j),2}\)
10:else
11: Set \(s_{i,j}=f_{a_{i}}(0)\), and calculate \(C_{(i,j),1},C_{(i,j),2}\)
12:endif
13:endfor
14: Calculate \(C_{(i,end),1},C_{(i,end),2}\)
15:endif
16:endfor
17:\(MI=\Big{\{}\Gamma_{c},\{C_{(i,j),1},C_{(i,j),2}\}_{\forall a_{i}\in\gamma_{c},j=1,\cdots,\omega_{i},\prime}\{C_{(i,end),1},C_{(i,end),2}\}_{\forall a_{i} \in\gamma_{c}}\Big{\}}\)
```  
**Algorithm 1** The mutual information generation algorithm (**MutualInfoGen**). **Encrypt\((PP,M_{1},\Gamma_{1},MI)\). ** MIE sends \(MI\) to the providers. Then, they encrypt the messages \(M_{1},M_{2}\), respectively. Consider Provider A as an instance. It runs **Encrypt** as follows. Provider A creates the access tree \(\Gamma_{1}\) based on \(\Gamma_{\epsilon}\), which is a sub-tree of \(\Gamma_{1}\). For any trunk node \(N_{c}\) above \(N_{\epsilon}\) in \(\Gamma_{1}\), the polynomial \(f_{c}(x)\) is determined as follows. \[MSK=g^{-\alpha}. \tag{2}\]0  
where \(trunkchild(N_{c})\) denotes the child node of \(N_{c}\) along the trunk and \(index(N_{c})\) is the index value of \(N_{c}\) to its parent node. In order to calculate conveniently, when providers construct the access policies, it sets \(index(trunkchild(N_{c}))=1\) for each trunk node. For \(d_{c}\) non-constant coefficients of (3), Provider A selects them randomly. Then, the constant term \(f_{c}(0)\) can be computed by (10). Taking a simple instance, let \(N_{\delta}\) be the parent of \(N_{\epsilon}\). Provider A needs to determine:  
\[MSK=g^{-\alpha}. \tag{2}\]1  
Provider A selects \(d_{\delta}\) coefficients \(\{b_{1},b_{2},\cdots,b_{d_{\delta}}\}\) randomly, and \(index(trunkchild(N_{\delta}))=1\). Due to (10), Provider A knows that:  
\[MSK=g^{-\alpha}. \tag{2}\]2  
then it calculates the constant term \(b_{0}\) with (3), as:  
\[MSK=g^{-\alpha}. \tag{2}\]3  
Similarly, MIE determines every trunk node's polynomial. For any other node \(N_{q}\) of \(\Gamma_{1}\), the method of determining \(f_{q}(x)\) is identical to the method of MIE creating \(\Gamma_{\epsilon}\). Provider A obtains every polynomial of node in \(\Gamma_{1}\) with (4) and (10), and \(\Gamma_{1}\) is created completely. Provider B creates \(\Gamma_{2}\) based on \(\Gamma_{\epsilon}\) likewise. Let \(Y_{1}\) denote the set of the leaf nodes in \(\Gamma_{1}\). The number of leaf nodes is denoted by \(k_{1}\). Provider A produces the ciphertext \(CT_{1}\) of message \(M_{1}\) as follows:  
Provider A first calculates \(C_{M}=M_{1}\cdot\widehat{e}(g,g)^{af_{N_{1}}(0)}\), where \(f_{N_{1}}(\cdot)\) is the polynomial of access tree \(\Gamma_{1}\)'s root node \(N_{1}\). For \(\forall a_{i}\in Y_{1}\setminus Y_{\epsilon},i=k_{\epsilon}+1,\cdots,k_{1}\), Provider A chooses random values \(s_{k_{\epsilon}+1,0,\cdots}\), \(s_{k+1,\omega_{k_{\epsilon}+1}-1},\cdots,s_{k_{1},0},\cdots,s_{k_{1},\omega_{ k_{1}}-1}\in\mathbb{Z}_{p}\), and calculates:  
\[MSK=g^{-\alpha}. \tag{2}\]4  
Then, for \(j=1\) to \(\omega_{i}-1\), MIE calculates:  
\[MSK=g^{-\alpha}. \tag{2}\]5  
When \(j=\omega_{i}\), let \(s_{i,j}=f_{a_{i}}(0)\), where \(f_{a_{i}}(\cdot)\) is the polynomial of the node whose attribute is \(a_{i}\). MIE calculates:  
\[MSK=g^{-\alpha}. \tag{2}\]6  
Then, MIE calculates:  
\[MSK=g^{-\alpha}. \tag{2}\]7  
Finally, Provider A creates the ciphertext \(CT_{1}\):  
\[MSK=g^{-\alpha}. \tag{2}\]8  
Algorithm 2 represents the pseudocode of **Encrypt** algorithm. **KeyGen\((PP,MSK,\mathbb{S})\)**. WAA calls this algorithm to produce \(SK\) on the basis of \(MSK\) and the data consumer's attributes.