| Crates.io | schemapin |
| lib.rs | schemapin |
| version | 1.1.4 |
| created_at | 2025-07-21 02:16:49.729389+00 |
| updated_at | 2025-07-21 02:16:49.729389+00 |
| description | Cryptographic schema integrity verification for AI tools - Rust implementation |
| homepage | https://github.com/thirdkey/schemapin |
| repository | https://github.com/thirdkey/schemapin |
| max_upload_size | |
| id | 1761630 |
| size | 33,264 |
Cryptographic schema integrity verification for AI tools - Rust implementation using ECDSA P-256.
SchemaPin provides a robust framework for verifying the integrity and authenticity of JSON schemas used by AI tools and services. This Rust implementation uses ECDSA P-256 cryptographic signatures to ensure that schemas haven't been tampered with and come from trusted sources.
This implementation is fully compatible with the Python, JavaScript, and Go implementations, using the same cryptographic standards:
Add this to your Cargo.toml:
[dependencies]
schemapin = "1.1.4"
Or install from git:
cargo add --git https://github.com/thirdkey/schemapin schemapin
use schemapin::crypto::{generate_key_pair, sign_data, verify_signature, calculate_key_id};
// Generate a new key pair
let key_pair = generate_key_pair().unwrap();
// Sign some data
let data = b"Hello, World!";
let signature = sign_data(&key_pair.private_key_pem, data).unwrap();
// Verify the signature
let is_valid = verify_signature(&key_pair.public_key_pem, data, &signature).unwrap();
assert!(is_valid);
// Calculate key ID
let key_id = calculate_key_id(&key_pair.public_key_pem).unwrap();
println!("Key ID: {}", key_id);
use schemapin::crypto::{KeyManager, SignatureManager};
// Generate keys using the manager
let (private_key, public_key) = KeyManager::generate_keypair().unwrap();
let private_key_pem = KeyManager::export_private_key_pem(&private_key).unwrap();
let public_key_pem = KeyManager::export_public_key_pem(&public_key).unwrap();
// Sign and verify using the manager
let data = b"Schema data to sign";
let signature = SignatureManager::sign_hash(data, &private_key).unwrap();
let is_valid = SignatureManager::verify_signature(data, &signature, &public_key).unwrap();
assert!(is_valid);
# Build the project
cargo build
# Run tests
cargo test
# Run with optimizations
cargo build --release
# Check code quality
cargo clippy
# Format code
cargo fmt
This implementation uses:
OsRngThe cryptographic operations are provided by the p256 crate, which implements the ECDSA algorithm according to industry standards.
This Rust implementation is designed to be fully compatible with other SchemaPin implementations:
All cryptographic operations return Result<T, Error> types for proper error handling. The Error enum provides detailed error information:
Ecdsa: ECDSA key generation or operation errorsPkcs8: PKCS#8 encoding/decoding errorsBase64: Base64 encoding/decoding errorsSignature: Signature verification errorsInvalidKeyFormat: Invalid key format errorsp256: ECDSA P-256 cryptographic operationsrand: Secure random number generationsha2: SHA-256 hashingbase64: Base64 encoding/decodinghex: Hexadecimal encodingserde: Serialization supportMIT License - see the main project LICENSE file for details.