From a0c3022ce6c0ce95fc406142c08c1397d8eab026 Mon Sep 17 00:00:00 2001 From: mcisb <83702309+KyryloKilin@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:34:22 +0200 Subject: [PATCH 1/5] Update Deploying.mdx --- docs/tutorial/Basic/Deploying.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/Basic/Deploying.mdx b/docs/tutorial/Basic/Deploying.mdx index e7074988..d308c833 100644 --- a/docs/tutorial/Basic/Deploying.mdx +++ b/docs/tutorial/Basic/Deploying.mdx @@ -8,7 +8,7 @@ Now that we have our completed WrappingERC20 token, the next step is to see if o To do this, we'll be writing tests in typescript using hardhat, and deploying them on our [LocalFhenix ](../../devdocs/Setting%20Up%20Your%20Environment/Hardhat.md) environment which we set up earlier :::tip[Note] -At this stage, using hardhat network is not supported, as Fhenix uses extentions to the EVM that enable FHE operations +At this stage, using hardhat network is not supported, as Fhenix uses extensions to the EVM that enable FHE operations ::: ### Compiling the Contract From abc8cfbf18815047127dfc44e30196b144efc9de Mon Sep 17 00:00:00 2001 From: mcisb <83702309+KyryloKilin@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:36:48 +0200 Subject: [PATCH 2/5] Update Permits-Access-Control.md --- .../Encryption and Privacy/Permits-Access-Control.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md index 296ebcb5..8f0f5504 100644 --- a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md +++ b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md @@ -37,7 +37,7 @@ In the context of Fhenix and blockchain, a permit refers to a signed JSON object #### How to Generate a Permit -Permits are generated using the `getPermit` method. This method requires a the following parameter: +Permits are generated using the `getPermit` method. This method requires the following parameter: * `contractAddress` (required, string): The address of the contract. * `provider` (required): Note that if you want to unseal data using your wallet's encryption key you can't use "JsonRpcProvider" you will need to use a provider that can sign. @@ -55,7 +55,7 @@ In the context of Fhenix, a permission is the part of a permit that supplies the const permission = client.extractPermitPermissions(permit); ``` -#### Using an Permission +#### Using a Permission Once generated, you can use the permission and send it to the contract. You can also unseal the outputs of "sealoutput" assuming it was sealed using your permission. @@ -70,4 +70,4 @@ 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); -``` \ No newline at end of file +``` From fdb239576582fa7c61be1b3e9a080b6a78d43669 Mon Sep 17 00:00:00 2001 From: mcisb <83702309+KyryloKilin@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:40:40 +0200 Subject: [PATCH 3/5] Update Utilities.md --- docs/devdocs/Solidity API/Utilities.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/devdocs/Solidity API/Utilities.md b/docs/devdocs/Solidity API/Utilities.md index 1c40bd88..d5c0a310 100644 --- a/docs/devdocs/Solidity API/Utilities.md +++ b/docs/devdocs/Solidity API/Utilities.md @@ -1,6 +1,6 @@ # Utility Contracts -#### Encrepted Address +#### Encrypted Address Encrypting address is not an easy task as we currently only support encrypted uint32s (4 bytes) and address are formed out of 20 bytes. We created a tool that implements `Eaddress` which is formed by 5 uint32s. @@ -10,8 +10,8 @@ An example of how to use the tool can be found it: TBD #### Random Number -Confidentiality is a crucial step in order to achieve on-chain randomness. Fhenix, as a chain that implements confidintiality, is a great space to implement and use on-chain random numbers and this is part of our roadmap. -We know that there are some #BUIDLers that are planing to implement dapps that leverage both confidentiality and random numbers so until we will have on-chain true random we are suggesting to use the following implementation as a MOCKUP. +Confidentiality is a crucial step in order to achieve on-chain randomness. Fhenix, as a chain that implements confidentiality, is a great space to implement and use on-chain random numbers and this is part of our roadmap. +We know that there are some #BUIDLers that are planning to implement dapps that leverage both confidentiality and random numbers so until we will have on-chain true random we are suggesting to use the following implementation as a MOCKUP. PLEASE NOTE THAT THIS RANDOM NUMBER IS VERY PREDICTABLE AND CAN'T BE REALLY TRUSTED ```javascript From bca52712f219c1b5dea0dda1393291379afd9b58 Mon Sep 17 00:00:00 2001 From: mcisb <83702309+KyryloKilin@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:43:47 +0200 Subject: [PATCH 4/5] Update Useful-Tips.md --- docs/devdocs/Tips/Useful-Tips.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/devdocs/Tips/Useful-Tips.md b/docs/devdocs/Tips/Useful-Tips.md index 6ebc6bd2..531492d0 100644 --- a/docs/devdocs/Tips/Useful-Tips.md +++ b/docs/devdocs/Tips/Useful-Tips.md @@ -4,7 +4,7 @@ This section will list some useful tips and good practices for you to be able to #### Trivial Encryption -When we are using `FHE.asEuint*(PLAINTEXT_NUMBER)` we are actually using a trivial encrpytion of our FHE scheme. Unlike normal FHE encryption trivial encryption is a deterministic encryption. The meaning is that if you will do it twice you will still get the same result +When we are using `FHE.asEuint*(PLAINTEXT_NUMBER)` we are actually using a trivial encryption of our FHE scheme. Unlike normal FHE encryption trivial encryption is a deterministic encryption. The meaning is that if you will do it twice you will still get the same result #### Default Value of a Euint @@ -14,19 +14,19 @@ You can assume now that `FHE.asEuint*(0)`is quite oftenly used - Luckily we real #### Re-encrypting a Value To explain this tip we will use an example. Let's assume we want to develop a confidential voting and let's say we have 4 candidates. -Assuming that on each vote we increase (cryptographicaly with FHE.add) the tally, one can just monitor the key in the DB that represents this specific tally and once the key was changes he will know who we voted for. +Assuming that on each vote we increase (cryptographically with FHE.add) the tally, one can just monitor the key in the DB that represents this specific tally and once the key was changes he will know who we voted for. An ideal solution for this issue is to change all keys no matter who we voted for, but how?! In order to understand how we will first need to understand that FHE encryption is a non-determenisitic encryption means that encrypting (non-trivial encryption) a number twice will result with 2 different encrypted outputs. -Now that we know that, we can add 0 (cryptographicaly with FHE.add) to all of those tallies that shouldn't be changed and they will be changed in the DB! +Now that we know that, we can add 0 (cryptographically with FHE.add) to all of those tallies that shouldn't be changed and they will be changed in the DB! #### FHE.req() in TXs -All of the operations are supported both in TXs and in Queries. That being said we strongly advice to think twice before you use those operations inside a TX. FHE.req() is actually exposing the value of your encrypted data. Assuming we will send the transaction and monitor the gas usage we can probably identify whenther the FHE.req() condition met or not and understand a lot about what the encrypted values represent +All of the operations are supported both in TXs and in Queries. That being said we strongly advise to think twice before you use those operations inside a TX. FHE.req() is actually exposing the value of your encrypted data. Assuming we will send the transaction and monitor the gas usage we can probably identify whether the FHE.req() condition met or not and understand a lot about what the encrypted values represent. #### Performance and Gas Usage Currently we are supporting a lot of FHE operations. Some of them might take a lot of time to compute, some good examples are: Div (5 seconds for euint32), Mul, Rem, and the time will grow depends on the value types you are using. -When writing FHE code we encourage you to use the operations wisely and choose what opeation should be used. +When writing FHE code we encourage you to use the operations wisely and choose what operation should be used. Example: Instead of `FHE.mul(ENCRYPTED_UINT_32, FHE.asEuint32(2))` you can use `FHE.shl(ENCRYPTED_UINT_32, FHE.asEuint32(1))` in some cases `FHE.div(ENCRYPTED_UINT_32, FHE.asEuint32(2))` can be replaced by `FHE.shr(ENCRYPTED_UINT_32, FHE.asEuint32(1))` -For more detailed banchmarks please refer to: TBD +For more detailed benchmarks please refer to: TBD From 2e439919a3cea6de7803ce89ae31d0d6850115a4 Mon Sep 17 00:00:00 2001 From: mcisb <83702309+KyryloKilin@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:45:57 +0200 Subject: [PATCH 5/5] Update Fhenix-Encryption-UI.md --- docs/devdocs/Tools and Utilities/Fhenix-Encryption-UI.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/devdocs/Tools and Utilities/Fhenix-Encryption-UI.md b/docs/devdocs/Tools and Utilities/Fhenix-Encryption-UI.md index d2bc9b82..c6cef420 100644 --- a/docs/devdocs/Tools and Utilities/Fhenix-Encryption-UI.md +++ b/docs/devdocs/Tools and Utilities/Fhenix-Encryption-UI.md @@ -8,16 +8,16 @@ This UI is useful for those who are not using remix or using remix without using #### Encryption In order to encrypt a number you can simply write the number you want to encrypt instead of the "Enter a number" text. -You can choouse what Euint\* type you want as an output and evantually you can choose one of the two options: +You can choose what Euint\* type you want as an output and eventually you can choose one of the two options: 1. Encrypt (Plain) - Will output hex encoded bytes (`0x04000...`) that can be used as "bytes calldata" input or as the input for the remix plugin 2. Encrypt (InEuint) - Will output hex encoded bytes in a square brackets (`[0x04000...]`) that can be used in remix (not with the plugin) for function that receive inEuint\* -All output will be copied to your clipboard and a notification will pop telling you that the output was coppied. +All output will be copied to your clipboard and a notification will pop telling you that the output was copied. #### Unsealing You can only unseal data that was sealed using your wallet public encryption key. -In order to get your wallets public encryption key you can click on "Get Public Key" that will use metamask in order to retreive the key. The key will be shown as a notification on which you can click in order to copy the value to your clipboard. +In order to get your wallets public encryption key you can click on "Get Public Key" that will use metamask in order to retrieve the key. The key will be shown as a notification on which you can click in order to copy the value to your clipboard. Decryption can be done by simply pasting the encrypted value instead of the "Enter sealed value" text and clicking on the Unseal button which will use metamask to decrypt the value.