Detect MIME type from file magic bytes.
Supports PNG, JPEG, GIF, WebP, TIFF, ICO, and SVG.
Returns “application/octet-stream” for unrecognized formats.
Every type mime_from_magic_bytes can name.
Identity basis for a RECEIVED attachment: the sender’s ox (plaintext
hash) when provided — it’s what enables honest cross-message dedup — else
a digest of nonce+url. Never the raw nonce: senders can and do reuse
nonces, which cross-bound DIFFERENT files to one identity (the “new image
renders as an old one” class). The upload URL is unique per ciphertext,
so the digest is collision-resistant even against nonce reuse. Nothing
honest ever writes a file under the digest name, so existence of one is
never proof of download — reuse decisions stay with the content-verified
download path.
Decode an image with allocation limits. A tiny file declaring 60000×60000
would otherwise allocate ~14 GB before a single pixel decodes — every
decode of bytes we didn’t author must go through this.
Decrypt a hex-encoded ChaCha20-Poly1305 ciphertext with a key. Mirrors
maybe_decrypt_inner’s fast path: SIMD hex decode, no plaintext copy, and
from_utf8_unchecked.
Decrypt a secret key BLOB. Tolerant of the half-migrated DB: a 32-byte value
is a raw (not-yet-wrapped / encryption-off) key, and anything that fails to
authenticate is returned as-is, so a mixed store always reads back correctly.