Skip to main content
Strails supports X25519 payload encryption using libsodium’s sealed-box (crypto_box_seal) construction. Encryption is optional on some endpoints, but you should enable it for any production integration that handles PII, wallet addresses, or financial data - an intercepted transport layer will not expose your payload contents.

Security Model

Every encrypted exchange involves two X25519 key pairs. Both parties generate their own pair; each shares only their public key. Strails exposes its public key via GET /getplatformpublickey. You generate your own X25519 key pair and register the 64-character hex public key with Strails via POST /storepublickey so it can encrypt responses and webhooks back to you. The stored key is a raw X25519 public key (not an Ed25519 signing key). It is used only for crypto_box_seal.

Request Encryption Flow

To send an encrypted request:
1

Build your JSON payload

Construct the request body as documented for the endpoint - a plain JSON object.
2

Seal the payload

Use the Strails X25519 public key to seal the payload with libsodium crypto_box_seal. This produces an opaque byte array that only Strails can unseal.
3

Base64-encode and send

Base64-encode the sealed bytes and send the resulting string in the payload field of your request body.

Response Decryption Flow

To decrypt an encrypted response:
1

Extract the payload field

Pull the payload string from the response body.
2

Base64-decode it

Convert the string back to raw bytes.
3

Unseal with your private key

Use libsodium crypto_box_seal_open with your public and private keys to recover the original JSON.

Generate Your Key Pair

Storing Your Public Key

Register your public key with Strails by calling POST /storepublickey. /storepublickey accepts { "data": "<64-hex-character X25519 public key>" } or the AES-encrypted legacy envelope whose decrypted data is the same 64-hex key. Strails will use this key to encrypt all responses and webhooks sent back to your integration.
A successful registration returns 200 OK. After this, Strails will seal response payloads and webhook bodies to your public key so only you can decrypt them.

Platform Public Key

Retrieve the Strails X25519 public key via GET /getplatformpublickey. Use it to seal requests to Strails with libsodium crypto_box_seal.

AES Key (Legacy)

Call GET /getaeskey to retrieve your raw, unmasked AES key. You can use it to decrypt legacy AES-GCM payloads and to verify webhook signatures when no dedicated webhook secret is configured.

Best Practices

  • Never expose your private key. Keep it out of client-side code, logs, environment files committed to source control, and any network call.
  • Use a dedicated secrets manager. Store your private key in AWS Secrets Manager, HashiCorp Vault, or an equivalent service - not in a plain .env file.
  • Rotate keys periodically. Generate a new key pair on a regular schedule, register the new public key with Strails, and retire the old private key from your secrets manager.
  • Test encryption in staging first. Validate your encrypt/decrypt round-trip against https://beta.stablesrail.io/v1/ before enabling it in production.
Contact support@strails.io to receive the current Strails public key, register your own public key, or get help troubleshooting encryption issues.