---
related_nodes:
  - webhook_trigger
  - webhook_response
  - js_script
---

# Verify Signature

Verifies a payload against a signature and routes the original input down `valid` or `invalid`.

## When to Use

- Gate a workflow on a valid public-key signature
- Verify Discord interaction payloads without putting crypto logic in `js_script`
- Verify RSA or ECDSA signed payloads with a configured public key

## How It Works

`Verify Signature` takes a single `input` object with `payload`, `signature`, and optional `timestamp`. It verifies that exact payload using the node configuration, then forwards the original input unchanged on either `valid` or `invalid`.

The node does not read headers, inspect webhook payload shapes, or extract fields from other objects. Upstream nodes are responsible for preparing `{ payload, signature, timestamp }` before verification.

## Configuration

**algorithm** - Public-key algorithm to use.
- Values: `ed25519`, `rsa`, `ecdsa`
- Default: `ed25519`

**public_key** - Public key text in the selected format.
- Required: yes

**public_key_format** - How to parse `public_key`.
- Values: `hex_raw_32`, `hex_spki_der`, `pem_spki`
- Default: `hex_raw_32`
- `ed25519` supports `hex_raw_32` and `hex_spki_der`
- `rsa` and `ecdsa` support `pem_spki`

**message_mode** - Message bytes to verify.
- Values: `payload`, `timestamp_plus_payload`
- Default: `timestamp_plus_payload`

**signature_encoding** - How to decode the incoming signature string.
- Values: `hex`, `base64`
- Default: `hex`

**hash_algorithm** - Hash function for RSA verification, and the supported hash/curve pairing for ECDSA verification.
- Values: `sha256`, `sha384`, `sha512`
- Required for `rsa` and `ecdsa`
- ECDSA pairings in v1:
  - `sha256` -> P-256 keys with DER signatures
  - `sha384` -> P-384 keys with DER signatures
  - `sha512` -> P-521 keys with DER signatures
- Ignored for `ed25519`

**verify_timestamp_freshness** - Reject stale timestamps before signature verification.
- Default: `false`

**timestamp_max_age_seconds** - Max allowed age when freshness checking is enabled.
- Default: `300`

## Inputs

**input** - Object with verification material.

```json
{
  "payload": "{\"type\":1}",
  "signature": "ce3a...",
  "timestamp": "1712345678"
}
```

Notes:

- `payload` and `signature` are required strings
- `timestamp` is optional unless `message_mode` or freshness checking requires it
- `payload` must be the exact content that was signed

## Outputs

**valid** - The original `input` object when verification succeeds.

**invalid** - The original `input` object when verification fails.

Inactive branch behavior:

- Valid signature -> `valid` gets the input, `invalid` is `null`
- Invalid signature -> `invalid` gets the input, `valid` is `null`

## Examples

### Discord verification after preparing input

```text
[Webhook Trigger] -> [Prepare { payload, signature, timestamp }] -> [Verify Signature] -> valid -> [Webhook Response]
```

Recommended config:

```json
{
  "algorithm": "ed25519",
  "public_key": "YOUR_DISCORD_PUBLIC_KEY_HEX",
  "public_key_format": "hex_raw_32",
  "message_mode": "timestamp_plus_payload",
  "signature_encoding": "hex"
}
```

### RSA payload verification

```json
{
  "algorithm": "rsa",
  "public_key": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----",
  "public_key_format": "pem_spki",
  "message_mode": "payload",
  "signature_encoding": "base64",
  "hash_algorithm": "sha256"
}
```

## Runtime Errors

| Error | Cause | Remediation |
|---|---|---|
| `VerifySignature input.payload is required` | Input did not include `payload`. | Prepare `{ payload, signature, timestamp }` upstream before verification. |
| `VerifySignature input.signature is required` | Input did not include `signature`. | Extract or compute the signature upstream and pass it into the node input. |
| `invalid hex encoding for signature` | Signature text did not match the configured encoding. | Fix `signature_encoding` or provide the correctly encoded signature. |
| `unsupported public key format ...` | Algorithm and key format do not match. | Use `hex_raw_32`/`hex_spki_der` for Ed25519 or `pem_spki` for RSA/ECDSA. |
| `timestamp is too old ...` | Freshness validation failed. | Disable freshness checking or increase `timestamp_max_age_seconds` if appropriate. |

## Common Mistakes

- **Passing parsed JSON instead of the signed payload**
  - Problem: Parsed data may not match the exact bytes or text that were signed.
  - Fix: Pass the exact signed payload string into `payload`.

- **Expecting the node to read headers**
  - Problem: `Verify Signature` does not inspect webhook headers or request envelopes.
  - Fix: Prepare `{ payload, signature, timestamp }` upstream.

- **Expecting malformed input to route to `invalid`**
  - Problem: Missing fields, bad encodings, and malformed keys are runtime errors.
  - Fix: Reserve `invalid` for cryptographically invalid signatures only.

## Tips

- Keep this node focused: extract request data upstream, verify here, branch downstream.
- For webhook flows, use the exact `raw_body` from `Webhook Trigger` as `payload` when that is what the provider signs.
- Use `js_script` only when you need custom cryptographic behavior beyond this node's supported algorithms and message modes.
