KYA Validator
A robust Rust-core validator for KYA (Know Your AI) Manifests with Python, Rust, and TypeScript/JavaScript bindings.
Overview
The KYA Validator provides comprehensive validation of AI agent manifests, ensuring cryptographic proof of identity, attestation of secure execution environments, and enforcement of policy rules.
Features
Core Validation ✅
- Schema Validation: JSON Schema (Draft 7) compliance checking
- DID Resolution: Support for
did:key,did:web, anddid:pkh - Cryptographic Verification: Ed25519 and Secp256k1 signature validation
- TTL Checks: Time-to-live validation for manifest freshness
- External Link Validation: URL reachability and content verification
- Content Hashing: SHA256/384/512 digest verification
Advanced Features (Phase 2) 🚀
- TEE Evidence Validation: Intel SGX and AMD SEV-SNP attestation
- Blockchain Solvency: Multi-provider on-chain balance verification
- Advanced Policy Engine: Complex rule composition and evaluation
- WebAssembly/TypeScript: Full browser and Node.js support
Installation
Rust
Python
TypeScript/JavaScript (WASM)
# From npm
# Local build
&&
Note: For local development builds, see bindings/wasm/README.md.
Quick Start
Rust
use ;
use json;
let manifest = json!;
let report = validate_manifest_value;
println!;
Python
=
=
TypeScript/JavaScript (Browser)
import { validateManifest, init } from '@open-kya/kya-validator-wasm/browser';
// Initialize WASM module
await init();
const manifest = {
kyaVersion: "1.0",
agentId: "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK",
proof: []
};
const report = await validateManifest(manifest);
console.log("Valid:", report.schema_valid);
TypeScript/JavaScript (Node.js)
import { validateManifest } from '@open-kya/kya-validator-wasm/node';
// No async init needed in Node.js
const manifest = {
kyaVersion: "1.0",
agentId: "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK",
proof: []
};
const report = validateManifest(manifest);
console.log("Valid:", report.schema_valid);
Python API
Core Types
The Python package provides the following core types:
ValidationConfig- Configuration for manifest validationValidationReport- Results of manifest validationValidationMode- Validation mode (selfAudit/clientAudit)HashAlgorithm- Hash algorithm for digest computationCryptoReport- Cryptographic verification reportTeeEvidence- TEE attestation evidenceTeeReport- TEE verification reportSolvencyCheck- Blockchain solvency check configurationSolvencyReport- Blockchain solvency reportPolicyContext- Context for policy evaluation
Main Classes
Validator- Main validator for manifest validationPolicyEngine- Advanced policy rule evaluationTeeVerifier- TEE attestation evidence verifierSolvencyChecker- Blockchain solvency checkerStreamingValidator- Chunk-based validation for large manifestsPluginManager- Plugin system managerInspector- Manifest inspectorResolver- DID and verification method resolver
Configuration
# Load from file
=
# Load from environment variables
= # Uses KYA_VALIDATOR_* env vars
# Create preset
=
Validation
# Simple validation
=
=
# With configuration
=
=
TEE Verification
=
=
=
Blockchain Solvency
=
Policy Evaluation
=
=
=
Streaming Validation
=
=
=
=
Plugin System
return
return
return
return
=
=
=
DID Resolution
=
# Resolve did:key
=
# Parse did:pkh
=
Configuration
Default Configuration
Self-Audit Preset
Client-Audit Preset
Documentation
Core Modules
- Schema Validation - JSON Schema compliance checking
- DID Resolution - DID key resolution
- Cryptographic Verification - Signature validation
- Inspector Module - Field validation
- Policy Engine - Basic policy evaluation
Testing
Run All Tests
Run Python Tests
Configuration
Environment Variables
Configuration can be loaded from environment variables with the KYA_VALIDATOR_ prefix:
KYA_VALIDATOR_MODE- Validation modeKYA_VALIDATOR_ALLOWED_VERSIONS- Comma-separated list of allowed versionsKYA_VALIDATOR_REQUIRED_FIELDS- Comma-separated list of required fieldsKYA_VALIDATOR_ENFORCE_CONTROLLER_MATCH- Boolean for controller matchingKYA_VALIDATOR_CHECK_EXTERNAL_LINKS- Boolean for external link checkingKYA_VALIDATOR_REQUIRE_ALL_PROOFS- Boolean for requiring all proofs
Example: Setting Environment Variables
Performance
Validation Performance
- Schema Validation: ~1-5ms
- Crypto Verification: ~5-20ms
- TTL Checks: <1ms
- Policy Evaluation: ~0.1-1ms per rule
Advanced Features
- TEE Quote Validation: <10ms (structural), ~50-100ms (full)
- Blockchain Balance: <1ms (cached), ~50-200ms (network)
- WASM Validation: ~5-20ms per manifest
Optimization Tips
- Reuse Configurations: Parse and reuse config objects
- Batch Validations: Validate multiple manifests together
- Use Caching: Enable blockchain/TTL caching
- Pre-Validate JSON: Check JSON format before validation
- Skip Unnecessary Checks: Disable features not needed for your use case
Security Considerations
Best Practices
- Validate Input: Always validate JSON before processing
- Check Signatures: Never skip cryptographic verification
- Verify TEE: Validate attestation claims
- Check Solvency: Verify on-chain balances
- Enforce Policies: Apply strict validation rules
- Use CSP Headers: Set Content-Security-Policy headers for external requests
CSP Headers
Content-Security-Policy:
default-src 'self';
script-src 'self' blob:;
worker-src 'self' blob:;
Architecture
Modular Design
kya-validator/
├── core/ # Rust core library
│ ├── types.rs # Core data structures
│ ├── validator.rs # Main validation logic
│ ├── resolver.rs # DID resolution
│ ├── verifier.rs # Crypto verification
│ ├── inspector.rs # Field validation
│ ├── policy.rs # Basic policies
│ ├── tee.rs # TEE attestation
│ ├── blockchain.rs # Solvency checks
│ ├── policy_advanced.rs # Advanced policies
│ ├── wasm.rs # WASM bindings
│ ├── plugin.rs # Plugin system
│ ├── plugin_manager.rs # Plugin management
│ └── lib.rs # Exports
├── bindings/ # Language bindings
│ ├── python/ # Python bindings (PyO3)
│ │ ├── __init__.py
│ │ ├── types.py
│ │ ├── errors.py
│ │ ├── config.py
│ │ ├── utils.py
│ │ ├── validator.py
│ │ ├── policy.py
│ │ ├── tee.py
│ │ ├── blockchain.py
│ │ ├── streaming.py
│ │ ├── plugins.py
│ │ ├── inspector.py
│ │ ├── resolver.py
│ │ └── _ffi.py
│ └── wasm/ # WASM examples
│ ├── wasm-usage.ts
│ ├── wasm-usage.js
│ ├── wasm-async-usage.ts
│ ├── streaming-validation.ts
│ └── custom-plugin-example.ts
├── apps/ # Applications
│ ├── ui/ # Policy editor UI (React/Vite)
│ └── demo_backend/ # Demo backend (FastAPI)
└── tests/ # Test suite
Integration Points
- Resolver → DID to public key mapping
- Verifier → Signature verification
- Inspector → Schema and TTL validation
- TEE Module → Attestation verification
- Blockchain Module → Solvency checks
- Policy Engine → Rule enforcement
- Streaming Validator → Chunk-based validation
- Plugin System → Custom validation rules
Contributing
Development Setup
# Install Rust toolchain
|
# Install dependencies
# Run tests
# Format code
# Check code
Adding Features
- Create feature branch
- Write tests for new feature
- Update documentation
- Submit PR
Code Style
- Follow Rust naming conventions
- Use
#[allow(...)]sparingly - Document public APIs
- Write tests for all public functions
License
See LICENSE file for details.
Resources
- KYA Standard - KYA protocol specification
- W3C DID Core - DID specification
- W3C VC Data Model - Verifiable Credentials
- Intel SGX - TEE attestation
Roadmap
Phase 2 (In Progress - 80% Complete)
- TEE Evidence Validation
- Enhanced Solvency Verification
- Advanced Policy Engine
- TypeScript/WASM Bindings
- Performance Optimization
- Documentation Polish
Phase 3 (Planned)
- Async WASM Operations
- Streaming Validation
- Plugin System
- Policy Editor UI
- Telemetry Integration
- Performance Optimization
- Documentation Polish
Release & Packaging
Versioning
Version follows semantic versioning (MAJOR.MINOR.PATCH):
Cargo.toml(Rust): Source of truth for core versionpyproject.toml(Python): Must match Rust version- Update both files together before release
Packaging
# Build Rust release
# Build Python wheel (requires maturin)
# Build WASM package
Release Checklist
- Update version in
Cargo.tomlandpyproject.toml - Update
CHANGELOG.md(if present) - Tag release:
git tag -a v0.x.x -m "Release v0.x.x" - Push tags:
git push --tags - Build and publish Python package:
uv tool run maturin build --release && uv publish - Publish WASM to npm (if applicable)
Optional Components
The following components are not required for core validation functionality:
- UI Demo (
apps/ui/) - React/Vite policy editor demo - Demo Backend (
apps/demo_backend/) - FastAPI demo with LLM integration - WASM Bindings (
bindings/wasm/) - Browser/Node.js WASM package. See README for documentation.
These are optional and may be moved to separate packages in future releases.
Support
For issues, questions, or contributions, please open an issue or pull request in the repository.
Version: 0.2.0 Status: Production Ready (Core) / Beta (Phase 2 Features)