load static method

Future<UVaultKeys> load(
  1. UStorageBackend backend
)

Loads the master key from the platform key store, creating it on first use. When the platform has no key store the key falls back to a private file under the support bucket.

Implementation

static Future<UVaultKeys> load(UStorageBackend backend) async {
  Uint8List? key = await backend.loadSecret(_alias);
  final String fallback = uJoinPath(await backend.root(UStorageBucket.support), ".vault.key");
  key ??= await backend.readAll(fallback);
  if (key == null || key.length != 32) {
    key = uRandomBytes(32);
    if (!await backend.storeSecret(_alias, key)) await backend.writeAll(fallback, key);
  }
  return UVaultKeys(await backend.aead(key), backend);
}