@mingchain/bsv-geo-shield
v0.1.0
Published
BSV-powered GEO poisoning defense for AI — data attestation, RAG verification, trust network on blockchain
Downloads
122
Maintainers
Readme
BSV-GEO Shield
BSV-powered GEO poisoning defense for AI — data attestation, RAG verification, trust network on blockchain.
Protect your AI systems from GEO (Generative Engine Optimization) poisoning attacks. BSV-GEO Shield verifies RAG retrieval data, anchors content provenance on BSV blockchain, and filters poisoned data before it reaches your LLM.
Open source, MIT licensed — pay only BSV transaction fees (~$0.01/anchor).
Features
- Data Attestation — Hash content, build Merkle tree, anchor to BSV OP_RETURN
- RAGShield Verification — Real-time verification of RAG-retrieved documents
- Trust Network — Decentralized reputation scoring for content sources
- Risk Assessment — Multi-dimensional scoring: attestation, hash, timestamp, reputation
- Fallback Strategies — Filter, reduce weight, or flag untrusted content
- BSV Anchoring — Immutable on-chain proof, SPV verifiable
Quick Start
npm install @mingchain/bsv-geo-shieldimport { GEOShield, createGEOShield } from '@mingchain/bsv-geo-shield';
// Create shield instance
const shield = new GEOShield({
bsvWallet: 'your-bsv-wallet-address'
});
// Attest training data
const batch = shield.attestBatch([
{ content: 'Medical research text...', metadata: { title: 'Research', sourceDomain: 'nih.gov' } },
{ content: 'Academic article...', metadata: { title: 'Paper', sourceDomain: 'arxiv.org' } }
]);
console.log('Merkle Root:', batch.merkleRoot);
console.log('BSV Anchor TX:', batch.bsvAnchorTx?.unsignedHex);
// Verify RAG retrieved documents
const { results, allowed, rejected, stats } = shield.verify([
{ id: 'doc1', content: 'Medical research...', sourceDomain: 'nih.gov' },
{ id: 'doc2', content: 'Unknown content...', sourceDomain: 'suspicious-site.xyz' }
]);
results.forEach(r => {
console.log(`${r.documentId}: ${r.status} (${r.trustLevel}) - ${r.confidenceScore.toFixed(2)}`);
});Architecture
┌──────────────┐ ┌───────────────┐ ┌─────────────────┐ ┌──────────────┐
│ Data Source │───▶│DataAttestation│───▶│Merkle Aggregation│───▶│ BSV Anchor │
│ (content) │ │ (hash+index) │ │ (batch root) │ │ (OP_RETURN) │
└──────────────┘ └───────────────┘ └─────────────────┘ └──────────────┘
│
┌──────────────┐ ┌───────────────┐ ┌─────────────────┐ │
│ RAG Retrieval│───▶│RAGShieldVerify│───▶│ TrustNetwork │─────────┘
│ (documents) │ │ (attest+hash+ │ │ (reputation │
│ │ │ timestamp+ │ │ scoring) │
│ │ │ reputation) │ │ │
└──────────────┘ └───────────────┘ └─────────────────┘Core Modules
| Module | Description |
|--------|-------------|
| DataAttestation | SHA-256 hash → Merkle tree → BSV OP_RETURN anchoring |
| RAGShieldVerifier | Multi-dimensional document verification |
| TrustNetwork | Decentralized reputation scoring network |
| BSV Anchor | OP_RETURN transaction builder (unsigned, ready to sign) |
API Reference
GEOShield
Main unified class for GEO poisoning defense.
const shield = new GEOShield(options);Options:
bsvWallet— BSV wallet address for anchoringpolicy—VerificationPolicy.DEFAULT | STRICT | RELAXEDattestationOptions— DataAttestation configtrustNetworkOptions— TrustNetwork config
Methods:
// Attest single content
shield.attest({ content, metadata });
// Batch attest + flush (builds Merkle tree)
shield.attestBatch([{ content, metadata }, ...]);
// Verify RAG documents
shield.verify([{ id, content, metadata }, ...]);
// Get reputation for a source
shield.getReputation('wikipedia.org', 'domain');
// Register reputation score
shield.registerReputation({ subjectId, finalScore, tier });
// Get system status
shield.status();DataAttestation
import { DataAttestation } from '@mingchain/bsv-geo-shield';
const attester = new DataAttestation({ bsvWallet: '...', batchSize: 50 });
// Create attestation
const record = attester.attest({ content: '...', metadata: {...} });
// Flush pending: build Merkle tree, create BSV anchor tx
const { batchId, merkleRoot, records, anchorTx } = attester.flush();
// Verify content
const result = attester.verify(content, attestationId);RAGShieldVerifier
import { RAGShieldVerifier, RAGDocument, VerificationPolicy } from '@mingchain/bsv-geo-shield';
const verifier = new RAGShieldVerifier({ policy: VerificationPolicy.STRICT });
verifier.setAttestations(attester); // Connect to attestation records
// Verify documents
const docs = [
new RAGDocument({ id: 'd1', content: '...', sourceDomain: 'wikipedia.org' }),
new RAGDocument({ id: 'd2', content: '...', sourceDomain: 'unknown.xyz' })
];
const results = verifier.verifyDocuments(docs);
const { allowed, rejected } = verifier.applyFallback(docs, results);TrustNetwork
import { TrustNetwork, TrustTier } from '@mingchain/bsv-geo-shield';
const network = new TrustNetwork();
// Query reputation
const rep = network.getReputation('wikipedia.org');
// { finalScore: 0.8, tier: 'high', totalReviews: 100, isTrusted: true }
// Register new reputation
network.registerReputation({
subjectId: 'new-source.com',
finalScore: 0.7,
tier: TrustTier.MEDIUM,
participantIds: ['r1', 'r2', 'r3']
});
// Batch query
network.batchGetReputation([
{ subjectId: 'wikipedia.org' },
{ subjectId: 'github.com' }
]);Verification Policies
import { VerificationPolicy } from '@mingchain/bsv-geo-shield';
// Standard (default)
const standard = new VerificationPolicy();
// Strict: require attestation, 3+ confirmations, 0.7 min reputation
const strict = VerificationPolicy.STRICT;
// Relaxed: no attestation required
const relaxed = VerificationPolicy.RELAXED;
// Custom
const custom = new VerificationPolicy({
requireAttestation: true,
minConfirmations: 1,
verifyContentHash: true,
checkTimestampAnomaly: true,
checkReputation: true,
minReputationScore: 0.5,
weights: { attestation: 0.4, hash: 0.2, timestamp: 0.1, reputation: 0.3 },
fallbackMode: 'filter', // filter | reduce_weight | flag
lowScoreThreshold: 0.3
});BSV Cost
Each BSV anchor transaction costs approximately $0.01 in transaction fees (at BSV ~$500):
| Batch Size | Cost per Item | |------------|---------------| | 50 items | ~$0.0002 | | 100 items | ~$0.0001 | | 1000 items | ~$0.00001 |
With default settings (50 items/batch), that's less than $0.001 per document verified.
Commercial Model
Software is free. The blockchain is the business.
BSV-GEO Shield is MIT-licensed open source. The revenue comes from BSV blockchain usage — every anchor creates a BSV transaction.
Tiers
- Free (Open Source): Self-deployed, user pays own BSV fees
- Hosted (Future): Minglian Tech SaaS API, no BSV wallet needed
- Enterprise (Future): Private deployment, custom policies, SLA
See docs/commercial.md for full details.
OpenClaw Integration
Add to your openclaw.plugin.json skills:
{
"skills": ["skills/bsv-geo-shield"]
}Or use the OpenClaw plugin config at openclaw-plugin/openclaw.plugin.json.
License
MIT — see LICENSE
Links
- GitHub: https://github.com/minglian-tech/bsv-geo-shield
- npm: https://www.npmjs.com/package/@mingchain/bsv-geo-shield
- BSV Blockchain: https://bsvblockchain.org/
