| Algorithm 3: |
| // Params: message M, attribute weights // Returns: ciphertext function EncryptMessageWithAttributes(char[] M, int[] ) → 01: // Select a random number from to be used as the symmetric encryption key 02: = selectRandom() 03: // Encrypt the message M with using symmetric encryption 04: = symmetricEncrypt() 05: // Store the encrypted message on IPFS and get the storage address 06: Address_ = IPFS.store() 07: // Step (i): Compute the sum of weights and select prime numbers to 08: 09: selectPrimes() 10: // Select a random number from 11: selectRandom() 12: // Encrypt using the formula given 13: 14: // Step (ii): Set the attribute weight threshold t and compute 15: product() // Product of the first t primes in 16: selectInteger(0, floor() 17: 18: // Construct the ciphertext 19: 20: // Store the ciphertext on the blockchain using a regulatory node 21: blockchain.store() 22: // Provide a description of the ciphertext, link it with the attribute category and data storage address 23: blockchain.associate(, “description”, “attribute category”, Address_) 24: return endfunction |