Quantum Crypto Wallet Build Plan v1.4

File: /.env


(Empty or environment-specific variables here)

File: /PLAN_MAP.txt


Quantum Crypto Wallet Build Plan v1.4
=====================================

Project: Quantum-Resistant Wallet + Simulated Quantum Chain
Status: Expanded Spec — EXECUTION ENFORCED

Core Rules:
- Implement all features listed in the Feature Matrix.
- Use modular crypto adapters (no hardcoding).
- No scope drift. If any change deviates, emit:
  "Plan Check: Rejected (Step #?). Reason: [explain]. Reverting to spec."

Build Steps:
1) Bootstrap Next.js app + folders (app, src/lib, tests).
2) Add PQCrypto abstraction:
   - Interfaces: KeyGen, Sign/Verify, KEM, DRBG.
   - Default to MOCK adapter in dev only.
3) Implement keystore (sealed JSON, PBKDF, versioned).
4) Implement wallet create/import APIs + UI.
5) Implement chain simulator (headers, epochs, staking).
6) Implement tx builder/signer + /api/tx/send (verify via sim).
7) Add tokens + NFTs (transfer/mint/burn) APIs + UI pages.
8) Add DEX (AMM pool) API + slippage calc + UI.
9) Add governance module (proposals/votes) + UI.
10) Tests: crypto, wallet, tx, staking, dex (must pass).
11) Persistence: local settings + encrypted key blobs.
12) Analytics (opt-in), theming, a11y, i18n.
13) Security review placeholders; swap-in real PQC libs.
14) Deploy devnet; document endpoints and ops.

--- Migration Path ---
15) Testnet Deployment:
   - Swap mock crypto adapters with real, audited PQC libraries.
   - Replace SimChain with a connection to a live testnet node.
   - Conduct rigorous end-to-end testing on the public testnet.

16) Mainnet Readiness:
   - Complete a full, third-party security audit of all code.
   - Finalize UI/UX based on testnet feedback.
   - Prepare mainnet deployment scripts, infrastructure, and monitoring.

17) Mainnet Launch:
   - Deploy to production environment.
   - Execute genesis block ceremony.
   - Enable public access and monitor network health.

Self-Execution Rule:
Before any code step, include a comment:
// Plan Check: Step X - Approved. (why)
If out-of-scope:
// Plan Check: Rejected (Step X). Reason: ...
// Reverting to spec.

File: /README.md


# Firebase Studio

This is a NextJS starter in Firebase Studio.

To get started, take a look at src/app/page.tsx.

File: /apphosting.yaml


# Settings to manage and configure a Firebase App Hosting backend.
# https://firebase.google.com/docs/app-hosting/configure

runConfig:
  maxInstances: 1

File: /components.json


{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "default",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "tailwind.config.ts",
    "css": "src/app/globals.css",
    "baseColor": "neutral",
    "cssVariables": true,
    "prefix": ""
  },
  "aliases": {
    "components": "@/components",
    "utils": "@/lib/utils",
    "ui": "@/components/ui",
    "lib": "@/lib",
    "hooks": "@/hooks"
  },
  "iconLibrary": "lucide"
}

File: /jsconfig.json


{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

File: /next.config.mjs


/** @type {import('next').NextConfig} */
const nextConfig = {
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: 'images.unsplash.com' },
      { protocol: 'https', hostname: 'storage.googleapis.com' },
      { protocol: 'https', hostname: 'picsum.photos' }
    ],
  },
};
export default nextConfig;

File: /package.json


{
  "name": "quantum-wallet",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "test": "vitest run"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.6.0",
    "@radix-ui/react-accordion": "^1.1.2",
    "@radix-ui/react-alert-dialog": "^1.0.5",
    "@radix-ui/react-avatar": "^1.0.4",
    "ethers": "^6.13.0",
    "next": "14.2.4",
    "react": "18.2.0",
    "three": "^0.165.0",
    "zod": "3.23.8"
  },
  "devDependencies": {
    "tailwindcss": "^3.4.1",
    "typescript": "5.9.3",
    "vitest": "1.6.0"
  }
}

File: /quantum-worker/main.py


import os, json, hashlib, time
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
from dotenv import load_dotenv
from qiskit import QuantumCircuit
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Options

load_dotenv()
IBM_API_KEY = os.getenv("IBM_QUANTUM_API_KEY")
IBM_INSTANCE = os.getenv("IBM_QUANTUM_INSTANCE", None)
app = FastAPI()
...
@app.get("/")
def read_root():
    return {"message": "Quantum Worker is running"}

File: /src/ai/dev.ts


import { config } from 'dotenv';
config();

import '@/ai/flows/analyze-quantum-blockchain-metrics.ts';
import '@/ai/flows/chat-with-echo-prime.ts';
import '@/ai/tools/wallet-tools.ts';

File: /src/ai/flows/analyze-quantum-blockchain-metrics.ts


'use server';
import {ai} from '@/ai/genkit';
import { googleAI } from '@genkit-ai/google-genai';
import {z} from 'genkit';
...
Recommendations:

File: /src/ai/flows/chat-with-echo-prime.ts


'use server';
/**
 * @fileOverview A flow for chatting with the Echo Prime AI.
 */