Skip to content

Latest commit

ย 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŒ Cygnus

Zero-Knowledge Academic Credential Wallet on Midnight Network

Prove you qualify. Reveal nothing else.

Midnight Network Built With Compact React TypeScript License: MIT


Brainwave 2026 โ€” Midnight Blockchain Track

๐Ÿ”— Live Contract ยท ๐Ÿ“ Architecture ยท โš™๏ธ Setup ยท ๐ŸŽฌ Demo ยท ๐Ÿง  How ZK Works


๐Ÿงฉ The Problem

Every year, millions of students hand over their entire academic transcript to employers or universities just to answer a single binary question:

"Do you meet the minimum CGPA requirement?"

This exposes everything โ€” failed courses, personal grades, irrelevant subjects, retake history โ€” to a third party who only needed one data point. Traditional systems have no concept of selective disclosure.


โœจ The Solution โ€” Cygnus

Cygnus is a privacy-preserving academic credential system built on the Midnight Network, the first blockchain with native privacy built into the consensus layer.

Using Zero-Knowledge cryptography and Compact smart contracts, Cygnus enables a paradigm shift:

Role What They Do What They Reveal
๐Ÿ›๏ธ University (Issuer) Signs & publishes a cryptographic commitment of the student's grade Only a hash. Raw grade stays off-chain.
๐ŸŽ“ Student (Holder) Generates a ZK proof locally that grade โ‰ฅ threshold Nothing. Proof is computed entirely on-device.
๐Ÿข Employer (Verifier) Reads the on-chain verified status Only PASS or FAIL. Never sees the grade.

๐Ÿ”ฌ How Zero-Knowledge Proofs Work

The core of Cygnus is a ZK circuit written in Compact โ€” Midnight's purpose-built smart contract language. Here is the end-to-end cryptographic lifecycle:

sequenceDiagram
    autonumber
    actor University
    actor Student
    actor Employer
    participant API as Attestation API<br/>(Off-Chain)
    participant Contract as Midnight Smart Contract<br/>(On-Chain Ledger)
    participant ProofServer as Local Proof Server<br/>(Docker Container)

    University->>API: POST /sign-credential {studentId, cgpa, threshold}
    API->>API: HMAC-SHA256 sign credential hash
    API-->>University: { credentialHash, signature }
    University->>Contract: issueCredential(credentialId, commitmentHash)
    Contract-->>University: โœ… Commitment stored on ledger

    Note over Contract: Only the HASH lives on-chain.<br/>Raw CGPA never stored.

    Student->>ProofServer: Generate ZK Proof (private: cgpa, witness)
    ProofServer->>ProofServer: Run Compact ZK circuit locally
    ProofServer-->>Student: ZK Proof object (verifiable, non-revealing)
    Student->>Contract: proveEligible(credentialId, proof)
    Contract->>Contract: Verify proof against on-chain commitment
    Contract-->>Student: โœ… On-chain status โ†’ ELIGIBLE

    Employer->>Contract: checkEligibility(credentialId)
    Contract-->>Employer: โœ… PASS (grade never disclosed)
Loading

๐Ÿ—๏ธ System Architecture

graph TB
    subgraph Client["๐Ÿ–ฅ๏ธ Client Layer"]
        FE["โš›๏ธ React + Vite<br/>DApp Frontend<br/>(localhost:5173)"]
        LACE["๐Ÿ”‘ Midnight Lace<br/>Chrome Wallet Extension"]
    end

    subgraph Backend["๐Ÿ› ๏ธ Backend Layer"]
        API["๐Ÿ“ก Express Attestation API<br/>(localhost:4000)<br/>HMAC-SHA256 Signing"]
        PS["๐Ÿณ Proof Server<br/>Docker Container<br/>(localhost:6300)<br/>ZK Circuit Execution"]
    end

    subgraph Blockchain["๐ŸŒ Midnight PreProd Network"]
        CONTRACT["๐Ÿ“œ Compact Smart Contract<br/>credential.compact<br/>issueCredential()<br/>proveEligible()<br/>checkEligibility()"]
        LEDGER["๐Ÿ“’ On-Chain Ledger<br/>Stores only:<br/>โ€ข Commitment Hashes<br/>โ€ข ZK Verification Status"]
        INDEXER["๐Ÿ” PreProd Indexer<br/>rpc.preprod.midnight.network"]
    end

    FE -->|"REST calls"| API
    FE -->|"Wallet connect / sign tx"| LACE
    FE -->|"ZK proof generation"| PS
    LACE -->|"Submit signed transactions"| INDEXER
    INDEXER -->|"Block sync / state queries"| CONTRACT
    CONTRACT --> LEDGER

    style Client fill:#1e1e2e,color:#cdd6f4
    style Backend fill:#181825,color:#cdd6f4
    style Blockchain fill:#11111b,color:#cdd6f4
Loading

๐Ÿ“ Project Structure

Cygnus/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“œ contract/                   # Compact smart contract
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ credential.compact     # ZK circuits: issue, prove, verify
โ”‚   โ”‚   โ””โ”€โ”€ managed/               # Compiled keys & TypeScript bindings
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ tsconfig.json
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ก api/                        # Express Attestation API (off-chain signer)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ server.ts              # Route handlers (POST /sign-credential)
โ”‚   โ”‚   โ””โ”€โ”€ index.ts               # Server entrypoint
โ”‚   โ”œโ”€โ”€ .env.example
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ โš›๏ธ frontend/                   # React + Vite DApp
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ConnectWallet.tsx   # Midnight Lace wallet connector
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ IssuerPanel.tsx     # University credential issuance UI
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ StudentWallet.tsx   # Student ZK proof generation UI
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ VerifierPanel.tsx   # Employer verification panel
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ MidnightContext.tsx # Global wallet & contract state
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx
โ”‚   โ”‚   โ””โ”€โ”€ styles.css             # Glassmorphism dark theme
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ ๐Ÿ”ง cli/                        # CLI deployment utilities
โ”‚   โ””โ”€โ”€ src/deploy.ts              # Network config & node mapping
โ”‚
โ”œโ”€โ”€ ๐Ÿš€ preprod-deploy/             # Midnight deployment runner
โ”‚   โ”œโ”€โ”€ contracts/                 # Template hello-world contract
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ setup.ts               # Wallet init, sync, faucet detection
โ”‚   โ”‚   โ”œโ”€โ”€ deploy.ts              # Contract deployment logic
โ”‚   โ”‚   โ””โ”€โ”€ wallet.ts              # Wallet & DUST token management
โ”‚   โ”œโ”€โ”€ docker-compose.yml         # Local Midnight proof server
โ”‚   โ””โ”€โ”€ .midnight-state.json       # Deployed contract address (gitignored)
โ”‚
โ”œโ”€โ”€ package.json                   # NPM Workspaces root
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ DEMO.md                        # Hackathon demo script

๐Ÿ”— Live Deployment

Cygnus is live on the public Midnight PreProd Network:

Field Value
๐ŸŒ Network Midnight PreProd Testnet
๐Ÿ“œ Contract Address 53fe8fbc9c9cf5477266d6bf60e8be66525016d55a5e69bddf2a5bf2c3d6b3e1
๐Ÿ”‘ Deployer Wallet mn_addr_preprod1vc393m7q2n60...
๐Ÿ“… Deployed At 2026-08-22T14:26:08 UTC
๐Ÿ” RPC Endpoint wss://rpc.preprod.midnight.network
๐Ÿ“Š Indexer https://indexer.preprod.midnight.network/api/v1/graphql

โš™๏ธ Installation & Setup

Prerequisites

Ensure the following are installed:

Tool Version Link
Node.js v22+ nodejs.org
npm v11+ Bundled with Node.js
Docker Desktop Latest docker.com
Compact Compiler v0.31.1+ Midnight Docs
Chrome Browser Latest For Midnight Lace Wallet

Step 1 โ€” Install the Compact Compiler

curl --proto '=https' --tlsv1.2 -LsSf \
  https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh
source ~/.zshrc
compact update
compact --version   # Should print 0.31.1 or higher

Step 2 โ€” Clone & Install Dependencies

git clone https://github.com/AdeshDeshmukh/Cygnus.git
cd Cygnus
npm install          # Installs all workspaces: contract, api, frontend, cli

Step 3 โ€” Spin up the Local Proof Server

Ensure Docker Desktop is running, then start the proof server:

docker run -d \
  -p 6300:6300 \
  midnightntwrk/proof-server:8.1.0 \
  midnight-proof-server -v

Step 4 โ€” Compile the Smart Contract

cd contract
npm run compact      # Compiles ZK circuits, generates proving keys & TS bindings
npm run build        # TypeScript build
cd ..

Step 5 โ€” Launch the Attestation API

cd api
cp .env.example .env  # Configure HMAC signing secret
npm run dev           # Starts on http://localhost:4000

Step 6 โ€” Launch the Frontend DApp

cd frontend
npm run dev           # Starts on http://localhost:5173

๐ŸŽฌ Demo Workflow

Once all services are running, open http://localhost:5173 in Chrome.

flowchart LR
    A["๐Ÿ”Œ Connect Wallet\nMidnight Lace\nPreProd Network"] --> B

    B["๐Ÿ›๏ธ UNIVERSITY PANEL\nEnter Student ID\nEnter CGPA: 8.7\nThreshold: 8.0\nClick: Issue Credential"] --> C

    C["โ›“๏ธ On-Chain\nCommitment Hash\npublished to\nMidnight Ledger"] --> D

    D["๐ŸŽ“ STUDENT PANEL\nEnter Credential ID\nEnter private CGPA: 8.7\nClick: Generate ZK Proof"] --> E

    E["๐Ÿงฎ Local ZK Circuit\nRuns via Proof Server\nProof generated\n(grade never leaves browser)"] --> F

    F["โœ… EMPLOYER PANEL\nEnter Credential ID\nClick: Verify\nResult: ELIGIBLE"] --> G

    G["๐Ÿ”’ Privacy Preserved\nEmployer learns:\nOnly PASS / FAIL\nNever raw grade"]

    style A fill:#6A0DAD,color:white
    style B fill:#1e3a5f,color:white
    style C fill:#0f4c35,color:white
    style D fill:#1e3a5f,color:white
    style E fill:#4a1f5f,color:white
    style F fill:#0f4c35,color:white
    style G fill:#1a1a2e,color:#a78bfa
Loading

๐Ÿง  Key Technical Decisions

Why Midnight Network?

Midnight is the only blockchain where privacy is a first-class primitive at the protocol level. Unlike Ethereum with opt-in privacy tools, Midnight distinguishes between public (on-chain) and private (off-chain, shielded) state natively in its smart contract execution model.

Why Compact?

Compact is Midnight's purpose-built language that compiles directly to ZK circuits. It treats all function arguments as private witnesses by default, requiring explicit disclose() annotations for any data that should flow onto the public ledger. This makes it impossible to accidentally leak private data on-chain.

Why Off-Chain Signing (Attestation API)?

The HMAC-SHA256 signing step in the Attestation API serves as an institutional trust anchor. It binds the University's server-side secret key to the credential hash, meaning only the legitimate university can issue credentials. This prevents students from fabricating their own commitments.

Why DUST Tokens?

Midnight uses a two-token model โ€” NIGHT for transaction fees and DUST for shielded, privacy-preserving operations. ZK proof submissions happen in the DUST layer, ensuring that even the act of submitting a proof does not link the student's public identity to the transaction on the transparent layer.


๐Ÿ›ก๏ธ Security Properties

Property Status Mechanism
Grade Confidentiality โœ… Guaranteed ZK proof: grade never leaves student's browser
Commitment Integrity โœ… Guaranteed HMAC-SHA256 institutional signature
Proof Soundness โœ… Guaranteed Compact ZK circuit verifies witness matches hash
Non-Repudiation โœ… Guaranteed On-chain immutable commitment timestamp
Verifier Privacy โœ… Guaranteed Employer only reads on-chain boolean flag
Replay Prevention โœ… Guaranteed Credential IDs are unique per issuance

๐Ÿ“ฆ Tech Stack Summary

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         CYGNUS STACK                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Blockchain      โ”‚ Midnight Network (PreProd Testnet)             โ”‚
โ”‚ Smart Contract  โ”‚ Compact v0.31.1 (ZK Circuit Language)          โ”‚
โ”‚ ZK Proofs       โ”‚ Compact-generated WASM proving keys            โ”‚
โ”‚ Proof Server    โ”‚ Docker: midnightntwrk/proof-server:8.1.0       โ”‚
โ”‚ Frontend        โ”‚ React 18 + Vite + TypeScript                   โ”‚
โ”‚ Wallet          โ”‚ Midnight DApp Connector + Lace Extension       โ”‚
โ”‚ API Backend     โ”‚ Express.js + TypeScript (HMAC-SHA256)          โ”‚
โ”‚ Build Tools     โ”‚ npm Workspaces + tsx + tsc                     โ”‚
โ”‚ Deployment      โ”‚ create-mn-app PreProd template                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ‘ค Author

Adesh Kishor Deshmukh

Built with โค๏ธ for Brainwave 2026 โ€” Midnight Blockchain Track

GitHub


๐Ÿ“„ License

MIT ยฉ 2026 Adesh Kishor Deshmukh โ€” See LICENSE for details.

About

Privacy-preserving academic credential verification system built on the Midnight Network using zero-knowledge proofs and Compact smart contracts. Brainwave 2026 Midnight Track

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages