Rotor Machine Permutation
Reflector, entry wheel, plugboard
- perm_obj
Not every part of a cipher machine moves. The reflector, the entry wheel and the plugboard are all just wiring - a fixed mapping from letters to letters - and this node builds one. Its output perm_obj is a PERMUTATION, which is the type Rotor Machine State accepts in its entry, reflector and plugboard inputs.
It's the least glamorous node in the rotor category and the one that most changes how a machine behaves. A rotor machine with no plugboard is a museum piece; add ten steckered pairs and the effective key space more than doubles in the way that made Enigma's operators feel safe and Bletchley's cryptanalysts busy.
Two inputs, both strings
alphabet is the symbol set the wiring is expressed in, default A–Z. wiring is the mapped alphabet: the i-th character is what the i-th character of alphabet becomes.
That's it. No positions, no notches, no stepping - a fixed stage applies the same mapping at every keystroke.
Concretely, a plugboard that swaps one pair (A↔B) and leaves everything else alone is:
alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ
wiring: BACDEFGHIJKLMNOPQRSTUVWXYZ
Extend it to A↔B and C↔D and you get BADCEFGHIJKLMNOPQRSTUVWXYZ - every swapped letter replaced by its partner, all the untouched letters in their original place. Writing a ten-cable Steckerbrett this way is fiddly but entirely mechanical, and honestly it's the most satisfying five minutes in this pack: you can watch the error rate in the encrypt node change as you add pairs.
Reflector B is the string YRUHQSLDPXNGOKMIEBFZCWVJAT. Paste that in and you have the standard UKW-B, ready for the machine node's reflector input. Reflector C is FVPJIAOYEDRZXWGCTKUQSBNMHL if you want the other one.
The rules, and who enforces them
This node checks exactly one thing: that wiring uses every symbol of alphabet exactly once. Get it wrong and you get Wiring must use every symbols exactly once. Required 26, got 25. - which is the author's grammar, not a typo on your end.
The involution rule is not checked here. It's checked at assembly, in Rotor Machine State, which rejects a reflector or plugboard that isn't its own inverse with its own message. That division of labour is sensible - a PERMUTATION can legitimately be a non-symmetric stage in other machine designs - but it means this node will happily hand you something the next node refuses. Don't read a clean output here as "valid reflector".
The most common way to break involution is a one-character typo in a long wiring string. If A maps to Y but Y maps to something other than A, the machine throws. Keep the string symmetrical as you type it and you'll never see the error.
Installing it
Manager → search ComfyUI ARG Toolkit → install → restart → refresh the browser. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
pip install -r requirements.txt
Nothing here needs models or the cryptography library; this node is string parsing and a tuple. The pack's requirements file is still the heavyweight it is everywhere else - torch==2.14.1, torchaudio, stegano, invisible-watermark and friends, none of which a reflector cares about. Installing the full list into a live ComfyUI venv is the standard route to a dependency afternoon; Manager puts the same pins in the same interpreter, but at least it's consistent with everything else you've installed.
Getting the wiring right without pain
The trick that makes this node usable: build the machine first with no plugboard and no reflector, encrypt a short test string, and note the output. Then add the reflector alone and check that the cipher is now reciprocal - encrypt the ciphertext and you should get your plaintext back exactly, because a reflected machine is its own inverse. If that round trip fails, your reflector isn't an involution, whatever the node said.
Then add the plugboard and watch the reciprocity survive. That property - ciphertext decrypts with the same settings - is the thing that made Enigma practical for field use, and it's the fastest way to tell whether a PERMUTATION you built is actually doing its job.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| alphabet | STRING | ABCDEFGHIJKLMNOPQRSTUVWXYZ | — |
| wiring | STRING | EKMFLGDQVZNTOWYHXUSPAIBRCJ | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| perm_obj | PERMUTATION | — |