From 4b6260b8246eb10baa4cd593eb6a70e0a246dc02 Mon Sep 17 00:00:00 2001 From: Benoit Chevallier-Mames Date: Thu, 26 Dec 2024 14:56:14 +0100 Subject: [PATCH] chore: fixing a few typos --- README.md | 4 +- docs/developer/contribute.md | 2 +- docs/fundamentals/decryption/decrypt.md | 83 ++++++++++++------------- docs/fundamentals/inputs.md | 4 +- docs/guides/contracts.md | 2 +- docs/guides/debug_decrypt.md | 15 +++-- docs/guides/frontend/webapp.md | 2 +- docs/guides/loop.md | 2 +- 8 files changed, 58 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index af6c177f..63c3d9f0 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Master `fhEVM` and build smart contracts using these resources: - 📘 [**Comprehensive fhEVM Documentation**](https://docs.zama.ai/fhevm) Dive deep into Zama's detailed guide for utilizing the full potential of fhEVM. -- 🤖 [**ZAMA Solidity Developer (Modified ChatGPT Model)**](https://chatgpt.com/g/g-67518aee3c708191b9f08d077a7d6fa1-zama-solidity-developer) +- 🤖 [**Zama Solidity Developer (Modified ChatGPT Model)**](https://chatgpt.com/g/g-67518aee3c708191b9f08d077a7d6fa1-zama-solidity-developer) Accelerate your smart contract development with AI-powered assistance. ### **Development templates** @@ -264,7 +264,7 @@ There are two ways to contribute to the Zama fhEVM: - [Open issues](https://github.com/zama-ai/fhevm/issues/new/choose) to report bugs and typos, or to suggest new ideas - Request to become an official contributor by emailing hello@zama.ai. -Becoming an approved contributor involves signing our Contributor License Agreement (CLA)). Only approved contributors can send pull requests, so please make sure to get in touch before you do! +Becoming an approved contributor involves signing our Contributor License Agreement (CLA). Only approved contributors can send pull requests, so please make sure to get in touch before you do!

### License diff --git a/docs/developer/contribute.md b/docs/developer/contribute.md index 7df81d1a..a19ddc29 100644 --- a/docs/developer/contribute.md +++ b/docs/developer/contribute.md @@ -5,7 +5,7 @@ There are two ways to contribute to the Zama fhEVM: - [Open issues](https://github.com/zama-ai/fhevm/issues/new/choose) to report bugs and typos, or to suggest new ideas - Request to become an official contributor by emailing [hello@zama.ai](mailto:hello@zama.ai). -Becoming an approved contributor involves signing our Contributor License Agreement (CLA)). Only approved contributors can send pull requests, so please make sure to get in touch before you do! +Becoming an approved contributor involves signing our Contributor License Agreement (CLA). Only approved contributors can send pull requests, so please make sure to get in touch before you do! ## Zama Bounty Program diff --git a/docs/fundamentals/decryption/decrypt.md b/docs/fundamentals/decryption/decrypt.md index a64764f5..c05a381e 100644 --- a/docs/fundamentals/decryption/decrypt.md +++ b/docs/fundamentals/decryption/decrypt.md @@ -70,7 +70,7 @@ contract TestAsyncDecrypt is SepoliaZamaFHEVMConfig, SepoliaZamaGatewayConfig, G Remember our [**Encrypted Counter**](../../getting_started/first_smart_contract.md) contract from before? Here’s an improved version of it, upgraded to support decryption: -``` +```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; @@ -84,47 +84,46 @@ import "fhevm/gateway/GatewayCaller.sol"; /// @dev Uses TFHE library for fully homomorphic encryption operations and Gateway for decryption /// @custom:experimental This contract is experimental and uses FHE technology with decryption capabilities contract EncryptedCounter3 is SepoliaZamaFHEVMConfig, SepoliaZamaGatewayConfig, GatewayCaller { - /// @dev Decrypted state variable - euint8 internal counter; - uint8 public decryptedCounter; - - constructor() { - Gateway.setGateway(Gateway.defaultGatewayAddress()); - - // Initialize counter with an encrypted zero value - counter = TFHE.asEuint8(0); - TFHE.allowThis(counter); - } - - function incrementBy(einput amount, bytes calldata inputProof) public { - // Convert input to euint8 and add to counter - euint8 incrementAmount = TFHE.asEuint8(amount, inputProof); - counter = TFHE.add(counter, incrementAmount); - TFHE.allowThis(counter); - } - - /// @notice Request decryption of the counter value - function requestDecryptCounter() public { - uint256[] memory cts = new uint256[](1); - cts[0] = Gateway.toUint256(counter); - Gateway.requestDecryption(cts, this.callbackCounter.selector, 0, block.timestamp + 100, false); - } - - /// @notice Callback function for counter decryption - /// @param decryptedInput The decrypted counter value - /// @return The decrypted value - function callbackCounter(uint256, uint8 decryptedInput) public onlyGateway returns (uint8) { - decryptedCounter = decryptedInput; - return decryptedInput; - } - - /// @notice Get the decrypted counter value - /// @return The decrypted counter value - function getDecryptedCounter() public view returns (uint8) { - return decryptedCounter; - } -} + /// @dev Decrypted state variable + euint8 internal counter; + uint8 public decryptedCounter; + + constructor() { + Gateway.setGateway(Gateway.defaultGatewayAddress()); + + // Initialize counter with an encrypted zero value + counter = TFHE.asEuint8(0); + TFHE.allowThis(counter); + } + + function incrementBy(einput amount, bytes calldata inputProof) public { + // Convert input to euint8 and add to counter + euint8 incrementAmount = TFHE.asEuint8(amount, inputProof); + counter = TFHE.add(counter, incrementAmount); + TFHE.allowThis(counter); + } + + /// @notice Request decryption of the counter value + function requestDecryptCounter() public { + uint256[] memory cts = new uint256[](1); + cts[0] = Gateway.toUint256(counter); + Gateway.requestDecryption(cts, this.callbackCounter.selector, 0, block.timestamp + 100, false); + } + /// @notice Callback function for counter decryption + /// @param decryptedInput The decrypted counter value + /// @return The decrypted value + function callbackCounter(uint256, uint8 decryptedInput) public onlyGateway returns (uint8) { + decryptedCounter = decryptedInput; + return decryptedInput; + } + + /// @notice Get the decrypted counter value + /// @return The decrypted counter value + function getDecryptedCounter() public view returns (uint8) { + return decryptedCounter; + } +} ``` ### Tests for `EncryptedCounter3` @@ -169,7 +168,7 @@ describe("EncryptedCounter3", function () { // Wait for decryption to complete await awaitAllDecryptionResults(); - // Check decrypted value (should be 3: initial 0 + three increments) + // Check decrypted value (should be 5: initial 0 + an increment of 5) const decryptedValue = await this.counterContract.getDecryptedCounter(); expect(decryptedValue).to.equal(5); }); diff --git a/docs/fundamentals/inputs.md b/docs/fundamentals/inputs.md index 2ee85526..5c0f98b4 100644 --- a/docs/fundamentals/inputs.md +++ b/docs/fundamentals/inputs.md @@ -113,7 +113,7 @@ This example demonstrates a function that performs multiple encrypted operations } ``` -### Example validation in the `encyrptedERC20.sol` smart contract +### Example validation in the `encryptedERC20.sol` smart contract Here’s an example of a smart contract function that verifies an encrypted input before proceeding: @@ -179,7 +179,7 @@ contract EncryptedCounter2 is SepoliaZamaFHEVMConfig { } ``` -### Tests of for the Counter contract +### Tests of the Counter contract ```ts import { createInstance } from "../instance"; diff --git a/docs/guides/contracts.md b/docs/guides/contracts.md index 3106b6a2..f11e5bcc 100644 --- a/docs/guides/contracts.md +++ b/docs/guides/contracts.md @@ -4,7 +4,7 @@ This guide explains how to use the [fhEVM Contracts standard library](https://gi ## Overview -The **fhEVM Contracts standard library** streamlines the development of confidential smart contracts by providing templates and utilities for tokens, governance, and error management. These contracts have been rigorously tested by ZAMA's engineers and are designed to accelerate development while enhancing security. +The **fhEVM Contracts standard library** streamlines the development of confidential smart contracts by providing templates and utilities for tokens, governance, and error management. These contracts have been rigorously tested by Zama's engineers and are designed to accelerate development while enhancing security. ## Installation diff --git a/docs/guides/debug_decrypt.md b/docs/guides/debug_decrypt.md index 01a4c1b4..176098e4 100644 --- a/docs/guides/debug_decrypt.md +++ b/docs/guides/debug_decrypt.md @@ -2,8 +2,9 @@ This guide explains how to use the `debug.decrypt[XX]` functions for debugging encrypted data in mocked environments during development with fhEVM. -> [!WARNING] -> The `debug.decrypt[XX]` functions should not be used in production as they rely on private keys. +{% hint style="warning" %} +The `debug.decrypt[XX]` functions should not be used in production as they rely on private keys. +{% endhint %} ## Overview @@ -71,8 +72,9 @@ const plaintextValue: bigint = await debug.decrypt64(handle64); console.log("Decrypted Balance:", plaintextValue); ``` -> [!NOTE] -> To utilize the debug functions, import the [utils.ts](https://github.com/zama-ai/fhevm-hardhat-template/blob/main/test/utils.ts) file. +{% hint style="info" %} +To utilize the debug functions, import the [utils.ts](https://github.com/zama-ai/fhevm-hardhat-template/blob/main/test/utils.ts) file. +{% endhint %} For a more complete example, refer to the [ConfidentialERC20 test file](https://github.com/zama-ai/fhevm-hardhat-template/blob/f9505a67db31c988f49b6f4210df47ca3ce97841/test/confidentialERC20/ConfidentialERC20.ts#L181-L205). @@ -102,8 +104,9 @@ function verifyType(handle: bigint, expectedType: number) { ### Environment checks -> [!CAUTION] -> The functions only work in the `hardhat` network. Attempting to use them in a production environment will result in an error. +{% hint style="danger" %} +The functions only work in the `hardhat` network. Attempting to use them in a production environment will result in an error. +{% endhint %} ```typescript if (network.name !== "hardhat") { diff --git a/docs/guides/frontend/webapp.md b/docs/guides/frontend/webapp.md index 93728117..ac340815 100644 --- a/docs/guides/frontend/webapp.md +++ b/docs/guides/frontend/webapp.md @@ -18,7 +18,7 @@ You can also use [this template](https://github.com/zama-ai/fhevmjs-vue-template You can also use [this template](https://github.com/zama-ai/fhevmjs-next-template) to start an application with fhevmjs, using Next + TypeScript. -## Using the mocked coprocessor for front end +## Using the mocked coprocessor for frontend As an alternative to use the real coprocessor deployed on Sepolia to help you develop your dApp faster and without needing testnet tokens, you can use a mocked fhevm. Currently, we recommend you to use the `ConfidentialERC20` dApp example available on the `mockedFrontend` branch of the [React template](https://github.com/zama-ai/fhevm-react-template/tree/mockedFrontend). Follow the README on this branch, and you will be able to deploy exactly the same dApp both on Sepolia as well as on the mocked coprocessor seamlessly. diff --git a/docs/guides/loop.md b/docs/guides/loop.md index 48d8a154..291685a6 100644 --- a/docs/guides/loop.md +++ b/docs/guides/loop.md @@ -43,7 +43,7 @@ However, this is sometimes not enough. Enhancing the privacy of smart contracts For example, if implementing a simple AMM for two encrypted ERC20 tokens based on a linear constant function, it is recommended to not only hide the amounts being swapped, but also the token which is swapped in a pair. -✅ Here is a very simplified example implementations, we suppose here that the the rate between tokenA and tokenB is constant and equals to 1: +✅ Here is a very simplified example implementations, we suppose here that the rate between tokenA and tokenB is constant and equals to 1: ```solidity // typically either encryptedAmountAIn or encryptedAmountBIn is an encrypted null value