# chunkLayout

## Interfaces

| Interface | Description |
| ------ | ------ |
| [ChunkLayout](/reference/filoz/filecoin-encryption-envelope/namespaces/chunklayout/interfaces/chunklayout/) | - |

## Functions

| Function | Description |
| ------ | ------ |
| [chunkCountForPlaintext](/reference/filoz/filecoin-encryption-envelope/namespaces/chunklayout/functions/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](/reference/filoz/filecoin-encryption-envelope/namespaces/chunklayout/functions/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](/reference/filoz/filecoin-encryption-envelope/namespaces/chunklayout/functions/ciphertextlengthforplaintext/) | Detached ciphertext length a plaintext of `plaintextLength` bytes produces at `chunkSize`: `P + 16 × max(1, ceil(P / S))`, one tag per chunk. |