Physically-Fused, Self-Alerting Hash-Chained Verification Ledger for Anti-Counterfeiting in Critical Supply Chains
- Frontend Web Application (Vercel): https://trust-chain-gilt.vercel.app/
- Backend API & Ledger Engine (Render): Hosted backend providing cryptographic verification, chain ledger, and AI endpoints.
Over 1 in 10 medical products in low- and middle-income nations are counterfeit or substandard (WHO). Counterfeit medications lead to treatment failure, antimicrobial resistance, and tragic loss of life.
Traditional anti-counterfeiting solutions rely on static barcodes or QR stickers. The fatal flaw: standard databases only check "Does this QR code exist in our database?" Counterfeiters easily clone genuine labels and stick them on fake batches.
TrustChain solves this by cryptographically fusing the digital ledger record with unclonable physical micro-textures, cold-chain sensor physics, geo-velocity bounds, and swarm consensus. A cloned QR code alone can never pass verification.
At every custody handoff and consumer scan, TrustChain executes an autonomous verification pipeline under 500ms:
+-------------------------------------------------------------------------------+
| TRUSTCHAIN 4-LAYER TRUST MESH |
+-------------------------------------------------------------------------------+
| 1. π Cryptographic Hash-Chain | Deterministic SHA-256 block ledger with |
| Integrity | parent-hash pointers and tamper check. |
+------------------------------------+------------------------------------------+
| 2. π¬ Packaging DNA Micro- | 64-bit Perceptual Hash (pHash) of paper |
| Fingerprinting | fibers & ink speckles (Hamming <=10). |
+------------------------------------+------------------------------------------+
| 3. π¨ Impossible-Travel | Haversine distance vs. time delta |
| Geo-Velocity Engine | detection (>900 km/h physical anomaly). |
+------------------------------------+------------------------------------------+
| 4. π₯ Swarm Counter-Signature | k-of-n multi-signature consensus from |
| Consensus | neighboring independent network nodes. |
+------------------------------------+------------------------------------------+
| βοΈ Cold-Chain-Fused Integrity | Environmental telemetry (temp/humidity) |
| | hashed into blocks (detects spoilage). |
+------------------------------------+------------------------------------------+
| π΅οΈ Silent Regulatory Trip-Wire | Instant background GPS dispatch to FDA/ |
| | police without tipping off fraudsters. |
+------------------------------------+------------------------------------------+
| π Zero-Knowledge Proofs | zk-SNARK proof of authentic custody |
| | without exposing confidential volumes. |
+------------------------------------+------------------------------------------+
| π€ AI Regulatory Co-Pilot | Natural language assistant querying the |
| | live ledger and counterfeit heatmap. |
+------------------------------------+------------------------------------------+
| Portal | Role | Key Capabilities |
|---|---|---|
| π± Consumer Scan PWA | CONSUMER |
Camera QR scanner, instant 4-layer trust analysis, interactive block journey timeline, and one-click "Simulate Counterfeit" pitch demo. |
| π Manufacturer Portal | MANUFACTURER |
Register new products/batches, capture substrate packaging DNA (8Γ8 bit blueprint), configure cold-chain limits, and append Genesis Blocks. |
| π Distributor Logistics | DISTRIBUTOR |
Record transit handoffs, log temperature/humidity readings, attach multi-sig signatures, and generate Zero-Knowledge Proofs (zk-SNARKs). |
| π₯ Pharmacy Dispensary | PHARMACY |
Confirm shipment arrival, execute cold-chain safety gate checks (2Β°Cβ8Β°C), and record patient dispensing events. |
| ποΈ Regulatory Center | REGULATOR |
Live threat monitor, incident triage heatmap, automated silent trip-wire audit feed, and AI Regulatory Co-Pilot. |
For convenience during hackathon evaluation, the platform is pre-configured with demo accounts:
| Portal | Actor ID | Role | Demo Password |
|---|---|---|---|
| Manufacturer | MANUFACTURER_ALPHA |
Manufacturer (AstraBiotech Pharma) | password123 |
| Distributor | DISTRIBUTOR_BETA |
Distributor (Global ColdChain Logistics) | password123 |
| Pharmacy | PHARMACY_GAMMA |
Pharmacy (Apex Central Pharmacy) | password123 |
| Regulator | REGULATOR_FDA |
Regulator (National Drug Safety Authority) | password123 |
| Consumer | Public Access | Consumer Scan PWA | No login needed |
- Open the TrustChain Live App.
- On the Consumer Scan PWA tab, verify that Product ID
MED-789204-Xis loaded. - Click "Verify Authenticity (Scan)".
- Observe all 4 trust layers turn Green ("VERIFIED AUTHENTIC"), showing the full immutable custody history from factory to distributor to pharmacy.
- Click the red "Simulate Counterfeit Attack" button.
- The engine simulates a cloned QR scan arriving from London (5,000+ km away instantly) with a mismatched packaging DNA substrate.
- Result:
- Immediate Red Flag: COUNTERFEIT.
- Packaging DNA Layer highlights Bit Mismatch between baseline and cloned micro-texture.
- Impossible-Travel Engine triggers Geo-Velocity Anomaly Alert (>5000 km/h).
- Silent Regulatory Trip-Wire fires in the background with precise coordinates.
- Switch to the Regulator Portal tab (sign in with
REGULATOR_FDA/password123or select from dropdown). - Review the Incident Triage & Alert Heatmap showing the newly logged critical counterfeit attempt.
- In the AI Regulatory Co-Pilot box on the right, click suggested queries or type:
- "How many counterfeits were detected?"
- "Where are the hotspot locations?"
- "Which product is most targeted?"
- Switch to the Distributor Portal (sign in with
DISTRIBUTOR_BETA/password123). - Scroll to the Zero-Knowledge Proof Generator card.
- Click "Generate ZK Proof".
- Observe the interactive zk-SNARK Groth16 witness construction certifying authentic custody without revealing commercial volumes or supply routes.
graph TD
subgraph Physical Capture Layer
A[Packaging Micro-Texture] -->|pHash / 64-bit| D[Packaging DNA Engine]
B[IoT Cold-Chain Sensors] -->|Temp / Humidity| E[Cold-Chain Validator]
C[GPS Geolocation] -->|Lat / Lng Delta| F[Impossible-Travel Engine]
end
subgraph Ledger Core
D & E & F --> G[SHA-256 Hash-Chained Ledger Engine]
H[Actor Private Key] -->|ECDSA Sig| G
G --> I[(Immutable Block Store)]
end
subgraph 4-Layer Verification Mesh
I --> J{Master Verification Engine}
J -->|All Layers Pass| K[VERIFIED AUTHENTIC]
J -->|Anomaly Detected| L[RED FLAG: COUNTERFEIT / SPOILED]
end
subgraph Automated Response
L --> M[Silent Regulatory Trip-Wire]
M --> N[Regulator Incident Map & AI Co-Pilot]
L --> O[Community Bounty Mesh]
end
{
"block_index": 1,
"product_id": "MED-789204-X",
"event_type": "CUSTODY_TRANSFER",
"actor_id": "DISTRIBUTOR_BETA",
"latitude": 28.7041,
"longitude": 77.1025,
"location_name": "Delhi Cold Chain Hub, India",
"timestamp": "2026-08-28T14:32:00.000Z",
"temp_celsius": 4.5,
"humidity_pct": 52.0,
"fingerprint_hash": "a8f9c13b21e45678",
"counter_signatures": ["sig_distributor_beta_key", "sig_peer_node_88"],
"previous_block_hash": "c5f1a92e8471b002de9f0183b6c20894589d84126c8b054238e2197127e7f1aa",
"data_hash": "e4a2d890bc178491cba03891726a8f1092837418293749182374981723948172"
}- Frontend: React 18, Tailwind CSS, Lucide Icons, Vite, HTML5 Canvas QR Scanner (
jsQR). - Backend & API: Node.js, Express.js, JWT Authentication, CORS.
- Cryptography & Math: SHA-256 Ledger Hashing (
crypto), 64-bit Perceptual Hashing (pHash), Hamming Distance Matcher, Haversine Geo-Velocity Calculations. - Zero-Knowledge Simulation: Groth16 zk-SNARK proof verification framework.
- Database & Persistence: Structured storage engine with disk snapshotting & checkpoint verification.
- Deployment: Vercel (SPA Frontend) + Render (Node.js API Engine).
- Node.js (v18 or v20+)
- npm (v9+)
-
Clone the repository:
git clone https://github.com/sunraycodes/TrustChain.git cd TrustChain -
Install all dependencies:
npm run install:all
-
Start both Frontend and Backend concurrently:
npm run dev
- Client:
http://localhost:5173 - API Server:
http://localhost:5000
- Client:
-
Run the Automated Test Suite:
npm test --prefix server
TrustChain includes a comprehensive test suite validating cryptographic ledger immutability and physical packaging DNA matching:
$ npm test --prefix server
βΆ TrustChain Ledger Engine Integrity Suite
β 1. Genesis block creation and chain validation
β 2. Appending custody blocks and verifying unbroken chain
β 3. Single-field tamper detection test (tampering breaks SHA-256 pointer)
β TrustChain Ledger Engine Integrity Suite (4.5ms)
βΆ Packaging DNA & Perceptual Hash Engine Suite
β 1. Normalization and 64-bit binary expansion
β 2. Authentic identical DNA evaluates to 100% similarity
β 3. Minor sensor noise (1-2 bit flips) maintains authentic status (>85%)
β 4. Counterfeit / cloned packaging DNA triggers mismatch (<85%) and clone alert
β 5. Perceptual hash computation from base64 image strings
β Packaging DNA & Perceptual Hash Engine Suite (2.6ms)
βΉ tests 10 | pass 10 | fail 0- Framework Preset: Vite
- Root Directory:
client - Build Command:
npm run build - Output Directory:
dist - Environment Variable:
VITE_API_URLset to your Render backend URL (e.g.https://trustchain-api.onrender.comor local fallback/api).
- Environment: Node.js
- Root Directory:
server(or repository root withnode start.js) - Build Command:
npm install - Start Command:
node src/index.js - Environment Variables:
PORT:5000(or dynamic$PORT)NODE_ENV:productionJWT_SECRET:trustchain_production_secret_omnikon_2026
- Core Ledger Engine: SHA-256 immutable block creation & single-field tamper detection.
- Packaging DNA Engine: 64-bit pHash comparison & 8Γ8 bit visual blueprint.
- Impossible-Travel Engine: Real-time geo-velocity physics calculations.
- Swarm Multi-Sig Consensus: Counter-signature verification for custody transfers.
- Cold-Chain-Fused Hashes: Temperature/humidity telemetry integration with spoilage flags.
- Silent Regulatory Trip-Wire: Background alert channel with incident geo-coordinates.
- Zero-Knowledge Proofs: zk-SNARK authentic custody proof generator.
- AI Regulatory Co-Pilot: Interactive intelligence assistant for threat analysis.
- Role-Based Portals: Manufacturer, Distributor, Pharmacy, Regulator, & Consumer PWA.
- Live Deployments Verified: Vercel frontend and Render backend operational.
Developed for OMNIKON 2026 Hackathon (Problem Statement: OMNI_CYBERTECH_5).
Licensed under the MIT License.