This package adapts the UMIS wallet to React Native and Expo. It sets up the cryptography and gives the app a key store and a credential store on the phone. You need it when you build the mobile wallet app.
It runs in Expo Go and in development builds. It is also the only package of the SDK that touches the phone. The frames,
requests and OpenID4VCI client live in @umis/wallet.
setupCrypto picks WebCrypto or the @noble libraries for the runtime, and installRnPolyfills adds the
one global that some React Native runtimes lack. The @noble libraries are audited on their own, and the audits do
not extend to this SDK.npm install @umis/wallet-rn @umis/core @umis/wallet
npx expo install expo-secure-store expo-crypto
expo version 58 or later, expo-secure-store, expo-crypto and react-native are peer dependencies that the app
provides. For hardware keys in a development build, add the optional peer @animo-id/expo-secure-environment. An app
without it still bundles and runs, and its keys are software keys.
Run this once at start-up, before any other call of the SDK.
import { isRunningInExpoGo } from 'expo';
import * as ExpoCrypto from 'expo-crypto';
import { createKeyStore, installRnPolyfills, setupCrypto } from '@umis/wallet-rn';
installRnPolyfills();
setupCrypto({ getRandomValues: ExpoCrypto.getRandomValues });
export const keys = createKeyStore(isRunningInExpoGo() ? 'expo_go' : 'dev_client', { authenticate });
Put these calls at the top of the app’s entry file, in this order. On a runtime without a TextDecoder, setupCrypto
fails with INVALID_ARGUMENT and asks for installRnPolyfills() first.
authenticate(prompt) shows the biometric prompt and resolves to true only when the phone recognises the member.
Software keys made with requireBiometric need it. The example below builds it on expo-local-authentication.
import * as LocalAuthentication from 'expo-local-authentication';
const authenticate = async (promptMessage: string): Promise<boolean> =>
(await LocalAuthentication.authenticateAsync({ promptMessage })).success;
| Development build | Expo Go | |
|---|---|---|
| Where new keys are made | Secure Enclave, StrongBox or Trusted Execution Environment, and a software key on a device without them, such as the iOS Simulator or Android below 11 | secret store of the device, as a software key |
protection of the signer |
'hardware', or 'software' for the fallback |
'software' |
| Private key | never leaves the secure hardware | the app holds it while it signs |
| Biometric confirmation | enforced by the secure hardware, and a change of the enrolled biometrics invalidates the key | the key store asks authenticate before every signature |
| Native module | optional @animo-id/expo-secure-environment |
none |
| Key attestation | none, shown as attestation: 'none' |
none |
| Random numbers and SHA-256 | WebCrypto if the runtime has it, else @noble with expo-crypto |
@noble with expo-crypto |
const signer = await keys.create('holder-emma-1', { requireBiometric: true, prompt: 'Confirm to use your pass' });
signer.protection; // 'hardware' | 'software'
signer.publicJwk; // P-256 public key, with the RFC 7638 thumbprint as kid
await signer.sign(bytes); // ES256 signature r‖s, 64 bytes; pass the signer to @umis/wallet
await keys.get('holder-emma-1'); // the signer again, or null
await keys.remove('holder-emma-1');
A-Z a-z 0-9 _ -. create refuses a taken alias and never replaces a key. remove
does nothing for an alias that does not exist. The calls for one alias run one after the other, so two creates of
the same alias never both succeed.create makes a hardware key. It makes a software key instead, and protection says so, only
in these four cases.
create fail with CRYPTO_UNAVAILABLE, and no software key is made. If a key
was generated but not completed, create deletes it again.protection: 'hardware' is hardware-backed. On iOS it lives in the Secure Enclave. On Android it lives in
StrongBox or in the Trusted Execution Environment, the TEE. A key in the TEE counts as hardware-backed, like one in
StrongBox. Anything weaker counts as software.create generates a hardware key, it writes the note umis.keymeta.<alias> with a pending mark. It removes
the mark once the key is complete. A key can be left behind when the app stops in between or when its deletion fails.
The secret store cannot be listed, so such a key is deleted the next time its alias is read with get or created with
create.umis.key.<alias>. It is never copied to another device, and on iOS it is readable
only while the device is unlocked. The signer keeps no secret. Each signature reads the key, so the key is released
only after the confirmation, and a removed key can no longer sign.requireBiometric, a software key awaits authenticate(prompt) before every signature. false, a rejection or
any answer other than true makes the signature fail with USER_CANCELLED. For such a key, create without an
authenticate function fails with INVALID_ARGUMENT. A hardware key leaves the confirmation to the hardware and
never calls authenticate.get asks for the confirmation with the prompt of createKeyStore, or with the default text
when there is none. This holds for hardware and software keys alike, because get takes no prompt. The prompt of
create applies only to the signer that create returns.UmisErrors with the codes INVALID_ARGUMENT, USER_CANCELLED, KEY_NOT_FOUND, CRYPTO_UNAVAILABLE
and MALFORMED. KEY_NOT_FOUND means the key is gone or was invalidated. MALFORMED means a stored key record or
note cannot be read, and the error does not quote the stored text. Errors of the secret store itself pass through as
they are.import { createCredentialStore } from '@umis/wallet-rn';
const credentials = createCredentialStore(); // { namespace, chunkChars } are optional
await credentials.put(storedCredential); // StoredCredential from @umis/wallet
await credentials.list();
await credentials.get(id);
await credentials.remove(id);
The store turns a credential into JSON, encodes it as UTF-8 and then base64url, and cuts the text into pieces of 1 800
characters. Each piece stays below the 2 048 bytes that the platform stores accept for one value. Piece n of
credential id is umis.cred.<id>.<n>, or umis.cred.<id>.b<n> in the second of two sets of pieces. The record
umis.cred.<id>.n holds the number of pieces, followed by b when the second set is the one in use. umis.creds.index
lists the ids.
put writes a new credential piece by piece, then its count, then the index. The credential exists once its id is in
the index, so a write that fails leaves the list as it was. A credential that replaces a stored one goes to the set that
the record does not name. Writing the record is what makes it the credential. A write that fails or is cut short
therefore leaves the stored credential as it was, never a mixture of the two. put deletes the old pieces afterwards. A
write can land and still report an error. In that case a new credential whose id reached the index is kept.
remove writes the index first, then deletes the pieces from the last one down, and deletes the count record last. A
removal cut short therefore leaves nothing listed. The next put or remove of the same id deletes the pieces that a
failed or cut-short clean-up left behind.
A-Z a-z 0-9 _ -. The namespace replaces the umis prefix of every key and defaults to
umis. It has the same alphabet and up to 32 characters.put
of a further id fails with INVALID_ARGUMENT and stores nothing.list returns the credentials in the order they were first stored and skips one that cannot be read. get of such a
credential fails with MALFORMED, and remove clears it.puts never lose each other’s index entry.setupCrypto uses WebCrypto when globalThis.crypto.subtle has all six methods that the SDK calls. These are digest,
generateKey, importKey, exportKey, sign and verify. Otherwise it uses the @noble provider of
@umis/core/noble. The random numbers then come from the function you pass, or from expo-crypto when you pass none.
setupCrypto makes the chosen provider the default of the SDK and returns it.
installRnPolyfills adds a UTF-8 TextDecoder with the fatal option to a runtime that has none. The SD-JWT library
needs it. A runtime that has one keeps it, and a second call changes nothing. The decoder does not offer streaming
decoding.
requireBiometric for a software key is a confirmation that the app asks for, not one that the
hardware enforces.requireBiometric, the hardware refuses to sign without a
biometric confirmation.protection is what the app reports about its own key, and a verifier cannot check it.Copyright 2026 Ishtvan Komonii. Licensed under the Apache License 2.0.