Skip to content

Repository files navigation

๐Ÿ”— WitnessChain

Decentralized Bystander Evidence Network on Solana

"We turned civic evidence collection into a game โ€” where every witness is a player, every recording is immutable, and justice has a leaderboard."

License: MIT Built on Solana IPFS NMIT Hacks 2026


๐Ÿ“Œ Table of Contents


๐Ÿšจ Problem Statement

Every day in India, 53+ hit-and-run accidents and countless street crimes go unpunished โ€” not because no one witnessed them, but because evidence dies before it reaches justice.

The Gap Reality
Bystanders record everything Video gets deleted under pressure or coercion
Evidence exists Chain-of-custody cannot be proven in court
Witnesses are willing Zero incentive to formally report
Authorities need proof No tamper-proof submission channel exists

Current systems rely on centralized storage โ€” a single point of failure where evidence can be wiped, modified, or suppressed. There is no mechanism that makes tampering mathematically impossible from the moment of capture.

The result: Perpetrators walk free. Witnesses stay silent. Justice has no memory.


๐Ÿ’ก Proposed Solution

WitnessChain is a decentralized civic evidence network that transforms every smartphone into a tamper-proof evidence terminal.

When a user captures an incident:

  1. Media is hashed instantly (SHA-256) on-device before upload โ€” the fingerprint is immutable from second zero
  2. Hash is anchored on Solana via a Program Derived Address โ€” timestamped permanently on-chain
  3. Media is stored on IPFS via Pinata โ€” decentralized, uncensorable, content-addressed
  4. Multi-witness corroboration โ€” when 3+ independent users hash the same incident window, evidence is auto-elevated to "Confirmed" status
  5. Legal export API โ€” authorities can pull tamper-proof evidence bundles with full provenance metadata
  6. Witness Score + Soul-bound NFT badges โ€” gamified reputation system that rewards honest civic participation

The cryptographic guarantee: if even one byte of evidence is altered after submission, the hash mismatch is immediately detectable. Tampering becomes mathematically visible.


โœจ Key Features

๐Ÿ” Tamper-Proof Evidence Capture

  • On-device SHA-256 hashing before any upload
  • IPFS content-addressed storage (CID = fingerprint)
  • Solana PDA anchoring with block timestamp
  • Metadata bundle: GPS coordinates, device ID hash, timestamp, media CID

๐Ÿ‘ฅ Multi-Witness Corroboration

  • Incident clustering by GPS radius + time window (configurable)
  • Consensus threshold: 3 independent witnesses = "Confirmed" status
  • Anti-Sybil: wallet-bound submissions, one submission per wallet per incident

๐ŸŽฎ Gamified Witness Reputation

  • Witness Score โ€” cumulative reputation metric
  • Soul-bound NFT Badges โ€” non-transferable, wallet-bound achievement tokens
    • ๐Ÿฅ‰ First Witness โ€” submitted first evidence of an incident
    • ๐Ÿฅˆ Corroborator โ€” part of a confirmed multi-witness cluster
    • ๐Ÿฅ‡ Civic Guardian โ€” 10+ confirmed submissions
    • ๐Ÿ’Ž Chain Anchor โ€” evidence used in an active legal case
  • Leaderboard โ€” top witnesses in your city/district

๐Ÿค– Deepfake / Duplicate Flagging

  • TensorFlow.js model flags AI-generated or manipulated media at submission
  • Perceptual hash (pHash) deduplication to prevent spam submissions
  • Confidence score surfaced to reviewing authorities

๐Ÿ“ค Legal Export API

  • Read-only REST endpoint for authorized law enforcement
  • Returns: IPFS CID, Solana transaction signature, witness count, GPS metadata, timestamp
  • Exportable as signed PDF evidence bundle

๐Ÿ—บ๏ธ Incident Heat Map

  • Public dashboard showing anonymized incident clusters
  • Filter by type, time, corroboration status
  • City/district level granularity

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    WITNESS DEVICE                        โ”‚
โ”‚                                                          โ”‚
โ”‚  [Camera/Gallery] โ†’ [On-device SHA-256 Hash]            โ”‚
โ”‚        โ†“                      โ†“                          โ”‚
โ”‚  [Media Upload]         [Hash + Metadata]               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€-โ”˜
           โ”‚                    โ”‚
           โ–ผ                    โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚    IPFS     โ”‚    โ”‚   Solana Blockchain  โ”‚
    โ”‚  (Pinata)   โ”‚    โ”‚                      โ”‚
    โ”‚             โ”‚    โ”‚  Program Derived     โ”‚
    โ”‚  Returns    โ”‚    โ”‚  Address (PDA)       โ”‚
    โ”‚    CID      โ”‚    โ”‚  anchors:            โ”‚
    โ”‚             โ”‚    โ”‚  - SHA-256 hash      โ”‚
    โ”‚             โ”‚    โ”‚  - IPFS CID          โ”‚
    โ”‚             โ”‚    โ”‚  - GPS metadata      โ”‚
    โ”‚             โ”‚    โ”‚  - Block timestamp   โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚                      โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ผ
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚   Node.js Backend   โ”‚
           โ”‚   + Supabase DB     โ”‚
           โ”‚                     โ”‚
           โ”‚  - Incident cluster โ”‚
           โ”‚  - Witness scoring  โ”‚
           โ”‚  - Corroboration    โ”‚
           โ”‚  - Legal export API โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ–ผ                     โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  React Nativeโ”‚    โ”‚  Next.js Dashboardโ”‚
    โ”‚  Mobile App  โ”‚    โ”‚  (Public Heatmap  โ”‚
    โ”‚  (Witnesses) โ”‚    โ”‚   + Legal Portal) โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Mobile React Native + Expo Cross-platform witness app
Blockchain Solana (Devnet โ†’ Mainnet) Immutable hash anchoring
Smart Contracts Anchor Framework (Rust) PDA-based evidence registry
Decentralized Storage IPFS via Pinata Censorship-resistant media storage
Backend Node.js + Express API, clustering, scoring logic
Database Supabase (PostgreSQL) Incident metadata, user profiles
Frontend Dashboard Next.js + Tailwind CSS Heatmap, legal portal, leaderboard
ML / AI TensorFlow.js Deepfake detection, pHash dedup
NFT Minting Metaplex (Soul-bound tokens) Non-transferable witness badges
Wallet Phantom / Solana Wallet Adapter User authentication
Maps Mapbox GL JS Incident heatmap visualization

๐Ÿ“œ Smart Contract Design

Evidence Registry Program (Anchor / Rust)

// Evidence Account PDA
// Seeds: ["evidence", wallet_pubkey, incident_id]

#[account]
pub struct EvidenceRecord {
    pub witness: Pubkey,          // Submitting wallet
    pub sha256_hash: [u8; 32],    // On-device computed hash
    pub ipfs_cid: String,         // IPFS content identifier
    pub incident_id: String,      // Clustered incident UUID
    pub latitude: i64,            // GPS lat * 1e7 (integer)
    pub longitude: i64,           // GPS lon * 1e7 (integer)
    pub timestamp: i64,           // Unix timestamp (on-chain)
    pub corroboration_count: u8,  // Number of matching witnesses
    pub status: EvidenceStatus,   // Pending / Confirmed / Flagged
    pub bump: u8,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq)]
pub enum EvidenceStatus {
    Pending,    // < 3 witnesses
    Confirmed,  // >= 3 independent witnesses
    Flagged,    // ML flagged as potentially manipulated
}

// Instructions:
// - submit_evidence(hash, cid, lat, lon, incident_id)
// - corroborate_evidence(incident_id)
// - flag_evidence(incident_id, reason)
// - export_evidence(incident_id) โ†’ read-only

๐ŸŽฎ Gamification System

Witness Score Formula

WitnessScore = ฮฃ (SubmissionWeight ร— CorroborationMultiplier ร— RecencyDecay)

Where:
  SubmissionWeight      = 10 (base) | 25 (first witness) | 5 (corroborator)
  CorroborationMultiplier = 1.0 (pending) | 2.5 (confirmed) | 0.0 (flagged)
  RecencyDecay          = e^(-0.01 ร— days_since_submission)

Badge Tiers

Badge Trigger Type
๐Ÿ” First Witness First to submit evidence of an incident Soul-bound NFT
๐Ÿค Corroborator Part of a 3+ witness confirmed cluster Soul-bound NFT
๐Ÿ›ก๏ธ Civic Guardian 10+ confirmed submissions Soul-bound NFT
โš–๏ธ Chain Anchor Evidence used in an active legal export Soul-bound NFT
๐Ÿ™๏ธ City Sentinel Top 10 witness score in your city Soul-bound NFT

All badges are non-transferable (soul-bound) โ€” they cannot be bought, sold, or gamed.


๐Ÿš€ Getting Started

Prerequisites

node >= 18.0.0
npm >= 9.0.0
Rust + Cargo (for Anchor)
Solana CLI >= 1.18
Anchor CLI >= 0.30
Expo CLI (for mobile)

Installation

# Clone the repository
git clone https://github.com/ZeroTamper/witnesschain.git
cd witnesschain

# Install root dependencies
npm install

# Install smart contract dependencies
cd programs/evidence-registry
cargo build

# Install mobile app dependencies
cd ../../apps/mobile
npm install

# Install dashboard dependencies
cd ../dashboard
npm install

Environment Setup

# apps/mobile/.env
EXPO_PUBLIC_BACKEND_URL=http://localhost:4000
EXPO_PUBLIC_DEMO_WALLET=DemoWitness111111111111111111111111111111111
EXPO_PUBLIC_SUPABASE_URL=your_supabase_url
EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
EXPO_PUBLIC_PINATA_JWT=your_pinata_jwt
EXPO_PUBLIC_SOLANA_RPC=https://api.devnet.solana.com
EXPO_PUBLIC_PROGRAM_ID=your_deployed_program_id

# apps/dashboard/.env
NEXT_PUBLIC_BACKEND_URL=http://localhost:4000
NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your_supabase_publishable_key
SUPABASE_SERVICE_KEY=your_service_key
LEGAL_API_SECRET=your_legal_api_secret

Deploy Smart Contract

# Configure Solana CLI for devnet
solana config set --url devnet
solana airdrop 2

# Build and deploy
cd programs/evidence-registry
anchor build
anchor deploy

# Copy Program ID to your .env files

Run Locally

# Start backend
cd apps/backend
npm run dev

# Start dashboard
cd apps/dashboard
npm run dev

# Start mobile (Expo)
cd apps/mobile
npx expo start

๐Ÿ“ Project Structure

witnesschain/
โ”œโ”€โ”€ programs/
โ”‚   โ””โ”€โ”€ evidence-registry/        # Anchor smart contract (Rust)
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ lib.rs            # Program entrypoint
โ”‚       โ”‚   โ”œโ”€โ”€ instructions/     # submit, corroborate, flag, export
โ”‚       โ”‚   โ””โ”€โ”€ state/            # EvidenceRecord, EvidenceStatus
โ”‚       โ””โ”€โ”€ Cargo.toml
โ”‚
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ mobile/                   # React Native witness app
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ screens/          # Capture, Submit, Profile, Leaderboard
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ components/       # WitnessCard, BadgeDisplay, HeatMap
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hooks/            # useSolana, useIPFS, useWitnessScore
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils/            # sha256.ts, pHash.ts, cluster.ts
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ dashboard/                # Next.js public dashboard + legal portal
โ”‚   โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx          # Incident heatmap
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ leaderboard/      # City witness rankings
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ legal/            # Authorized evidence export portal
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ backend/                  # Node.js API
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ routes/           # /evidence, /incidents, /export, /score
โ”‚       โ”‚   โ”œโ”€โ”€ services/         # clustering, scoring, deepfake-flag
โ”‚       โ”‚   โ””โ”€โ”€ middleware/       # auth, rate-limit, legal-auth
โ”‚       โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ ml/
โ”‚   โ””โ”€โ”€ deepfake-detector/        # TensorFlow.js model + pHash logic
โ”‚
โ”œโ”€โ”€ tests/                        # Anchor program tests
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ package.json

๐Ÿ“ก API Reference

Submit Evidence

POST /api/evidence/submit
Authorization: Bearer <wallet_signature>

{
  "sha256Hash": "abc123...",
  "ipfsCid": "QmXyz...",
  "incidentId": "uuid-v4",
  "latitude": 12.9716,
  "longitude": 77.5946,
  "mediaType": "video/mp4",
  "deviceIdHash": "sha256_of_device_id"
}

Get Incident Cluster

GET /api/incidents/:incidentId

Response:
{
  "incidentId": "uuid-v4",
  "status": "Confirmed",
  "witnessCount": 4,
  "firstSeenAt": "2026-05-08T14:23:00Z",
  "location": { "lat": 12.9716, "lon": 77.5946 },
  "evidenceRecords": [ ... ],
  "solanaSignatures": [ "sig1...", "sig2..." ]
}

Legal Export (Authorized Only)

GET /api/export/:incidentId
Authorization: Bearer <legal_api_secret>

Response:
{
  "incidentId": "uuid-v4",
  "exportedAt": "2026-05-08T16:00:00Z",
  "evidenceBundle": [ ... ],
  "chainOfCustody": [ ... ],
  "verificationInstructions": "..."
}

๐Ÿ—บ๏ธ Roadmap

Hackathon MVP (48 hours)

  • On-device SHA-256 hashing
  • IPFS upload via Pinata
  • Solana PDA anchoring (devnet)
  • Basic incident clustering
  • Witness Score calculation
  • Soul-bound NFT badge minting (1 badge type)
  • Public heatmap dashboard
  • Live demo flow end-to-end

Post-Hackathon (Month 1โ€“3)

  • Deepfake detection ML model (production-grade)
  • Full badge tier system (5 badge types)
  • Legal export API with authentication
  • Anti-Sybil improvements
  • Multi-language support (Hindi, Kannada, Tamil)
  • Mainnet deployment

Scale (Month 3โ€“6)

  • MoU with state police departments
  • Integration with DigiLocker for witness identity verification
  • DAO governance for evidence dispute resolution
  • iOS + Android app store release
  • Partnership with road safety NGOs

๐Ÿ‘ฅ Team

Team ZeroTamper โ€” NMIT Hacks 2026

Name Role
[Member 1] Blockchain / Smart Contracts
[Member 2] Mobile App / React Native
[Member 3] Backend / ML
[Member 4] Frontend / Design

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


๐Ÿ™ Acknowledgements


Built in 48 hours at NMIT Hacks 2026 ยท Bengaluru, India

Every witness is a player. Every recording is immutable. Justice has a leaderboard.

About

Decentralized Bystander Evidence Network on Solana

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages