Official Rust SDK for Hanzo AI infrastructure, providing secure key management, post-quantum cryptography, LLM safety, content extraction, and core primitives for building AI applications.
This workspace contains the following crates:
| Crate | Description |
|---|---|
hanzo-guard |
LLM I/O sanitization with PII redaction, injection detection, rate limiting |
hanzo-extract |
Content extraction from web/PDF with built-in sanitization |
| Crate | Description |
|---|---|
hanzo-kbs |
Key Broker Service for confidential computing with privacy tiers |
hanzo-pqc |
Post-Quantum Cryptography (ML-KEM, ML-DSA, hybrid modes) |
| Crate | Description |
|---|---|
hanzo-message-primitives |
Core message types and schemas for Hanzo AI systems |
Add the desired crates to your Cargo.toml:
[dependencies]
hanzo-guard = "0.1"
hanzo-extract = "0.1"
hanzo-kbs = "0.1"
hanzo-pqc = "0.1"use hanzo_guard::{Guard, GuardConfig, SanitizeResult};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let guard = Guard::new(GuardConfig::default());
let result = guard.sanitize_input("My SSN is 123-45-6789").await?;
match result {
SanitizeResult::Clean(text) => println!("Clean: {text}"),
SanitizeResult::Redacted { text, .. } => println!("Redacted: {text}"),
SanitizeResult::Blocked { reason, .. } => println!("Blocked: {reason}"),
}
Ok(())
}use hanzo_extract::{Extractor, WebExtractor};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let extractor = WebExtractor::default();
// Extract and sanitize web content
let result = extractor.extract_sanitized("https://example.com").await?;
println!("Title: {:?}", result.title);
println!("Text: {}", result.text);
Ok(())
}use hanzo_kbs::{
kbs::Kbs,
kms::{Kms, MemoryKms},
types::PrivacyTier,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let kms = MemoryKms::new().await?;
let kbs = Kbs::new(kms);
// Initialize for GPU Confidential Computing
kbs.initialize_vault(PrivacyTier::GpuCc, None).await?;
Ok(())
}use hanzo_pqc::{
kem::{Kem, KemAlgorithm, MlKem},
signature::{Signature, SignatureAlgorithm, MlDsa},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate ML-KEM keypair
let ml_kem = MlKem::new();
let keypair = ml_kem.generate_keypair(KemAlgorithm::MlKem768).await?;
// Generate ML-DSA keypair
let ml_dsa = MlDsa::new();
let (verifying_key, signing_key) = ml_dsa.generate_keypair(SignatureAlgorithm::MlDsa65).await?;
Ok(())
}# Build all crates
cargo build --all
# Run tests
cargo test --all
# Build for release
cargo build --release --allThis monorepo supports per-package releases:
# Release a single package
./scripts/release-package.sh hanzo-kbs 0.1.1
# Release all packages
./scripts/release-package.sh all 0.2.0See PUBLISHING.md for detailed release instructions.
All crates are dual licensed under MIT OR Apache-2.0.
Contributions are welcome! Please feel free to submit a Pull Request.