Skip to content

Commit b4e31de

Browse files
authored
docs(common): remove ebytes (#293)
* docs(common): remove ebytes * docs(common): simplify user decryption
1 parent f64b19b commit b4e31de

File tree

3 files changed

+1
-56
lines changed

3 files changed

+1
-56
lines changed

docs/solidity-guides/decryption/user-decryption.md

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ User decryption is facilitated by the **Relayer** and the **Key Management Syste
2525

2626
## Step 1: retrieve the ciphertext
2727

28-
To retrieve the ciphertext that needs to be re-encrypted, you can implement a view function in your smart contract. Below is an example implementation:
28+
To retrieve the ciphertext that needs to be decrypted, you can implement a view function in your smart contract. Below is an example implementation:
2929

3030
```solidity
3131
import "@fhevm/solidity/lib/FHE.sol";
@@ -44,56 +44,3 @@ Here, `balanceOf` allows retrieval of the user’s encrypted balance stored on t
4444
## Step 2: decrypt the ciphertext
4545

4646
User decryption is performed client-side using the `@fhevm/sdk` library. [Refer to the guide](../../frontend/webapp.md) to learn how to include `@fhevm/sdk` in your project.
47-
Below is an example of how to implement user decryption in a dApp:
48-
49-
```ts
50-
import { createInstances } from "../instance";
51-
import { getSigners, initSigners } from "../signers";
52-
import abi from "./abi.json";
53-
import { createInstance } from "@fhevm/sdk/bundle";
54-
import { Contract, BrowserProvider } from "ethers";
55-
56-
const CONTRACT_ADDRESS = "";
57-
58-
const provider = new BrowserProvider(window.ethereum);
59-
const accounts = await provider.send("eth_requestAccounts", []);
60-
const USER_ADDRESS = accounts[0];
61-
62-
await initSigners(); // Initialize signers
63-
const signers = await getSigners();
64-
65-
const instance = await createInstances(this.signers);
66-
// Generate the private and public key, used for the user decryption
67-
const { publicKey, privateKey } = instance.generateKeypair();
68-
69-
// Create an EIP712 object for the user to sign.
70-
const eip712 = instance.createEIP712(publicKey, CONTRACT_ADDRESS);
71-
72-
// Request the user's signature on the public key
73-
const params = [USER_ADDRESS, JSON.stringify(eip712)];
74-
const signature = await window.ethereum.request({ method: "eth_signTypedData_v4", params });
75-
76-
// Get the ciphertext to reencrypt
77-
const ConfidentialERC20 = new Contract(CONTRACT_ADDRESS, abi, signer).connect(provider);
78-
const encryptedBalance = ConfidentialERC20.balanceOf(userAddress);
79-
80-
// This function will call the relayer and decrypt the received value with the provided private key
81-
const userBalance = instance.reencrypt(
82-
encryptedBalance, // the encrypted balance
83-
privateKey, // the private key generated by the dApp
84-
publicKey, // the public key generated by the dApp
85-
signature, // the user's signature of the public key
86-
CONTRACT_ADDRESS, // The contract address where the ciphertext is
87-
USER_ADDRESS, // The user address where the ciphertext is
88-
);
89-
90-
console.log(userBalance);
91-
```
92-
93-
This code retrieves the user’s encrypted balance, re-encrypts it with their public key, and decrypts it on the client-side using their private key.
94-
95-
### Key additions to the code
96-
97-
- **`instance.generateKeypair()`**: Generates a public-private keypair for the user.
98-
- **`instance.createEIP712(publicKey, CONTRACT_ADDRESS)`**: Creates an EIP712 object for signing the user’s public key.
99-
- **`instance.reencrypt()`**: Facilitates the user decryption process by contacting the relayer and decrypting the data locally with the private key.

docs/solidity-guides/functions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ The library ensures that all operations on encrypted data follow the constraints
5959
- **Casting between encrypted types**: `FHE.asEbool` converts encrypted integers to encrypted booleans
6060
- **Casting to encrypted types**: `FHE.asEuintX` converts plaintext values to encrypted types
6161
- **Casting to encrypted addresses**: `FHE.asEaddress` converts plaintext addresses to encrypted addresses
62-
- **Casting to encrypted bytes**: `FHE.asEbytesX` converts plaintext bytes to encrypted bytes
6362

6463
#### `asEuint`
6564

docs/solidity-guides/key_concepts.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fhevm provides functions to cast between encrypted types:
3232
- **Casting between encrypted types**: `FHE.asEbool` converts encrypted integers to encrypted booleans
3333
- **Casting to encrypted types**: `FHE.asEuintX` converts plaintext values to encrypted types
3434
- **Casting to encrypted addresses**: `FHE.asEaddress` converts plaintext addresses to encrypted addresses
35-
- **Casting to encrypted bytes**: `FHE.asEbytesX` converts plaintext bytes to encrypted bytes
3635

3736
For more information see [use of encrypted types](types.md).
3837

0 commit comments

Comments
 (0)