# Efficient and HRA Secure Universal Conditional Proxy Re-Encryption for Cloud-Based Data Sharing
## 4 Generic Construction for UCPREA
### Generic Construction  
Our UCPRE supports the proxy to convert the ciphertext of the delegator under an encryption scheme \(\Pi_{f}\) into the ciphertext of the delegatee under a (possibly different) encryption scheme \(\Pi_{t}\). These schemes \(\Pi_{f}\) and \(\Pi_{t}\) are Additive homomorphism encryption scheme \(\Pi_{+}\) or Multiplicative homomorphic encryption scheme \(\Pi_{\times}\), respectively. Our generic construction for UCPRE consists of the algorithms \(\mathrm{ReKeyGen}\) and \(\mathrm{ReEnc}\) shown as follows:  
* \(\mathrm{ReKeyGen}\ \left(1^{\lambda},\Pi_{f},\Pi_{t},\mathrm{pk}_{t},\mathrm{pk}_{f}, \mathrm{sk}_{f},\mathrm{ct}_{f}^{m}\right)\rightarrow\mathrm{rk}_{f\to t}\): The delegator performs the algorithm \(\mathrm{ReKeyGen}\) to set the re-encryption key \(\mathrm{rk}_{f\to t}\). In the process, the delegator firstly runs the algorithm \(\Pi_{f}\).ScalMul to generate ciphertext \(\mathrm{ct}_{f}^{mR}\) about message \(mR\). Second, the delegator runs the algorithm \(\Pi_{t}\). Enc to generate ciphertext \(\mathrm{ct}_{f}^{R^{-1}}\) about message \(R^{-1}\). Third, the delegator executes the algorithm \(\Pi_{f}\). HiddenSecret to generate the hidden secret key \(\mathrm{hsk}_{f}\). Finally, we output the re-encryption key \(\mathrm{rk}_{f\to t}\) that includes \(\mathrm{ct}_{f}^{mR}\), \(\mathrm{ct}_{f}^{R^{-1}}\), and \(\mathrm{hsk}_{f}\). 1. Compute \(\mathrm{ct}_{f}^{mR}\leftarrow\Pi_{f}\). \(\mathrm{ScalMul}\Big{(}\mathrm{pk}_{f},\mathrm{ct}_{f}^{m},R\Big{)}\): The delegator runs the algorithm \(\Pi_{f}\). \(\mathrm{ScalMul}\) in scheme \(\Pi_{f}\) to generate ciphertext \(\mathrm{ct}_{f}^{mR}\) about message \(mR\). This algorithm inputs the public key \(\mathrm{pk}_{f}\) of the delegator, a ciphertext \(\mathrm{ct}_{f}^{m}\) encrypting the message \(m\), and a message \(R\) and ouputs a ciphertext \(\mathrm{ct}_{f}^{mR}\) about message \(mR\). 2. Compute \(\mathrm{ct}_{t}^{R^{-1}}\leftarrow\Pi_{t}\). \(\mathrm{Enc}\big{(}\mathrm{pk}_{t},R^{-1}\big{)}\): The delegator executes the algorithm \(\Pi_{t}\). Enc in scheme \(\Pi_{t}\) to generate the ciphertext \(\mathrm{ct}_{t}^{R^{-1}}\) about message \(R^{-1}\). This algorithm inputs the public key \(\mathrm{pk}_{t}\) of the delegatee and a message \(R^{-1}\) and ouputs a ciphertext \(\mathrm{ct}_{t}^{R^{-1}}\) about message \(R^{-1}\). 3. Compute \(\mathrm{hsk}_{f}\leftarrow\Pi_{f}\). HiddenSecret \(\Big{(}\mathrm{sk}_{f},\mathrm{ct}_{f}^{mR}\Big{)}\): The delegator executes the algorithm \(\mathrm{hsk}_{f}\) about the secret key \(\mathrm{sk}_{f}\). This algorithm inputs the secret key \(\mathrm{sk}_{f}\) of the delegator and a ciphertext \(\mathrm{ct}_{f}^{mR}\) and outputs the hidden secret key \(\mathrm{hsk}_{f}\). 4. Output \(\mathrm{rk}_{f\to t}=(\mathrm{ct}_{f}^{mR},\mathrm{ct}_{t}^{R^{-1}}, \mathrm{hsk}_{f})\). 5. ReEnc \(\Big{(}\Pi_{f},\Pi_{t},\mathrm{pk}_{t},\mathrm{rk}_{f\to t}\Big{)}\to \mathrm{rct}\): The proxy parses \(\mathrm{rk}_{f\to t}=(\mathrm{ct}_{f}^{mR},\mathrm{ct}_{t}^{R^{-1}}, \mathrm{hsk}_{f})\) that performs the algorithm ReEnc to set the re-encryption ciphertext \(\mathrm{rk}_{f\to t}\). In the process, the delegator firstly runs the algorithm \(\Pi_{f}\). \(\mathrm{Combine}\) to recover the message \(mR\). Second, the proxy runs the algorithm \(\Pi_{t}\). \(\mathrm{ScalMul}\) to generate re-encryption ciphertext \(\mathrm{rct}\). Finally, we output re-encryption ciphertext \(\mathrm{rct}\). 1. Compute \(mR\leftarrow\Pi_{f}\). \(\mathrm{Combine}\)\(\Big{(}\mathrm{hsk}_{f},\mathrm{ct}_{f}^{mR}\Big{)}\): The proxy executes the algorithm \(\Pi_{f}\). \(\mathrm{Combine}\) in scheme \(\Pi_{f}\) to recover the message \(mR\). This algorithm inputs the hidden secret key \(\mathrm{hsk}_{f}\) and a ciphertext \(\mathrm{ct}_{f}^{mR}\) encrypting the message \(mR\) and outputs the message \(mR\). 2. Compute \(\mathrm{ct}_{f}^{m}\leftarrow\Pi_{t}\). \(\mathrm{ScalMul}\Big{(}\mathrm{pk}_{t},\mathrm{ct}_{t}^{R^{-1}},mR\Big{)}\): The proxy executes the algorithm \(\Pi_{t}\).