You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-96Lines changed: 11 additions & 96 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,108 +4,21 @@ This repository contains example dApps built using fhEVM (Fully Homomorphic EVM)
4
4
5
5
## Examples featured
6
6
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:
9
8
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
14
10
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
16
12
17
-
### GuessRandomNumberGame
13
+
3.**Decentralized Identity** - System for encrypted identity management and credential verification
18
14
19
-
**How the Game Works**
15
+
4.**FHE Wordle** - Privacy-preserving word guessing game using encrypted letter comparisons
20
16
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
22
20
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.
0 commit comments