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
Your project is structured as a monorepo with the main application in the frontend directory. The root directory contains configuration files for the entire project, while the frontend directory has its own configuration and source files.
4
+
Frontend Application:
5
+
Built with React and TypeScript
6
+
Uses Vite as the build tool
7
+
Implements a basic wallet functionality for the Aztec Protocol
8
+
Main Components:
9
+
Home (frontend/src/pages/Home.tsx): The landing page with options to create an account or sign in
10
+
CreateAccount (frontend/src/pages/CreateAccount.tsx): Handles the account creation process
11
+
Wallet (frontend/src/pages/Wallet.tsx): Displays wallet information and balance
12
+
State Management:
13
+
Uses React Context (WalletContext) for managing wallet state across the application
14
+
Routing:
15
+
Utilizes React Router for navigation between different pages
16
+
6. Styling:
17
+
Uses CSS modules (styles/Common.module.css) for component-specific styles
18
+
Has a global App.css file for general styling
19
+
Testing:
20
+
Jest is set up for unit testing
21
+
SimpleTest.test.tsx contains tests for various components and functionalities
22
+
Build and Configuration:
23
+
Vite is used as the build tool (vite.config.ts)
24
+
TypeScript configurations for both the app (tsconfig.json) and Node environment (tsconfig.node.json)
25
+
ESLint for code linting (eslint.config.js)
26
+
Dependencies:
27
+
React and React DOM
28
+
@aztec/aztec.js for Aztec Protocol integration
29
+
Various development tools (TypeScript, Jest, ESLint, etc.)
Your project is a React-based frontend for an Aztec Protocol wallet. It's set up with modern tooling and practices, including TypeScript for type safety, Jest for testing, and Vite for fast builds. The application currently provides basic wallet functionality with plans for more advanced features in the future.
40
+
The codebase is well-structured and follows React best practices, using functional components and hooks. It's set up to be easily expandable as you add more features to your wallet application.
41
+
42
+
43
+
44
+
Frontend Code Structure and Explanation:
45
+
An overview of my frontend code structure and explain the main components:
46
+
Entry Point (frontend/src/main.tsx):
47
+
This file is the entry point of your React application. It renders the main App component into the DOM.
48
+
App Component (frontend/src/App.tsx):
49
+
This is your main application component. It sets up the routing using React Router and wraps the entire application with the WalletProvider for state management.
50
+
Home Page (frontend/src/pages/Home.tsx):
51
+
This is the landing page of your application. It provides options to create an account or sign in.
This file sets up the React Context for managing wallet state across your application.
58
+
Key Features:
59
+
The application uses React Router for navigation between different pages.
60
+
State management is handled through React Context (WalletContext).
61
+
The app simulates wallet creation and management without actual blockchain integration yet.
62
+
There's a basic UI with buttons for creating an account and signing in.
63
+
The wallet view shows sensitive information (private key, transaction signing key) with a warning.
64
+
Styling:
65
+
The app uses CSS modules for styling (styles/Common.module.css).
66
+
There's also a global App.css file for some general styling.
67
+
Testing:
68
+
There's a test file (SimpleTest.test.tsx) that includes tests for various components and functionalities.
69
+
Build and Configuration:
70
+
The project uses Vite as the build tool, configured in vite.config.ts.
71
+
There are separate TypeScript configurations for the app (tsconfig.json) and Node environment (tsconfig.node.json).
72
+
Dependencies:
73
+
The project uses React, React Router, and various development tools like TypeScript, Jest for testing, and ESLint for linting.
74
+
Overall, this frontend provides a basic structure for a wallet application, with placeholders for future functionality like actual account creation and transaction management. The code is organized in a typical React application structure, with separate files for components, context, and pages.
75
+
76
+
Logical flow for create account to put new account details display from wallet component to create-account component
77
+
The main wallet functionality (display of address, private key, transaction signing key followed by the done button) that is now part of Wallet component,is logically a part of the create-account component. The user goes through this stage (if they dont yet have an account only. if they do then from the Home screen they click on 'Already have an account? Sign in' and go into a different flow which we dont need to consider here) when they click on 'Create Account' from the Home screen. The create-account component simulates this action and then displays the address, private key, and transaction signing key in the Wallet component. so can we just add the functionality of displaying the address, private key, and transaction signing key in the create-account component and then redirect to the wallet component? If yes, tell me how you will do it. If not, tell me what other changes need to be made. dont make any changes to the code yet till i ask you to.
78
+
79
+
80
+
'Sign in if you have an account' story:
81
+
on the home screen, on clicking 'Already have an account? Sign in', the user is redirected to the 'enter private key' screen. this screen has a form with 1 field 'Enter your private key'. once the user enters their private key which is essentially the encryptionSecretKey and another key, transaction signing key and clicks on 'Sign in', we fetch the account and wallet, when successfully done, user are redirected to the wallet component. if the credentials are not correct, show error and redirect to landing page/ component. salt=0
82
+
83
+
84
+
implement createschnorr account functionality in the frontend. for real:
85
+
As shown in @aztec.tsx there is a way to use @getSchnorrAccount.
86
+
@createSchnorrAccount has the details. we start in the create-account component. we want to create the schnorr account. first create the pxe client and return it as an object. once @pxe object is available in the function to create schnorr account, then generate at random an @encryptionSecretKey and @signingSecretKey .
87
+
now create new account by calling @getSchnorrAccount with the parameters we already have. get @Wallet object for the account. return an object with 3 properties: the wallet @address (User Address) , @encryptionSecretKey (Private Key) and @signingSecretKey (Transaction Signing Key) . use salt=0
88
+
89
+
separate creating pxe client and creating schnorr account in aztec.tsx. because pxe is used much more widely in in the lifetime of a user. user will use it to hold their private data including tokens, transactions, etc. the create schnorr account once at the beginning of their use.
90
+
91
+
changes to make in getting real schnorr account:
92
+
1. currently address, encryptionSecretKey, signingSecretKey are returned as strings, Fr, Fq to create-account component. we need to change this to the actual object for address. account object?
93
+
2. we need to make changes in create-account component to handle the new objects.
94
+
3. we need to make changes in the aztec.tsx file to handle the new objects.
95
+
4. we need to make changes in the wallet component to handle the new objects.
96
+
what is stored in context, where walletinfo is defined. walletinfo has address as string, encryptionSecretKey as string, signingSecretKey as string, balance, transactions as its properties. does this make sense. is it what we want? why dont we retain it as the wallet object as defined by aztec.
97
+
Wallet component does not need to show EncryptionSecretKey and SigningSecretKey. it only needs to show the address and balance. the transaction signing key is only needed for signing transactions, which we currently do not support. the private key is only needed for creating public key and we do not need to show that. so we can remove all these from context. we are only left with address and balance.
98
+
99
+
add initialization or waiting logic for pxe client in aztec.tsx.
100
+
101
+
deploy a token contract name, symbol, total supply. transfer some tokens to address from terminal.
102
+
103
+
add token feature to frontend. show token balance for hardcoded token contract. show token amount. put dummy value as 0 always for now. first log the balance quantity of tokens for token address for signed in user address.
104
+
105
+
email id as input in ui. hash it and use it as input in getSchnorrAccount method
106
+
107
+
this error - fs/promises related in github codespaces. how to fix.
108
+
109
+
if an account with an email is already registered, then if user uses different signing key next time, it should not create a totally new and different account. it should throw up error saying wrong signing key! else if a new account for created everytime a different signing key is used for same email, that results in terrible user experience.
110
+
111
+
version update of aztec to 0.57.0 is breaking smart contract tests. compiles well. but tests break. reference repo, aztec-starter on github works.
Create an email based aztec account. That one can sign into using an email address (gmail) and a password. The user can sign transactions using the password.
4
+
5
+
This project uses zkemail.nr library for email verification on the user's device. The email ID and the password are kept private and do not leave the user's browser.
6
+
7
+
[watch the demo here](https://youtu.be/V_2vtAR1lzo)
8
+
9
+
How to run the project locally:
10
+
1. Clone the repo (either this or the parent repo: https://github.com/rajeshb62/ab2)
11
+
2. From project root (email_based_account), run:
12
+
```
13
+
nargo compile
14
+
```
15
+
3. From project root, run:
16
+
```
17
+
yarn install
18
+
cd frontend
19
+
yarn install
20
+
cd ..
21
+
```
22
+
4. From project root (email_based_account folder), run:
23
+
```
24
+
yarn workspace frontend dev
25
+
```
26
+
5. Run tests:
27
+
```
28
+
# to run both noir and frontend tests
29
+
yarn test
30
+
# to run only frontend tests
31
+
yarn test:frontend
32
+
```
33
+
34
+
35
+
## Challenge Selection
36
+
Read [this article](https://aztec.network/blog/unlocking-the-future-of-privacy-exploring-identity-and-social-use-cases-in-alpha-build-2-with-100k-in-prizes) that announces Alpha Build 2 to learn more about the challenges and get ideas on what to build!
37
+
38
+
-[x] ZKEmail Guardian
39
+
-[ ] Social Cipher
40
+
41
+
**Note**: You can change which challenges you've selected during the competition if you'd like. You are not bound by your choices or descriptions entered during the one week check-in.
42
+
43
+
## Team information
44
+
45
+
[Rajesh ](https://github.com/rajeshb62)
46
+
47
+
## Technical Approach
48
+
### Questions/ approach
49
+
- create an account for an email address abc@xyz.com based on .eml file:
50
+
- verify header is valid using dkim signature verification
51
+
- check sender is 'abc@xyz.com'
52
+
- (additional check) check if subject contains a specific random string shown in UI
53
+
- hash email+password into sha256 hash, and use it as encryption key in getSchnorrAccount(..) function, hash the password and use it as signing key. Show the account wallet in UI (user can sign tx from this wallet using their password)
Inspiration codebases: Loads account based on Face ID of user: loads account based on password: https://github.com/skaunov/aabch1_23
58
+
59
+
## Expected Outcomes
60
+
A wallet app (previously created in alpha build 1 https://github.com/rajeshb62/aztec-wallet) that now is modified to use email ownership proof to create aztec account
61
+
62
+
## Lessons Learned (For Submission)
63
+
64
+
- What are the most important takeaways from your project?
65
+
Creation of email based private blockchain accounts are a reality.
66
+
- Are there any patterns or best practices that you've learned that would be useful for other projects?Learning about zkemail.nr library will help improve readme/ other documentation for this library.
67
+
- Highlight reusable code patterns, key code snippets, and best practices - what are some of the ‘lego bricks’ you’ve built, and how could someone else best use them?
68
+
69
+
## Project Links (For Submission)
70
+
71
+
Please provide links to any relevant documentation, code, or other resources that you've used in your project.
72
+
73
+
## Video Demo (For Submission)
74
+
75
+
[![Email Based Account Demo]](https://www.youtube.com/watch?v=V_2vtAR1lzo)
76
+
77
+
A brief demo showing:
78
+
- Email verification process
79
+
- Account creation
80
+
81
+
- How does your project leverage Aztec's unique features? (programmable cryptography, private/public state, etc.)
82
+
While not directly within scope of AB2, the wallet is being built only because
83
+
1. it allows fully private state and activities, most importantly:
84
+
- private transfers of stablecoins and eth
85
+
- assets can stay fully private for user, as absolutely esstial for card games
86
+
2. account abstraction features that make possible
87
+
- user friendly encryption and signing key namely, email based hash for private key and Face ID for signing key
88
+
- email ID based token transfer (???)
89
+
- transaction rules like 'allow only transactions below $100 / day by email(???)'
90
+
- allow session ID based transaction approval
91
+
3. fee abstraction features:
92
+
-allow for wallet provider to pay gas (needed for activities like card games)
93
+
94
+
- What is the potential real-world impact of your project?
95
+
- onboard web2 users using familiar account creation and signing methods like email ID and password
96
+
- ( there are other features relevant for web2 users in wallet but that are not directly within scope of AB2)
97
+
98
+
## Scope for future research, improvements and problems to solve
99
+
- emails and aliases need to be studied. The goal is one email ID one aztec account (users have multiple aliases for one email ID, how does that work and how to handle that? Users can own domain name and have emails sent from and to all email ids using that domain name (a@joshcrites.com, b@joshcrites.com) be operated from the same inbox (??). there is lot of scope to better understand the email protocol)
100
+
- current implementation has users sending emails to an inbox controlled by the developer. It defeats the purpose of user privacy. It needs a better solution (user sending verification email to themselves for the verification step???)
101
+
- zkemail seems to support a limited number of domains currently. The app itself only supports emails sent from icloud.com and that too emails of a small size.
102
+
- Replace password with touch/face ID for better UX and security
0 commit comments