unlock method
Implementation
Future<void> unlock(
{String? passphrase,
String? recoveryKey,
String? keyOrPassphrase,
bool postUnlock = true}) async {
if (keyOrPassphrase != null) {
try {
await unlock(recoveryKey: keyOrPassphrase, postUnlock: postUnlock);
} catch (_) {
if (hasPassphrase) {
await unlock(passphrase: keyOrPassphrase, postUnlock: postUnlock);
} else {
rethrow;
}
}
return;
} else if (passphrase != null) {
if (!hasPassphrase) {
throw InvalidPassphraseException(
'Tried to unlock with passphrase while key does not have a passphrase');
}
privateKey = await Future.value(
ssss.client.nativeImplementations.keyFromPassphrase(
KeyFromPassphraseArgs(
passphrase: passphrase,
info: keyData.passphrase!,
),
),
).timeout(Duration(seconds: 10));
} else if (recoveryKey != null) {
privateKey = SSSS.decodeRecoveryKey(recoveryKey);
} else {
throw InvalidPassphraseException('Nothing specified');
}
// verify the validity of the key
if (!await ssss.checkKey(privateKey!, keyData)) {
privateKey = null;
throw InvalidPassphraseException('Inalid key');
}
if (postUnlock) {
await runInRoot(() => _postUnlock());
}
}