# Project export: Cipher Shield

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2025
- Tagline: Making discrimination mathematically impossible via the blockchain & homomorphic encryption
- Devpost: https://devpost.com/software/cipher-shield
- GitHub: https://github.com/zoraizmohammad/treehacks-2025
- Video: https://www.youtube.com/embed/KuZTRNEq4pU?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Result: winner (Taisu Ventures: Next-Gen Web3 Security Award (4x Deeper Network Air + 1 NGRAVE cold wallet))
- Team: 4 GitHub contributor(s) — gpt-engineer-app[bot] (79 commits), Adel Müürsepp (24 commits), Mohammad Zoraiz (23 commits), SoniaBendre (19 commits)

## Devpost submission (written by the team)

### Inspiration

The inspiration for our project came from a problem based approach to ideation. We as students fill out countless job applications, and each one asks for demographic data. Most simply opt out as there seems to be no tangible benefit. In fact, there seems to only exist a potential downside: that it may be illegally misused to negatively affect your application. And yet, demographic collection does serve a large social purpose for society, specifically for detecting trends that may expose discrimination. In numerous cases, including employment, healthcare, loans, and credit cards, collecting demographic data is actually mandated by the federal government. We figured that in the era of decentralization and advanced encryption schemes, there is no reason for misuse of this information to even be mathematically possible.

### What it does

Cipher Shield acts as a trusted third party, providing completely secure data aggregation services via the blockchain. We empower companies to extract aggregate statistical insights from homomorphically encrypted data, thus making it impossible to profile individuals based on their protected data.

### How we built it

Blockchain: The chain is a critical component of our architecture and business model since it accelerates trust in our services. Every aggregation request is stored on the chain, creating an immutable, public record. Before any homomorphic computation is initiated, our smart contract performs critical on-chain validation - a transparent verification that ensures enough records exist to make reverse engineering mathematically impossible. If there aren't enough data points to maintain statistical anonymity, the contract automatically rejects the request. Once the request is validated and the computation is complete, the final aggregated result is also stored on chain, creating an audit trail of our services that companies can trust - we can't nullify data because every step is permanently and publicly verifiable on the blockchain. Dealing with advanced encryption schemes and blockchain operations, our business logic was written entirely in C++ and solidity. We leveraged OpenFHE homomorphic encryption operations and key generation. As a B2B product, our demo needed to include an entire demo business to use our product, which required a whole other backend+frontend pair.

### Challenges we ran into

We ran into a number of challenges while building the product: Implementing our design of the homomorphic encryption in OpenFHE library, specifically with the dual private key setup which did not come as a out of the box solution. Writing the implementation for the backend responsible for the data aggregation in C++ and facilitating the key exchange with correct serialization, deserialization. Managing the large payloads of ciphertext in the communications between company and server and storing ciphertext.

### Accomplishments we're proud of

We started off as 4 complete strangers with incredibly varying interests and skillsets and we were able to collaborate seamlessly. Together, we created the first ever implementation of a split key homomorphic encryption scheme that’s also verified through blockchain technology. We learned a lot about homorphic encryption as well as blockchain. We were able to intergrate the full stack of the application together and make all of the parts of the system working locally, with all of the Customer Data, Company/Organization, and Authority.

### What we learned

We learned about how to implement Homomorphic Encryption libraries and packages and alter their fundamentals to be able to work with split keys. We learned about the different ways that data security and insurance is important in B2B SaaS solutions, as well as potential business market ideas that could benefit both business and consumer at the same time. We also learned about the integration of Web-2 with Web-3 technology as well as integrating visualizations on the full-stack end despite coming in with very limited knowledge about blockchain. Moreover, we also learned about creating front-end web applications as well as a balance of creativity, inspiration, and feasibility when implementing a large scale and ambitious project. We also learned about the importance of Web-3 in web-application security.

### What's next

We believe Cipher Shield should mediate the demographic collection and protected data collection processes of every company in America, and we believe this will have transformative societal outcomes in mitigating discrimination. The data aggregation capabilities of our scheme extend far beyond single company aggregation, but can even be used to securely combine hospital datasets. To encourage companies to adopt our tech, we would also want to create an easy to use SDK for organizations, companies, and industries less knowledgeable on the prospect and understanding of Blockchain and encryption. Furthermore, the ability to directly create a form or application directly on Cipher Shield and embed it into any company or organizations’ website directly through a Web Embedding that CipherShield uses would be essential to seamless adoption.

## README (from the GitHub repository)

# CipherShield

**Cipher Shield** is a decentralized data aggregation platform that leverages advanced **homomorphic encryption** and **blockchain** technology to provide secure, privacy-preserving insights. This document outlines the inspiration behind our project, how it works, our architecture, the challenges we faced, our learnings, and our future roadmap.

## Table of Contents
- [Inspiration](#inspiration)
- [What It Does](#what-it-does)
- [How We Built It](#how-we-built-it)
- [Challenges We Ran Into](#challenges-we-ran-into)
- [Accomplishments That We’re Proud Of](#accomplishments-that-were-proud-of)
- [What We Learned](#what-we-learned)
- [What’s Next for Cipher Shield](#whats-next-for-cipher-shield)

## Inspiration
The inspiration for our project came from a **problem-based approach** to ideation. As students, we frequently fill out job applications that require demographic data. Most applicants simply opt out, as there appears to be no tangible benefit—only a potential downside if the information is **illegally misused** to negatively affect applications.

> **Note:** Despite these concerns, demographic collection is crucial for detecting trends that may expose discrimination. In fields like **employment**, **healthcare**, **loans**, and **credit cards**, collecting this data is often mandated by the federal government.  
>  
> In an era defined by **decentralization** and advanced **encryption schemes**, we believe there is no reason for such sensitive information to be misused, rendering harmful practices **mathematically impossible**.

## What It Does
**Cipher Shield** serves as a trusted third party that provides secure data aggregation services via the **blockchain**. It empowers companies to extract aggregate statistical insights from **homomorphically encrypted data**, ensuring that individual profiles remain completely private.

## How We Built It
### Blockchain Integration
- **Immutable Records:** Every aggregation request is stored on the blockchain, creating a transparent, permanent record.
- **On-Chain Validation:**  
  Before any homomorphic computation begins, our smart contract conducts a critical on-chain validation to ensure that there are enough records to prevent reverse engineering.  
  - If insufficient data points exist, the contract automatically **rejects the request**.
- **Audit Trail:**  
  Once validated and computed, the aggregated result is stored on-chain, ensuring every step is permanently verifiable.

### Technology Stack
- **Business Logic:** Written entirely in `C++` and `solidity` to handle complex encryption schemes and blockchain operations.
- **Encryption:** Utilizes the **OpenFHE** library for homomorphic encryption operations and key generation.
- **Demo Ecosystem:** As a B2B product, our demo features a full demo business, which necessitated a complete backend and frontend solution.

## Challenges We Ran Into
We encountered several challenges during the development process:
- **Homomorphic Encryption Implementation:**  
  Implementing our custom design in the **OpenFHE** library, particularly with the dual private key setup that wasn’t available out of the box.
- **Backend Development:**  
  Developing the backend in `C++` to manage data aggregation and ensuring the proper serialization/deserialization for key exchange.
- **Ciphertext Management:**  
  Handling large payloads of ciphertext in communications between the company and server, as well as storing this data securely.

## Accomplishments That We’re Proud Of
- **Pioneering Implementation:**  
  Created the **first-ever implementation** of a split key homomorphic encryption scheme that is also verified through blockchain technology.
- **Deep Technical Insights:**  
  Gained extensive knowledge about **homomorphic encryption** and **blockchain** technologies.
- **Full-Stack Integration:**  
  Successfully integrated the complete stack of the application, ensuring that all components—including Customer Data, Company/Organization interfaces, and the Authority layer—worked seamlessly together in a local environment.

## What We Learned
During the project, we expanded our knowledge in several key areas:
- **Advanced Encryption Techniques:**  
  Implementing and modifying homomorphic encryption libraries to support split keys.
- **Data Security in B2B SaaS:**  
  Understanding the significance of data security and insurance in B2B solutions, and identifying market opportunities that benefit both businesses and consumers.
- **Web Integration:**  
  Integrating **Web-2** with **Web-3** technologies, including the creation of full-stack visualizations and blockchain integrations, even with limited initial experience.
- **Full-Stack Development:**  
  Building robust front-end applications and learning to balance creativity with technical feasibility.
- **Web-3 Security:**  
  Recognizing the crucial role of Web-3 in enhancing web application security.

## What’s Next for Cipher Shield
We envision Cipher Shield as the standard for mediating demographic and protected data collection across American companies—driving transformative societal outcomes in mitigating discrimination.

### Future Plans:
- **Scalable Data Aggregation:**  
  Extending our capabilities to securely combine datasets from multiple sources (e.g., hospital records).
- **Developer SDK:**  
  Creating an easy-to-use SDK for organizations and industries that are less familiar with blockchain and encryption.
- **Seamless Integration:**  
  Developing a web embedding feature to allow companies to directly integrate a Cipher Shield form or application into their websites.

---


## Detected evidence (automated analysis)

Indexed codebase: 175 recognized source files, 999 KB.
- C (language) — detected in the code
- C++ (language) — detected in the code
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- React (technology) — detected in the code
- Solidity (language) — detected in the code
- Supabase (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- TypeScript (language) — detected in the code
- Node.js (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (120 of 197)

```
blockchain/.gitignore
blockchain/api/company-mock-api.ts
blockchain/api/server.ts
blockchain/contracts/PrivateDataAggregator.sol
blockchain/hardhat.config.ts
blockchain/ignition/modules/Lock.ts
blockchain/package.json
blockchain/README.md
blockchain/scripts/deploy.ts
blockchain/scripts/listener.ts
blockchain/scripts/test-aggregation.ts
blockchain/scripts/test-external-data.ts
blockchain/scripts/verify-request.ts
blockchain/test/Lock.ts
blockchain/tsconfig.json
ciphertext-landing/.gitignore
ciphertext-landing/bun.lockb
ciphertext-landing/components.json
ciphertext-landing/eslint.config.js
ciphertext-landing/index.html
ciphertext-landing/package.json
ciphertext-landing/postcss.config.js
ciphertext-landing/README.md
ciphertext-landing/src/App.css
ciphertext-landing/src/App.tsx
ciphertext-landing/src/components/ParticleBackground.tsx
ciphertext-landing/src/components/ui/accordion.tsx
ciphertext-landing/src/components/ui/alert-dialog.tsx
ciphertext-landing/src/components/ui/alert.tsx
ciphertext-landing/src/components/ui/aspect-ratio.tsx
ciphertext-landing/src/components/ui/avatar.tsx
ciphertext-landing/src/components/ui/badge.tsx
ciphertext-landing/src/components/ui/breadcrumb.tsx
ciphertext-landing/src/components/ui/button.tsx
ciphertext-landing/src/components/ui/calendar.tsx
ciphertext-landing/src/components/ui/card.tsx
ciphertext-landing/src/components/ui/carousel.tsx
ciphertext-landing/src/components/ui/chart.tsx
ciphertext-landing/src/components/ui/checkbox.tsx
ciphertext-landing/src/components/ui/collapsible.tsx
ciphertext-landing/src/components/ui/command.tsx
ciphertext-landing/src/components/ui/context-menu.tsx
ciphertext-landing/src/components/ui/dialog.tsx
ciphertext-landing/src/components/ui/drawer.tsx
ciphertext-landing/src/components/ui/dropdown-menu.tsx
ciphertext-landing/src/components/ui/form.tsx
ciphertext-landing/src/components/ui/hover-card.tsx
ciphertext-landing/src/components/ui/input-otp.tsx
ciphertext-landing/src/components/ui/input.tsx
ciphertext-landing/src/components/ui/label.tsx
ciphertext-landing/src/components/ui/menubar.tsx
ciphertext-landing/src/components/ui/navigation-menu.tsx
ciphertext-landing/src/components/ui/pagination.tsx
ciphertext-landing/src/components/ui/popover.tsx
ciphertext-landing/src/components/ui/progress.tsx
ciphertext-landing/src/components/ui/radio-group.tsx
ciphertext-landing/src/components/ui/resizable.tsx
ciphertext-landing/src/components/ui/scroll-area.tsx
ciphertext-landing/src/components/ui/select.tsx
ciphertext-landing/src/components/ui/separator.tsx
ciphertext-landing/src/components/ui/sheet.tsx
ciphertext-landing/src/components/ui/sidebar.tsx
ciphertext-landing/src/components/ui/skeleton.tsx
ciphertext-landing/src/components/ui/slider.tsx
ciphertext-landing/src/components/ui/sonner.tsx
ciphertext-landing/src/components/ui/switch.tsx
ciphertext-landing/src/components/ui/table.tsx
ciphertext-landing/src/components/ui/tabs.tsx
ciphertext-landing/src/components/ui/textarea.tsx
ciphertext-landing/src/components/ui/toast.tsx
ciphertext-landing/src/components/ui/toaster.tsx
ciphertext-landing/src/components/ui/toggle-group.tsx
ciphertext-landing/src/components/ui/toggle.tsx
ciphertext-landing/src/components/ui/tooltip.tsx
ciphertext-landing/src/components/ui/use-toast.ts
ciphertext-landing/src/components/WorkflowSection.tsx
ciphertext-landing/src/hooks/use-mobile.tsx
ciphertext-landing/src/hooks/use-toast.ts
ciphertext-landing/src/index.css
ciphertext-landing/src/lib/utils.ts
ciphertext-landing/src/main.tsx
ciphertext-landing/src/pages/CompanySignup.tsx
ciphertext-landing/src/pages/Index.tsx
ciphertext-landing/src/pages/NotFound.tsx
ciphertext-landing/src/pages/SurveyCreation.tsx
ciphertext-landing/src/vite-env.d.ts
ciphertext-landing/tailwind.config.ts
ciphertext-landing/tsconfig.app.json
ciphertext-landing/tsconfig.json
ciphertext-landing/tsconfig.node.json
ciphertext-landing/vite.config.ts
diagrams/Untitled Diagram.drawio
frontend/.gitignore
frontend/bun.lockb
frontend/components.json
frontend/eslint.config.js
frontend/index.html
frontend/package.json
frontend/postcss.config.js
frontend/README.md
frontend/src/App.css
frontend/src/App.tsx
frontend/src/components/AggregationButton.tsx
frontend/src/components/Header.tsx
frontend/src/components/health-form/AdditionalHealthInfo.tsx
frontend/src/components/health-form/BasicHealthInfo.tsx
frontend/src/components/health-form/SecurityInfo.tsx
frontend/src/components/SecurityInfo.tsx
frontend/src/components/ui/accordion.tsx
frontend/src/components/ui/alert-dialog.tsx
frontend/src/components/ui/alert.tsx
frontend/src/components/ui/aspect-ratio.tsx
frontend/src/components/ui/avatar.tsx
frontend/src/components/ui/badge.tsx
frontend/src/components/ui/breadcrumb.tsx
frontend/src/components/ui/button.tsx
frontend/src/components/ui/calendar.tsx
frontend/src/components/ui/card.tsx
frontend/src/components/ui/carousel.tsx
frontend/src/components/ui/chart.tsx
[77 more files omitted for size]
```

### Dependencies

- blockchain/package.json: @nomicfoundation/hardhat-toolbox@^2.0.2, @nomiclabs/hardhat-ethers@^2.2.3, @openzeppelin/contracts@^4.9.3, @types/cors@^2.8.17, @types/express@^4.17.21, @types/node@^20.11.19, @typescript-eslint/eslint-plugin@^7.0.1, @typescript-eslint/parser@^7.0.1, axios@^1.6.7, cors@^2.8.5, dotenv@^16.4.4, eslint@^8.56.0, ethers@^5.7.2, express@^4.18.2, hardhat@^2.14.0, prettier@^3.2.5, ts-node@^10.9.2, typescript@^5.3.3
- ciphertext-landing/package.json: @eslint/js@^9.9.0, @hookform/resolvers@^3.9.0, @radix-ui/react-accordion@^1.2.0, @radix-ui/react-alert-dialog@^1.1.1, @radix-ui/react-aspect-ratio@^1.1.0, @radix-ui/react-avatar@^1.1.0, @radix-ui/react-checkbox@^1.1.1, @radix-ui/react-collapsible@^1.1.0, @radix-ui/react-context-menu@^2.2.1, @radix-ui/react-dialog@^1.1.2, @radix-ui/react-dropdown-menu@^2.1.1, @radix-ui/react-hover-card@^1.1.1, @radix-ui/react-label@^2.1.0, @radix-ui/react-menubar@^1.1.1, @radix-ui/react-navigation-menu@^1.2.0, @radix-ui/react-popover@^1.1.1, @radix-ui/react-progress@^1.1.0, @radix-ui/react-radio-group@^1.2.0, @radix-ui/react-scroll-area@^1.1.0, @radix-ui/react-select@^2.1.1, @radix-ui/react-separator@^1.1.0, @radix-ui/react-slider@^1.2.0, @radix-ui/react-slot@^1.1.0, @radix-ui/react-switch@^1.1.0, @radix-ui/react-tabs@^1.1.0, @radix-ui/react-toast@^1.2.1, @radix-ui/react-toggle@^1.1.0, @radix-ui/react-toggle-group@^1.1.0, @radix-ui/react-tooltip@^1.1.4, @tailwindcss/typography@^0.5.15, @tanstack/react-query@^5.56.2, @types/node@^22.5.5, @types/react@^18.3.3, @types/react-dom@^18.3.0, @vitejs/plugin-react-swc@^3.5.0, autoprefixer@^10.4.20, class-variance-authority@^0.7.1, clsx@^2.1.1, cmdk@^1.0.0, date-fns@^3.6.0, embla-carousel-react@^8.3.0, eslint@^9.9.0, eslint-plugin-react-hooks@^5.1.0-rc.0, eslint-plugin-react-refresh@^0.4.9, framer-motion@^12.4.3, globals@^15.9.0, input-otp@^1.2.4, lovable-tagger@^1.1.3, lucide-react@^0.462.0, next-themes@^0.3.0, postcss@^8.4.47, react@^18.3.1, react-day-picker@^8.10.1, react-dom@^18.3.1, react-hook-form@^7.53.0, react-resizable-panels@^2.1.3, react-router-dom@^6.26.2, recharts@^2.12.7, sonner@^1.5.0, tailwind-merge@^2.5.2, tailwindcss@^3.4.11, tailwindcss-animate@^1.0.7, typescript@^5.5.3, typescript-eslint@^8.0.1, vaul@^0.9.3, vite@^5.4.1, zod@^3.23.8
- frontend/package.json: @eslint/js@^9.9.0, @hookform/resolvers@^3.9.0, @radix-ui/react-accordion@^1.2.0, @radix-ui/react-alert-dialog@^1.1.1, @radix-ui/react-aspect-ratio@^1.1.0, @radix-ui/react-avatar@^1.1.0, @radix-ui/react-checkbox@^1.1.1, @radix-ui/react-collapsible@^1.1.0, @radix-ui/react-context-menu@^2.2.1, @radix-ui/react-dialog@^1.1.2, @radix-ui/react-dropdown-menu@^2.1.1, @radix-ui/react-hover-card@^1.1.1, @radix-ui/react-label@^2.1.0, @radix-ui/react-menubar@^1.1.1, @radix-ui/react-navigation-menu@^1.2.0, @radix-ui/react-popover@^1.1.1, @radix-ui/react-progress@^1.1.0, @radix-ui/react-radio-group@^1.2.0, @radix-ui/react-scroll-area@^1.1.0, @radix-ui/react-select@^2.1.1, @radix-ui/react-separator@^1.1.0, @radix-ui/react-slider@^1.2.0, @radix-ui/react-slot@^1.1.0, @radix-ui/react-switch@^1.1.0, @radix-ui/react-tabs@^1.1.0, @radix-ui/react-toast@^1.2.1, @radix-ui/react-toggle@^1.1.0, @radix-ui/react-toggle-group@^1.1.0, @radix-ui/react-tooltip@^1.1.4, @supabase/supabase-js@^2.48.1, @tailwindcss/typography@^0.5.15, @tanstack/react-query@^5.56.2, @types/node@^22.5.5, @types/react@^18.3.3, @types/react-dom@^18.3.0, @vitejs/plugin-react-swc@^3.5.0, autoprefixer@^10.4.20, class-variance-authority@^0.7.1, clsx@^2.1.1, cmdk@^1.0.0, d3@^7.9.0, date-fns@^3.6.0, embla-carousel-react@^8.3.0, eslint@^9.9.0, eslint-plugin-react-hooks@^5.1.0-rc.0, eslint-plugin-react-refresh@^0.4.9, ethers@^6.13.5, framer-motion@^12.4.3, globals@^15.9.0, input-otp@^1.2.4, lovable-tagger@^1.1.3, lucide-react@^0.462.0, next-themes@^0.3.0, postcss@^8.4.47, react@^18.3.1, react-day-picker@^8.10.1, react-dom@^18.3.1, react-hook-form@^7.53.0, react-resizable-panels@^2.1.3, react-router-dom@^6.26.2, recharts@^2.12.7, sonner@^1.5.0, tailwind-merge@^2.5.2, tailwindcss@^3.4.11, tailwindcss-animate@^1.0.7, typescript@^5.5.3, typescript-eslint@^8.0.1, vaul@^0.9.3, vite@^5.4.1, zod@^3.23.8

### Recent commits (newest first)

- Added all techspec and about project to ReadMe
- Update README.md
- Add 'ciphertext-landing/' from commit '5900219b40676d91fdd8e313d5ac3c5c85084976'
- adding the CSV viewer
- adding more edits to the dashboard
- adding more features
- Merge branch 'main' of https://github.com/zoraizmohammad/treehacks-2025
- adding worknight transaction data calls
- Blockchain added
- Update homepage description
- Merge branch 'main' of https://github.com/zoraizmohammad/treehacks-2025
- Update homepage text styling
- fix frontend dashboard
- Improve logo styling and placement
- Update button text
- Implement Company Signup Form
- Enlarge CipherShield component
- Reverted to edit edt-cbeeba18-677a-4d01-aeea-84e21e8a5332: "Fix CompanySignup component syntax error
- Update homepage design
- Fix CompanySignup component syntax error

## Key source files (fetched from GitHub, selected and truncated for size)

### blockchain/package.json

```
{
  "name": "blockchain",
  "version": "1.0.0",
  "description": "Blockchain component for private data aggregation",
  "main": "index.js",
  "scripts": {
    "compile": "hardhat compile",
    "test": "hardhat test",
    "deploy": "hardhat run scripts/deploy.ts",
    "deploy:local": "hardhat run scripts/deploy.ts --network localhost",
    "listener": "ts-node scripts/listener.ts",
    "api": "ts-node api/server.ts",
    "lint": "eslint . --ext .ts",
    "format": "prettier --write ."
  },
  "keywords": [
    "blockchain",
    "privacy",
    "homomorphic-encryption",
    "ethereum"
  ],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^2.0.2",
    "@nomiclabs/hardhat-ethers": "^2.2.3",
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/node": "^20.11.19",
    "@typescript-eslint/eslint-plugin": "^7.0.1",
    "@typescript-eslint/parser": "^7.0.1",
    "eslint": "^8.56.0",
    "hardhat": "^2.14.0",
    "prettier": "^3.2.5",
    "ts-node": "^10.9.2",
    "typescript": "^5.3.3"
  },
  "dependencies": {
    "@openzeppelin/contracts": "^4.9.3",
    "axios": "^1.6.7",
    "cors": "^2.8.5",
    "dotenv": "^16.4.4",
    "ethers": "^5.7.2",
    "express": "^4.18.2"
  }
}
```

### ciphertext-landing/package.json

```
{
  "name": "vite_react_shadcn_ts",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "build:dev": "vite build --mode development",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.9.0",
    "@radix-ui/react-accordion": "^1.2.0",
    "@radix-ui/react-alert-dialog": "^1.1.1",
    "@radix-ui/react-aspect-ratio": "^1.1.0",
    "@radix-ui/react-avatar": "^1.1.0",
    "@radix-ui/react-checkbox": "^1.1.1",
    "@radix-ui/react-collapsible": "^1.1.0",
    "@radix-ui/react-context-menu": "^2.2.1",
    "@radix-ui/react-dialog": "^1.1.2",
    "@radix-ui/react-dropdown-menu": "^2.1.1",
    "@radix-ui/react-hover-card": "^1.1.1",
    "@radix-ui/react-label": "^2.1.0",
    "@radix-ui/react-menubar": "^1.1.1",
    "@radix-ui/react-navigation-menu": "^1.2.0",
    "@radix-ui/react-popover": "^1.1.1",
    "@radix-ui/react-progress": "^1.1.0",
    "@radix-ui/react-radio-group": "^1.2.0",
    "@radix-ui/react-scroll-area": "^1.1.0",
    "@radix-ui/react-select": "^2.1.1",
    "@radix-ui/react-separator": "^1.1.0",
    "@radix-ui/react-slider": "^1.2.0",
    "@radix-ui/react-slot": "^1.1.0",
    "@radix-ui/react-switch": "^1.1.0",
    "@radix-ui/react-tabs": "^1.1.0",
    "@radix-ui/react-toast": "^1.2.1",
    "@radix-ui/react-toggle": "^1.1.0",
    "@radix-ui/react-toggle-group": "^1.1.0",
    "@radix-ui/react-tooltip": "^1.1.4",
    "@tanstack/react-query": "^5.56.2",
    "class-variance-authority": "^0.7.1",
    "clsx": "^2.1.1",
    "cmdk": "^1.0.0",
    "date-fns": "^3.6.0",
    "embla-carousel-react": "^8.3.0",
    "framer-motion": "^12.4.3",
    "input-otp": "^1.2.4",
    "lucide-react": "^0.462.0",
    "next-themes": "^0.3.0",
    "react": "^18.3.1",
    "react-day-picker": "^8.10.1",
    "react-dom": "^18.3.1",
    "react-hook-form": "^7.53.0",
    "react-resizable-panels": "^2.1.3",
    "react-router-dom": "^6.26.2",
    "recharts": "^2.12.7",
    "sonner": "^1.5.0",
    "tailwind-merge": "^2.5.2",
    "tailwindcss-animate": "^1.0.7",
    "vaul": "^0.9.3",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@eslint/js": "^9.9.0",
    "@tailwindcss/typography": "^0.5.15",
    "@types/node": "^22.5.5",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "@vitejs/plugin-react-swc": "^3.5.0",
    "autoprefixer": "^10.4.20",
    "eslint": "^9.9.0",
    "eslint-plugin-react-hooks": "^5.1.0-rc.0",
    "eslint-plugin-react-refresh": "^0.4.9",
    "globals": "^15.9.0",
    "lovable-tagger": "^1.1.3",
    "postcss": "^8.4.47",
    "tailwindcss": "^3.4.11",
    "typescript": "^5.5.3",
    "typescript-eslint": "^8.0.1",
    "vite": "^5.4.1"
  }
}

```

### frontend/package.json

```
{
  "name": "vite_react_shadcn_ts",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "build:dev": "vite build --mode development",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.9.0",
    "@radix-ui/react-accordion": "^1.2.0",
    "@radix-ui/react-alert-dialog": "^1.1.1",
    "@radix-ui/react-aspect-ratio": "^1.1.0",
    "@radix-ui/react-avatar": "^1.1.0",
    "@radix-ui/react-checkbox": "^1.1.1",
    "@radix-ui/react-collapsible": "^1.1.0",
    "@radix-ui/react-context-menu": "^2.2.1",
    "@radix-ui/react-dialog": "^1.1.2",
    "@radix-ui/react-dropdown-menu": "^2.1.1",
    "@radix-ui/react-hover-card": "^1.1.1",
    "@radix-ui/react-label": "^2.1.0",
    "@radix-ui/react-menubar": "^1.1.1",
    "@radix-ui/react-navigation-menu": "^1.2.0",
    "@radix-ui/react-popover": "^1.1.1",
    "@radix-ui/react-progress": "^1.1.0",
    "@radix-ui/react-radio-group": "^1.2.0",
    "@radix-ui/react-scroll-area": "^1.1.0",
    "@radix-ui/react-select": "^2.1.1",
    "@radix-ui/react-separator": "^1.1.0",
    "@radix-ui/react-slider": "^1.2.0",
    "@radix-ui/react-slot": "^1.1.0",
    "@radix-ui/react-switch": "^1.1.0",
    "@radix-ui/react-tabs": "^1.1.0",
    "@radix-ui/react-toast": "^1.2.1",
    "@radix-ui/react-toggle": "^1.1.0",
    "@radix-ui/react-toggle-group": "^1.1.0",
    "@radix-ui/react-tooltip": "^1.1.4",
    "@supabase/supabase-js": "^2.48.1",
    "@tanstack/react-query": "^5.56.2",
    "class-variance-authority": "^0.7.1",
    "clsx": "^2.1.1",
    "cmdk": "^1.0.0",
    "d3": "^7.9.0",
    "date-fns": "^3.6.0",
    "embla-carousel-react": "^8.3.0",
    "ethers": "^6.13.5",
    "framer-motion": "^12.4.3",
    "input-otp": "^1.2.4",
    "lucide-react": "^0.462.0",
    "next-themes": "^0.3.0",
    "react": "^18.3.1",
    "react-day-picker": "^8.10.1",
    "react-dom": "^18.3.1",
    "react-hook-form": "^7.53.0",
    "react-resizable-panels": "^2.1.3",
    "react-router-dom": "^6.26.2",
    "recharts": "^2.12.7",
    "sonner": "^1.5.0",
    "tailwind-merge": "^2.5.2",
    "tailwindcss-animate": "^1.0.7",
    "vaul": "^0.9.3",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@eslint/js": "^9.9.0",
    "@tailwindcss/typography": "^0.5.15",
    "@types/node": "^22.5.5",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "@vitejs/plugin-react-swc": "^3.5.0",
    "autoprefixer": "^10.4.20",
    "eslint": "^9.9.0",
    "eslint-plugin-react-hooks": "^5.1.0-rc.0",
    "eslint-plugin-react-refresh": "^0.4.9",
    "globals": "^15.9.0",
    "lovable-tagger": "^1.1.3",
    "postcss": "^8.4.47",
    "tailwindcss": "^3.4.11",
    "typescript": "^5.5.3",
    "typescript-eslint": "^8.0.1",
    "vite": "^5.4.1"
  }
}

```

### ciphertext-landing/src/main.tsx

```typescript
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import './index.css'

createRoot(document.getElementById("root")!).render(<App />);

```

### frontend/src/main.tsx

```typescript
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import './index.css'

createRoot(document.getElementById("root")!).render(<App />);

```

### ciphertext-landing/src/App.tsx

```typescript

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Index from "@/pages/Index";
import CompanySignup from "@/pages/CompanySignup";
import SurveyCreation from "@/pages/SurveyCreation";
import NotFound from "@/pages/NotFound";
import "./App.css";

function App() {
  return (
    <Router>
      <Routes>
        <Route path="/" element={<Index />} />
        <Route path="/company-signup" element={<CompanySignup />} />
        <Route path="/survey-creation" element={<SurveyCreation />} />
        <Route path="*" element={<NotFound />} />
      </Routes>
    </Router>
  );
}

export default App;

```

### frontend/src/App.tsx

```typescript

import { Toaster } from "@/components/ui/toaster";
import { Toaster as Sonner } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Index from "./pages/Index";
import WorkNight from "./pages/WorkNight";
import Form from "./pages/Form";
import NotFound from "./pages/NotFound";
import AdminDashboard from "./pages/Admin";
import TrustedLoans from "./pages/TrustedLoans";
import TrustedLoansAdmin from "./pages/TrustedLoansAdmin";

const queryClient = new QueryClient();

const App = () => (
  <QueryClientProvider client={queryClient}>
    <TooltipProvider>
      <Toaster />
      <Sonner />
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<Index />} />
          <Route path="/worknight" element={<WorkNight />} />
          <Route path="/worknight/admin" element={<AdminDashboard />} />
          <Route path="/trustedloans" element={<TrustedLoans />} />
          <Route path="/trustedloans/admin" element={<TrustedLoansAdmin />} />
          <Route path="/form" element={<Form />} />
          <Route path="/admin" element={<AdminDashboard />} />
          <Route path="*" element={<NotFound />} />
        </Routes>
      </BrowserRouter>
    </TooltipProvider>
  </QueryClientProvider>
);

export default App;

```

### blockchain/api/server.ts

```typescript
import express from 'express';
import { utils } from 'ethers';
import cors from 'cors';

const app = express();
// Increase JSON payload limit to 100MB to handle all records at once
app.use(express.json({ limit: '100mb' }));
app.use(cors());

// Simulated aggregation function
function aggregateData(encryptedData: string[], type: string): number {
    // For testing, we'll decrypt the mock data and perform the requested aggregation
    const decryptedData = encryptedData.map(row => {
        const hexString = row.startsWith('0x') ? row.slice(2) : row;
        const jsonString = utils.toUtf8String('0x' + hexString);
        return JSON.parse(jsonString).value;
    });

    let result: number;
    switch (type.toLowerCase()) {
        case 'sum':
            result = decryptedData.reduce((a, b) => a + b, 0);
            break;
        case 'average':
            result = decryptedData.reduce((a, b) => a + b, 0) / decryptedData.length;
            break;
        case 'count':
            result = decryptedData.length;
            break;
        case 'median': {
            const sorted = [...decryptedData].sort((a, b) => a - b);
            const mid = Math.floor(sorted.length / 2);
            result = sorted.length % 2 === 0
                ? (sorted[mid - 1] + sorted[mid]) / 2
                : sorted[mid];
            break;
        }
        default:
            throw new Error(`Unsupported aggregation type: ${type}`);
    }

    // Round to nearest integer
    return Math.round(result);
}

// Main aggregation endpoint
app.post('/api/aggregate', (req, res) => {
    try {
        const { requestId, aggregationType, encryptedData } = req.body;
        console.log(`Processing request ${requestId}`);
        console.log(`Aggregation type: ${aggregationType}`);
        console.log(`Number of records: ${encryptedData.length}`);

        // Perform aggregation
        const result = aggregateData(encryptedData, aggregationType);
        console.log(`Aggregation result (rounded): ${result}`);

        res.json({
            success: true,
            requestId,
            result,
            message: `Successfully aggregated ${encryptedData.length} records`
        });
    } catch (error: any) {
        console.error('Error processing request:', error);
        res.status(500).json({
            success: false,
            error: error.message
        });
    }
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`API server running on port ${PORT}`);
}); 
```

### ciphertext-landing/src/pages/Index.tsx

```typescript

import React from "react";
import ParticleBackground from "@/components/ParticleBackground";
import WorkflowSection from "@/components/WorkflowSection";
import { Button } from "@/components/ui/button";
import { motion } from "framer-motion";
import { ArrowRight, Shield, Database, Network } from "lucide-react";
import { useNavigate } from "react-router-dom";

const Index = () => {
  const navigate = useNavigate();
  
  const features = [
    {
      icon: <Shield className="w-6 h-6 text-white" />,
      title: "Secure & Private",
      description: "Advanced cryptographic protocols ensuring user privacy and data security",
    },
    {
      icon: <Database className="w-6 h-6 text-white" />,
      title: "Decentralized",
      description: "Distributed system architecture eliminating single points of failure",
    },
    {
      icon: <Network className="w-6 h-6 text-white" />,
      title: "Transparent",
      description: "Open-source algorithms with mathematical proofs of fairness",
    },
  ];

  return (
    <div className="min-h-screen relative">
      <ParticleBackground />
      
      {/* Hero Section */}
      <section className="relative pt-32 pb-24 px-6">
        <div className="container mx-auto max-w-6xl">
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ duration: 0.8 }}
            className="text-center"
          >
            <h1 className="text-6xl md:text-7xl lg:text-8xl font-bold mb-8 bg-gradient-to-r from-teal-200 to-cyan-200 bg-clip-text text-transparent">
              CipherShield
            </h1>
            <p className="text-2xl md:text-3xl mb-8 bg-gradient-to-r from-teal-200 to-cyan-200 bg-clip-text text-transparent">
              Making discrimination mathematically impossible
            </p>
            <p className="text-xl md:text-2xl text-gray-300 max-w-3xl mx-auto mb-12">
              Our innovative Web3 protocol ensures complete security, privacy, and trust through mathematical principles
            </p>
            <Button 
              className="bg-teal-500 hover:bg-teal-600 text-white rounded-full px-8 py-6 text-lg transition-all duration-300 transform hover:scale-105"
              onClick={() => navigate('/survey-creation')}
            >
              Companies Sign in Here <ArrowRight className="ml-2 h-5 w-5" />
            </Button>
          </motion.div>
        </div>
      </section>

      {/* Features Section */}
      <section className="py-24 px-6">
        <div className="container mx-auto max-w-6xl">
          <div className="grid grid-cols-1 md:grid-cols-3 gap-8">
            {features.map((feature, index) => (
              <motion.div
                key={index}
                initial={{ opacity: 0, y: 20 }}
                animate={{ opacity: 1, y: 0 }}
                transition={{ duration: 0.5, delay: index * 0.2 }}
                className="glass-card p-8 hover:transform hover:scale-105 transition-all duration-300 text-center"
              >
                <div className="mb-4 p-3 rounded-lg bg-teal-500/10 w-fit mx-auto">
                  {feature.icon}
                </div>
                <h3 className="text-xl font-semibold mb-3 text-white">
                  {feature.title}
                </h3>
                <p className="text-gray-300">
                  {feature.description}
                </p>
              </motion.div>
            ))}
          </div>
        </div>
      </section>

      {/* Workflow Section */}
      <WorkflowSection />
    </div>
  );
};

export default Index;

```

### frontend/src/pages/Index.tsx

```typescript
import { useState } from "react";
import { motion } from "framer-motion";
import { useToast } from "@/hooks/use-toast";
import Header from "@/components/Header";
import BasicHealthInfo from "@/components/health-form/BasicHealthInfo";
import AdditionalHealthInfo from "@/components/health-form/AdditionalHealthInfo";
import SecurityInfo from "@/components/health-form/SecurityInfo";
import { HealthFormData } from "@/types/form";
import { getResponseVector } from "@/constants/vectorMappings";

interface BasicHealthVector {
  firstName: string;
  lastName: string;
  email: string;
  age: string;
  height: string;
  weight: string;
  bloodType: string;
}

interface AdditionalHealthVector {
  exerciseFrequency: string;
  sleepHours: string;
  sleepQuality: string;
  dietaryBalance: string;
  mentalHealth: string;
  energyLevels: string;
  generalHealth: string;
  chronicPain: string;
  screenTimeImpact: string;
  mindfulnessPractices: string;
  writtenResponses: {
    dietaryBalance: string;
    mentalHealth: string;
    generalHealth: string;
    chronicPain: string;
    screenTimeImpact: string;
    mindfulnessPractices: string;
  };
}

type EncryptableData = BasicHealthVector | AdditionalHealthVector;

const encryptData = (data: EncryptableData, publicKey: string) => {
  return JSON.stringify(data) + `_encrypted_with_${publicKey}`;
};

const initialFormData: HealthFormData = {
  firstName: "David",
  lastName: "Smith",
  email: "david.smith@university.edu",
  age: "20",
  height: "175",
  weight: "70",
  bloodType: "A+",
  exerciseFrequency: "3",
  sleepHours: "7",
  sleepQuality: "good",
  dietaryBalance: "",
  mentalHealth: "",
  energyLevels: "moderate",
  generalHealth: "",
  chronicPain: "",
  screenTimeImpact: "",
  mindfulnessPractices: "",
  responseType: "dropdown",
  writtenResponses: {
    dietaryBalance: "",
    mentalHealth: "",
    generalHealth: "",
    chronicPain: "",
    screenTimeImpact: "",
    mindfulnessPractices: ""
  }
};

const Index = () => {
  const [formData, setFormData] = useState<HealthFormData>(initialFormData);
  const [isSubmitted, setIsSubmitted] = useState(false);
  const { toast } = useToast();

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    
    // Create Basic Health Information vector
    const basicHealthVector: BasicHealthVector = {
      firstName: formData.firstName,
      lastName: formData.lastName,
      email: formData.email,
      age: formData.age,
      height: formData.height,
      weight: formData.weight,
      bloodType: formData.bloodType
    };

    // Create Additional Health Information vector with original responses
    const additionalHealthVector: AdditionalHealthVector = {
      exerciseFrequency: formData.exerciseFrequency,
      sleepHours: formData.sleepHours,
      sleepQuality: formData.sleepQuality,
      dietaryBalance: formData.dietaryBalance,
      mentalHealth: formData.mentalHealth,
      energyLevels: formData.energyLevels,
      generalHealth: formData.generalHealth,
      chronicPain: formData.chronicPain,
      screenTimeImpact: formData.screenTimeImpact,
      mindfulnessPractices: formData.mindfulnessPractices,
      writtenResponses: formData.writtenResponses
    };

    // Create vectorized version of the additional health information
    const localVectorizedData = {
      exerciseFrequency: formData.exerciseFrequency,
      sleepHours: formData.sleepHours,
      sleepQuality: formData.sleepQuality,
      energyLevels: formData.energyLevels,
      dietaryBalance: getResponseVector('dietaryBalance', formData.dietaryBalance),
      mentalHealth: getResponseVector('mentalHealth', formData.mentalHealth),
      generalHealth: getResponseVector('generalHealth', formData.generalHealth),
      chronicPain: getResponseVector('chronicPain', formData.chronicPain),
      screenTimeImpact: getResponseVector('screenTimeImpact', formData.screenTimeImpact),
      mindfulnessPractices: getResponseVector('mindfulnessPractices', formData.mindfulnessPractices),
      writtenResponses: formData.writtenResponses
    };

    // Create concatenated vector in specified order
    const userRawOutputMed = [
      ...getResponseVector('chronicPain', formData.chronicPain),
      ...getResponseVector('dietaryBalance', formData.dietaryBalance),
      ...getResponseVector('generalHealth', formData.generalHealth),
      ...getResponseVector('mentalHealth', formData.mentalHealth),
      ...getResponseVector('mindfulnessPractices', formData.mindfulnessPractices),
      ...getResponseVector('screenTimeImpact', formData.screenTimeImpact)
    ];

    const publicKey = "pk_demo123";
    const encryptedBasicData = encryptData(basicHealthVector, publicKey);
    const encryptedAdditionalData = encryptData(additionalHealthVector, publicKey);
    
    console.log('Basic Health Information Vector:', basicHealthVector);
    console.log('Original Additional Health Information:', additionalHealthVector);
    console.log('Vectorized Additional Health Information:', localVectorizedData);
    console.log('Concatenated User Raw Output Med Vector:', userRawOutputMed);

    toast({
      title: "Response Submitted Securely!",
      description: "Your data has been encrypted and sent.",
    });
    
    setIsSubmitted(true);
  };

  if (isSubmitted) {
    return (
      <div className="min-h-screen bg-[#1A1F2C]">
        <Header />
        <div className="max-w-4xl mx-auto p-6">
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={{ opacity: 1, y: 0 }}
            className="text-center"
          >
            <h1 className="text-5xl font-bold rainbow-text mb-8">Application Submitted!</h1>
            <div className="glass-card p-8 relative overflow-hidden">
              <div className="encryption-visualizer" />
              <p className="text-white text-lg">
                Thank you for your application. Your information is secure and protected through Dual Key homomorphic encryption.
            
[truncated — 1245 more characters]
```

[163 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]