Files
blackroad-operating-system/backend/app/schemas/leo.py
Claude 45bd2cc194 Add IP Vault: Cryptographic proof-of-origin system
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
2025-11-18 11:18:39 +00:00

73 lines
1.7 KiB
Python

"""LEO (Ledger Evidence Object) schemas"""
from pydantic import BaseModel, Field
from typing import Optional, Dict, Any
from datetime import datetime
class LEOCreate(BaseModel):
"""LEO creation schema"""
idea: str = Field(..., min_length=1, description="Raw idea text to vault")
author: str = Field(default="Alexa", description="Author of the idea")
title: Optional[str] = Field(None, max_length=500, description="Optional title for the idea")
class LEOResponse(BaseModel):
"""LEO response schema"""
id: str
author: str
title: Optional[str]
sha256: str
sha512: str
keccak256: str
canonical_size: int
anchor_status: str
anchor_txid: Optional[str]
anchor_chain: Optional[str]
anchor_block_height: Optional[int]
anchored_at: Optional[datetime]
created_at: datetime
updated_at: Optional[datetime]
class Config:
from_attributes = True
class LEODetail(LEOResponse):
"""
Detailed LEO response with verification and anchoring info
"""
verification_text: str
anchoring_options: Dict[str, Any]
class LEOList(BaseModel):
"""Paginated LEO list response"""
leos: list[LEOResponse]
total: int
page: int
per_page: int
class AnchorRequest(BaseModel):
"""Blockchain anchor request"""
chain: str = Field(
default="bitcoin",
description="Target blockchain (bitcoin, litecoin, ethereum)"
)
class AnchorEventResponse(BaseModel):
"""Anchor event response"""
id: int
leo_id: str
event_type: str
chain: Optional[str]
txid: Optional[str]
block_height: Optional[int]
status: str
error_message: Optional[str]
created_at: datetime
class Config:
from_attributes = True