Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing typo + other things I see in the doc #676

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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 [email protected].

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!
<br></br>

### License
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[email protected]](mailto:[email protected]).

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

Expand Down
83 changes: 41 additions & 42 deletions docs/fundamentals/decryption/decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
bcm-at-zama marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified by prettier

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`
Expand Down Expand Up @@ -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)
bcm-at-zama marked this conversation as resolved.
Show resolved Hide resolved
const decryptedValue = await this.counterContract.getDecryptedCounter();
expect(decryptedValue).to.equal(5);
});
Expand Down
4 changes: 2 additions & 2 deletions docs/fundamentals/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -179,7 +179,7 @@ contract EncryptedCounter2 is SepoliaZamaFHEVMConfig {
}
```

### Tests of for the Counter contract
### Tests of the Counter contract

```ts
import { createInstance } from "../instance";
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions docs/guides/debug_decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/frontend/webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading