This guide is for the wallet-app developers. It shows, with the PowerAuth Mobile SDK, how the app builds the signed request, encrypts it and calls the Secure Keystore through the Wallet Integration Server. Terms are explained in the Glossary.
The keystore REST API is the target design; the endpoints are not implemented yet. The SDK calls below are taken from the PowerAuth Mobile SDK documentation and sources, and the snippets are illustrations, not tested code.
unitId. See Integration Guide: Backend.persistActivationWithPassword on Android, persistActivation(withPassword:) on iOS) and its status is ACTIVE. The keystore refuses every call of an activation in another state with 403 invalid_user_authorization; check the status (fetchActivationStatusWithCallback on Android, fetchActivationStatus on iOS) before the first call.CustomActivationProvider. If the app uses the user-signing keys, it does so during the activation and returns the wrapped keys in the customAttributes of the encrypted activation response, see Read the Wrapped User-Signing Keys. Otherwise the response contains no keys and the app stores none. Ask the backend team whether the keys are returned./pa/v4/keystore/create for the temporary encryption key and /pa/v4/vault/unlock for the vault unlock (see Vault Unlock and Signed Request).
EncryptedRequest) and the X-PowerAuth-Encryption header.Every call needs a new signed request (new jti, current iat) and a new encryption. Never resend an old body.
There is no separate vault call for the keystore: calculateJwsSignature unlocks the vault and signs in one step. The vault unlock is a network call: the SDK sends POST /pa/v4/vault/unlock to the Wallet Integration Server with a PowerAuth authentication code, and PowerAuth Server checks the PIN or biometry there. A wrong PIN fails the call before anything reaches the keystore, and PowerAuth Server counts it as a failed attempt; after the configured number of failed attempts the activation is blocked.
Each keystore call needs its own PowerAuthAuthentication object, because one object is used for one vault unlock only. The app may ask the user once and build a new object from the same PIN for every call of a flow (an issuance makes four keystore calls, see EUDI Wallet Flows); with biometry, every call shows the biometric prompt. Pass the key identifier DEVICE (Android) or .device (iOS) to sign with all device keys, and compact = false to get the JSON serialization (see Signed Request for the claims and rules). The typ must be sk-request+jwt.
The keystore requires an iat from the SDK’s synchronized time. The Android service returns milliseconds and iOS returns seconds as TimeInterval. Synchronize the time first if isTimeSynchronized is false.
val unitId = "2a7d9c14-5e0b-4c1e-9d0a-6f3b8e21c7a4"
val timeService = powerAuthSDK.timeSynchronizationService
val claims = JSONObject()
.put("aud", "/v1/eudi/units/$unitId/wallet-instance-keys")
.put("sub", unitId)
.put("iat", timeService.currentTime / 1000) // milliseconds to seconds
.put("jti", randomBase64Url(16)) // your helper: 16 random bytes, base64url without padding
.put("request", JSONObject()) // the request members of the endpoint
val claimsData = claims.toString().toByteArray(Charsets.UTF_8)
// PIN; for biometry use powerAuthSDK.authenticateUsingBiometrics(...) to get the authentication object
val authentication = PowerAuthAuthentication.possessionWithPassword("1234")
powerAuthSDK.calculateJwsSignature(context, authentication, claimsData, "sk-request+jwt", false,
PowerAuthSignatureKeyId.DEVICE, object : IJwsSignatureListener {
override fun onJwsSignatureSucceed(signedData: String, compactForm: Boolean) {
// signedData is the JSON serialization of the signed request
}
override fun onJwsSignatureFailed(throwable: Throwable) { /* wrong PIN, canceled, ... */ }
})
let unitId = "2a7d9c14-5e0b-4c1e-9d0a-6f3b8e21c7a4"
let timeService = powerAuthSDK.timeSynchronizationService
let claims: [String: Any] = [
"aud": "/v1/eudi/units/\(unitId)/wallet-instance-keys",
"sub": unitId,
"iat": Int(timeService.currentTime()), // seconds
"jti": randomBase64Url(16), // your helper: 16 random bytes, base64url without padding
"request": [String: Any]() // the request members of the endpoint
]
let claimsData = try JSONSerialization.data(withJSONObject: claims)
let auth = PowerAuthAuthentication.possessionWithPassword(password: "1234")
powerAuthSDK.calculateJwsSignature(authentication: auth, forData: claimsData, dataType: "sk-request+jwt",
compact: false, withKey: .device) { jws, error in
if let jws {
// jws is the JSON serialization of the signed request
} else {
// authentication failed or canceled
}
}
A wrong iat or a repeated jti is refused as 403 invalid_user_authorization. The Secure Vault functions (fetchSecureVaultKey) return a key-derivation key for the app’s own purposes; the keystore flows do not use them.
powerAuthSDK.getEncryptorForActivationScope(object : IGetEncryptorListener {
override fun onGetEncryptorSuccess(encryptor: CoreEncryptor) {
val encrypted = encryptor.encryptRequest(signedData.toByteArray(Charsets.UTF_8))
val body = encrypted.requestBody // the EncryptedRequest JSON
val headers = encrypted.requestHeaders // contains X-PowerAuth-Encryption (key, value)
// POST body with all headers to the Wallet Integration Server ...
// ... then, for a 2xx response:
val response = encryptor.decryptResponse(CoreEncryptedResponse(responseBody))
}
override fun onGetEncryptorFailed(t: Throwable) { /* no activation, temporary key not available, ... */ }
})
On Android, getEncryptorForActivationScope takes only the listener.
powerAuthSDK.encryptorForActivationScope { encryptor, error in
guard let encryptor else { return } // report the error
do {
let encrypted = try encryptor.encryptRequest(Data(jws.utf8))
var request = URLRequest(url: wallet.keystoreUrl(operation: "wallet-instance-keys")) // your helper
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
encrypted.requestHeaders.forEach { request.addValue($0.value, forHTTPHeaderField: $0.key) }
request.httpBody = encrypted.requestBody
// send the request; for a 2xx response:
// let plain = try encryptor.decryptResponse(PowerAuthEncryptedResponse(responseBody: responseBody))
} catch { /* report */ }
}
Error responses are application/problem+json and are not encrypted; do not try to decrypt them. A 403 on a fresh request usually means a wrong iat, an inactive activation or a reused jti; see Possible Error Codes. On 503, wait for Retry-After and build a new request.
The request members below go into the request claim. The full contract is in the EUDI API, and the order of the calls in EUDI Wallet Flows. Each call repeats the three steps above with its own aud.
| Step | Route (POST) |
request claim |
Result to keep |
|---|---|---|---|
| Create the WIA key | /v1/eudi/units/{unitId}/wallet-instance-keys |
{} |
publicJwk, wrappedKey of the WIA key |
| WIA and signed PoP | /v1/eudi/units/{unitId}/wallet-instance-attestations |
publicJwk, wrappedKey, walletVersion, unsignedPop |
wia and signedPop, used at once for the authorization server |
| Create credential keys | /v1/eudi/units/{unitId}/credential-keys |
keyCount, cNonce, optional includeProofJwt, credentialIssuer, clientId |
keys[] (publicJwk, wrappedKey), keyAttestation, proofJwt |
| Sign a key-binding JWT | /v1/eudi/units/{unitId}/key-binding-signatures |
items[] of wrappedKey and signingInput (SHA-256 of the KB-JWT signing input) |
signatures[], to build the KB-JWT |
Notes:
The keystore signs, but it does not build the OAuth and OpenID4VP messages. The app builds these inputs:
wallet-instance-attestations: BASE64URL(header) || '.' || BASE64URL(payload), no signature. The header is {"typ":"oauth-client-attestation-pop+jwt","alg":"ES256"}. The payload has iss (the client id of the wallet solution, the WIA’s sub), aud (the issuer identifier of the authorization server the PoP is for), a fresh random jti and iat (Unix seconds); add a challenge if the authorization server issued one. The keystore checks these rules (Issue a WIA) and returns the signed PoP. The app sends the WIA in the OAuth-Client-Attestation header and the signed PoP in OAuth-Client-Attestation-PoP, as OAuth 2.0 Attestation-Based Client Authentication defines. Make one wallet-instance-attestations call for each request to the authorization server (PAR, token request, refresh), right before it.{"typ":"kb+jwt","alg":"ES256"}, the payload with iat, aud (the verifier’s client id from the request object), nonce (the request object’s nonce) and sd_hash (base64url SHA-256 of the presented SD-JWT with the selected disclosures, ending with ~). The signing input is BASE64URL(header) || '.' || BASE64URL(payload). Send its SHA-256, base64url without padding, as signingInput to key-binding-signatures with the credential’s wrapped key. The answer is the ES256 signature as R‖S, base64url, ready for the JWS: the KB-JWT is <signing input>.<signature>, appended to the SD-JWT. The presentation itself follows OpenID4VP 1.0.includeProofJwt, the keystore returns the key proof (proofJwt) for proofs.jwt; without it, the app sends the key attestation (keyAttestation) in proofs.attestation. The cNonce is the issuer’s c_nonce from its nonce endpoint.The DPoP proofs for the authorization server and the issuer are signed with a key the app holds itself; they are not keystore calls.
If the wallet uses user signing, the keystore creates the user-signing keys while the activation is created, and the Wallet Integration Server returns their wrapped keys in the customAttributes of the activation result. The PowerAuth SDK decrypts the activation response, so the app reads them from the result of createActivation and stores them at once: without them POST /v1/pa/units/{unitId}/signatures cannot be used. The attribute name (keystoreKeys below) and its layout are agreed with your backend team.
// Android: result is the CreateActivationResult of createActivation
val keys = result.customActivationAttributes?.get("keystoreKeys") as? List<*> // items: {keyType, wrappedKey}
// iOS: result is the PowerAuthActivationResult of createActivation
let keys = result.customAttributes?["keystoreKeys"] as? [[String: Any]] // items: {keyType, wrappedKey}
If the activation response contains the keystore keys, store them. If your backend is set up to return them and the attribute is missing, treat the activation as failed and remove it; the keys cannot be fetched later. The wrappedKey for ECDSA_P384 is always present, plus MLDSA_65 or MLDSA_87 for a hybrid activation. Persist the activation as usual (the commit happens on the server); the unit needs nothing more.
A wrapped key is an opaque string: store and send it unchanged and never parse it. It is useless without the device keys, but it is still tied to the credential, so keep it in encrypted app storage. To remove the activation, call removeActivationWithAuthentication (Android) or removeActivation(with:) (iOS) with the user’s authentication; the request goes through the Wallet Integration Server, which revokes the unit. Then delete the stored wrapped keys.