NodeCrypto Help

Bit Shift & Rotate

Category: Utility ยท Node Type ID: utility-bitshift

Shifts or rotates a byte array by a number of bits (SHL, SHR, ROL, ROR)

Overview

Treats the entire input byte array as a single contiguous big-endian bit vector of $8 \times N$ bits and shifts or circularly rotates all bits by the specified bit count: Logical Shift Left (SHL, <<), Logical Shift Right (SHR, >>), Rotate Left (ROL), or Rotate Right (ROR).

Carry bits shifted out of one byte cross seamlessly into the adjacent byte! The bit count can be configured via the Bits property or overridden dynamically at runtime by connecting an integer to the optional Bits input port. Output byte length always equals the input byte length.

When to Use

Parameter Configuration

Parameter (ID)Type & DefaultVisibility ConditionDescription & Options
Operation
operation
select
Default: SHL
Always visible Selects the bit-level operation across the entire byte array: SHL (zeros shifted in from the right), SHR (zeros shifted in from the left), ROL (MSB wraps around to LSB), or ROR (LSB wraps around to MSB).
  • SHL: SHL (Bit Shift Left <<)
  • SHR: SHR (Bit Shift Right >>)
  • ROL: ROL (Bit Rotate Left)
  • ROR: ROR (Bit Rotate Right)
Bits
bits
number
Default: 1
Supports Variable Reference ($var: int)
Always visible Number of bits to shift or rotate (integer ≥ 0; default 1). Ignored if the optional Bits 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 NamePort IDData TypeRequiredVisibility ConditionDescription
Value data Bytes Required Always visible Input byte array (Uint8Array) treated as a contiguous big-endian bit stream.

Output Ports

Port Nature: Fixed Output Ports (1 total).

Port NamePort IDData TypeVisibility ConditionDescription
Result result Bytes Always visible Shifted or rotated byte array (Uint8Array) of the same byte length as Data.

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 CodeDefault Engine MessageTrigger Condition
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

Shifting a 16-Byte Block Left by 1 Bit (CMAC Subkey Step)

Shift a 128-bit block left by 1 bit across byte boundaries.

  1. Set Operation to SHL (Bit Shift Left <<) and Bits to 1.
  2. Connect a 16-byte buffer to Data; Result emits the 16-byte buffer shifted left by 1 bit.