Skip to content

0xvandesdev/zkcredential

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” ZK Credential - Privacy-First Identity Verification

Zero-Knowledge Proof Credentials on Sui Blockchain with Walrus Decentralized Storage

A cutting-edge decentralized identity verification system that proves your credentials without revealing your personal information. Built with Groth16 ZK-SNARKs, Sui blockchain, and Walrus storage.


🌟 The Story

The Problem

In today's digital world, proving your identity or credentials means sacrificing privacy:

  • πŸ”“ Companies collect and store your personal data
  • πŸ“Š Your exact age, income, and identity are exposed
  • 🎯 Data breaches put millions at risk
  • 🌍 Centralized systems control your information

The Solution

ZK Credential enables you to prove statements about yourself without revealing the underlying data:

βœ… Prove you're over 18 β†’ Without revealing your exact age
βœ… Prove your income meets requirements β†’ Without disclosing exact salary
βœ… Prove you passed KYC β†’ Without exposing personal details

How?

  • πŸ”¬ Zero-Knowledge Proofs (Groth16) - Cryptographic proofs that are mathematically impossible to fake
  • ⛓️ Sui Blockchain - Immutable verification and credential minting
  • πŸ’Ύ Walrus Storage - Decentralized, permanent credential storage
  • 🌐 Browser-Based - No servers, no databases, complete client-side execution

🎯 Use Cases

Scenario What You Prove What You Hide
DeFi Lending Income > $30,000 Exact income amount
Age-Restricted Services Age β‰₯ 18 Exact birthdate
Premium Access KYC verified Identity documents
Credit Applications Creditworthy status Financial details

πŸ—οΈ Architecture

graph TB
    A[User Input] --> B[ZK Proof Generator]
    B --> C[Groth16 Circuit]
    C --> D[Proof + Public Signals]
    D --> E[WASM Serializer]
    E --> F[Arkworks Format]
    F --> G[Sui Smart Contract]
    G --> H[On-Chain Verification]
    H --> I[Credential NFT Minted]
    D --> J[Walrus Storage]
    J --> K[Permanent Blob Storage]
    I --> L[Success Screen]
    K --> L
Loading

Tech Stack

Layer Technology Purpose
Frontend Next.js 16 + TypeScript Modern React framework
Styling Tailwind CSS + shadcn/ui Beautiful, responsive UI
ZK Proofs Circom + Groth16 + SnarkJS Zero-knowledge circuit & proof generation
Blockchain Sui Network (Testnet) On-chain verification & NFT minting
Storage Walrus (Testnet) Decentralized credential storage
Serialization Rust + WASM (Arkworks) Proof format conversion
Wallet Sui Wallet / Mysten dApp Kit Blockchain interaction

πŸš€ Getting Started

Prerequisites

  • Node.js 20+
  • A Sui Wallet (install from Sui Wallet)
  • Some testnet SUI tokens (faucet)

Installation

# Clone the repository
git clone https://github.com/yourusername/zkcredential.git
cd zkcredential

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env.local

# Edit .env.local with your configuration
# NEXT_PUBLIC_SUI_PACKAGE_ID=<your_deployed_package_id>
# NEXT_PUBLIC_WALRUS_ENDPOINT=https://testnet.walrus.xyz

Run Locally

npm run dev

Open http://localhost:3000 in your browser.


πŸ“± How to Use the App

Step 1: Connect Wallet πŸ”—

  1. Click "Connect Wallet" in the top-right corner
  2. Select your Sui Wallet
  3. Approve the connection

Connect Wallet


Step 2: Fill in Your Information πŸ“

Enter your credentials:

  • Age: Your actual age (e.g., 25)
  • Income: Your monthly income in Rupiah (e.g., 35000000)
  • KYC Status: Select "Verified"

πŸ’‘ Privacy Note: This data never leaves your browser!

Form Input


Step 3: Generate ZK Proof πŸ”¬

Click "Generate Proof"

The app will:

  1. βœ… Run the Circom circuit locally in your browser
  2. βœ… Generate a cryptographic proof
  3. βœ… Create public signals (only reveals: age β‰₯ 18, income β‰₯ 30M, KYC = true)

Time: ~3-5 seconds

Proof Generation


Step 4: Upload to Walrus πŸ’Ύ

Click "Upload to Walrus"

The app will:

  1. βœ… Package your credential data
  2. βœ… Upload to Walrus decentralized storage
  3. βœ… Receive a permanent Blob ID

Result: Your data is now stored forever on Walrus!

Walrus Upload


Step 5: Submit to Sui Blockchain ⛓️

Click "Submit to Blockchain"

The app will:

  1. βœ… Serialize proof using Arkworks (WASM)
  2. βœ… Send transaction to Sui smart contract
  3. βœ… Verify proof on-chain using Groth16
  4. βœ… Mint credential NFT

Your wallet will prompt you to approve the transaction.

Blockchain Submission


Step 6: View Your Credential πŸŽ‰

Success! Your credential is now:

  • βœ… Verified on Sui blockchain
  • βœ… Stored permanently on Walrus
  • βœ… Accessible as an NFT

Success Screen


πŸ” How to Verify Walrus & Sui Integration

1️⃣ Verify Walrus Storage

On the success screen, you'll see:

Walrus Blob ID
z3UAJMCNDQPMxxxxxxxxx
[View on Walrus] πŸ”—

Click the button to open Walruscan:

πŸ‘‰ URL: https://walruscan.com/testnet/blob/YOUR_BLOB_ID

What you'll see:

  • βœ… Your credential data stored as a blob
  • βœ… Storage metadata (size, upload time)
  • βœ… Proof that data is on Walrus testnet

Walruscan


2️⃣ Verify Sui Blockchain

On the success screen, you'll see:

Transaction Hash
0x8a3f2b1c9e4d7b5a...
[View on Sui Explorer] πŸ”—

Click the button to open SuiScan:

πŸ‘‰ URL: https://suiscan.xyz/testnet/tx/YOUR_TX_HASH

What you'll see:

  • βœ… Transaction details (sender, gas used, status)
  • βœ… Smart contract called: zk_credential::verify_proof
  • βœ… Events emitted (proof verified, NFT minted)
  • βœ… On-chain confirmation

SuiScan


3️⃣ Verify Proof Data (Developer Mode)

Open browser console (F12) and look for:

βœ… Proof generated successfully
βœ… Public Signals: ["1", "1", "1"] // [age>=18, income>=30M, KYC=true]
βœ… Walrus Blob ID: z3UAJMCNDQPMxxxxxxxxx
βœ… Sui Transaction: 0x8a3f2b1c9e4d7b5a...

πŸ§ͺ Testing the Integration

Quick Integration Test

# Test Walrus upload
curl -X PUT https://testnet.walrus.xyz/v1/store \
  --data-binary @test.json \
  -H "Content-Type: application/octet-stream"

# Test Sui RPC
curl -X POST https://fullnode.testnet.sui.io:443 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"sui_getChainIdentifier"}'

Expected Outputs

Walrus Response:

{
  "newlyCreated": {
    "blobObject": {
      "id": "0x...",
      "blobId": "z3UAJMCNDQPM..."
    }
  }
}

Sui Response:

{
  "jsonrpc": "2.0",
  "result": "testnet-1",
  "id": 1
}

πŸ“Š Proof of Integration

Walrus Integration Evidence

βœ… File: lib/walrusStorage.ts
βœ… Endpoint: https://testnet.walrus.xyz
βœ… Method: PUT /v1/store
βœ… Returns: Permanent Blob ID

Sui Integration Evidence

βœ… File: lib/smartContract.ts
βœ… Package ID: 0x91e5baf5bb184dc7b1eeca481d2720a7ea918c5967bbffa6e6573a67d51c1ef8
βœ… Contract: contracts/sources/verifier.move
βœ… Function: groth16::verify_groth16_proof


πŸ“¦ What Happens Behind the Scenes

1. Proof Generation (Client-Side)

// lib/zkProof.ts
const { proof, publicSignals } = await snarkjs.groth16.fullProve(
  { age: 25, income: 35000000, kycStatus: 1 },
  "/circuits/credential.wasm",
  "/circuits/credential_final.zkey"
);

Output:

  • proof: Groth16 proof (3 points: A, B, C)
  • publicSignals: ["1", "1", "1"] (only boolean results!)

2. Walrus Upload

// lib/walrusStorage.ts
const response = await fetch('https://testnet.walrus.xyz/v1/store', {
  method: 'PUT',
  body: credentialData
});

const { blobId } = await response.json();
// blobId: "z3UAJMCNDQPMxxxxxxxxx"

3. Proof Serialization (WASM)

// vk-converter/src/lib.rs
use ark_serialize::CanonicalSerialize;

let proof_bytes = proof.serialize_compressed();
// Converts to Arkworks format for Sui Move

4. On-Chain Verification

// contracts/sources/verifier.move
public fun verify_and_mint(
    proof: vector<u8>,
    public_inputs: vector<u8>,
    vk: vector<u8>,
    ctx: &mut TxContext
) {
    // Verify proof using groth16::verify_groth16_proof
    assert!(verified, E_INVALID_PROOF);
    
    // Mint credential NFT
    let credential = Credential { ... };
    transfer::transfer(credential, sender(ctx));
}

🌐 Deployment

Deploy to Railway

# Run deployment script
./deploy.sh

# Follow Railway setup instructions
# See: RAILWAY_DEPLOYMENT.md

Live Demo: [Your Railway URL]


πŸ” Security

Privacy Guarantees

  • βœ… Zero-Knowledge: Proofs reveal nothing beyond the statement
  • βœ… Client-Side: All computation happens in your browser
  • βœ… No Backend: No server stores your data
  • βœ… Immutable: Blockchain records can't be altered
  • βœ… Decentralized: Walrus ensures data availability

Cryptographic Security

  • Groth16: Industry-standard ZK-SNARK
  • Trusted Setup: Uses Powers of Tau ceremony
  • Curve: BN254 (same as Ethereum)
  • Security Level: 128-bit

πŸ› οΈ Development

Project Structure

zkcredential/
β”œβ”€β”€ app/                    # Next.js app directory
β”œβ”€β”€ components/             # React components
β”œβ”€β”€ lib/                    # Core libraries
β”‚   β”œβ”€β”€ zkProof.ts         # ZK proof generation
β”‚   β”œβ”€β”€ walrusStorage.ts   # Walrus integration
β”‚   β”œβ”€β”€ smartContract.ts   # Sui integration
β”‚   └── wasmSerializer.ts  # Arkworks serialization
β”œβ”€β”€ contracts/              # Sui Move contracts
β”‚   └── sources/
β”‚       └── verifier.move  # On-chain verifier
β”œβ”€β”€ vk-converter/           # Rust WASM module
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ circuits/          # ZK circuits (.wasm, .zkey)
β”‚   └── wasm/              # Compiled WASM modules
└── scripts/                # Deployment scripts

Key Files

File Purpose
lib/zkProof.ts Generates Groth16 proofs using SnarkJS
lib/walrusStorage.ts Uploads data to Walrus storage
lib/smartContract.ts Interacts with Sui blockchain
vk-converter/src/lib.rs Serializes proofs to Arkworks format
contracts/sources/verifier.move On-chain proof verification & NFT minting

πŸ“š Learn More

Zero-Knowledge Proofs

Sui Blockchain

Walrus Storage


🀝 Contributing

Contributions are welcome! Please:

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

πŸ“„ License

This project is licensed under the MIT License.


πŸ†˜ Support


πŸŽ‰ Acknowledgments

Built with:


Made with ❀️ for a privacy-first future


πŸ“Έ Screenshots

Landing Page

Landing

Proof Generation

Proof Gen

Success Screen

Success


πŸ”— Links


πŸš€ Ready to prove your credentials without revealing your secrets? Let's go!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors