rotateForEd25519 method

Future<void> rotateForEd25519()

Rotates the keys (the backup key becomes currently used and new key is generated as backup).

Implementation

Future<void> rotateForEd25519() async {
  var isCorrectUuid =
      await _channel.invokeMethod('checkUuid', {'uuid': uuid});
  if (isCorrectUuid) {
    // if (Platform.isWindows) {
    //   var pubKey1 =
    //       await _channel.invokeMethod('readData', {'key': "${uuid}_1_pub"});
    //   var privKey1 =
    //       await _channel.invokeMethod('readData', {'key': "${uuid}_1_priv"});
    //   await _channel.invokeMethod('deleteData', {'key': "${uuid}_0_pub"});
    //   await _channel.invokeMethod('deleteData', {'key': "${uuid}_0_priv"});
    //   await _channel.invokeMethod('deleteData', {'key': "${uuid}_1_pub"});
    //   await _channel.invokeMethod('deleteData', {'key': "${uuid}_1_priv"});
    //   await _channel.invokeMethod(
    //       'writeData', {'key': "${uuid}_0_pub", 'data': pubKey1});
    //   await _channel.invokeMethod(
    //       'writeData', {'key': "${uuid}_0_priv", 'data': privKey1});
    //   var edKeyPair = await NaclWin.generateKey();
    //   await _channel.invokeMethod(
    //       'writeData', {'key': "${uuid}_1_pub", 'data': edKeyPair.pubKey});
    //   await _channel.invokeMethod(
    //       'writeData', {'key': "${uuid}_1_priv", 'data': edKeyPair.privKey});
    //} else {
    await _channel.invokeMethod("rotateForEd25519", {'uuid': uuid});
    //}
  } else {
    throw IncorrectUuidException(
        'There are no keys associated with this UUID saved on the device');
  }
}