init method

Future<void> init()

Implementation

Future<void> init() async {
  final privateKey = await _devicePrivateKey.read();

  /// On first app start, the app initializes the device's signing key.
  if (privateKey == null) {
    _keyPair = await _algorithm.newKeyPair();
    await _devicePrivateKey.write(
      base64Encode(await _keyPair.extractPrivateKeyBytes()),
    );
  } else {
    _keyPair = await _algorithm.newKeyPairFromSeed(base64Decode(privateKey));
  }
  _publicKey = await _getPublicKey(_keyPair);
}