deriveKeyWithSerializedOptions function

Future<DerivedKey> deriveKeyWithSerializedOptions(
  1. String passphrase,
  2. String serializedDerivationArtefacts
)

Provided a user-entered passphrase and artifacts serialized in cryppo's serialization format, derive the data encryption key.

Implementation

Future<DerivedKey> deriveKeyWithSerializedOptions(
    String passphrase, String serializedDerivationArtefacts) async {
  final DerivationArtefacts artefacts =
      DerivationArtefacts.fromSerialized(serializedDerivationArtefacts);
  final service = artefacts.strategy.toService();
  final keyBytes =
      await service.deriveKey(passphrase: passphrase, artefacts: artefacts);
  return DerivedKey._(
      key: DataEncryptionKey.loadFromBytes(keyBytes),
      derivationArtefacts: artefacts);
}