Skip to content

narasim-teja/chainSpeed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— ChainSpeed - Secure Drive-to-Earn with TEE Technology

Revolutionary mobile app that uses hardware-backed TEE security to track driving speed, rewards safe driving behavior, and generates court-admissible evidence for legal protection.

๐ŸŒŸ Overview

ChainSpeed combines iOS Secure Enclave TEE technology with multi-chain blockchain infrastructure to create the world's first legally-admissible speed tracking system that rewards safe driving. Built during a hackathon, this app addresses three major markets: the $6B annual speeding ticket industry, the $200B insurance data market, and the growing drive-to-earn ecosystem.

๐ŸŽฏ Key Features

  • ๐Ÿ” Hardware-Backed Security: Real iOS Secure Enclave integration for tamper-proof speed records
  • โš–๏ธ Legal Protection: Generate court-admissible evidence against false speeding tickets
  • ๐Ÿ’ฐ Drive-to-Earn: Earn XP for safe driving, redeem for real gift cards (Target, Netflix)
  • ๐Ÿ”— Multi-Chain: Hedera for legal records, Zircuit for rewards
  • ๐Ÿ“ฑ Seamless UX: Privy embedded wallets with gasless transactions
  • ๐Ÿ“Š Privacy-First: Anonymous data aggregation for traffic insights

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Native  โ”‚โ”€โ”€โ”€โ–ถโ”‚  Privy Wallet    โ”‚โ”€โ”€โ”€โ–ถโ”‚ Multi-Chain     โ”‚
โ”‚   + TEE Securityโ”‚    โ”‚  Gasless Txns    โ”‚    โ”‚ Deployment      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                        โ”‚                        โ”‚
         โ–ผ                        โ–ผ                        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  iOS Secure     โ”‚    โ”‚  Merkle Trees    โ”‚    โ”‚  Legal Proof    โ”‚
โ”‚  Enclave        โ”‚    โ”‚  30s Checkpoints โ”‚    โ”‚  Generation     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Smart Contract Deployments

Hedera Testnet

Zircuit Testnet

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • iOS device with Face ID/Touch ID (for TEE features)
  • Expo CLI or Expo Go app

Installation

# Clone the repository
git clone https://github.com/narasim-teja/chainSpeed.git
cd chainSpeed

# Install dependencies
yarn install

# Start the development server
yarn start

# Run on iOS
yarn ios

Environment Setup

Create your Privy account and update app.json:

{
  "expo": {
    "extra": {
      "privyAppId": "your-privy-app-id",
      "privyClientId": "your-privy-client-id"
    }
  }
}

๐Ÿ’ก How It Works

1. TEE Security Layer

// Real iOS Secure Enclave integration
const teeService = getTEECryptoService();
await teeService.initialize(); // Generate hardware keys
await teeService.authenticateSession(); // Face ID auth
const signature = await teeService.signSpeedData(speedRecord); // Hardware signing

2. Speed Tracking

  • GPS + accelerometer data collected every second
  • Each record signed by Secure Enclave with Face ID protection
  • 30-second Merkle tree checkpoints for efficient verification

3. Multi-Chain Deployment

  • Hedera: Stores legal speed checkpoints (low cost, enterprise security)
  • Zircuit: Processes XP rewards (enhanced security for user assets)

4. Drive-to-Earn Mechanics

  • 1 XP per safe mile (under 75 mph speed limit)
  • Streak bonuses for consecutive safe driving days
  • Real gift cards (Target, Netflix) redeemable with XP

๐Ÿ”ง Key Technologies

Mobile Stack

  • React Native + Expo: Cross-platform mobile development
  • TypeScript: Type-safe development
  • iOS Secure Enclave: Hardware-backed cryptographic signing
  • Multi-sensor fusion: GPS, accelerometer, gyroscope validation

Blockchain Stack

  • Hedera: Primary blockchain for legal records
  • Zircuit: Secondary chain for rewards system
  • Privy: Embedded wallets and gasless transactions
  • Viem: Ethereum interactions

Security Features

  • TEE Hardware Signing: Tamper-proof speed record signatures
  • Merkle Trees: Efficient cryptographic proofs
  • Chain Linking: Sequential record validation
  • Anonymous Aggregation: Privacy-preserving data insights

๐Ÿ“ฑ App Structure

chainspeed/
โ”œโ”€โ”€ app/                    # Expo Router screens
โ”‚   โ”œโ”€โ”€ index.tsx          # Main tracking screen
โ”‚   โ”œโ”€โ”€ rewards.tsx        # XP and gift card redemption
โ”‚   โ””โ”€โ”€ profile.tsx        # Legal proof generation
โ”œโ”€โ”€ components/            # Reusable UI components
โ”œโ”€โ”€ services/              # Core business logic
โ”‚   โ”œโ”€โ”€ TEECryptoService.ts      # Secure Enclave integration
โ”‚   โ”œโ”€โ”€ LocationService.ts       # GPS tracking
โ”‚   โ”œโ”€โ”€ MerkleService.ts         # Checkpoint creation
โ”‚   โ”œโ”€โ”€ BlockchainService.ts     # Multi-chain interactions
โ”‚   โ””โ”€โ”€ XPService.ts             # Drive-to-earn logic
โ”œโ”€โ”€ contracts/             # Smart contracts
โ”‚   โ”œโ”€โ”€ SpeedRegistry.sol        # Speed checkpoint storage
โ”‚   โ””โ”€โ”€ XPRewards.sol           # Drive-to-earn system
โ””โ”€โ”€ constants/             # Configuration

๐ŸŽฎ Usage Guide

Starting a Tracking Session

  1. Login: Seamless authentication with Privy
  2. TEE Setup: Initialize Secure Enclave with Face ID
  3. Start Tracking: Begin secure speed recording
  4. Drive Safely: Earn XP for staying under speed limits
  5. Generate Proofs: Create legal evidence when needed

Earning Rewards

  • Drive under 75 mph to earn 1 XP per mile
  • Maintain daily driving streaks for bonus XP
  • Redeem XP for real gift cards:
    • Target $10 = 1,000 XP
    • Netflix $10 = 1,000 XP
    • Target $50 = 5,000 XP
    • Netflix $50 = 5,000 XP

Legal Defense

  1. Navigate to Profile โ†’ Generate Speed Proof
  2. Select date/time range of alleged violation
  3. Generate blockchain-verified proof document
  4. Present QR code evidence in court

๐Ÿ”’ Security Model

TEE Implementation

  • Hardware Key Generation: Private keys created in iOS Secure Enclave
  • Biometric Protection: Face ID/Touch ID required for signing
  • Tamper Detection: Chain-linked signatures prevent data manipulation
  • Session Management: 30-minute authenticated sessions

Privacy Protection

  • Local Processing: GPS data processed on-device
  • Anonymous Aggregation: City-level statistics only
  • Selective Disclosure: Users control data sharing
  • Encrypted Storage: Sensitive data encrypted at rest

๐ŸŒ Market Impact

Problems Solved

  • $6B Speeding Tickets: Unfair violations with no defense mechanism
  • $200B Insurance Data: Companies profit while drivers get nothing
  • Drive-to-Earn Gap: No real-world utility in existing apps

Revenue Model

  • User Rewards: XP system funded by data insights
  • Insurance Partnerships: Anonymous safe driving analytics
  • Traffic Data: City planning and navigation services
  • Legal Services: Premium proof generation features

๐Ÿ› ๏ธ Development

Building for Production

# Build for iOS
yarn ios --configuration Release

# Build for Android
yarn android --variant=release

# Deploy smart contracts
cd contracts
npx hardhat deploy --network hedera-testnet
npx hardhat deploy --network zircuit-testnet

Testing

# Run tests
yarn test

# Test TEE functionality (requires physical iOS device)
yarn test:tee

# Test blockchain integration
yarn test:contracts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors