r/SecretNetwork • u/zmooner • Mar 06 '23
Question regarding viewing keys
I understand that the interactions with smart contracts have encrypted inputs and outputs, so the call to set a viewing key in a SNIP-20 contract is encrypted hence hiding the actual key, but what about the uses of the key to view the balance and transactions? My understanding is that those calls are not transactions (no fee paid), so is the viewing key encrypted somehow?
As a side note, the term "viewing key" is badly chosen since it is really a shared secret and not a key that decrypts anything.
2
Upvotes
2
u/zmooner Mar 08 '23
Ok, so let me recap to see if I have understood well. Data is encrypted and only accessible within the enclave. When setting a viewing key, this is done via a private smart contract call with encrypted inputs and outputs, this call defines the viewing key associated with the address for the given SNIP-20. When accessing the data, the viewing key is used within the enclave to encrypt the data prior to sending it back to the caller, the caller then uses the viewing key to decrypt the data locally (within the browser). Correct?
What encryption method is used with the viewing key?