Skip to main content
. 2024 Feb 5;24(3):1035. doi: 10.3390/s24031035
Algorithm 5: Encrypt(M){CT}
// Params: ciphertext CT, attribute permission parameters Ri, data storage address Address(EδM)
// Returns: plaintext message M
function DecryptMessage (CT,Ri, Address_EδM) →M
01: // Retrieve encrypted data EδM using the storage address from IPFS
02: EδM= IPFS.retrieve (Address_EδM)
03: // Step (i): Compute μ using the attribute permission parameters Ri
04: μ= computeCRTSolution (Ri, CT.B)
05: // Reverse compute β from μ
06: β=μAb0
07: // Step (ii): Decrypt δ using C from CT and β
08: u= publicParameters.u // u is obtained from the system’s public parameters
09: g1= publicParameters.g1 // g1 is a generator of G1
10: δ=Cue(g1,g1)β
11: // Decrypt the message M using symmetric decryption with δ
12: M= symmetricDecrypt (EδM,δ)
13: return M
endfunction

// Helper function to compute μ using Chinese Remainder Theorem and attribute permission parameters Ri
function computeCRTSolution (Ri,B,) → int
01: Y= product (b1,bt) // Y is the product of b1,b2,bt
02: μ=0
03: // Compute the sum for μ using the CRT formula
04: for v=1 to Ri.length do
05:   yv = modInverse (Ybv,bv) // Compute the modular inverse
06:   μ=μ+rvyvYbvmodY
07: return μ
endfunction