Set up signatures
1
Generate a webhook secret
In your dashboard, go to Developers → API Keys and generate a webhook secret.
2
Store it securely
Put it in an environment variable or a secrets manager. Never commit it.
3
Read the header
Zerocash includes the signature in the
X-Webhook-Signature header of every webhook request.Verify the signature
On each incoming webhook:- Read the signature from the
X-Webhook-Signatureheader. - Compare it against your stored webhook secret.
- Process the webhook only if they match.
Use a constant-time comparison (
timingSafeEqual, hmac.compare_digest, hash_equals) rather
than ==. A naive comparison returns faster the earlier it finds a mismatched byte, which leaks
enough information to recover the secret one character at a time.Security best practices
Always verify
Check the signature on every request, including ones you plan to ignore.
Keep the secret out of git
Environment variables or a secrets manager — never source control.
Rotate periodically
Regenerate the secret on a schedule, and immediately if you suspect exposure.
HTTPS only
Receive webhooks over TLS so payloads and headers cannot be read in transit.