chunkCountForPlaintext
chunkCountForPlaintext(
plaintextLength,chunkSize):number
Defined in: packages/filecoin-encryption-envelope/src/chunk-layout.ts:84
Chunk count an encoder writes into the chunk_count header for a
plaintext of the given length. This is deliberately not the inverse of
chunkLayout: a plaintext that is an exact multiple of the chunk
size can be sealed validly as either k chunks (last one full) or k+1
(last one empty, carrying only its tag), and both decrypt to identical
bytes. We always WRITE the k form here, but a decoder must ACCEPT both —
so the header this function produces is checked against
chunkLayout(ciphertextSize, chunkSize).chunkCount, never against
chunkCountForPlaintext run in reverse on the plaintext size.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
plaintextLength | number |
chunkSize | number |
Returns
Section titled “Returns”number