HKDF (Expand Only) Key Verification
The expand-only checker that confirms a derived key is what it should be
- message
- expected_key
- info
- verified_status
HKDFExpand_Verify is the "did we get the same key?" node. It takes the same inputs as HKDFExpand_Derive - the input key material, target length, algorithm, and optional info - plus an expected_key, and returns a single BOOLEAN: did this derivation produce that key or not? It's the verification mirror of the expand-only derive node, and its job is to let one party confirm that another party's derived key matches their own, without having to ship the key around.
How it works
Under the hood it builds the same HKDFExpand instance as the derive node and calls .verify(message, expected_key) instead of .derive(message). cryptography's verify does the derivation internally and compares against expected_key, raising InvalidKey on mismatch - which this node catches and turns into False. So the "verification" isn't magic: it's derive-and-compare, wrapped so a failed check comes back as a clean boolean rather than a thrown exception.
The inputs that matter
length- the target output length in bytes (16–256, default 32). Must match what the other party used, or the derivation differs and you getFalseeven though you both did everything "right."message(BYTESLIKE) - the pseudorandom key material being expanded.algorithm- the hash; must match the derive side.expected_key(BYTESLIKE) - the key you're checking against. This is what the other party derived and sent you.info(optional,BYTESLIKE) - the context label; must match the derive side exactly, including being empty on both ends.
The output
verified_status(BOOLEAN) -Truewhen the derivation reproducesexpected_key,Falseotherwise. Wire it into aBooleanOutputteror any boolean consumer.
Installing it
Part of the ComfyUI ARG Toolkit:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
Restart ComfyUI, or install via ComfyUI Manager ("ComfyUI ARG Toolkit") - cryptography provides HKDFExpand.
Where people get burned
- Any field off by a hair. Length, algorithm, or
infodiffering from the derive side meansFalse- even a byte ofinfodifference or a 31 vs 32 length. There's no "close enough" in KDF verification. This is the node's entire failure mode, and it's worth checking all three inputs before suspecting a bug. - Verifying a full-HKDF key with the expand-only node. If the other side ran extract+expand (
HKDF_Derivewith a salt) and you're checking with expand-only, you're comparing different schemes. Use the matching verify node (HKDF_Verify) for the full version. - A
Falseisn't proof of tampering. It only means the derivation didn't match - wrong inputs are the far more likely explanation than a compromised secret.
Realistically, most workflows don't need this node at all - the derive version hands you the key, and if you trust the pipeline you just use it. But in the "two parties each derive from a shared secret and want to confirm agreement" setup - which is exactly the kind of exchange an ARG final puzzle stages - this is the automated handshake that closes the loop.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| length | INT | 3216–256 | The desired length of the derived key in bytes. |
| message | BYTESLIKE | The message to derive key from. Must be bytes. | |
| algorithm | COMBO | The algorithm to use for hash generation. | |
| expected_key | BYTESLIKE | The expected result of key derivation. | |
| infoopt | BYTESLIKE | Application-specific context information. If left empty, will pass an empty byte string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| verified_status | BOOLEAN | — |