mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 06:57:17 -05:00
Implements a complete vertical slice of the IP Vault feature for BlackRoad OS,
providing cryptographic timestamping and evidence generation for ideas and
intellectual property.
## Components Added
### Agent Layer
- **VaultAgent** (`agents/categories/security/vault_agent.py`):
- Deterministic text canonicalization
- Multi-hash generation (SHA-256, SHA-512, Keccak-256)
- LEO (Ledger Evidence Object) construction
- Verification text generation
- Blockchain anchoring preparation
### Backend API
- **Models** (`backend/app/models/leo.py`):
- LEO: Stores cryptographic hashes and metadata
- AnchorEvent: Audit trail for blockchain anchoring
- **Schemas** (`backend/app/schemas/leo.py`):
- LEOCreate, LEOResponse, LEODetail, LEOList
- AnchorRequest, AnchorEventResponse
- **Router** (`backend/app/routers/ip_vault.py`):
- POST /api/vault/leos - Create new LEO
- GET /api/vault/leos - List LEOs (paginated)
- GET /api/vault/leos/{id} - Get LEO details
- POST /api/vault/leos/{id}/anchor - Initiate anchoring (stub)
- GET /api/vault/leos/{id}/events - Get anchor events
### Frontend
- **API Client** (`backend/static/js/api-client.js`):
- createLEO(), getLEOs(), getLEO()
- anchorLEO(), getLEOEvents()
- **App** (`backend/static/js/apps.js`):
- loadIPVault() - Load and display LEOs
- vaultIdea() - Create new LEO from form
- viewLEO() - Show detailed LEO modal with verification
- **UI** (`backend/static/index.html`):
- Desktop icon (🔐 IP Vault)
- Window with form and list view
- Start menu integration
## Features
- **Deterministic canonicalization**: Ensures reproducible hashing
- **Multi-hash support**: SHA-256, SHA-512, Keccak-256 (Ethereum-compatible)
- **Verification instructions**: Auto-generated proof-of-authenticity text
- **Blockchain-ready**: Prepared for Bitcoin, Litecoin, Ethereum anchoring
- **Clean separation**: Agent logic, API, database, frontend all decoupled
## Testing
- Python syntax validated for all new files
- JavaScript syntax validated
- VaultAgent tested end-to-end with sample idea
- All hashes computed successfully
## Next Steps
- Implement actual blockchain anchoring
- Add RoadChain integration
- Export LEOs as legal-grade PDFs
- Add user authentication to LEO creation
78 lines
2.4 KiB
Python
78 lines
2.4 KiB
Python
"""LEO (Ledger Evidence Object) model"""
|
|
from sqlalchemy import Column, Integer, String, DateTime, Text
|
|
from sqlalchemy.sql import func
|
|
from app.database import Base
|
|
|
|
|
|
class LEO(Base):
|
|
"""
|
|
Ledger Evidence Object (LEO) model
|
|
|
|
Cryptographic proof-of-origin for ideas and intellectual property.
|
|
Stores hashes and metadata suitable for blockchain anchoring.
|
|
"""
|
|
|
|
__tablename__ = "leos"
|
|
|
|
id = Column(String(36), primary_key=True, index=True) # UUID
|
|
author = Column(String(255), nullable=False, default="Alexa")
|
|
title = Column(String(500), nullable=True)
|
|
|
|
# Cryptographic hashes
|
|
sha256 = Column(String(64), nullable=False, index=True)
|
|
sha512 = Column(String(128), nullable=False)
|
|
keccak256 = Column(String(64), nullable=False)
|
|
|
|
# Metadata
|
|
canonical_size = Column(Integer, nullable=False)
|
|
|
|
# Blockchain anchoring
|
|
anchor_status = Column(
|
|
String(20),
|
|
nullable=False,
|
|
default="pending"
|
|
) # pending, anchored, failed
|
|
anchor_txid = Column(String(128), nullable=True)
|
|
anchor_chain = Column(String(50), nullable=True)
|
|
anchor_block_height = Column(Integer, nullable=True)
|
|
anchored_at = Column(DateTime(timezone=True), nullable=True)
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
def __repr__(self):
|
|
return f"<LEO {self.id} by {self.author}>"
|
|
|
|
|
|
class AnchorEvent(Base):
|
|
"""
|
|
Blockchain anchor event audit trail
|
|
|
|
Tracks all anchoring attempts and status changes for LEOs.
|
|
"""
|
|
|
|
__tablename__ = "anchor_events"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
leo_id = Column(String(36), nullable=False, index=True)
|
|
|
|
# Event details
|
|
event_type = Column(String(50), nullable=False) # anchor_initiated, anchor_confirmed, anchor_failed
|
|
chain = Column(String(50), nullable=True)
|
|
txid = Column(String(128), nullable=True)
|
|
block_height = Column(Integer, nullable=True)
|
|
|
|
# Status
|
|
status = Column(String(20), nullable=False) # pending, confirmed, failed
|
|
error_message = Column(Text, nullable=True)
|
|
|
|
# Metadata
|
|
metadata = Column(Text, nullable=True) # JSON serialized
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
|
|
|
def __repr__(self):
|
|
return f"<AnchorEvent {self.id} for LEO {self.leo_id}>"
|