| chunkCountForPlaintext | Chunk count for a plaintext of the given length: max(1, ceil(P / S)). The max matters — ceil(0 / S) is zero, and empty plaintext is still one chunk, carrying nothing but its tag. |
| chunkLayout | Derive the chunk layout of a stored blob from its ciphertext length and chunk size — never the reverse. A declared plaintext_length header is checked against what this function derives, not the other way around, or a rewritten header could change which chunk is treated as last and a truncated object would go undetected (docs/tech-spec.md, “plaintext_length and truncation”). |
| ciphertextLengthForPlaintext | Detached ciphertext length a plaintext of plaintextLength bytes produces at chunkSize: P + 16 × max(1, ceil(P / S)), one tag per chunk. |