Expand description
§stverify
Zero-bloat parallel cryptographic signer and integrity verifier for .safetensors model weights.
Purpose-built for multi-tenant GPU enclaves, sovereign AI clusters, and zero-trust inference pipelines.
§Features
- Constant-Memory Streaming: Hashes multi-gigabyte tensor shards in 64 KB buffers via SHA-256 without loading files entirely into memory.
- Parallel Multi-Shard Verification: Uses
rayonto parallelize hashing of dozens of shards across CPU cores. - Framing & Header Validation: Validates the 8-byte little-endian
.safetensorsheader length boundary with sanity caps. - Deterministic Ed25519 Signatures: Fast, constant-time signature generation and verification.
- Canonical Manifest Integrity:
sign-dir/verify-dirbuilds and authenticates signed manifests (<sha256> <filename>), catching modified, deleted, or injected rogue shards.
Structs§
- Signature
- Ed25519 signature.
- Signing
Key - ed25519 signing key which can be used to produce signatures.
- Verifying
Key - An ed25519 public key.
Constants§
- MAX_
HEADER_ SIZE - Maximum sanity cap on JSON metadata header (100 MB).
Traits§
- Signer
- Sign the provided message bytestring using
Self(e.g. a cryptographic key or connection to an HSM), returning a digital signature. - Verifier
- Verify the provided message bytestring using
Self(e.g. a public key)
Functions§
- build_
canonical_ manifest - Builds a canonical, newline-delimited manifest (
<sha256_hex> <filename>) across every shard indir, hashed in parallel using Rayon. - cmd_
keygen - CLI handler for
keygencommand. - cmd_
sign - CLI handler for
signcommand. - cmd_
sign_ dir - CLI handler for
sign-dircommand. - cmd_
verify - CLI handler for
verifycommand. - cmd_
verify_ dir - CLI handler for
verify-dircommand. - collect_
shards - Discovers all
.safetensorsshards in a directory, sorted deterministically by filename. - generate_
keypair - Generates a new random Ed25519 keypair and writes them as hex files.
- hash_
safetensors - Validates basic
.safetensorsframing (8-byte little-endian header length) and streams the entire file into SHA-256 in 64 KB chunks without loading it into RAM. - load_
signature - Reads a 64-byte hex-encoded Ed25519 signature from disk.
- load_
signing_ key - Reads a 32-byte hex-encoded Ed25519 private key from disk.
- load_
verifying_ key - Reads a 32-byte hex-encoded Ed25519 public key from disk.
- print_
usage - Prints the CLI usage instructions.
- sign_
dir - Computes SHA-256 for all shards in parallel, writes
stverify.manifestandstverify.sig. - sign_
single - Signs a single
.safetensorsfile, writing the 64-byte hex signature tosig_out. - verify_
dir - Verifies
stverify.manifestsignature and recomputes canonical manifest in parallel across disk. - verify_
single - Verifies a single
.safetensorsfile against an expected signature and public key.