Ciphertext persistence


Looking at fhevm-go, if you put the ciphertext in verifiedCiphertexts map[common.Hash]*verifiedCiphertext and return the key value for that value, the contract stores only the key value in storage.

verifiedCiphertexts map[common.Hash]*verifiedCiphertext
Since is a value stored in memory, wouldn’t it be lost when geth is restarted?

Is there separate logic for storing the ciphertext in storage?

We store ciphertext in what we call the “protected storage”. For this, we catch the EVM opcode SSTORE and if the content is a verified ciphertext, we save it in the protected storage.

You can see the function which stores the value here:

The function called during Opsstore here fhevm-go/fhevm/instructions.go at main · zama-ai/fhevm-go · GitHub

And where we hook the native opsstore in go-ethereum

You can get more details about protected storage, also called “privileged storage”, in section 4.4 of our whitepaper fhevm/fhevm-whitepaper.pdf at main · zama-ai/fhevm · GitHub

Thank you for the good explanation!!

1 Like