decodeRecoveryKey static method
Implementation
static Uint8List decodeRecoveryKey(String recoveryKey) {
final result = base58.decode(recoveryKey.replaceAll(RegExp(r'\s'), ''));
final parity = result.fold<int>(0, (a, b) => a ^ b);
if (parity != 0) {
throw InvalidPassphraseException('Incorrect parity');
}
for (var i = 0; i < olmRecoveryKeyPrefix.length; i++) {
if (result[i] != olmRecoveryKeyPrefix[i]) {
throw InvalidPassphraseException('Incorrect prefix');
}
}
if (result.length != olmRecoveryKeyPrefix.length + ssssKeyLength + 1) {
throw InvalidPassphraseException('Incorrect length');
}
return Uint8List.fromList(
result.sublist(
olmRecoveryKeyPrefix.length,
olmRecoveryKeyPrefix.length + ssssKeyLength,
),
);
}