Skip to content

Verify response signatures

Ripple Custody (Vault) protects critical entities, such as domains, users, accounts, and intents, with a data integrity protocol. The API returns each protected entity in a signed envelope with three fields: data, signature, and signingKey. The notary signs the envelope with its API-signing key.

The SDKs verify signed envelopes before they return data from successful responses. Signature verification detects changes to signed data, even when TLS is in place. The SDKs don't verify every object, even when you enable response verification. See Verification limits for the exceptions. Use this page to pin the notary key, handle verification failures, and verify stored payloads.

SDK versions

This page describes TypeScript SDK 0.6.0, Python SDK 0.6.1, and Java SDK 0.3.0. Earlier versions accept some responses that these versions reject, such as a response with its signature removed.

How verification works

Response verification is on by default in all three SDKs. For each successful (2xx) response, the SDK does the following:

  1. Finds the signed envelopes in the body, either a single envelope or the items of a collection.
  2. Verifies each signature over the canonical form of data, with the notary API public key you pinned in the configuration. The SDK ignores the signingKey field in the response, because the server controls that field.
  3. Requires a signature on the operations that return signed entities. See Operations that must return signed data.
  4. Checks that the signed entity is the one you requested, and not an older revision of it. See Request binding and revision checks.

If a check fails, the call throws ResponseSignatureError and doesn't return the data. UnsignedEntityError is a subclass of ResponseSignatureError. The SDK throws it when a response carries no signature where one is required.

The SDK never fetches the notary key on its own. Reading the key from the same API whose responses it verifies would let a compromised server supply its own key. You must pin the key from a source you trust.

Operations that must return signed data

The SDK knows which API operations return signed entities: domains, users, policies, accounts, account addresses, vaults, endpoints, ledgers, tickers, transaction orders, intents, manifests, trusted public keys, system properties, and trusted backup entities. On those operations, the SDK rejects the following responses instead of treating them as unsigned data:

  • An empty body, or a body that isn't JSON.
  • An entity without a signature, including one that contains only data, or only data and signingKey.
  • A collection in which any item has no signature.
  • A single entity where the operation returns a collection.

Responses from other operations, such as balances, transfers, or the requestId returned when you submit an intent, pass through unchanged. The platform doesn't sign them.

Request binding and revision checks

A valid signature proves that the notary signed an entity. It doesn't prove that the entity is the one you asked for, or its latest version. After the signature verifies, the SDK makes two more checks:

  • Requested entity: when you read a single entity by ID, the id in the signed data must match the ID you requested. You can't turn this check off while response verification is on.
  • Revision: the SDK records the highest metadata.revision it has seen for each entity. It rejects a response, or a collection item, that carries a lower revision. The record is held in memory for each client configuration, covers up to 10,000 entities, and starts empty when your application restarts. Addresses, intents, system properties, and trusted public keys have no revision to track.

Both failures throw ResponseSignatureError.

If your deployment can serve an older revision after a newer one, for example when reads are load-balanced across replicas that lag, turn off the revision check in code. No environment variable or config.toml key exists for it:

SDKSetting
TypeScriptPass rejectRevisionRollback: false to generateNewConfiguration. loadConfiguration() doesn't accept it.
JavaCustodyClientConfig.rejectRevisionRollback(false)
PythonSet reject_revision_rollback = False on the Configuration.

Verification limits

  • Unvalidated tickers: the platform signs a ticker only after it's validated. tickers.list() returns validated tickers only, each verified against the pinned key. To read tickers that aren't validated yet, use listUnvalidated() (list_unvalidated() in Python) or get the ticker by ID. The SDK can't verify the data of an unvalidated ticker.
  • Unsigned account addresses: the platform can return a generated account address without a signature. The client's account address methods return an unsigned address only if they can re-derive it from the account's extended public key. Otherwise they throw AddressIntegrityError. The SDKs can re-derive addresses only on Bitcoin-family ledgers. On other ledgers, set RC_VERIFY_DERIVED_ADDRESSES=false to accept an unsigned address. The SDK then returns the address with a warning and nothing verifies it. See Configure the SDK.
  • Generated API classes: if you call the generated API classes directly instead of the client's methods, the SDK rejects unvalidated tickers and unsigned account addresses with UnsignedEntityError.
  • Operations that return unsigned data: the SDK doesn't verify responses from operations outside the list in Operations that must return signed data.
  • Manual verification: the manual verifier doesn't know which operation a payload came from. It requires the payload to be signed: a single entity if the payload has data, otherwise every item in items. It throws UnsignedEntityError if the entity or any item has no signature, and returns the number of envelopes it verified. It returns 0 only for an empty items array. It doesn't make the requested-entity or revision checks.

If an operation requires verified data from a stored payload, check how many envelopes the manual verifier checked. For a single signed envelope, require a count of 1. For collections, compare the count with the number of items you expect to carry signatures. Investigate verification warnings. Don't suppress them or disable verification.

Behavior without a pinned key

If verification is on and you haven't configured a notary API public key, the SDK refuses to build a client instead of running without verification:

SDKWhere it failsError
TypeScriptloadConfiguration()CustodyError
JavaCustodyClient.fromConfig(config) or new CustodyClient(config)CustodyError
Pythonload_configuration()ConfigurationError

To fix the error, pin the key as described in Configure the key. To run without verification, see Disable verification.

Get the notary API public key

You need the notary's API-signing public key, encoded as a base64 DER (Distinguished Encoding Rules) SubjectPublicKeyInfo value. The notary has other keys, such as the messaging key and the collections key. They don't verify API responses, and pinning one of them causes every protected response to fail.

Get the key out of band from a source you trust:

  • If your organization operates Ripple Custody (Vault), ask the team that deployed the notary. The notary generates its API key during setup, and again during each key rotation. See Notary key rotation and migration.
  • If Ripple hosts your deployment, contact the Ripple support team.

To cross-check the value, call List API public keys and compare items[].data.publicKey with the key you received. Treat this only as a check: don't build a client that discovers its pinned key from the API at startup.

Configure the key

The RC_NOTARY_API_PUBLIC_KEY environment variable works the same way in all three SDKs:

export RC_NOTARY_API_PUBLIC_KEY="MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE..."

The config.toml key is notary_api_public_key in all three SDKs. The accepted key formats and the programmatic setter differ by SDK, as the following tabs show. Environment variables override the file.

notary_api_public_key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE..."

The SDK accepts a PEM (Privacy-Enhanced Mail) or base64 DER key and normalizes it. If you build the configuration in code with generateNewConfiguration, pass the key as notaryApiPublicKey.

Rotate the notary key

After a notary key rotation, the notary signs with its new API-signing key. Each SDK pins one key. Update the configured key when the new notary becomes active and restart your application.

Known limitation: entities signed before the rotation

A notary key rotation doesn't re-sign existing entities. An entity keeps the signature from the previous API-signing key until an intent next changes it. Each SDK pins one key, so after a rotation no single key verifies every response. A client that pins the new key rejects entities signed before the rotation with ResponseSignatureError, and a client that pins the old key rejects everything signed since. A rotation therefore breaks API integrations that verify response signatures.

Upcoming SDK patch releases will address this limitation. Until then, if your applications verify responses, contact the Ripple support team before you rotate the notary key.

For the rotation procedure, see Notary key rotation and migration.

Handle ResponseSignatureError

ResponseSignatureError is a subclass of CustodyError. It means one of the following:

  • A key other than the one you pinned signed the response. The usual cause is a notary key rotation, or a pinned key that isn't the API-signing key.
  • The signature doesn't match the data, or the envelope isn't well formed. This can mean that something altered the response between the notary and your application, for example a proxy that rewrites response bodies.
  • The response has no signature where the operation requires one. For this case the SDK can throw the subclass UnsignedEntityError. One cause that isn't tampering is a ticker that's awaiting validation.
  • The signed entity isn't the one you requested, or it's an older revision than one the client has already seen.

A handler that catches ResponseSignatureError also catches UnsignedEntityError.

Don't retry the call or turn off verification to get past the error. Confirm the pinned key with your operator first. If the key is correct, treat the response as untrusted and investigate the network path.

The following example shows where to handle the error:

import { ResponseSignatureError } from '@ripple/ripple-custody-client-lib-typescript';

try {
  await client.governance.domains.list({ limit: 10 });
} catch (err) {
  if (err instanceof ResponseSignatureError) {
    // Don't use the data. Check the pinned notary key, then alert.
  }
  throw err;
}

Verify a payload manually

The client checks supported response envelopes automatically, with the exceptions in Verification limits. To check a payload from another source or a response body you saved earlier, use the client's manual verification method. It uses the configured key unless you pass another key. It returns the number of envelopes it verified.

Preserve the raw JSON response. Converting it to SDK models and back to JSON can change signed fields and cause verification to fail. Parse the original JSON as shown in these examples instead.

The following examples require exactly one verified envelope in a stored response body, responseText (response_text in Python). For a collection, use the expected number of signed items instead:

const count = client.verifySigned(JSON.parse(responseText));
if (count !== 1) {
  throw new Error(`Expected one verified envelope, got ${count}`);
}

Disable verification

Turn verification off only for local development or a test cluster where no notary API key is available. Don't disable it in production: without it, your application trusts API responses on the strength of TLS alone. The TypeScript and Python SDKs treat the opt-out as deprecated and log a warning when you use it.

With verification off, the SDK makes none of the checks on this page. The client's account address methods also refuse an unsigned address that they can't re-derive, because nothing authenticates the account's extended public key. To accept such an address, also set RC_VERIFY_DERIVED_ADDRESSES=false.

To opt out in any SDK, set RC_VERIFY_RESPONSES=false. Each SDK also has its own options:

verify_responses = false

If you build the configuration in code with generateNewConfiguration, pass verifyResponses: false.