Skip to content

Commit

Permalink
doc: start to write about decryption and reencryption in fundamentals
Browse files Browse the repository at this point in the history
  • Loading branch information
leventdem committed Sep 5, 2024
1 parent 834b262 commit d26dbc0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/fundamentals/gateway/decryption.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# Decryption

Everything in fhEVM is encrypted, at some point one could need to decrypt somes values. Let's give as illustration a blind auction application.
After reaching the end of the auction, one need to discover (only) the winner, here is where a asynchronous decrypt could appear.


> :warning: **Decryption is public**: It means everyone will be able to see the value. If this is a personal information see [Reencryption](./reencryption.md)
## How it's working

The Gateway acts as an oracle service: it will listen to decryption request events and return the decrypted value through a callback function.
The responsabilities of the Gateway are:
- Listening decryption request from fhEVM that contains a handle `h` to the associated ciphertext `C`
- Computing a storage proof `P` to attest C is decryptable
- Retrieve C from fhEVM using `h` as key
- Send a decyption request to TKMS which in turn is running an internal blockchain aka `KMS BC`
- Wait and listen for `decyptionResponse` (containing the plaitext and a few signatures from KMS to attest the integrity of the palintext) event from `KMS BC`
- Return `decyptionResponse` through the callback function

## High level overview of the decryption flow

We allow explicit decryption requests for any encrypted type. The values are decrypted with the network private key.

![](asyncDecrypt.png)






8 changes: 8 additions & 0 deletions docs/fundamentals/gateway/reencryption.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# Reencryption


Reencryption is performed on the client side by calling the gateway service using the [fhevmjs](https://github.com/zama-ai/fhevmjs/) library. To do this, you need to provide a view function that returns the ciphertext to be reencrypted.

1. The dApp retrieves the ciphertext from the view function (e.g., balanceOf).
2. The dApp generates a keypair for the user and requests the user to sign the public key.
3. The dApp calls the gateway, providing the ciphertext, public key, user address, contract address, and the user's signature.
4. The dApp decrypts the received value with the private key.

0 comments on commit d26dbc0

Please sign in to comment.