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.
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.
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).
PowerAuth Server is set up as follows:
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.ECDSA_P384, alone or with MLDSA_65 or MLDSA_87 (a hybrid activation).keystore.powerauth.url and keystore.powerauth.application-id.CustomActivationProvider bean, as described in Register and Revoke Units with CustomActivationProvider.CustomActivationProviderThe 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:
processCustomActivationAttributes(customAttributes, activationId, userId, appId, activationType, context) is called for the CODE and CUSTOM activation types after the activation is created in PowerAuth Server and, in general, before the library commits it. For a CODE activation with an activation OTP, PowerAuth Server may already report ACTIVE when the hook runs, so do not rely on the activation still being PENDING_COMMIT. The attributes it returns are put into the customAttributes of the activation response, which the library encrypts for the device. Register the unit here when the wallet needs user signing, and return the wrapped keys this way. Throwing PowerAuthActivationException terminates the activation flow, so no activation result reaches the app.activationWasCommitted(...) is called after the activation is committed in the same request: automatically (shouldAutoCommitActivation) for the CODE and CUSTOM activation types, or for CODE right after an activation OTP. It is not called when the commit fails. The unit may be registered here instead (when user signing keys are not required).activationWasRemoved(activationId, userId, appId) is called after an activation is removed through the standard removal endpoint of this integration backend.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
}
}
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:
processCustomActivationAttributes, always throw PowerAuthActivationException, so no activation result reaches the app. A PENDING_COMMIT activation is removed automatically when it expires; an ACTIVE activation or one already committed (see above) needs explicit removal or durable recovery.503 hsm_unavailable, authorization_unavailable carry Retry-After) a few times within the request; 409 unit_revoked and 409 activation_state_invalid are final, so do not retry. A lost response is safe to repeat without keys, where 409 unit_already_exists is success. With keys, a repeat after a lost 201 also gets 409 unit_already_exists, but the wrapped keys cannot be fetched again.409 unit_revoked and 400 unit_not_found (the unit was never registered) are success.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.
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.
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.
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.
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.