Skip to content

dobbobalina2/Google_OAuth_Zk_AA_Demo

Repository files navigation

Google Oauth Aztec Zk Demo

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.

Prerequisites

Before you begin, ensure you have the following installed:

Google OAuth Setup

  1. Go to the Google Cloud Console

  2. Create a new project or select an existing one

  3. Enable the Google OAuth2 API:

    • Go to "APIs & Services" > "Library"
    • Search for "Google OAuth2 API"
    • Click "Enable"
  4. 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
  5. 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"
  6. Copy the generated Client ID and add it to your .env file:

Installation

  1. Clone the repository:
git clone https://github.com/<YourUsername>/Google_OAuth_Zk_Demo.git
cd noir-web-starter
  1. Install dependencies:
# Install root dependencies
npm install

# Install web dependencies
cd web && npm install
  1. Build the Noir circuits:
cd circuits
nargo compile
./build.sh

Project Structure

noir-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

Development

  1. Start the development server:
cd web
npm run vite:dev
  1. 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-report

Deployment

Export 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> \
  --verify

Testing

Contract Tests

To 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-report

Verifier Tests

forge test --match-test testVerify --gas-report -vvv

Features

  • 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

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Noir - Zero-knowledge programming language
  • Barretenberg - Zero-knowledge proof system
  • Foundry - Smart contract development toolchain

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published