Nodes/ComfyUI ARG Toolkit/ChaCha20Poly1305 Key Generator
ComfyUI Node

ChaCha20Poly1305 Key Generator

A 32-byte key, freshly rolled every run — no inputs, no drama

By AzelusLightvale·Created 12 months ago·Updated 4 days ago· 1
ChaCha20Poly1305 Key Generator
    • key

    ChaCha20Poly1305Keygen is the smallest node in the pack and possibly the most quietly useful: it generates a fresh, cryptographically random 32-byte key - exactly what the ChaCha20Poly1305 encryption node needs - with zero inputs. Click, run, and out pops a key wire carrying 32 bytes of os.urandom-quality randomness (it uses cryptography's ChaCha20Poly1305.generate_key() under the hood, which is backed by the operating system's CSPRNG). If you've ever needed a key in ComfyUI and found yourself typing random-looking characters and hoping, this is the node that stops the pretending.

    Because it has no inputs, it's also the cleanest way to demonstrate the pack's BYTESLIKE datatype working: drop this node in, wire its output to a ByteslikeDecode set to Hexadecimal, and watch it print a real random key. That's the exact pattern you'll reuse for the encryption node, and it's a two-node mental model for the whole modern half of the toolkit.

    How it works

    On every execution it calls ChaCha20Poly1305.generate_key(), which asks the platform for 32 secure random bytes and returns them. Two practical consequences worth internalizing:

    1. The key is new every run. Every queue or refresh produces a different key. Encrypt with one run's key, and you must keep that exact key to decrypt - which is why in a real workflow you don't regenerate keys carelessly mid-graph.
    2. It's a generator, not a storage locker. The key exists only as a wire in your graph. There's no persistence, so if you need the same key twice (say, in a separate workflow that decrypts), you'll want to record it as hex/base64 from a ByteslikeDecode output, then rebuild it later with ByteslikeEncode.

    The inputs that matter

    None. The required and optional input sections are both empty - the node is a pure source.

    Output: key, a BYTESLIKE value, 32 bytes, ready to wire into ChaCha20Poly1305's key slot (or anywhere else that wants a strong random 32 bytes - it's just bytes, so the KDF message input and hashing nodes will happily take it too).

    Installing it

    Ships in the ComfyUI ARG Toolkit pack. Install via ComfyUI Manager (search "ComfyUI ARG Toolkit") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
    

    Restart ComfyUI. It depends on the pack's cryptography package, along with the rest of the pack's stack (secretpy, stegano, invisible-watermark, reedsolo, transitive torch/opencv-python). No models, no API keys.

    Gotchas

    The "new key every run" behavior is the trap to remember: build your graph assuming you'll capture the key value somewhere readable, or the encryption becomes unrecoverable the moment the graph re-runs. And don't reach for this when you need a reproducible key - for that you want a KDF node like ConcatKDF, which derives a deterministic key from a message you control. This node is for the one-time, nobody-else-should-know key, and it does that one job flawlessly.

    CategoryARG Toolkit/Cryptography/Modern/Authenticated

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    keyBYTESLIKE