🔐 Chain Verification
Verify the cryptographic integrity of your SoWasIt blockchain chains
Chain Verification
Verify the cryptographic integrity of your SoWasIt blockchains offline, anytime, anywhere. No API key required for verification - complete transparency and independence.
Features
- Offline verification - Verify chain integrity without any API calls
- Cryptographic proof - Double SHA-256 hash verification
- Progress tracking - Visual progress bar for large chains
- CLI tool - Easy command-line interface
- NPM package - Programmatic API for Node.js applications
Why Verify?
- Trust, but verify - Don't just trust the platform, verify the cryptographic proof yourself
- Compliance - Meet audit requirements with independent verification
- Backup validation - Ensure your chain backups are intact and unmodified
- Transparency - Anyone can verify your chain's integrity, no special access needed
- Independence - Verification works offline, no dependency on SoWasIt infrastructure
Installation
Install via npm:
npm install @sowasit/chain-verifierOr use directly with npx (no installation needed):
npx @sowasit/chain-verifier verify my-chain.jsonCLI Usage
Verify a chain
You can verify either a local file or download and verify a chain by ID:
# Verify a local file
npx @sowasit/chain-verifier verify chain.json
# Download and verify a public chain
npx @sowasit/chain-verifier verify my-chain-id
# Download and verify a private chain
npx @sowasit/chain-verifier verify my-private-chain --api-key te_xxxxx
# Verify with detailed output
npx @sowasit/chain-verifier verify my-chain.json --verbose --output report.jsonOptions
-o, --output <file>- Save verification report to a file-v, --verbose- Show detailed block-by-block results-k, --api-key <key>- API key (or use SOWASIT_API_KEY environment variable). Required only for private chains-u, --api-url <url>- API URL (default: https://api.sowasit.io)--force-download- Force re-download, ignoring local cache--include-anchors- Include anchor blocks for verification
Caching: When verifying by chain ID, blocks are cached in .sowasit-cache/chainId/ and only new blocks are downloaded on subsequent runs.
Download a chain from API
Download a complete or partial chain from the SoWasIt API:
# Download a public chain
npx @sowasit/chain-verifier download my-public-chain-id
# Download a private chain
npx @sowasit/chain-verifier download my-chain-id --api-key te_xxxxx
# Download partial range of blocks
npx @sowasit/chain-verifier download my-chain-id --from 100 --to 200Programmatic API
Verify a chain
import { verifyChain } from '@sowasit/chain-verifier';
import { readFile } from 'fs/promises';
// Load chain export
const chainData = JSON.parse(await readFile('chain.json', 'utf-8'));
// Verify
const result = verifyChain(chainData);
if (result.valid) {
console.log(`✓ ${result.validBlocks} blocks are valid`);
} else {
console.log(`✗ ${result.invalidBlocks} invalid blocks`);
console.log('Errors:', result.errors);
}Download a chain
import { downloadChain } from '@sowasit/chain-verifier';
import { writeFile } from 'fs/promises';
// Download public chain (no API key required)
const publicChainData = await downloadChain('public-chain-id', {
apiUrl: 'https://api.sowasit.io',
});
// Download private chain (API key required)
const privateChainData = await downloadChain('private-chain-id', {
apiKey: 'te_xxxxx',
apiUrl: 'https://api.sowasit.io',
from: 0,
to: 100,
});
await writeFile('chain.json', JSON.stringify(privateChainData, null, 2));Verification Process
- Hash integrity - Each block's hash is recomputed using double SHA-256 and compared with the stored hash
- Chain continuity - Each block's prev_hash must match the previous block's hash
- Genesis block - The first block must have a prev_hash matching the chain hash (from chain.hash)
- Block ordering - Blocks are verified in sequential order by ID
- Anchor verification - If anchor blocks are included, verifies all referenced blocks exist and hashes match
Usage Examples
CI/CD Integration
Automate chain verification with GitHub Actions:
# .github/workflows/verify-chain.yml
name: Verify Chain Integrity
on:
schedule:
- cron: '0 0 * * *' # Daily
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Download chain
run: |
npx @sowasit/chain-verifier download ${{ secrets.CHAIN_ID }} \
--api-key ${{ secrets.SOWASIT_API_KEY }} \
--output chain.json
- name: Verify chain
run: |
npx @sowasit/chain-verifier verify chain.json \
--verbose \
--output verification-report.json
- name: Upload report
uses: actions/upload-artifact@v3
with:
name: verification-report
path: verification-report.jsonAutomatic Backup Script
Automatically download and verify your chains:
// backup-and-verify.js
import { downloadChain, verifyChain } from '@sowasit/chain-verifier';
import { writeFile } from 'fs/promises';
async function backupAndVerify() {
const chainId = process.env.CHAIN_ID;
const apiKey = process.env.SOWASIT_API_KEY;
// Download
console.log('Downloading chain...');
const chainData = await downloadChain(chainId, { apiKey });
// Save
const filename = `backup-${chainId}-${new Date().toISOString()}.json`;
await writeFile(filename, JSON.stringify(chainData, null, 2));
console.log(`Saved to ${filename}`);
// Verify
console.log('Verifying...');
const result = verifyChain(chainData);
if (!result.valid) {
throw new Error(`Verification failed: ${result.errors.join(', ')}`);
}
console.log(`✓ Backup verified: ${result.validBlocks} blocks`);
}
backupAndVerify().catch(console.error);How It Works
SoWasIt uses double SHA-256 hashing (the same algorithm as Bitcoin) to ensure immutability:
1. Each block's data is serialized deterministically (JSON canonicalization)
↓
2. The data is hashed twice with SHA-256: SHA256(SHA256(data))
↓
3. Each block contains the hash of the previous block (prev_hash)
↓
4. Changing any bit in any block invalidates all subsequent blocksGuarantees
- Tampering is impossible - Any modification breaks the chain
- Verification is fast - Only hashing, no complex cryptography
- Proof is portable - Just a JSON file, no special tools required