This demo application demonstrates how BSV blockchain can be used to verify data integrity and detect unauthorized changes to database records.
The application consists of:
- Frontend: React + Vite + TypeScript with shadcn/ui components
- Backend: Node.js + Express + TypeScript API server
- BSV Integration: Uses @bsv/sdk WalletClient for creating and verifying integrity proofs
-
Without BSV Blockchain Tab
- Shows data fetched from a compromised database
- Records 3 and 5 have been tampered with
- No way to detect the unauthorized changes
-
With BSV Blockchain Tab
- Shows original data with integrity verification
- Creates cryptographic proofs stored on BSV blockchain
- Immediately detects any tampering when validating against blockchain proofs
- Record 3: Award amount has been changed from $4.2B to $9.9B
- Record 5: Recipient name changed from "NATIONAL AEROSPACE SOLUTIONS, LLC" to "COMPROMISED AEROSPACE SOLUTIONS, LLC"
The BSV blockchain integration detects both modifications instantly using OP_RETURN data anchoring and transaction verification.
The easiest way to run the demo is using Docker from the root directory:
# From the root demo-day directory
docker-compose upThe application will be available at:
- Frontend: http://localhost
- Backend API: http://localhost:3001
To stop:
docker-compose down- Node.js (v18 or higher)
- npm or yarn
- Install Backend Dependencies
cd backend
npm install- Install Frontend Dependencies
cd frontend
npm installYou'll need two terminal windows:
Terminal 1 - Backend Server
cd backend
npm run devThe backend API will start on http://localhost:3001
Terminal 2 - Frontend Application
cd frontend
npm run devThe frontend will start on http://localhost:5173 (or the next available port)
-
Open the application in your browser (typically
http://localhost:5173) -
Without BSV Tab:
- View the compromised data
- Notice records 3 and 5 are highlighted as modified
- No verification is possible - you just have to trust the database
-
With BSV Tab:
- Click "Create Integrity Proofs" to store cryptographic hashes of records 3 and 5 on the BSV blockchain
- Click "Validate Data Integrity" to check current database records against blockchain proofs
- See clear visual indicators showing which records have been tampered with
The application uses BSV SDK's WalletClient for blockchain operations:
// Initialize wallet
const walletClient = new WalletClient();
// Create integrity proof
await wallet.createAction({
outputs: [{
lockingScript: LockingScript.fromASM(`OP_FALSE OP_RETURN ${dataHex}`),
satoshis: 0,
basket: 'integrity'
}]
});
// Validate integrity
const outputs = await wallet.listOutputs({ basket: 'integrity' });
const tx = Transaction.fromBEEF(output.beef);
await tx.verify();- Original data stored in
src/data/response-original.json - Altered data in
src/data/response-altered.json - Backend serves both datasets via REST API
- Frontend creates blockchain proofs of original records
- Validation compares current data against blockchain proofs
data-integrity/
├── backend/
│ ├── src/
│ │ └── server.ts # Express API server
│ ├── package.json
│ └── tsconfig.json
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── ui/ # shadcn/ui components
│ │ │ └── DataIntegrityDemo.tsx # Main demo component
│ │ ├── context/
│ │ │ └── WalletContext.tsx # BSV wallet context
│ │ ├── types/
│ │ │ └── index.ts # TypeScript interfaces
│ │ └── App.tsx # Root component
│ ├── package.json
│ └── tsconfig.json
└── src/
└── data/
├── response.json # Source data
├── response-original.json # Clean copy
└── response-altered.json # Tampered data
- React 18 - UI framework
- Vite - Build tool and dev server
- TypeScript - Type safety
- shadcn/ui - UI component library
- Tailwind CSS - Styling
- @bsv/sdk - BSV blockchain integration
- Express - Backend API server
- Switch to "Without BSV Blockchain" tab
- See modified records displayed as if they were legitimate
- No way to verify authenticity
- Switch to "With BSV Blockchain" tab
- Create integrity proofs (stores cryptographic hashes on blockchain)
- Validate data - system detects both tampered records immediately
- Visual alerts show exactly what was modified
MIT