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

RSA Private Numbers Values

Seven integers out of one opaque key

By AzelusLightvale·Created about a year ago·Updated a day ago· 3
RSA Private Numbers Values
  • private_numbers
  • private_key
  • public_numbers
  • var_p
  • var_q
  • private_exponent
  • dmp1
  • dmq1
  • iqmp

This is the node that opens the black box. Give it a private key and it hands back all seven numbers that key is made of: the two primes, the private exponent, the three CRT parameters, and the public numbers container. Nothing else in the RSA family of this pack is this transparent - and nothing else is this easy to miswire.

What it's good for

Two things, both niche, both real. First, forensics: a puzzle gives you a key file, and the whole solution hangs on these are the primes, now factor something. Second, chaining: you have p and q from RSA Private Numbers Values and want to feed them into RSA Private Numbers into Key to assemble a different key, or compare a modulus against a clue.

It's also the honest way to answer "is this key actually 2048-bit?" without leaving ComfyUI.

Mechanism

One branch, then a read-out. The node accepts either a private_numbers container or a live private_key object, and in either case normalises to the container via key.private_numbers(). Then it returns the fields straight:

return (pnum.public_numbers, pnum.p, pnum.q, pnum.d,
        pnum.dmp1, pnum.dmq1, pnum.iqmp)

No computation, no validation, no surprises - including no verification that the key is well-formed. That's the previous node's job.

Inputs and outputs

Both inputs are optional and both are forced to wires: private_numbers (NUMOBJ, from RSA Private Numbers into Key) and private_key (KEYOBJ, from RSA Private Key Bytes). Connect exactly one. Both wired, or neither wired, and you get Invalid configuration given. Input either the public numbers object or public key object only. - the node's optional-input shape is a strict-or, not a fallback.

The seven outputs, in order: public_numbers (a NUMOBJ you can hand to any node that wants the public half), var_p and var_q (the primes), private_exponent (that's d), then dmp1, dmq1 and iqmp - the CRT exponents and coefficient that most people never touch, computed by the libraries so you don't have to.

All the numeric outputs are Python INTs, so they carry full 2048-bit values across a wire without complaint. The catch is at either end of that wire: the integer widgets on these number nodes cap at 4,294,967,296, and reading a 617-digit number off the node and typing it back somewhere will lose precision before you finish. Wire, don't retype.

When it pays off: the RSA recovery chain

The interesting workflow with this node is key recovery. Say a challenge leaks d but not p and q. You load the key or container, pull public_numbers, private_exponent out of this node, and feed them plus the modulus into RSA Restore Prime Factors - which factors n given (n, e, d). Out come p and q, which go into RSA Private Numbers into Key to build a key you can decrypt with. That chain works because every step speaks INT or NUMOBJ, and this node sits at the top of it.

Install

ComfyUI Manager → search ComfyUI ARG Toolkit → install → restart → refresh the browser tab. Manually:

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

No models. The functional dependency is cryptography; the annoyance is that requirements.txt is a pinned uv lock that includes torch and torchaudio, so installing it into your existing environment may install a different torch build over the CUDA one you were using. Manager handles the dependency resolution more carefully - if you go manual, check torch afterwards.

Common issues

Invalid configuration given. You wired both inputs or neither. Exactly one.

Outputs connect to nothing. NUMOBJ only exists inside this pack. INT outputs will connect broadly, but don't expect a core ComfyUI node to understand what a modulus is.

The numbers look wrong. They aren't - d in particular is a huge, featureless integer, and that's what a correct d looks like. Compare against a known-good extraction (openssl, Python's cryptography in a shell) if you don't trust it.

You expected the CRT parameters to be optional. They're computed by the library, not by you, so they're always present on the way out. Only RSA Private Numbers into Key lets you skip supplying them, and there you're supplying p, q and d instead.

Small pack, single author, GPLv3, manual-testing testing story - fine for puzzle work, worth keeping your real key material out of.

CategoryARG Toolkit/Cryptography/Modern/Asymmetric

Inputs (2)

NameTypeDefaultDescription
private_numbersoptNUMOBJ—
private_keyoptKEYOBJ—

Outputs (7)

NameTypeDescription
public_numbersNUMOBJ—
var_pINT—
var_qINT—
private_exponentINT—
dmp1INT—
dmq1INT—
iqmpINT—