Skip to content

Commit 8cef799

Browse files
authored
feat: improves docs and removes not complete frontend examples (#24)
* bug: remove frontend that doesnt work atm * docs: adds README * feat: fix tests
1 parent bea3bd8 commit 8cef799

File tree

86 files changed

+8777
-49997
lines changed

Some content is hidden

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

86 files changed

+8777
-49997
lines changed

README.md

Lines changed: 11 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,108 +4,21 @@ This repository contains example dApps built using fhEVM (Fully Homomorphic EVM)
44

55
## Examples featured
66

7-
### Confidential Counter
8-
The Confidential Counter examples demonstrate progressively more complex uses of FHE operations through four samples:
7+
The `/hardhat` folder contains several privacy-preserving smart contract examples:
98

10-
1. **Basic Counter**: Simple encrypted counter with basic increment operations.
11-
2. **Input Counter**: Handles encrypted inputs with proofs and type conversions.
12-
3. **Decryptable Counter**: Adds decryption capabilities and state management.
13-
4. **Multi-User Counter**: Supports per-user encrypted counters with access control.
9+
1. **Confidential Counter** - Progressive examples demonstrating FHE operations from basic to multi-user counters
1410

15-
Each sample builds on the previous one to showcase different FHE capabilities.
11+
2. **Confidential ERC20** - Privacy-preserving token implementation with encrypted balances and transfers
1612

17-
### GuessRandomNumberGame
13+
3. **Decentralized Identity** - System for encrypted identity management and credential verification
1814

19-
**How the Game Works**
15+
4. **FHE Wordle** - Privacy-preserving word guessing game using encrypted letter comparisons
2016

21-
1. **Random Target Generation**: Contract generates an encrypted random number within `MAX_VALUE` range using TFHE.
17+
5. **Confidential Auctions** - Multiple auction implementations with encrypted bids:
18+
- Blind auctions with sealed bids
19+
- Dutch auctions with descending prices
2220

23-
2. **Player Participation**: Players submit encrypted guesses with ZK proofs. One guess per address per round.
24-
25-
3. **Minimum Players**: Game requires `MIN_PLAYERS` submissions before proceeding.
26-
27-
4. **Winner Determination**: Uses FHE operations to privately find the closest guess to target while maintaining confidentiality.
28-
29-
5. **Decryption & Results**: Target, winning guess, and winner's address are securely decrypted via Zama Gateway. Results announced through `WinnerDeclared` event.
30-
31-
6. **Game Reset**: Automatically clears state, generates new target, and prepares for next round.
32-
33-
The game showcases FHE capabilities for secure random number generation, private comparisons, and controlled decryption while maintaining player privacy throughout.
34-
35-
### FHEWordle
36-
37-
**How the Game Works**
38-
39-
1. **Game Setup**: A factory contract deploys unique game instances for each player using minimal proxies. Each game has:
40-
- An encrypted target word (represented as encrypted letter indices 0-25)
41-
- A player address who can submit guesses
42-
- A relayer address who helps with FHE operations
43-
44-
2. **Word Submission**: The relayer submits the encrypted target word letters using `submitWord1`. The letters are stored as encrypted uint8 values.
45-
46-
3. **Player Guessing**: Players submit guesses by calling `guessWord1` with:
47-
- A word encoded as a uint32 (each letter as index 0-25).
48-
- A Merkle proof verifying the word is valid.
49-
- Limited to 5 guesses total.
50-
51-
4. **Guess Feedback**: After each guess, players can request feedback via `getGuess` which returns:
52-
- An encrypted equality mask showing exact letter matches (green).
53-
- An encrypted letter presence mask showing letters in wrong positions (yellow).
54-
55-
5. **Winning**: Players can claim victory using `claimWin` if they get all letters correct. The contract verifies this using FHE operations.
56-
57-
6. **Word Revelation**: After game completion, the target word can be revealed using `revealWordAndStore`.
58-
59-
7. **Proof Verification**: The relayer can verify game outcomes using Merkle proofs via `checkProof`.
60-
61-
The game leverages FHE operations to keep the target word encrypted while still allowing comparison with guesses. This prevents players from seeing the word until the game is complete.
62-
63-
64-
### Decentralized Identity
65-
66-
**How it works**
67-
68-
1. **Identity Management**: The system consists of four main contracts:
69-
- `IdMapping`: Maps user addresses to unique IDs for identity tracking.
70-
- `PassportID`: Stores encrypted passport/identity data like name, birthdate.
71-
- `Diploma`: Manages encrypted educational credentials and degrees.
72-
- `EmployerClaim`: Generates verifiable claims about age and education.
73-
74-
2. **Identity Registration**:
75-
- Users first get a unique ID from `IdMapping` via `generateId()`.
76-
- Authorized registrars can register encrypted passport data using `PassportID.registerIdentity()`.
77-
- Educational institutions can register encrypted diploma data via `Diploma.registerDiploma()`.
78-
79-
3. **Encrypted Data Storage**: All sensitive data is stored encrypted using FHE:
80-
- Names, birthdates, and biometric data in `PassportID`.
81-
- University, degree type, and grades in `Diploma`.
82-
- Access controlled through TFHE permissions.
83-
84-
4. **Claim Generation**:
85-
- Users can generate verifiable claims about their identity/credentials.
86-
- `EmployerClaim` supports two types of claims:
87-
- Adult verification (18+ age check).
88-
- Degree verification (specific degree requirements).
89-
- Claims preserve privacy by using encrypted comparisons.
90-
91-
5. **Verification Process**:
92-
- Claims are generated as encrypted boolean results.
93-
- Employers can verify claims without seeing actual data.
94-
- Combined verification checks both age and education requirements.
95-
- Results stored as encrypted verification status.
96-
97-
The system leverages FHE operations to enable privacy-preserving identity and credential verification without exposing sensitive personal data.
98-
99-
### MyConfidentialERC20.sol
100-
101-
**How it works**
102-
1. **Confidential Token**: A privacy-preserving ERC20 token using FHE with encrypted balances, transfers and approvals.
103-
104-
2. **Key Features**: Encrypted balances (euint64), standard ERC20 functions with FHE, and owner-restricted minting.
105-
106-
3. **Privacy Protection**: All operations are encrypted using TFHE, with balances visible only to transaction participants.
107-
108-
The contract implements confidential tokens with ERC20 compatibility using FHE for privacy.
21+
Each example includes detailed documentation in its README explaining the implementation and FHE usage.
10922

11023
## How to use this repo
11124

@@ -122,6 +35,8 @@ npm run deploy-sepolia
12235
```
12336
> **Note:** Use your own private mnemonic in `.env`
12437
38+
> **WARNING:** The Frontend is not currently implemented
39+
12540
2. Launch frontend:
12641
```bash
12742
cd frontend/

frontend-visual/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

frontend-visual/.gitignore

Lines changed: 0 additions & 36 deletions
This file was deleted.

frontend-visual/README.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

frontend-visual/app/dapps/[slug]/page.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

frontend-visual/app/dapps/wordle/page.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

frontend-visual/app/favicon.ico

-25.3 KB
Binary file not shown.
-29.4 KB
Binary file not shown.
-25.6 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)