Skip to main content

Verifying Signatures

To ensure message integrity and authenticity, the system signs each webhook payload using its private Ed25519 key. You must verify this using the public_key you received during registration.

Verification Steps​

  1. Retrieve the timestamp from the X-DLT-Timestamp header.
  2. Retrieve the signature from the X-DLT-Signature header (Base64URL encoded).
  3. Read the raw request body (exact bytes, do not parse as JSON yet).
  4. Construct the signed message by concatenating the timestamp, a dot (.), and the raw body bytes: message = timestamp + "." + raw_body
  5. Use an Ed25519 library to verify the signature against this message using the provided public key.

Code Examples​

Requires the pynacl library.

import nacl.signing
import nacl.exceptions
import base64

def verify_signature(public_key_b64u, signature_b64u, timestamp, raw_body):
"""
Verifies the Ed25519 signature.
:param public_key_b64u: Base64URL encoded 32-byte public key
:param signature_b64u: Base64URL encoded 64-byte signature
:param timestamp: Value of X-DLT-Timestamp header
:param raw_body: Raw HTTP request body as bytes
"""
try:
# 1. Decode Base64URL strings
# Adding padding if necessary (handled automatically by urlsafe_b64decode in modern Python)
decoded_public_key = base64.urlsafe_b64decode(public_key_b64u + '==')
decoded_signature = base64.urlsafe_b64decode(signature_b64u + '==')

# 2. Construct the signed message
msg = timestamp.encode() + b"." + raw_body

# 3. Verify
verify_key = nacl.signing.VerifyKey(decoded_public_key)
verify_key.verify(msg, decoded_signature)
return True
except (nacl.exceptions.BadSignatureError, Exception):
return False