https://github.com/thecoderadi/zk-online-hackathon
https://github.com/thecoderadi/zk-online-hackathon
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thecoderadi/zk-online-hackathon
- Owner: TheCoderAdi
- Created: 2025-02-13T14:15:58.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-14T04:49:56.000Z (about 1 year ago)
- Last Synced: 2025-05-16T05:09:15.323Z (12 months ago)
- Language: JavaScript
- Size: 132 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## **(Full Setup Guide)**
# **ZK-Powered DeFi Credit Score System**
_A decentralized, privacy-preserving credit scoring system using zk-SNARKs, Arbitrum, and zkVerify._
---
## **π Project Structure**
```
π ZK-Online-Hackathon
βββ π circuits # zk-SNARK Circuits (Groth16)
βββ π backend # Express.js API with zkVerify integration
βββ π frontend # Next.js UI with Tailwind + Framer Motion
βββ π contracts # Solidity contract for on-chain credit score storage
βββ README.md # Setup & instructions
```
---
## **β
Prerequisites**
Before starting, ensure you have:
- **Node.js** (v18+)
- **Yarn** or **npm**
- **Circom** (for compiling circuits)
- **SnarkJS** (for proof generation)
- **Hardhat** (for smart contract deployment)
- **Metamask** (for wallet connection)
---
## **π Quick Setup**
### **1οΈβ£ Clone the Repository**
```sh
git clone https://github.com/TheCoderAdi/ZK-Online-Hackathon.git
cd ZK-Online-Hackathon
```
---
## **2οΈβ£ Generating Circuits (zk-SNARK Setup)**
_Navigate to the **circuits/** directory:_
```sh
cd circuits
```
### **πΉCommands for Circuit Generation**
```sh
# 1. Compile the circuit
circom creditScore.circom --r1cs --wasm --sym --c
# 2. Download or generate Powers of Tau file
snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
# 3. Contribute to phase 1 of trusted setup
snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="First contribution" -v
# 4. Prepare for phase 2 of trusted setup
snarkjs powersoftau prepare phase2 pot14_0001.ptau pot14_final.ptau -v
# 5. Generate proving and verification keys
snarkjs groth16 setup credit_score.r1cs pot14_final.ptau circuit_final.zkey
# 6. Contribute to the zkey (phase 2 of trusted setup)
snarkjs zkey contribute circuit_final.zkey circuit_final2.zkey --name="Second contribution" -v
# 7. Export verification key
snarkjs zkey export verificationkey circuit_final2.zkey verification_key.json
# 8. Generate proof (Example input)
snarkjs groth16 prove circuit_final2.zkey witness.wtns proof.json public.json
# 9. Verify proof
snarkjs groth16 verify verification_key.json public.json proof.json
# 10. Generate Solidity Verifier contract
snarkjs zkey export solidityverifier circuit_final2.zkey verifier.sol
```
---
## **3οΈβ£ Smart Contract Deployment (Hardhat)**
_Navigate to the **smart-contract/** directory:_
```sh
cd smart-contract
npm install
```
### **Compile & Deploy on Local Hardhat**
```sh
npx hardhat compile
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost
```
_For Arbitrum Testnet (Sepolia), replace `localhost` with `arbitrumSepolia`._
---
## **4οΈβ£ Backend Setup (Express.js)**
_Navigate to the **backend/** directory:_
```sh
cd backend
npm install
```
### **Start Backend Server**
```sh
node index.js
```
_Backend runs on **http://localhost:5000**_
---
## **5οΈβ£ Frontend Setup (Next.js)**
_Navigate to the **frontend/** directory:_
```sh
cd frontend
npm install
```
### **Start Frontend**
```sh
npm run dev
```
_Frontend available at **http://localhost:3000**_
---
## **6οΈβ£ Running the Full Application**
1. **Start Hardhat local node**
```sh
npx hardhat node
```
2. **Deploy smart contract**
```sh
npx hardhat run scripts/deploy.js --network localhost
```
3. **Start backend API**
```sh
cd backend && node index.js
```
4. **Start frontend UI**
```sh
cd frontend && npm run dev
```
---
## **π Features**
- **π Privacy-Preserving Credit Scoring** (zk-SNARKs)
- **β³ Instant Proof Verification** (zkVerify)
- **π° DeFi Credit System** with Secure On-Chain Storage
- **π‘ Beautiful UI** (Tailwind CSS + Framer Motion)
---
### **π Useful Links**
- **GitHub Repo:** [ZK-Online-Hackathon](https://github.com/TheCoderAdi/ZK-Online-Hackathon)
- **zkVerify Docs:** [zkVerify](https://docs.zkverify.io)
- **Arbitrum:** [Arbitrum Portal](https://portal.arbitrum.io/)