Skip to content

Commit 49c6354

Browse files
authored
Merge pull request #52 from FhenixProtocol/nitrogen-versioned
Nitrogen versioned
2 parents 93bbdbf + 6c53db7 commit 49c6354

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7626
-3
lines changed

docs/devdocs/Examples and References/Examples-fheDapps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Here you can find a list of some cool apps that you can use as a reference
6565
</tr>
6666
<tr>
6767
<td>Unique Bid Auction</td>
68-
<td><a href="https://github.com/Syndika-Corp/fhenix-contracts">View on Github</a></td>
68+
<td><a href=""></a></td>
6969
<td><a href="https://fhenix.netlify.app/">Bids_Party</a><br /></td>
7070
<td>A showcase of a blind bid auction using a unique bidding mechanism</td>
7171
</tr>

docusaurus.config.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const config: Config = {
3535
'classic',
3636
{
3737
docs: {
38+
lastVersion: 'current',
39+
versions: {
40+
current: {
41+
label: 'Nitrogen',
42+
path: '.'
43+
}
44+
},
3845
sidebarPath: './sidebars.ts',
3946
// Please change this to your repo.
4047
// Remove this to remove the "edit this page" links.
@@ -71,7 +78,7 @@ const config: Config = {
7178
alt: 'Fhenix',
7279
src: 'img/logo-black.svg',
7380
srcDark: 'img/logo-white.svg',
74-
href: 'https://fhenix.io',
81+
href: 'https://fhenix.io',
7582
},
7683
items: [
7784
{
@@ -94,6 +101,10 @@ const config: Config = {
94101
position: 'left',
95102
label: 'Developer Docs',
96103
},
104+
{
105+
type: "docsVersionDropdown",
106+
position: 'right'
107+
},
97108
// {
98109
// type: 'docSidebar',
99110
// sidebarId: 'tutorialSidebar',
@@ -176,7 +187,7 @@ const config: Config = {
176187

177188
// Public API key: it is safe to commit it
178189
apiKey: '7053edb0c71f9da5171b05b1836adf78',
179-
190+
180191
indexName: 'fhenix',
181192

182193
// Optional: see doc section below
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 📜 Permits & Access Control
2+
3+
4+
In a Fully Homomorphic Encryption (FHE) framework, all data stored in a contract's storage is encrypted. Access control involves granting selective access to data by authorized parties while restricting access to unauthorized users.
5+
6+
Solidity contracts generally expose their data using `view` functions. However, permissioned data is a challenge, since Solidity `view` functions do not come with any in-built mechanism to allow the contract to verify cryptographically that callers are who they say they are (for transactions, this is done by verifying the signature on the data).
7+
Fhenix handles this issue by implementing a `seal` function, which seals the data in a manner that only the intended recipient can decrypt and view (Fhenix uses the `decrypt` function for less sensitive data). This approach ensures that encrypted data remains confidential and only accessible to authorized users.
8+
9+
## Permits and Access Control
10+
11+
Fhenix Solidity libraries (specifically, fhenix.js) are equipped with an in-built access control scheme.
12+
This access control scheme enables contracts to perform a basic check of account ownership by adding authentication and authorization features to specific view functions.
13+
(An added benefit of the Fhenix Solidity libraries is that developers save coding effort each time a project has cryptographic access control requirements.)
14+
15+
#### What is a Permit?
16+
17+
A permit is a mechanism that allows the contract to verify cryptographically the identity of callers, ensuring that they are who they claim to be.
18+
19+
In Fhenix, a permit is a signed message that contains the caller's public key, which the contract can use to verify the caller. The permit is a signed JSON object that follows the EIP-712 standard.
20+
The permit contains the necessary information, including a public key, which allows data re-sealing in a smart contract environment.
21+
The inclusion of this public key into the permit enables a secure process of data re-sealing within a smart contract after the JSON object is signed by the user.
22+
23+
#### How to Generate a Permit
24+
25+
Permits are generated using the `getPermit` method in `fhenix.js`. This method requires the following parameters:
26+
27+
* `contractAddress` (required, string): The address of the contract.
28+
* `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")
29+
30+
```javascript
31+
const permit = await getPermit(contractAddress);
32+
```
33+
34+
#### What is a Permission?
35+
36+
In Fhenix, a permission is that part of a permit that supplies proof that callers are who they say they are.
37+
A permission contains the signature and corresponding public key.
38+
In order to see how to verify a permission in a Solidity contract, please refer to our [Permissioned](../Solidity%20API/Permissioned.md).
39+
40+
#### How to Generate a Permission
41+
42+
The following is the syntax for generating a permission:
43+
44+
```javascript
45+
const permission = client.extractPermitPermissions(permit);
46+
```
47+
48+
#### Using a Permission
49+
50+
Once generated, the permission can be used and sent to the contract. It can also be used to unseal the output of the `sealoutput` function, assuming it was sealed using that same permission.
51+
52+
The following code snippet shows how to implement the added cryptographic functionality of Fhenix (specifically, permits and permissions) on Ethereum using the Fhenix library.
53+
54+
```javascript
55+
import { BrowserProvider } from "ethers";
56+
import { FhenixClient, getPermit } from "fhenixjs";
57+
58+
const provider = new BrowserProvider(window.ethereum);
59+
const client = new FhenixClient({ provider });
60+
const permit = await getPermit(contractAddress, provider);
61+
const permission = client.extractPemitPermissions(permit);
62+
client.storePermit(permit); // Stores a permit for a specific contract address.
63+
const response = await contract.connect(owner).getValue(permission); // Calling "getValue" which is a view function in "contract"
64+
const plaintext = await client.unseal(contractAddress, response);
65+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# 🤫 Development Tips – Ensuring Privacy
2+
3+
Fhenix provides a secure and decentralized way to execute smart contracts on encrypted data; transactions and computations are fully encrypted. As such, Fhenix offers superior on-chain privacy. However, developers still need to be vigilant, because all blockchain privacy platforms have their idiosyncrasies and potential privacy risks.
4+
5+
##### Implement Best Practices
6+
Fhenix ensures end-to-end encryption, but developers should be careful not to become complacent on matters of privacy. Developers should always prioritize best practices to ensure privacy and confidentiality.
7+
8+
##### Analyze Your Privacy Model
9+
We recommend that Fhenix developers carefully analyze their smart contract privacy model (this applies to any blockchain platform with privacy features). Distinguish between the type of information that, if “leaked,” can affect contract privacy on the one hand, and the type of information that, if compromised, will not affect contract operation and user privacy on the other. Special attention should be given to the type of information that must remain confidential.
10+
11+
As a result of this analysis and the insights gained, structure your smart contracts in a way that safeguards the aspects that affect privacy, while ensuring that the smart contract continues to operate efficiently.
12+
13+
##### A Simple Example
14+
A simple example of metadata leakage is gas usage. Consider a smart contract coded in Solidity that contains a conditional statement. In this case, the path taken by the condition, though encrypted, may still reveal information. A typical scenario is a conditional branch based on the value of a private variable, where gas usage, events, or other metadata could reveal the branch taken.
15+
16+
```Javascript
17+
function performActionBasedOnBalance(uint256 amount) public {
18+
if (balance[msg.sender] >= amount) {
19+
// perform some operation
20+
} else {
21+
// perform another operation
22+
}
23+
}
24+
```
25+
26+
In the above Solidity example, someone observing the transaction could potentially infer the chosen branch based on gas usage, events or metadata, which would, in turn, indirectly reveal whether the sender's balance was greater than or equal to the specified amount.
27+
28+
This example might seem insignificant, but it is important to remember that transactions can often be cheaply simulated with different input parameters. In the above example, performing a logarithmic search would reveal the exact balance fairly quickly.
29+
30+
##### Add Access Controls
31+
It is important to provide access controls to functions that handle sensitive data. For instance, a function revealing a user’s balance should only be accessible to that specific user. We discuss this issue further in the [section on access control](./Permits-Access-Control.md)
32+
33+
##### In Conclusion
34+
Despite the embedded encryption protection provided by FHE, it is essential to understand and address potential risk areas that can compromise privacy. We will be updating this section and our other documentation as our product matures, so be sure to check back from time to time.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Encryption and Privacy",
3+
"position": 11
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
sidebar_position: 2
3+
title: Examples & fheDapps
4+
---
5+
6+
Here you can find a list of some cool apps that you can use as a reference
7+
8+
<table>
9+
<thead>
10+
<tr>
11+
<th>App</th>
12+
<th>Repo</th>
13+
<th>UI</th>
14+
<th>Notes</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
<tr>
19+
<td>FHERC-20</td>
20+
<td><a href="https://github.com/FhenixProtocol/example-contracts/blob/master/wrapping-ERC20/WrappingERC20.sol">View on Github</a><br /></td>
21+
<td><a href="http://fhenix-demo.pages.dev/">FHERC-20 Demo</a></td>
22+
<td>A token in which balances are encrypted and viewable only to the holder.</td>
23+
</tr>
24+
<tr>
25+
<td>Blind Auction</td>
26+
<td><a href="https://github.com/FhenixProtocol/blind-auction-example">View on Github</a></td>
27+
<td><a href="https://github.com/FhenixProtocol/blind-auction-example/tree/main/frontend">View on Github</a></td>
28+
<td>An auction in which is bid is kept encrypted until the Auction ends and the winner is revealed.</td>
29+
</tr>
30+
31+
[//]: # (<tr>)
32+
33+
[//]: # (<td>NFT + 128 bit key</td>)
34+
35+
[//]: # (<td><a href="https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol">https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol</a></td>)
36+
37+
[//]: # (<td></td>)
38+
39+
[//]: # (<td>This examples will need to be updated when using Fhenix's FHE.sol</td>)
40+
41+
[//]: # (</tr>)
42+
<tr>
43+
<td>Confidential Voting</td>
44+
<td><a href="https://github.com/FhenixProtocol/confidential-voting">View on Github</a></td>
45+
<td></td>
46+
<td>A voting in which the individual votes are kept secret.</td>
47+
</tr>
48+
<tr>
49+
<td>Simple Lottery</td>
50+
<td><a href="https://github.com/FhenixProtocol/example-contracts/blob/master/lottery/Lottery.sol">View on Github</a></td>
51+
<td></td>
52+
<td>A very simple game leveraging the fact that you can pick a winning number and keep it private.</td>
53+
</tr>
54+
<tr>
55+
<td>Contract Playground</td>
56+
<td><a href="https://github.com/FhenixProtocol/contracts-playground">View on Github</a></td>
57+
<td></td>
58+
<td>A monorepo with multiple examples of contracts in the same place</td>
59+
</tr>
60+
<tr>
61+
<td>Fhevm Examples</td>
62+
<td><a href="https://github.com/zama-ai/fhevm-solidity/tree/main/examples">View on Github</a></td>
63+
<td><a href="https://dapps.zama.ai/">https://dapps.zama.ai/</a><br /></td>
64+
<td>NOTE: These examples are not directly compatible with Fhenix and must be adapted</td>
65+
</tr>
66+
<tr>
67+
<td>Unique Bid Auction</td>
68+
<td><a href=""></a></td>
69+
<td><a href="https://fhenix.netlify.app/">Bids_Party</a><br /></td>
70+
<td>A showcase of a blind bid auction using a unique bidding mechanism</td>
71+
</tr>
72+
73+
74+
[//]: # (<tr>)
75+
76+
[//]: # (<td>NFT Event Ticket</td>)
77+
78+
[//]: # (<td><a href="https://github.com/FhenixProtocol/ticketing-contracts">https://github.com/FhenixProtocol/ticketing-contracts</a>)
79+
80+
[//]: # (<a href="https://github.com/FhenixProtocol/ticket-verifier">https://github.com/FhenixProtocol/ticket-verifier</a></td>)
81+
82+
[//]: # (<td><a href="https://ticket-manager.pages.dev/">https://ticket-manager.pages.dev/</a><a href="https://ticket-manager.pages.dev/?verifier=1">https://ticket-manager.pages.dev/?verifier=1</a></td>)
83+
84+
[//]: # (<td>This examples will need to be updated when using Fhenix's FHE.sol</td>)
85+
[//]: # (<td>FHE.sol Operation Examples</td>)
86+
87+
[//]: # (<td><a href="https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts">https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts</a></td>)
88+
89+
[//]: # (<td><a href="https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts">https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts</a></td>)
90+
91+
[//]: # (<td>The UI link is for a javascript interface that uses hardhat in order to interact with the contracts</td>)
92+
93+
[//]: # (</tr>)
94+
</tbody>
95+
</table>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
sidebar_position: 1
3+
title: Templates
4+
---
5+
6+
We compiled a list of a few templates that you can use as a reference to build your own dApp.
7+
8+
### Hardhat + React
9+
10+
https://github.com/FhenixProtocol/fhenix-hardhat-example
11+
12+
Has a basic contract, some tasks and a simple frontend (TODO: copy over from playground).
13+
14+
### Nuxt 3 + Fhenixjs + Ethers.js + Bootstrap Starter
15+
16+
With this template you can easily start developing your Fhenix front-end app using Nuxt 3 (vue3).
17+
18+
https://github.com/FhenixProtocol/fhenix-nuxt3-template
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Examples and References",
3+
"position": 6
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# 🔗 Connecting to Fhenix Helium Testnet
6+
7+
Fhenix Helium is the first publicly available FHE-based blockchain, and it is now live! Follow the instructions to connect to Fhenix Helium Testnet.
8+
9+
## Configuring MetaMask
10+
11+
1. Open MetaMask in your browser and click on the Ethereum network.
12+
2. Click **Add Network.**
13+
3. Click **Add a network manually**.
14+
15+
4. Fill out the network details form. To add a custom network, fill in the following fields:
16+
1. **Network Name: Fhenix Helium**
17+
2. **New RPC URL: https://api.helium.fhenix.zone**
18+
3. **Chain ID:** 8008135
19+
4. **Currency Symbol: tFHE**
20+
5. **Block Explorer URL: https://explorer.helium.fhenix.zone**
21+
5. Once you fill out all the details, click **Save**.
22+
6. Now you are ready to switch to Fhenix Helium Testnet. Tokens are available from the testnet faucet. Start building!
23+
24+
25+
## API endpoints
26+
27+
<table>
28+
<thead>
29+
<tr>
30+
<th width="222">Type</th>
31+
<th>API</th>
32+
</tr>
33+
</thead>
34+
<tbody>
35+
<tr>
36+
<td>JSON-RPC</td>
37+
<td><a href="https://api.helium.fhenix.zone"><strong>https://api.helium.fhenix.zone</strong></a></td>
38+
</tr>
39+
<tr>
40+
<td>Chain ID</td>
41+
<td>8008135</td>
42+
</tr>
43+
<tr>
44+
<td>Websocket</td>
45+
<td>wss://api.helium.fhenix.zone:8548</td>
46+
</tr>
47+
</tbody>
48+
</table>
49+
50+
## Explorer
51+
52+
* [https://explorer.helium.fhenix.zone](https://explorer.helium.fhenix.zone)
53+
54+
## Faucet
55+
56+
To get some test tokens, use the faucet at [https://get-helium.fhenix.zone/](https://get-helium.fhenix.zone/).
57+
You may receive 0.1 tokens once every five minutes. If you need more tokens, please reach out to us on Discord, or bridge some Sepolia!
58+
59+
## Bridge
60+
61+
The Helium testnet is connected to the Sepolia testnet. You can use the bridge to move tokens between the two networks.
62+
If you require more tokens, you can use the bridge to move tokens from Sepolia to Helium.
63+
64+
* [https://bridge.helium.fhenix.zone/](https://bridge.helium.fhenix.zone/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
sidebar_position: 2
3+
title: 📐 Fhenix Architecture
4+
---
5+
6+
Our goal with Fhenix is not only to provide the first FHE-based L2 solution, but also to create a platform that is modular, flexible, and can easily be changed, extended or improved as we see
7+
traffic, use-cases and requirements evolve.
8+
9+
The Fhenix Protocol is composed of several components that work together to provide a secure and private environment for smart contracts. The main components are:
10+
11+
* Core Chain (based on Arbitrum Nitro)
12+
* FheOS
13+
* Warp-Drive
14+
15+
These components are layered together to provide a modular approach, that allows for a flexible architecture
16+
17+
![](/img/fhenix-stack.webp)
18+
19+
### Core Chain
20+
21+
The Core Blockchain is the base layer of the Fhenix Protocol. It is based on Arbitrum Nitro, which is a Layer 2 scaling solution for Ethereum. Arbitrum Nitro is a rollup chain that uses a combination of fraud proofs and optimistic rollups to provide a scalable and secure environment for smart contracts.
22+
23+
The Core Blockchain is responsible for processing transactions, executing smart contracts, and maintaining the state of the blockchain.
24+
25+
### FheOS
26+
27+
FheOS is the heart of the FHE operations. Its goal is to be a modular & extendable component that can plug into the underlying blockchain and provide FHE capabilities to smart contracts.
28+
29+
It includes the relevant FHE function calls (precompiles), as well as the Solidity functions & ciphertext management that is required to interact with the FHE layer.
30+
31+
### Warp-Drive
32+
33+
Warp-Drive is responsible for managing the FHE keys and the FHE operations. It includes multiple components - key management, FHE operation interfaces, encryption/decryption functions, and more.
34+
35+
The integration of Warp Drive as a separate component creates a separation of responsibilities, where the chain itself does not need to be aware of the FHE operations, nor depend on specific functionality.
36+
This allows us to support multiple variants of FHE schemes, which can be used by developers according to their specific needs.
37+
38+
Warp Drive includes multiple components, which work together using shared interfaces to be easy to use and extend.
39+
40+
![](/img/warp-drive-schema.webp)
41+

0 commit comments

Comments
 (0)