From 3672a35d40263406220f7f20aeba821c24263005 Mon Sep 17 00:00:00 2001 From: Eshel Date: Mon, 7 Oct 2024 15:47:35 +0300 Subject: [PATCH 1/2] improved tip --- docs/devdocs/Writing Smart Contracts/Types-and-Operators.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md b/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md index 1755c9cd..4a867fa3 100644 --- a/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md +++ b/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md @@ -95,7 +95,7 @@ The `ebool` type is not a real boolean type. It is implemented as a `euint8` :::tip -A documented documentation of each and every function in FHE.sol (including inputs and outputs) can be found in [FHE.sol](../Solidity%20API/FHE.md) +A documentation of every function in FHE.sol (including inputs and outputs) can be found in [FHE.sol](../Solidity%20API/FHE.md) ::: All operations supported by FHE.sol are listed in the table below. For performance reasons, not all operations are supported for all types. @@ -142,4 +142,4 @@ Using require and decrypt in a TX is dangerous as it can break the confidentiali :::tip Division and Remainder by `0` will output with an encrypted representation of the maximal value of the uint that is used (Ex. encrypted 255 for euint8) -::: \ No newline at end of file +::: From 97d6a7f497fdfde49cb3288736ce1a0f4af613e2 Mon Sep 17 00:00:00 2001 From: Eshel Date: Sun, 27 Oct 2024 15:11:20 +0200 Subject: [PATCH 2/2] some changes regarding new fhenixjs permit generation --- .../Permits-Access-Control.md | 17 ++++++++++++----- .../Examples and References/Templates.md | 2 +- docs/devdocs/FhenixJS/Decryption.md | 14 +++++--------- docs/devdocs/FhenixJS/Encryption.md | 1 + 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md index 70bc309e..2e0f0976 100644 --- a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md +++ b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md @@ -22,13 +22,21 @@ The inclusion of this public key into the permit enables a secure process of dat #### How to Generate a Permit -Permits are generated using the `getPermit` method in `fhenix.js`. This method requires the following parameters: +Permits are generated using the `generatePermit` method in `fhenix.js`. This method receives the following parameters: * `contractAddress` (required, string): The address of the contract. -* `provider` (required): An `ethers` (or compatible) object that can sign EIP-712 formatted data. (Note that if you want to unseal data using your wallet's encryption key you can't use "JsonRpcProvider") +* `provider` (optional): An `ethers` (or compatible) object that can sign EIP-712 formatted data. (Note that if you want to unseal data using your wallet's encryption key you can't use "JsonRpcProvider") +* `signer` (optional): Another `ethers` (or compatible) signer if you want to use a different signer than the one in the provider (chain-id requests are still made via the provider) ```javascript -const permit = await getPermit(contractAddress); +const permit = await generatePermit(contractAddress); + +// passing a custom signer +let permit = await fhenixjs.generatePermit( + contractAddress, + undefined, // use the internal provider + signer, // created from, e.g. `ethers.getSigners()[0]` +); ``` #### What is a Permission? @@ -57,9 +65,8 @@ import { FhenixClient, getPermit } from "fhenixjs"; const provider = new BrowserProvider(window.ethereum); const client = new FhenixClient({ provider }); -const permit = await getPermit(contractAddress, provider); +const permit = await generatePermit(contractAddress, provider); const permission = client.extractPemitPermissions(permit); -client.storePermit(permit); // Stores a permit for a specific contract address. const response = await contract.connect(owner).getValue(permission); // Calling "getValue" which is a view function in "contract" const plaintext = await client.unseal(contractAddress, response); ``` diff --git a/docs/devdocs/Examples and References/Templates.md b/docs/devdocs/Examples and References/Templates.md index 1df5ca0e..fc0ce2e8 100644 --- a/docs/devdocs/Examples and References/Templates.md +++ b/docs/devdocs/Examples and References/Templates.md @@ -9,7 +9,7 @@ We compiled a list of a few templates that you can use as a reference to build y https://github.com/FhenixProtocol/fhenix-hardhat-example -Has a basic contract, some tasks and a simple frontend (TODO: copy over from playground). +Has a basic contract, some tasks and a simple frontend. ### Nuxt 3 + Fhenixjs + Ethers.js + Bootstrap Starter diff --git a/docs/devdocs/FhenixJS/Decryption.md b/docs/devdocs/FhenixJS/Decryption.md index 345c624b..802abbad 100644 --- a/docs/devdocs/FhenixJS/Decryption.md +++ b/docs/devdocs/FhenixJS/Decryption.md @@ -33,14 +33,12 @@ This is done in 3 steps: generating a permit, querying the contract and unsealin #### 1. Creating a Permit ```javascript -import { FhenixClient, getPermit } from 'fhenixjs'; +import { FhenixClient, generatePermit } from 'fhenixjs'; const provider = new ethers.JsonRpcProvider('https://api.helium.fhenix.zone/'); const client = new FhenixClient({ provider }); - -const permit = await getPermit(contractAddress, provider); -client.storePermit(permit); +const permit = await generatePermit(contractAddress, provider); ``` :::tip[Did you know?] @@ -74,18 +72,16 @@ Permits are currently limited to support a single contract #### Putting it all Together ```typescript -import { FhenixClient, getPermit } from 'fhenixjs'; +import { FhenixClient, generatePermit } from 'fhenixjs'; import { JsonRpcProvider } from 'ethers'; const provider = new ethers.JsonRpcProvider('https://api.helium.fhenix.zone/'); const client = new FhenixClient({provider}); -const permit = await getPermit(contractAddress, provider); -client.storePermit(permit); - +const permit = await generatePermit(contractAddress, provider); const permission = client.extractPermitPermission(permit); -const response = await contract.balanceOf(permission); +const response = await contract.balanceOf(permission); const plaintext = client.unseal(contractAddress, response); console.log(`My Balance: ${plaintext}`) diff --git a/docs/devdocs/FhenixJS/Encryption.md b/docs/devdocs/FhenixJS/Encryption.md index 9d9e2683..9f980f68 100644 --- a/docs/devdocs/FhenixJS/Encryption.md +++ b/docs/devdocs/FhenixJS/Encryption.md @@ -57,6 +57,7 @@ The `EncryptedUint` types sound scary, but are actually pretty simple. It's just ```typescript export interface EncryptedNumber { data: Uint8Array; + securityZone: number; // defaults to 0 } export interface EncryptedUint8 extends EncryptedNumber {}