This guide is for the developers of the Wallet Integration Server: the backend between the wallet app, PowerAuth Server and the Secure Keystore. It shows how to set up PowerAuth Server, how to register units during PowerAuth activation, and how to forward the encrypted wallet requests. Terms are explained in the Glossary.

The keystore REST API is the target design; the endpoints are not implemented yet, so this guide describes the intended integration.

What the Integration Backend Does

The Wallet Integration Server sits between the wallet (PowerAuth mobile SDK), PowerAuth Server and the Secure Keystore. It serves the PowerAuth endpoints through the PowerAuth RESTful integration library, calls PowerAuth Server for them, and calls or forwards to the keystore.

Task Wallet calls (Wallet Integration Server) Integration behavior
Activate the device POST /pa/v4/activation/create (and /pa/v4/activation/status) Handled by the library against PowerAuth Server; the commit is done by the library (auto-commit) or by your back office; the CustomActivationProvider registers the unit in the keystore: POST /v1/pa/units, see Register the Unit.
React to activation changes – processCustomActivationAttributes or activationWasCommitted: register the unit; activationWasRemoved: revoke it (POST /v1/pa/units/{unitId}/revocation).
Hand out temporary encryption keys POST /pa/v4/keystore/create Library calls POST /rest/v4/keystore/create of PowerAuth Server.
Unlock the vault POST /pa/v4/vault/unlock (authenticated with X-PowerAuth-Authorization) Library calls PowerAuth Server’s vault unlock and returns the encrypted vault key. The wallet needs it to decrypt the device private keys that sign the keystore requests.
Call the keystore Your forwarding routes, see EUDI Endpoint Mapping Forwards the encrypted body and the X-PowerAuth-Encryption header unchanged to /v1/eudi/... or /v1/pa/units/{unitId}/signatures.

The unit id is the PowerAuth activation id. See PowerAuth Integration for the checks the keystore makes on every request.

Register the Unit

The integration backend registers the unit with POST /v1/pa/units from its CustomActivationProvider. The call is accepted while the activation is PENDING_COMMIT or ACTIVE, so the backend can make it at any point of the activation. The one decision is whether the wallet needs the user-signing keys. They are used only by POST /v1/pa/units/{unitId}/signatures, and because the HSM stores no per-user keys, they exist only as the wrapped keys that the registration response returns. The EUDI endpoints create their own keys (WIA key, credential keys) in the user-authorized calls and do not require user signing keys returned during unit registration.

If the wallet needs user signing (outside EUDI scope), register in processCustomActivationAttributes with includeSigningKeys true (the default) and return the wrapped keys in the custom attributes; the wallet stores them. Otherwise set includeSigningKeys to false and register at any point, for example in activationWasCommitted: no key is created or returned, and user signing fails with 409 wrapped_key_invalid. Revoke the unit in activationWasRemoved either way (POST /v1/pa/units/{unitId}/revocation).

Set Up PowerAuth Server

PowerAuth Server is set up as follows:

  1. Application. Create the wallet application and an application version in PowerAuth Server (POST /rest/v4/application/create and the version methods of the PowerAuth Server REST API). The mobile app is configured with the application version’s mobile SDK configuration string.
  2. Protocol 4.0. The activations must use PowerAuth protocol version 4.0, with the device keys ECDSA_P384, alone or with MLDSA_65 or MLDSA_87 (a hybrid activation).
  3. Access for the keystore. The keystore calls PowerAuth Server’s REST API to resolve the temporary key for decryption and to read the activation status and device keys. Point the Secure Keystore at PowerAuth Server and set the wallet application with the properties keystore.powerauth.url and keystore.powerauth.application-id.
  4. Long-term keys of PowerAuth Server. These can be moved to the HSM; see Backend Key Storage.

Set Up the Wallet Integration Server

  1. PowerAuth RESTful integration library. Add the library and configure it with the PowerAuth Server URL. It serves the activation, temporary-key and vault-unlock endpoints for the wallet.
  2. Unit hooks. Implement and register the CustomActivationProvider bean, as described in Register and Revoke Units with CustomActivationProvider.
  3. Backend caller for the keystore. Ask the keystore operator for a bearer token with the right to manage units (see Backend Callers). Keep it in the Wallet Integration Server only.
  4. Forwarding routes. Expose the routes of the EUDI Endpoint Mapping.

Register and Revoke Units with CustomActivationProvider

The integration backend already serves the PowerAuth activation endpoints with the PowerAuth RESTful integration library. The library calls the hooks of the CustomActivationProvider interface (package com.wultra.security.powerauth.rest.api.spring.provider) during the activation flow. Implement the interface and register it as a Spring bean. Three hooks matter for the keystore:

Example Without Signing Keys: Register on Commit

Use this when the wallet needs only the EUDI endpoints. The unit is registered after the commit with includeSigningKeys set to false; no key is created or returned.

This requires the activation to be committed in the activation request: the provider must auto-commit it (shouldAutoCommitActivation returns true), or the activation must use an activation OTP. An activation that stays in PENDING_COMMIT and is committed later, outside the library, never reaches activationWasCommitted, so no unit is registered. In that case register in processCustomActivationAttributes with includeSigningKeys set to false; the API accepts PENDING_COMMIT.

@Component
class KeystoreActivationProvider implements CustomActivationProvider {

    private final KeystoreClient keystoreClient;

    KeystoreActivationProvider(KeystoreClient keystoreClient) {
        this.keystoreClient = keystoreClient;
    }

    @Override
    public String lookupUserIdForAttributes(Map<String, String> identityAttributes, Map<String, Object> context) {
        return null;   // only for the CUSTOM activation type; return the user id there
    }

    @Override
    public boolean shouldAutoCommitActivation(Map<String, String> identityAttributes, Map<String, Object> customAttributes,
                                              String activationId, String userId, String appId,
                                              ActivationType activationType, Map<String, Object> context) {
        return true;   // commit in the activation request, so that activationWasCommitted is called
    }

    @Override
    public void activationWasCommitted(Map<String, String> identityAttributes, Map<String, Object> customAttributes,
                                       String activationId, String userId, String appId,
                                       ActivationType activationType, Map<String, Object> context)
            throws PowerAuthActivationException {
        try {
            keystoreClient.registerUnit(activationId, false);   // includeSigningKeys: false; unit_already_exists is success
        } catch (KeystoreException e) {
            throw new PowerAuthActivationException("Keystore unit could not be created", e);
        }
    }

    @Override
    public void activationWasRemoved(String activationId, String userId, String appId) {
        keystoreClient.revokeUnit(activationId);   // repeat-safe: unit_revoked and unit_not_found count as success, see Retries
    }
}

Example With Signing Keys: Register During Activation

Use this when the wallet needs user signing. The unit is registered during the activation request (usually before the commit, but the activation may already be ACTIVE for a CODE activation with an activation OTP), and the wrapped keys travel to the app in the encrypted activation response.

@Component
class KeystoreActivationProvider implements CustomActivationProvider {

    private final KeystoreClient keystoreClient;

    KeystoreActivationProvider(KeystoreClient keystoreClient) {
        this.keystoreClient = keystoreClient;
    }

    @Override
    public String lookupUserIdForAttributes(Map<String, String> identityAttributes, Map<String, Object> context) {
        return null;   // only for the CUSTOM activation type; return the user id there
    }

    @Override
    public Map<String, Object> processCustomActivationAttributes(Map<String, Object> customAttributes,
                                                                 String activationId, String userId, String appId,
                                                                 ActivationType activationType,
                                                                 Map<String, Object> context)
            throws PowerAuthActivationException {
        final List<WrappedKeyInfo> keys;
        try {
            keys = keystoreClient.registerUnit(activationId, true);   // includeSigningKeys: keyType and wrappedKey only
        } catch (KeystoreException e) {
            // No unit, no activation: nothing reaches the device
            throw new PowerAuthActivationException("Keystore unit could not be created", e);
        }
        final Map<String, Object> result = new HashMap<>(customAttributes);
        result.put("signingKeys", keys);   // reaches the app in the encrypted activation response
        return result;
    }

    @Override
    public void activationWasRemoved(String activationId, String userId, String appId) {
        keystoreClient.revokeUnit(activationId);
    }
}

Do not store, log or cache the wrapped keys or the response.

Clean up when the hook fails. An exception from processCustomActivationAttributes stops the response, but the library does not remove the activation. A PENDING_COMMIT activation is removed automatically by PowerAuth Server after its expiration; an already ACTIVE one (a CODE activation with an activation OTP) is not, so remove it explicitly through PowerAuth Server (removeActivation) or record it durably for recovery.

Registration failure in activationWasCommitted. The library commits before invoking this hook, so the activation is already committed when registration throws, and aborting the response leaves a server activation the app never received. Expiration does not cover it. Remove the activation explicitly through PowerAuth Server (removeActivation), or record it durably and retry the registration, so the user can be re-activated; do not leave it ACTIVE without a unit.

Rules:

activationWasRemoved covers only the standard removal endpoint of this backend. Removals done directly in PowerAuth Server or through another backend do not call it, and the unit stays active. A user-authorized request of such an activation is still refused, because the keystore checks that the activation is ACTIVE on every request, but the unit is not revoked. To cover these removals, you can complement the hook with a PowerAuth Server callback of type ACTIVATION_STATUS_CHANGE (Method createCallbackUrl) for the REMOVED status, and revoke the unit from the callback handler. The callback is optional.

Forward the Wallet Requests

Every user call of the wallet to the keystore (/v1/eudi/..., /v1/pa/units/{unitId}/signatures) is end-to-end encrypted with the PowerAuth v4 AEAD scheme (End-To-End Encryption) between the wallet and the keystore, in the activation scope. The integration backend is a transport hop.

Forwarding

Expose a route for each keystore endpoint, or one proxy route, and forward the call unchanged:

@PostMapping("/wallet/eudi/units/{unitId}/{operation}")
ResponseEntity<byte[]> forward(@PathVariable String unitId, @PathVariable String operation,
                               @RequestHeader("X-PowerAuth-Encryption") String encryption,
                               @RequestBody byte[] body) {
    // Allow-list "operation" (wallet-instance-keys, wallet-instance-attestations,
    // credential-keys, key-binding-signatures) and validate unitId as a UUID.
    return keystoreClient.post("/v1/eudi/units/" + unitId + "/" + operation, encryption, body);
}

Do not use @PowerAuthEncryption or @EncryptedRequestBody for these routes: they would decrypt the body in the integration backend, which must never happen. Those annotations are for encrypted requests that the integration backend itself consumes.

EUDI Endpoint Mapping

The wallet calls the Wallet Integration Server; the route names below are suggestions, the keystore endpoints are fixed. Every call is a POST with an EncryptedRequest body and the X-PowerAuth-Encryption header, and every success response is encrypted.

EUDI step Wallet route (suggested) Keystore endpoint Reference
Create the WIA key /wallet/units/{unitId}/wallet-instance-keys POST /v1/eudi/units/{unitId}/wallet-instance-keys Create the WIA Key
Issue a WIA and sign the PoP for the PAR /wallet/units/{unitId}/wallet-instance-attestations POST /v1/eudi/units/{unitId}/wallet-instance-attestations Issue a WIA
Create credential keys with a key attestation (and optional proof JWT) /wallet/units/{unitId}/credential-keys POST /v1/eudi/units/{unitId}/credential-keys Credential Keys
Sign the KB-JWT or mdoc device authentication /wallet/units/{unitId}/key-binding-signatures POST /v1/eudi/units/{unitId}/key-binding-signatures Key-Binding Signatures

The aud of the signed request is the keystore path, so a body signed for one endpoint is refused at another. The complete contract is in the OpenAPI document.

The keystore, not the integration backend, authorizes the user: it decrypts the envelope through PowerAuth Server, verifies the device signatures of the signed request and checks that the activation is ACTIVE.

Errors and Timeouts

Return the keystore status and body to the wallet unchanged. Error responses are never encrypted, and 503 carries Retry-After. The wallet creates a new signed request for every attempt. See Possible Error Codes.