-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 113b0ad
Showing
86 changed files
with
18,154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
# Review gh actions docs if you want to further define triggers, paths, etc | ||
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy to GitHub Pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Build website | ||
run: yarn build | ||
|
||
# Popular action to deploy to GitHub Pages: | ||
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Build output to publish to the `gh-pages` branch: | ||
publish_dir: ./build | ||
# The following lines assign commit authorship to the official | ||
# GH-Actions bot for deploys to `gh-pages` branch: | ||
# https://github.com/actions/checkout/issues/13#issuecomment-724415212 | ||
# The GH actions bot is used by default if you didn't specify the two fields. | ||
# You can swap them out with your own user credentials. | ||
user_name: github-actions[bot] | ||
user_email: 41898282+github-actions[bot]@users.noreply.github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test deployment | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
# Review gh actions docs if you want to further define triggers, paths, etc | ||
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on | ||
|
||
jobs: | ||
test-deploy: | ||
name: Test deployment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Test build website | ||
run: yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Website | ||
|
||
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true yarn deploy | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> yarn deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
slug: first-blog-post | ||
title: First Blog Post | ||
authors: | ||
name: Gao Wei | ||
title: Docusaurus Core Team | ||
url: https://github.com/wgao19 | ||
image_url: https://github.com/wgao19.png | ||
tags: [hola, docusaurus] | ||
--- | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
slug: long-blog-post | ||
title: Long Blog Post | ||
authors: endi | ||
tags: [hello, docusaurus] | ||
--- | ||
|
||
This is the summary of a very long blog post, | ||
|
||
Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view. | ||
|
||
<!--truncate--> | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
slug: mdx-blog-post | ||
title: MDX Blog Post | ||
authors: [slorber] | ||
tags: [docusaurus] | ||
--- | ||
|
||
Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/). | ||
|
||
:::tip | ||
|
||
Use the power of React to create interactive blog posts. | ||
|
||
```js | ||
<button onClick={() => alert('button clicked!')}>Click me!</button> | ||
``` | ||
|
||
<button onClick={() => alert('button clicked!')}>Click me!</button> | ||
|
||
::: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
slug: welcome | ||
title: Welcome | ||
authors: [slorber, yangshun] | ||
tags: [facebook, hello, docusaurus] | ||
--- | ||
|
||
[Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog). | ||
|
||
Simply add Markdown files (or folders) to the `blog` directory. | ||
|
||
Regular blog authors can be added to `authors.yml`. | ||
|
||
The blog post date can be extracted from filenames, such as: | ||
|
||
- `2019-05-30-welcome.md` | ||
- `2019-05-30-welcome/index.md` | ||
|
||
A blog post folder can be convenient to co-locate blog post images: | ||
|
||
![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg) | ||
|
||
The blog supports tags as well! | ||
|
||
**And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
endi: | ||
name: Endilie Yacop Sucipto | ||
title: Maintainer of Docusaurus | ||
url: https://github.com/endiliey | ||
image_url: https://github.com/endiliey.png | ||
|
||
yangshun: | ||
name: Yangshun Tay | ||
title: Front End Engineer @ Facebook | ||
url: https://github.com/yangshun | ||
image_url: https://github.com/yangshun.png | ||
|
||
slorber: | ||
name: Sébastien Lorber | ||
title: Docusaurus maintainer | ||
url: https://sebastienlorber.com | ||
image_url: https://github.com/slorber.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Concepts | ||
|
||
Start typing here... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Developer Guides | ||
|
||
Here we'll explain everything about how to use Fhenix and how to use FHE to create privacy-preserving Web3 applications. We include an extension to the Ethereum Virtual Machine (EVM) that introduces operations on encrypted data using Fully Homomorphic Encryption (FHE). We've added special precompiles to the EVM that allow computations on encrypted data without the need for decryption. | ||
|
||
> Did You Know? Fhenix uses a special type of FHE called TFHE (FHE over the Torus) that is especially suited for Blockchain. We may use TFHE and FHE interchangeably | ||
> | ||
|
||
The integration of the FHE with Solidity means you can continue to write your smart contracts with familiar syntax while leveraging the capabilities of FHE. | ||
|
||
In this documentation, you'll find guidance on operating on encrypted data, understanding patterns in FHE-friendly code writing, and access control in FHE-based smart contracts. Let's get started. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Differences From Fhevm | ||
|
||
You might be familiar with fhevm, which is a fork of the Ethereum Virtual Machine that supports homomorphic encryption by Zama. | ||
|
||
As the FHE blockchain ecosystem evolves, so will the number of ways that similar actions can be achieved. In this page, we try and document the differences users that are familiar with fhevm should be aware of. | ||
|
||
## Differences | ||
|
||
* fhenix.js is the recommended Javascript library for interacting with Fhenix smart contracts. | ||
* FHE library is available at the npm repository [@fhenixprotocol/contracts](https://www.npmjs.com/package/@fhenixprotocol/contracts). | ||
* `cmux` is named `select`. | ||
* `reencrypt` is named `sealoutput`. | ||
* Operations can be called directly as properties of encrypted types (e.g. `euint32.add(euint32)` instead of `FHE.add(euint32, euint32)`). | ||
* Operations between encrypted types expect the types to match (e.g. `euint32 + euint32` instead of `euint32 + euint64)`). | ||
* In Fhenix, we recommend using the `inEuintXX` input types instead of raw bytes when receiving encrypted data. | ||
* Conversion to other encrypted types can be done using the `.toUxx` functions. E.g. `euint32 b = a.toU32();` | ||
* Division by zero will return a MAX_UINT value instead of throwing an error (e.g. `euint8(1) / euint8(0)` will return `euint8(255)` instead of throwing an error). | ||
* `Permits` are the recommended way to handle permissioned requests in Fhenix. To read more about permits and access control, see [Access Control](/topics/Access-Control.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Permits & Access Control (EIP-712) | ||
|
||
Out-of-the-box, Fhenix Solidity libraries come with a basic access control scheme. This helps contracts perform a basic check for ownership of an account. | ||
|
||
This makes it easy for contracts to add authentication & authorization to specific view functions, without having to reinvent the wheel every time. To learn more about why this can be important, and what EIP712 is, refer to our [fundamentals section on Access Control](../fhevm-solidity/access-control.md). | ||
|
||
This page will cover how access tokens are created and used in FhenixJS. | ||
|
||
#### What is a Permit? | ||
|
||
In the context of Fhenix and blockchain, an access token refers to a signed JSON object that follows the EIP-712 standard. This token contains the necessary information, including a public key, that allows data reencryption in a smart contract environment. The inclusion of this public key into the access token enables a secure process of data re-encryption within a smart contract once the JSON object is signed by the user. | ||
|
||
#### How to Generate a Permit | ||
|
||
Access tokens are generated using the `FhevmInstance.generateToken` method. This method requires a few parameters: | ||
|
||
* `options` (required): An object containing the following properties: | ||
* `verifyingContract` (required, string): The address of the contract. | ||
* `name` (optional, string): The name used in the EIP712 token. | ||
* `version` (optional, string): The version used in the EIP712 token. | ||
|
||
The `generateToken` method returns an object containing a keypair (publicKey and privateKey) and a token (EIP712 formatted). | ||
|
||
```javascript | ||
const instance = await createInstance({ chainId, publicKey }); | ||
const encryptedParam = instance.generateToken({ | ||
name: 'Authentication', | ||
verifyingContract: '0x1c786b8ca49D932AFaDCEc00827352B503edf16c', | ||
}); | ||
``` | ||
|
||
Behind the scenes, this function not only creates an access token, but also generates an ephemeral key that is used for decryption of the responses.  | ||
|
||
#### Using an Access Token | ||
|
||
Once generated, the access token can be used in a variety of ways, such as being signed for data re-encryption in a smart contract or to retrieve balance information of a contract. Here's an example of using an access token for getting balance: | ||
|
||
```javascript | ||
const instance = await createInstance({ chainId, publicKey }); | ||
const token = instance.generateToken({ | ||
name: 'Authentication', | ||
verifyingContract: '0x1c786b8ca49D932AFaDCEc00827352B503edf16c', | ||
}); | ||
const params = [userAddress, JSON.stringify(generatedToken.token)]; | ||
const sign = await window.ethereum.request({ method: 'eth_signTypedData_v4', params }); | ||
const response = await contract.balanceOf(token.publicKey, sign); | ||
``` | ||
|
||
#### Storing and Loading Access Tokens | ||
|
||
Tokens can be stored for later use by using the `FhevmInstance.setTokenSignature` method. This method allows you to store the signature of a public key for a specific contract. The `FhevmInstance.getTokenSignature` method can then be used to fetch the stored public key and signature later. | ||
|
||
```javascript | ||
// Store signature | ||
instance.setTokenSignature(contractAddress, sign); | ||
|
||
// Fetch public key and signature | ||
const { publicKey, signature } = instance.getTokenSignature(); | ||
``` | ||
|
||
For batch operations or caching purposes, the `FhevmInstance.serializeKeypairs` method is useful as it allows you to store contract keypairs in the user's LocalStorage. The method returns a mapping of contract addresses to their associated keypairs and signatures. | ||
|
||
```javascript | ||
const keypairs = instance.serializeKeypairs(); | ||
console.log(keypairs); | ||
``` | ||
|
||
This structure can then be used when reloading the instance | ||
|
||
```javascript | ||
const instance = await createInstance({ chainId, publicKey, keypairs }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 🤫 Privacy Pitfalls | ||
|
||
Similar to any blockchain-based implementation, while smart contracts on Fhenix provide a secure and decentralized way of executing transactions on encrypted data, there exist potential security risks that developers should be mindful of. Although the computations themselves are encrypted, offering privacy, metadata can still inadvertently disclose confidential information. | ||
|
||
For all blockchain privacy platforms, there exist a different set of potential issues that developers need to be mindful of. The specific scenarios depend on the implementation details of the chain, and the tools that the infrastructure provides to mitigate such issues. Fhenix is at a very early stage and constantly changing, so instead we'll keep this section light and give a simple example of metadata leakage - gas usage. | ||
|
||
For example, suppose a smart contract written in Solidity contains a conditional statement. In such cases, the path taken by the conditional, though encrypted, can leak 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. | ||
|
||
```Javascript | ||
function performActionBasedOnBalance(uint256 amount) public { | ||
if (balance[msg.sender] >= amount) { | ||
// perform some operation | ||
} else { | ||
// perform another operation | ||
} | ||
} | ||
``` | ||
|
||
In the above Solidity example, an observer could infer from the gas usage, emitted events, or other metadata, the branch that was executed, indirectly revealing whether the sender's balance was greater than or equal to the specified amount. | ||
|
||
While this example seems simple, it is important to remember that often transactions can be cheaply simulated with different input parameters. In the above example, performing logarithmic search would reveal the exact balance fairly quickly.   | ||
|
||
Also, it's essential to mention the importance of adding access control to functions that handle sensitive data. For instance, a function that displays the balance of a user should only be accessible by the specific user. We expand on this in our sections about access control. | ||
|
||
Developers on Fhenix (and any chain that provides privacy or encryption) should analyse their contract's privacy model. Recognizing the type of information that should remain confidential and understanding what information, if leaked, won't affect the operation of the contract and its users, is critical. This helps in structuring your smart contracts in a way that safeguards the private aspects, while still operating efficiently. Despite the encryption provided by FHE, it is essential to understand and address these potential issues. |
Oops, something went wrong.