A full-stack web application demonstrating zero-knowledge proof generation using Noir circuits with browser-based proving using bb.js. This project implements JWT verification using zero-knowledge proofs and includes both webpack and vite bundling options.
⚠️ Security Disclaimer: This is a demonstration project and does not implement full security measures. We do not recommend using this code in production without thorough security audits and additional security implementations.
Before you begin, ensure you have the following installed:
- Node.js (v16 or higher)
- Foundry (v1.0.0 or higher)
- Nargo (v1.0.0-beta.2)
- Barretenberg (v0.72.0)
- Yarn or npm
-
Go to the Google Cloud Console
-
Create a new project or select an existing one
-
Enable the Google OAuth2 API:
- Go to "APIs & Services" > "Library"
- Search for "Google OAuth2 API"
- Click "Enable"
-
Configure OAuth consent screen:
- Go to "APIs & Services" > "OAuth consent screen"
- Choose "External" user type
- Fill in required app information
- Add necessary scopes (email, profile)
- Add test users if in testing mode
-
Create OAuth 2.0 Client ID:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web application"
- Add authorized JavaScript origins (e.g., http://localhost:5173 for development)
- Add authorized redirect URIs (e.g., http://localhost:5173)
- Click "Create"
-
Copy the generated Client ID and add it to your
.envfile:
- Clone the repository:
git clone https://github.com/<YourUsername>/Google_OAuth_Zk_Demo.git
cd noir-web-starter- Install dependencies:
# Install root dependencies
npm install
# Install web dependencies
cd web && npm install- Build the Noir circuits:
cd circuits
nargo compile
./build.shnoir-web-starter/
├── circuits/ # Noir circuit definitions
├── contracts/ # Solidity smart contracts
├── web/ # Frontend application
│ ├── src/ # Source code
│ └── public/ # Static assets
├── test/ # Test files
└── script/ # Deployment scripts
- Start the development server:
cd web
npm run vite:dev- Run tests:
# Run contract tests
forge test --match-test testHandleOps --fork-url <rpc-url> -vv --gas-report
forge test NoirAccount.t.sol -vv --disable-block-gas-limit --gas-reportExport ETH private key to ENV
export ETH_WALLET_PRIVATE_KEY=<YOUR_PRIVATE_KEY>Deploy the contracts to your chosen network:
forge script script/Deploy.s.sol \
--rpc-url <rpc-url> \
--broadcast \
--etherscan-api-key <etherscan-api-key> \
--verifyTo run these tests on your specfic transaction generally speaking you need to replace the userop information with the one in the console logs in JS. You'll also need to be sure to change the sender, userophash (for NoirAccount.t.sol) and the entrypoint,verifer and factory contract if you wish to test entrypoint with your deployed contracts.
# Run specific test with gas reporting
forge test NoirAccount.t.sol -vv --disable-block-gas-limit --gas-report
# Run handleOps test with forking
forge test --match-test testHandleOps \
--fork-url <rpc-url> \
-vv \
--gas-reportforge test --match-test testVerify --gas-report -vvv- JWT verification using zero-knowledge proofs
- Browser-based proof generation using bb.js
- Account abstraction (EIP-4337) implementation
- Google OAuth integration
- Gas optimization reporting
- Comprehensive test suite
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Noir - Zero-knowledge programming language
- Barretenberg - Zero-knowledge proof system
- Foundry - Smart contract development toolchain