Skip to main content

split_into_chunks

Function split_into_chunks 

Source
pub fn split_into_chunks(
    canonical_bytecode: &[u8],
    chunk_set_id: u32,
) -> Result<Vec<ChunkFragment>>
Expand description

Split canonical bytecode into chunks, appending the cross-chunk integrity hash.

The split target is CHUNKED_FRAGMENT_LONG_BYTES (= 53 bytes) per fragment so each chunk lands in long-code BCH territory under typical mk1 sizes; the last fragment may be shorter, in which case the pipeline auto-falls-back to regular code per encode_5bit_to_string.

Returns Error::CardPayloadTooLarge if the bytecode (plus the 4-byte hash) exceeds MAX_CHUNKS * CHUNKED_FRAGMENT_LONG_BYTES.

ยงDeterminism

The output is byte-deterministic in (canonical_bytecode, chunk_set_id): callers passing the same arguments produce the same chunk sequence, which is the property Phase 6 relies on for vector regeneration.