Byte Slicer
Extracts bytes like the script slice b[offset, length]: empty length = to the end, negative = end position counted from the back (excluded)
Overview
Extracts a contiguous sub-array from the input byte array using the exact same two-argument semantics as the built-in Script byte slice b[offset, length].
Offset specifies the starting byte index (0-based; negative values count backward from the end of the buffer, e.g., -16 starts 16 bytes from the end). Length has three modes depending on its value: if left blank (empty), it slices all the way to the end of the buffer; if ≥ 0, it extracts at most that many bytes; if negative (< 0), it specifies the exclusive end position counted backward from the end of the buffer (for example, Offset = 0, Length = -16 extracts everything except the final 16-byte authentication tag). Both values can be overridden dynamically via the optional Offset and Length input ports.
When to Use
- Splitting a combined wire payload (such as
Nonce || Ciphertext || Tag) into separate fields for decryption. - Truncating a hash or KDF output to a shorter key or IV length (e.g., taking the first 16 bytes or last 12 bytes).
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Offset (Start)offset |
numberDefault: 0 |
Always visible | Starting byte index (0-based; negative values count from the end of the input buffer). Overridden at runtime if the Offset input port is connected. |
Lengthlength |
textDefault: "" (empty) |
Always visible | When blank: slices to the end of the buffer. When ≥ 0: number of bytes to extract. When < 0: exclusive end index counted from the end of the buffer (e.g., -16 stops 16 bytes before the end). Overridden at runtime if the Length input port is connected. |
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (1 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Data |
data |
Bytes |
Required | Always visible | Source byte array (Uint8Array) to slice. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Sliced Bytes |
sliced |
Bytes |
Always visible | Extracted sub-array (Uint8Array). Out-of-bounds ranges are safely clamped without throwing an error. |
Error Cases
When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
BYTES_OUT_OF_RANGE |
Index or range is outside the value | Raised when a byte or bit index/slice range falls outside the valid bounds of the buffer. |
BYTES_INVALID_ARGUMENT |
Invalid argument value | Raised when an argument (such as bit shift count, byte length, or negative integer) is invalid or negative. |
Examples
Splitting a Combined (Ciphertext || 16B GCM Tag) Payload
Use two Byte Slicer nodes to separate the ciphertext body from the trailing 16-byte authentication tag.
- On the first Byte Slicer (Ciphertext), set Offset to
0and Length to-16(extracts from byte 0 up to 16 bytes before the end). - On the second Byte Slicer (Tag), set Offset to
-16and leave Length blank (extracts the last 16 bytes to the end).