Monetize sensitive documents without ever revealing the raw file to a server.
Features โข Demo โข Architecture โข Quick Start โข Tech Stack
Companies can't upload secrets to ChatGPT. Experts can't sell knowledge without piracy.
- Enterprises have sensitive documents (contracts, research, internal memos) but can't use AI tools due to privacy concerns
- Knowledge workers want to monetize their expertise but fear piracy and unauthorized distribution
- Current solutions require trusting centralized servers with your most valuable data
GhostContext solves both.
Instead of sending your private data to OpenAI, we download the AI model to your browser.
Your secrets never leave your device.
We built the world's first AI-powered decentralized knowledge marketplace that combines *on-chain access control, **decentralized storage, and *client-side inference to create a trustless data economy. Documents are encrypted locally, stored on Walrus, tokenized as NFTs on Sui, and queried using browser-based LLMsโenabling monetization without ever exposing plaintext to any server.
|
Files are encrypted on the user's device before going to Walrus. Plaintext never leaves the browser. |
Decryption rights are tied to Sui NFTs. No NFT โ No decryption. Simple. |
Documents are decrypted and processed fully inside the user's browser using a locally-run Llama-3 model. No internet required. No server inference. Zero data leakage. |
Running a local LLM (like Ollama or LM Studio) is NOT the same as GhostContext.
| Feature | Local LLM (Ollama/LM Studio) | GhostContext |
|---|---|---|
| Monetization | โ No way to sell access to your documents | โ Built-in marketplace with NFT-based access control |
| Access Control | โ Anyone with the file can use it | โ Smart contract-enforced permissions (pay-per-query) |
| Distribution | โ Must manually share files (piracy risk) | โ Encrypted storage + on-chain keys (piracy-proof) |
| Decentralization | โ Files stored locally or on your server | โ Decentralized storage (Walrus) + blockchain (Sui) |
| Revenue Tracking | โ No built-in payment or analytics | โ On-chain revenue tracking and query limits |
| Transferability | โ Can't transfer ownership of documents | โ NFTs are tradeable, keys transfer automatically |
| Discovery | โ No marketplace or search | โ Browse and purchase from global marketplace |
| Trust Model | โ Requires trusting the file sender | โ Trustless: Verify encryption + access on-chain |
*In short: Local LLMs let you chat with YOUR documents privately. GhostContext lets you *monetize and trade encrypted knowledge in a decentralized marketplace while maintaining the same privacy guarantees.
GhostContext supports multiple state-of-the-art language models optimized for browser inference:
| Model | Size | Speed | Quality | Use Case |
|---|---|---|---|---|
| Llama 3.2 1B | ~1GB | โก Fast | Good | Quick queries, mobile devices |
| Llama 3.2 3B | ~1.5GB | โกโก Medium-Fast | Very Good | Balanced performance |
| Phi-3 Mini | ~2GB | โกโก Medium | Good | Efficient reasoning |
| Mistral 7B | ~4GB | โกโกโก Slower | Excellent | Complex analysis |
| Qwen 2.5 1.5B | ~1GB | โก Fast | Good | Multilingual support |
Engine Options:
- WebLLM (Standard): Original implementation with full compatibility
- WeInfer (Optimized): ~3.76x faster with buffer reuse and memory optimization
Hardware Requirements:
- Minimum: 4GB RAM, Intel HD 5500+ / NVIDIA GTX 650+ / AMD HD 7750+
- Recommended: 8GB+ RAM, Modern GPU with WebGPU support
- Browser: Chrome 113+ or Edge 113+ with WebGPU enabled
Central hub for accessing all GhostContext features with a clean, modern interface.
- Local AI Models: Run Llama-3, Phi-3, Mistral, and Qwen models directly in your browser
- WebGPU Acceleration: Hardware-accelerated inference for fast responses
- WeInfer Optimization: ~3.76x faster inference with buffer reuse
- RAG Pipeline: Retrieval-Augmented Generation for accurate document-based answers
- Conversational Memory: Context-aware multi-turn conversations
- Source Citations: Track which pages information comes from
- Hybrid Search: Semantic + keyword search for better retrieval
- Client-Side Encryption: AES-256-GCM encryption in the browser
- Walrus Upload: Encrypted blobs stored on decentralized Walrus network
- NFT Minting: Create GhostContext NFTs with embedded encryption keys
- Access Control: Smart contract-based permission management
- Listing: Set price per query and list contexts for sale
- Browse Contexts: Discover encrypted knowledge from other users
- Category Filtering: General, Technical, Research, Education
- Purchase Queries: Buy access to encrypted documents
- Metrics Display: View total queries sold and revenue
- Modern UI: Codeforces-style cards with gradients and animations
- Query Management: Track remaining queries for purchased contexts
- One-Click Load: Decrypt and load purchased documents instantly
- Blob ID Display: Copy Walrus blob IDs for reference
- Receipt NFTs: On-chain proof of purchase with encryption keys
Visit: https://ghost-context-1.vercel.app
Watch the full demo: YouTube Demo
- Connect Wallet: Use Sui Wallet (Testnet)
- Select Engine: Choose WebLLM or WeInfer
- Load Model: Pick Llama-3.2 1B for fast inference
- Upload PDF: Drop any document (100% local processing)
- Ask Questions: Chat with your document using AI
- Encrypt & Mint: Create an NFT and list it on the marketplace
- Purchase: Buy access to other users' encrypted knowledge
Sui is the only blockchain fast enough for real-time AI commerce.
- โก Sub-Second Finality: Instant NFT minting and purchases (400ms average)
- ๐ฐ Low Gas Fees: Transactions cost <$0.01, making micro-payments viable
- ๐ฏ Object-Centric Model: Perfect for NFTs with embedded metadata (encryption keys)
- ๐ Move Language: Memory-safe smart contracts prevent common vulnerabilities
- ๐ Horizontal Scaling: Can handle millions of users without congestion
- ๐ซ Programmable NFTs: Dynamic access control and query tracking built-in
Alternative blockchains (Ethereum, Solana) either have:
- High gas fees (Ethereum: $5-50 per transaction)
- Network congestion issues
- Less flexible NFT standards
Walrus is the native decentralized storage layer for Sui, allowing us to bind Blob IDs directly to NFT Metadata objects efficiently.
- ๐ Native Sui Integration: Seamless blob storage with on-chain references
- ๐พ Cost-Effective: ~$0.10 per GB vs. $5-20 on competitors
- ๐ Decentralized: No single point of failure or censorship
- โก Fast Retrieval: Content-addressed storage with CDN-like performance
- ๐ Immutable: Once uploaded, blobs cannot be modified or deleted
- ๐ฆ Large File Support: Handle documents up to 1GB+
Why not IPFS/Arweave?
- IPFS requires pinning services (centralization risk)
- Arweave is expensive for frequent updates
- Neither integrate natively with Sui's object model
Seal enables policy-based encryption for enterprise use cases.
- ๐ฏ Policy-Based Access: Define complex access rules (time-based, role-based)
- ๐ Attribute-Based Encryption: Encrypt once, decrypt based on attributes
- ๐ข Enterprise Ready: Compliance with data governance requirements
- ๐ Key Rotation: Update encryption without re-uploading data
- ๐ฅ Multi-Party Access: Share with teams while maintaining control
Current Implementation: We use Web Crypto API (AES-256-GCM) for MVP simplicity.
Future: Seal integration will enable advanced features like:
- Time-locked documents (auto-expire after X days)
- Role-based access (only "researchers" can decrypt)
- Conditional access (require 2-of-3 signatures)
flowchart TD
%% Styling
classDef browser fill:#FFD700,stroke:#333,stroke-width:2px,color:#000;
classDef chain fill:#87CEEB,stroke:#333,stroke-width:2px,color:#000;
classDef storage fill:#98FB98,stroke:#333,stroke-width:2px,color:#000;
subgraph Creator ["๐ค Creator Flow (Browser)"]
Raw["๐ Raw PDF Document"]
Encrypt["๐ AES-256-GCM Encryption"]
KeyGen["๐ Generate Random Key/IV"]
Raw --> KeyGen
KeyGen --> Encrypt
end
subgraph Infrastructure ["๐ Decentralized Protocol"]
Walrus[(" Walrus Storage\n(Encrypted Blobs Only)")]
Sui[("Sui Smart Contract\n(Marketplace & Access Control)")]
end
subgraph Consumer ["๐ฅ Buyer Flow (Browser + WebGPU)"]
Pay["๐ฐ Purchase (SUI Token)"]
Fetch["๐ฅ Fetch Encrypted Blob"]
Decrypt["๐ Client-Side Decryption"]
Vector["๐ RAG Vector Store (IndexedDB)"]
Inference[" WebLLM Inference (Local GPU)"]
end
%% Connections - Upload Flow
Encrypt -- "1. Upload Encrypted Blob" --> Walrus
Walrus -- "2. Return Blob ID" --> Creator
Creator -- "3. Mint NFT (Blob ID + Encr. Key)" --> Sui
%% Connections - Purchase Flow
Pay -- "4. Buy Access" --> Sui
Sui -- "5. Deliver NFT (Key + Blob ID)" --> Consumer
%% Connections - Usage Flow
Walrus -.->|"6. Download Blob"| Fetch
Fetch --> Decrypt
Decrypt --> Vector
Vector --> Inference
%% Apply Styles
class Creator,Consumer browser;
class Sui chain;
class Walrus storage;
-
Frontend (React + TypeScript)
- Modern UI with Tailwind CSS
- WebGPU-accelerated AI inference
- Client-side encryption/decryption
-
Smart Contracts (Move on Sui)
- GhostContext NFTs with embedded keys
- Query-based access control
- Marketplace with revenue tracking
-
Storage (Walrus)
- Decentralized blob storage
- Encrypted document hosting
- Content-addressed retrieval
-
AI Engine (WebLLM)
- Browser-based LLM inference
- RAG pipeline for document Q&A
- Vector embeddings for semantic search
ghostcontext/
โโโ contracts/ # Sui Move smart contracts
โ โโโ source/
โ โ โโโ ghostcontext.move # Main contract with NFT logic
โ โโโ Move.toml # Contract configuration
โ โโโ build/ # Compiled contracts
โ
โโโ src/
โ โโโ components/ # React components
โ โ โโโ Home.tsx # Chat interface with RAG
โ โ โโโ HomeNew.tsx # Dashboard landing
โ โ โโโ Vault.tsx # Encryption & minting
โ โ โโโ Marketplace.tsx # Browse & purchase
โ โ โโโ MyPurchases.tsx # Manage bought contexts
โ โ โโโ Navbar.tsx # Navigation bar
โ โ โโโ landingPage.tsx # Public landing page
โ โ โโโ ui/ # Reusable UI components
โ โ โโโ Card.tsx
โ โ โโโ Button.tsx
โ โ โโโ Input.tsx
โ โ
โ โโโ services/ # Core business logic
โ โ โโโ rag-engine.ts # RAG pipeline (WebLLM)
โ โ โโโ rag-engine-weinfer.ts # Optimized RAG (WeInfer)
โ โ โโโ llm-client.ts # LLM interface
โ โ โโโ embedder.ts # Text embedding
โ โ โโโ vector-store.ts # In-memory vector DB
โ โ โโโ pdf-parser.ts # PDF text extraction
โ โ โโโ ghostcontext-payload.ts # Data serialization
โ โ
โ โโโ ghostcontext/ # Encryption & Walrus
โ โ โโโ crypto.ts # AES-256-GCM encryption
โ โ โโโ walrus.ts # Walrus API client
โ โ โโโ encryption-workflow.ts # End-to-end flow
โ โ
โ โโโ hooks/ # React hooks
โ โโโ lib/ # Utilities
โ โโโ App.tsx # Main app component
โ โโโ main.tsx # Entry point
โ โโโ theme.css # Global styles
โ
โโโ scripts/ # Deployment scripts
โ โโโ deploy.ts # Contract deployment
โ โโโ test-seal.ts # Encryption testing
โ
โโโ public/ # Static assets
โโโ .env # Environment variables
โโโ package.json # Dependencies
โโโ vite.config.ts # Vite configuration
โโโ README.md # This file
- โ React 18 - UI framework
- ๐ TypeScript - Type safety
- ๐จ Tailwind CSS - Styling
- ๐ญ Framer Motion - Animations
- ๐งญ React Router - Navigation
- ๐ค WebLLM - Browser-based LLM inference
- ๐ง Transformers.js - Text embeddings
- ๐ Custom RAG Pipeline - Document Q&A
- ๐ Vector Store - Semantic search
- โก WebGPU - Hardware acceleration
- ๐ท Sui Network - Layer 1 blockchain
- ๐ Move Language - Smart contracts
- ๐ซ NFT Standard - Token-gated access
- ๐ฐ SUI Token - Payments
- ๐ Walrus - Decentralized blob storage
- ๐ Web Crypto API - AES-256-GCM encryption
- ๐ On-Chain Keys - Secure key management
- โก Vite - Build tool
- ๐ฆ pnpm - Package manager
- ๐งช TypeScript - Type checking
- ๐ฏ ESLint - Code linting
- Node.js 18+ and pnpm
- Sui Wallet (Browser extension)
- Modern Browser with WebGPU support (Chrome 113+, Edge 113+)
# Clone the repository
git clone https://github.com/yourusername/ghostcontext.git
cd ghostcontext
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env
# Edit .env with your Sui contract addresses
# Start development server
pnpm devVITE_GHOSTCONTEXT_PACKAGE_ID=0x8ddf7cece3571b8758acbe667a8e2ddf8e0cef8e283a589459619b63fa4cb97a # Deployed contract address
# View on Sui Explorer (testnet): https://explorer.sui.io/object/0x8ddf7cece3571b8758acbe667a8e2ddf8e0cef8e283a589459619b63fa4cb97a?network=testnet
VITE_GHOSTCONTEXT_REGISTRY_ID=0x... # Registry object ID
VITE_WALRUS_PUBLISHER_URL=https://... # Walrus publisher endpoint
VITE_WALRUS_AGGREGATOR_URL=https://... # Walrus aggregator endpointcd contracts
# Build contracts
sui move build
# Deploy to Sui testnet
sui client publish --gas-budget 100000000
# Note the package ID and registry ID for .env- Visit chrome://flags or edge://flags
- Search for "WebGPU"
- Enable "Unsafe WebGPU"
- Relaunch browser
// Upload a PDF document
const file = document.getElementById('fileInput').files[0];
// Encrypt locally (AES-256-GCM)
const { encryptedData, key, iv } = await encryptFile(file);
// Upload to Walrus
const blobId = await uploadToWalrus(encryptedData);// Create GhostContext NFT with embedded keys
const tx = new Transaction();
tx.moveCall({
target: `${packageId}::ghostcontext::create_context`,
arguments: [
tx.pure.string(title),
tx.pure.string(blobId),
tx.pure.string(key),
tx.pure.string(iv),
tx.pure.string(category),
tx.object(registryId),
],
});// Set price per query (in MIST)
tx.moveCall({
target: `${packageId}::ghostcontext::list_context`,
arguments: [
tx.object(contextId),
tx.pure.u64(pricePerQuery),
],
});// Buy queries
tx.moveCall({
target: `${packageId}::ghostcontext::purchase_queries`,
arguments: [
tx.object(contextId),
tx.pure.u64(queryCount),
coin,
tx.object(registryId),
],
});
// Decrypt with keys from receipt NFT
const decrypted = await decryptData(encryptedBlob, key, iv);// Load document into RAG
await rag.ingest(decryptedFile);
// Ask questions
const answer = await rag.query(
"What is this document about?",
(partial) => console.log(partial) // Streaming
);- Client-Side Encryption: Files are encrypted using AES-256-GCM before leaving the browser
- Random Key Generation: Cryptographically secure random keys via Web Crypto API
- On-Chain Storage: Encryption keys stored in NFT metadata for transferability
- Decryption on Purchase: Buyers receive keys automatically via QueryReceipt NFT
- Model Selection: Choose from Llama-3, Phi-3, Mistral, Qwen
- WebGPU Acceleration: 10-100x faster than CPU inference
- Streaming Responses: Real-time token generation
- RAG Pipeline: Semantic search + LLM generation
- Conversational Memory: Multi-turn context awareness
- Category Filtering: Browse by General, Technical, Research, Education
- Metrics Display: Total queries sold, revenue earned
- Purchase Modal: Clean UI for buying queries
- Real-time Updates: Instant marketplace refresh after transactions
- Query Tracking: Monitor remaining queries per purchase
- Revenue Dashboard: Track earnings from listed contexts
- Usage Metrics: View total queries sold per context
- โ Client-Side Encryption: Data encrypted before upload
- โ Zero-Knowledge: Server never sees plaintext
- โ On-Chain Access Control: Smart contract-enforced permissions
- โ Decentralized Storage: No single point of failure
- โ Local AI Inference: Queries never sent to external servers
- โ Auditable: All transactions on-chain and verifiable
- Local encryption & Walrus upload
- Sui smart contracts
- WebLLM integration
- Basic marketplace
- NFT minting & trading
- WeInfer optimization (3.76x faster)
- Improved vector search
- Better UI/UX
- Mobile responsiveness
- Multi-file contexts
- Collaborative contexts
- Revenue sharing
- Advanced analytics
- API access
- GhostNodes (GPU rental)
- Decentralized training
- Cross-chain support
- Enterprise features
We welcome contributions! Please see our Contributing Guide for details.
bash
git clone https://github.com/yourusername/ghostcontext.git
git checkout -b feature/amazing-feature
git commit -m "Add amazing feature"
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.
- Sui Foundation - Blockchain infrastructure
- Walrus Team - Decentralized storage
- MLC Team - WebLLM framework
- Hugging Face - Transformers.js
- Open Source Community - Amazing tools and libraries
- Website: https://ghost-context-1.vercel.app
- Twitter: @Riddhisen382324
- Discord: Join our community
- Email: hello@ghostcontext.app
Current Status: โ Not Integrated (Using Web Crypto API instead)
Why? We initially planned to use Seal (Sui's policy-based encryption framework) for advanced access control. However, we encountered several blockers:
- Seal requires defining complex policy objects on-chain
- Our use case (simple key-based encryption) doesn't need policy overhead
- Web Crypto API provides sufficient security for MVP
- Seal's policy-based approach requires additional infrastructure
- Managing policy updates adds complexity for users
- Direct key storage in NFTs is simpler and more transparent
- Limited production examples of Seal integration
- Unclear best practices for browser-based encryption
- Testnet stability issues during development
We implemented a hybrid approach:
- โ AES-256-GCM encryption (industry standard, battle-tested)
- โ Keys stored on-chain in NFT metadata (transparent, auditable)
- โ Smart contract access control (token-gated decryption)
- โ Client-side processing (zero-knowledge, privacy-preserving)
Important demo note: During development we switched to the browser Web Crypto API because integrating Seal required significant policy setup and we encountered a decryption bug in the current Seal SDK that blocked reliable end-to-end testing. As a result, the demo and reference code use client-side AES encryption and simplified on-chain key handling. This means that in the demo any document may be purchased by any buyer (the demo does not enforce the full seller-granted Seal policy flow). When we migrate to Seal in production, access will be enforced by Seal policies so the seller (or on-chain policy) explicitly grants access to the buyer.
Once Seal matures and provides:
- Better documentation
- Browser-friendly SDKs
- Stable testnet/mainnet support
We will migrate to Seal for:
- ๐ฏ Time-locked documents
- ๐ฅ Multi-party access control
- ๐ Key rotation without re-upload
- ๐ข Enterprise compliance features
Tracking Issue: #42 - Seal Integration
-
Browser Compatibility
- Requires WebGPU support (Chrome 113+, Edge 113+)
- Safari not yet supported (WebGPU in development)
- Mobile browsers have limited support
-
File Size Limits
- Recommended: <10MB PDFs for optimal performance
- Large files may cause browser memory issues
- Walrus supports up to 1GB, but browser processing is the bottleneck
-
Model Loading Time
- First-time model download: 1-5 minutes (depending on model size)
- Models cached locally after first load
- Requires stable internet connection for initial download
-
Testnet Limitations
- Using Sui Testnet (not production-ready)
- Testnet tokens have no real value
- Network may be reset periodically
- Seal integration for advanced policies
- Mobile app (React Native)
- Safari/Firefox support
- Improved model caching
- Multi-file contexts
- Collaborative editing
- Revenue analytics dashboard
- API for developers
- GhostNodes (decentralized GPU rental)
- Cross-chain support
- Enterprise features
- Mainnet launch
Built with โค by the GhostContext Team
Founders: Ankit & Rick
โญ Star us on GitHub โข ๐ฆ Follow on Twitter โข ๐ฌ Join Discord