init method

Future<void> init()

Implementation

Future<void> init() async {
  final privateKey = await _encryptionPrivateKey.read();
  if (privateKey == null) {
    _keyPair = await _algorithm.newKeyPair();
    await _encryptionPrivateKey.write(
      base64Encode(await _keyPair.extractPrivateKeyBytes()),
    );
  } else {
    _keyPair = await _algorithm.newKeyPairFromSeed(base64Decode(privateKey));
  }

  _publicKey = base64Encode((await _keyPair.extractPublicKey()).bytes);
}