Skip to main content

Crate stverify

Crate stverify 

Source
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 rayon to parallelize hashing of dozens of shards across CPU cores.
  • Framing & Header Validation: Validates the 8-byte little-endian .safetensors header length boundary with sanity caps.
  • Deterministic Ed25519 Signatures: Fast, constant-time signature generation and verification.
  • Canonical Manifest Integrity: sign-dir / verify-dir builds and authenticates signed manifests (<sha256> <filename>), catching modified, deleted, or injected rogue shards.

Structs§

Signature
Ed25519 signature.
SigningKey
ed25519 signing key which can be used to produce signatures.
VerifyingKey
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 in dir, hashed in parallel using Rayon.
cmd_keygen
CLI handler for keygen command.
cmd_sign
CLI handler for sign command.
cmd_sign_dir
CLI handler for sign-dir command.
cmd_verify
CLI handler for verify command.
cmd_verify_dir
CLI handler for verify-dir command.
collect_shards
Discovers all .safetensors shards 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 .safetensors framing (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.manifest and stverify.sig.
sign_single
Signs a single .safetensors file, writing the 64-byte hex signature to sig_out.
verify_dir
Verifies stverify.manifest signature and recomputes canonical manifest in parallel across disk.
verify_single
Verifies a single .safetensors file against an expected signature and public key.