Idea: Introduce an abstraction layer for access control to encrypted data using roles. Each role has its own secret key and public key, generated off-chain. Data is encrypted using the role's public key. When a role is granted to Alice, the smart contract encrypts the role's secret key with Alice's public key: encryptECIES(roleSecret, AlicePublicKey). Alice can then decrypt the role secret key off-chain and use it to decrypt the encrypted value.
Interface example
createRole(rolePubKey, encryptedRoleSecret, roleID) – stores the role public key and the encrypted role secret
grantRole(roleID, AlicePublicKey) – re-encrypts the role secret using Alice’s public key
encryptForRole(encryptedValue, roleID) – encrypts the value using the role public key
getValueForRole(roleID) – returns the value encrypted with the role public key
Decryption flow
- Get
encryptedRoleSecret for roleID
decrypt(encryptedRoleSecret, AlicePrivateKey) → decryptedRoleSecret
getValueForRole(roleID) → encryptedValue
decrypt(encryptedValue, decryptedRoleSecret) → decryptedValue
Idea: Introduce an abstraction layer for access control to encrypted data using roles. Each role has its own secret key and public key, generated off-chain. Data is encrypted using the role's public key. When a role is granted to Alice, the smart contract encrypts the role's secret key with Alice's public key:
encryptECIES(roleSecret, AlicePublicKey). Alice can then decrypt the role secret key off-chain and use it to decrypt the encrypted value.Interface example
createRole(rolePubKey, encryptedRoleSecret, roleID)– stores the role public key and the encrypted role secretgrantRole(roleID, AlicePublicKey)– re-encrypts the role secret using Alice’s public keyencryptForRole(encryptedValue, roleID)– encrypts the value using the role public keygetValueForRole(roleID)– returns the value encrypted with the role public keyDecryption flow
encryptedRoleSecretforroleIDdecrypt(encryptedRoleSecret, AlicePrivateKey)→decryptedRoleSecretgetValueForRole(roleID)→encryptedValuedecrypt(encryptedValue, decryptedRoleSecret)→decryptedValue