Bitwise Logic
Performs bitwise logic (XOR, AND, OR) across byte arrays of equal length
Overview
Performs a byte-by-byte bitwise logical operation—Exclusive OR (XOR, $\oplus$), Logical AND (AND, $\wedge$), or Logical OR (OR, $\vee$)—across two or more byte arrays of equal byte length.
All connected input ports are evaluated left-associatively in top-to-bottom port order (Input_1 OP Input_2 OP ... OP Input_N). Every connected input buffer must have the exact same byte length; if any two connected inputs differ in length, execution halts with LENGTH_MISMATCH.
When to Use
- XORing two or more equal-length blocks when building or teaching custom cipher modes (such as manual CBC chaining, CTR keystream XOR, or one-time pad encryption).
- Applying bitmasks (
ANDto clear bits,ORto set bits,XORto toggle bits) across multi-byte flags or key shares.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Operationoperation |
selectDefault: XOR |
Always visible | Selects the bitwise logic operator applied across all connected input byte arrays: XOR ($A \oplus B$), AND ($A \wedge B$), or OR ($A \vee B$).
|
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
| Attribute | Specification |
|---|---|
| Port Nature | Dynamic / Variable Input Ports |
| Initial Default on Canvas | Starts with 2 initial convenience input ports (Input A, id: in_a and Input B, id: in_b) on the canvas. These are initial default dynamic ports, not fixed ports. |
| Port Count Range | Minimum 2 connected input ports; supports 3 or more inputs via [+]. |
| Allowed Data Types | Bytes only (all connected inputs must have the exact same byte length). |
| Adding & Managing Ports | Add additional operand ports by dragging a Bytes wire onto the [+] handle or via the inspector; rename or remove extra ports in the inspector. |
| Evaluation & Ordering Rule | Bitwise XOR, AND, and OR are associative and commutative across all connected input buffers. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Result |
result |
Bytes |
Always visible | Resulting byte array (Uint8Array) of the same byte length as the connected inputs. |
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_LENGTH_MISMATCH |
Two values that must be the same length differ in length | Raised when connected byte array operands do not all have the exact same byte length. |
Examples
Combining Three 16-Byte Key Shares with XOR
Reconstruct a secret key from three equal-length XOR shares.
- Set Operation to
XOR (Exclusive OR, ⊕). - Connect Share 1 to
Input A, Share 2 toInput B, and drag Share 3 onto the[+]handle to create a third input port. - The
Resultport outputsShare1 ⊕ Share2 ⊕ Share3.