Nodes/ComfyUI ARG Toolkit/RSA Public Numbers Values
ComfyUI Node

RSA Public Numbers Values

Pulling n and e out of a key you can't read

By AzelusLightvale·Created about a year ago·Updated a day ago· 3
RSA Public Numbers Values
  • public_numbers
  • public_key
  • public_modulus
  • public_exponent

RSA Public Numbers Values is the inverse of the "numbers into key" node: give it a key - or the key's number container - and it prints the modulus and the public exponent as plain integers. Two outputs, no settings to speak of.

Its job is inspection. When a key object lands on your canvas from RSA Public Key Bytes or RSA Public Numbers into Key and you have no idea what's inside it, this is how you look. It's also how you feed n and e into other nodes as INT values, which in a puzzle graph is a real need - you might want to compare a modulus against one that arrived in a clue, or feed it forward to RSA Restore Prime Factors.

The mechanism, and the one rule

The source is a two-branch passthrough:

if public_numbers is None and public_key is not None:
    pnum = public_key.public_numbers()
elif public_numbers is not None and public_key is None:
    pnum = public_numbers
else:
    raise ValueError("Invalid configuration given. ...")

Both inputs are optional, and that's the trap. You must connect exactly one of them. Connect public_numbers and public_key together, or connect neither, and the node raises the pack's own Invalid configuration given. Input either the public numbers object or public key object only. - which, credit where due, is about as clear as Python error messages get.

If you connect the key, it calls .public_numbers() on it to extract the pair. If you connect the numbers container, it just reads the fields directly. Either way you get the same values back.

Inputs and outputs

Optional inputs: public_numbers (NUMOBJ, the container most of this family emits) and public_key (KEYOBJ, the live key object). Both are forced inputs - wires only, no typing, because neither type has a widget representation.

Outputs are public_modulus (that's n) and public_exponent (that's e), both INT types. In practice public_exponent will read 65537 for anything modern, and the modulus will be an enormous odd number.

A note on what "enormous" means for a ComfyUI integer: these arrive as Python ints, so the wire carries the full 617-digit value fine. What it can't survive is being hand-copied or typed back into a widget - the integer widgets on these number nodes are capped at 4,294,967,296, and a real modulus is roughly 2^2048. Treat the outputs as a readout and as wire-feeders, not as something you'll retype.

Where you'd actually use it

Mostly two places. First, sanity checks: an RSA puzzle usually hands you a modulus, and confirming that the key you built matches the modulus in the clue is the difference between five minutes and an hour. Second, key recovery: n, e and a leaked d are exactly the inputs RSA Restore Prime Factors wants, and this node is how you get the first two out of a key object.

For the private side of the same idea, RSA Private Numbers Values emits seven outputs including p, q and d.

Install

Manager, search ComfyUI ARG Toolkit, install, restart, refresh the browser. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
pip install -r requirements.txt

No model downloads. The real dependency is cryptography; be aware the shipped requirements.txt is a full lock including torch and torchaudio, so a manual install into an existing ComfyUI venv can swap your CUDA torch build. Manager's path avoids that surprise.

Common issues

Invalid configuration given. Both inputs wired, or neither. It's a strict-or node, not a fallback node. This is the single most common way to break it.

The output shows a giant number and you want to use it elsewhere. Wire it. Don't retype it - the widget ceiling and JavaScript's float precision will both happily mangle it.

Type mismatch on connect. public_key wants KEYOBJ, public_numbers wants NUMOBJ. They look similar in the dropdown and are not interchangeable; the key object is a live key, the container is just numbers.

This is a small, single-author, GPLv3 pack with no meaningful community discussion behind it yet - the README is upfront that testing is manual rather than a unit-test suite. For a puzzle tool that's fine. For anything long-lived, keep your key material in files outside ComfyUI too.

CategoryARG Toolkit/Cryptography/Modern/Asymmetric

Inputs (2)

NameTypeDefaultDescription
public_numbersoptNUMOBJ—
public_keyoptKEYOBJ—

Outputs (2)

NameTypeDescription
public_modulusINT—
public_exponentINT—