NodeCrypto Help

Types and Operators

Data Types

TypeDescription
intArbitrary-precision mathematical integer (no fixed-width overflow; up to 1,048,576 bits).
boolBoolean truth value (True or False).
bytesByte sequence (up to 16 MiB).
stringUnicode text string. Used for error messages, hex/UTF-8 conversions, and f-strings; supports +, ==, and !=.
list[T]Homogeneous list where T is int, bool, bytes, or string. Nested lists (list[list[...]]) are not permitted. Up to 1,048,576 elements.
tuple[...]Used exclusively for multi-value function returns and unpacking assignments; cannot be stored in variables or lists.

Script node input and output ports can use bytes, int, bool, and string. Lists and tuples are script-internal types.

Type Checking Rules

Definite Assignment Analysis

Every local variable must be assigned before it is read, and every output port variable must be definitely assigned along all non-failing execution paths by the end of the script:

if n > 100:
    o = "big"
else:
    o = "small"

Omitting the else branch above causes a compile-time SCRIPT_OUTPUT_UNASSIGNED diagnostic.

Value Semantics

All values—including bytes and list[T]—have value semantics. Variable assignment and function argument passing behave as independent copies; mutating a byte or list element in one variable never mutates another variable:

a = h"00 00"
b = a
b[0] = 255

Operators

Operator precedence matches Python. Bitwise operators bind tighter than comparisons, so x & 0x80 != 0 parses as (x & 0x80) != 0. Chained comparisons (a < b < c) are rejected.

OperatorOperandsResultMeaning
+int, intintAddition
+bytes, bytesbytesConcatenation
+string, stringstringString concatenation
+list[T], list[T]list[T]List concatenation
-, *int, intintSubtraction, multiplication
*bytes, int (or int, bytes)bytesByte repetition (negative count raises BYTES_INVALID_ARGUMENT)
//, %int, intintFloor division and modulo (remainder sign matches divisor; divisor 0 raises SCRIPT_DIVISION_BY_ZERO)
Unary -intintArithmetic negation
&, |, ^, ~intintTwo's-complement bitwise operations
<<, >>int, intintArithmetic bit shift (negative shift count raises SCRIPT_INVALID_ARGUMENT)
&, |, ^bytes, bytesbytesBytewise AND, OR, XOR (unequal lengths raise BYTES_LENGTH_MISMATCH)
~bytesbytesBitwise NOT across all bytes
<<, >>bytes, intbytesWhole-buffer bit shift preserving byte length (carries cross byte boundaries; vacant bits zero-filled)
==, !=Same typeboolEquality / inequality
<, <=, >, >=int, intboolNumeric ordering
<, <=, >, >=bytes, bytesboolLexicographical byte ordering
and, or, notboolboolBoolean logic

Operator Examples

ExpressionResult
2 + 3 * 414
7 // 23
-7 // 2-4 (floor division)
-7 % 21
7 % -2-1 (sign of divisor)
0xF0 & 0x3C48 (0x30)
0xF0 | 0x0F255
0xFF ^ 0x0F240 (0xF0)
~5-6
1 << 8256
-16 >> 2-4 (arithmetic shift)
h"0f f0" & h"3c 3c"0c30
h"0f" | h"f0"ff
h"ff" ^ h"0f"f0
~h"0f"f0
h"81 00" << 10200 (length preserved, overflow bit dropped)
h"81 00" >> 14080
h"01" + h"02"0102
h"00" * 3000000
2 * h"ff"ffff
"ab" + "cd"abcd
h"01 02" < h"01 03"True (lexicographical)
h"01" < h"01 00"True (shorter prefix is smaller)
h"01" == h"02"False
x == 0 and not (x > 1)True