sign method

Future<String> sign(
  1. String message
)

Signs provided message using Ed25519. Returns signature if successfully signed.

Implementation

Future<String> sign(String message) async {
  var isCorrectUuid =
      await _channel.invokeMethod('checkUuid', {'uuid': uuid});
  if (isCorrectUuid) {
    // if (Platform.isWindows) {
    //   var key =
    //       await _channel.invokeMethod('readData', {'key': "${uuid}_0_priv"});
    //   final LocalAuthentication auth = LocalAuthentication();
    //   try {
    //     final bool didAuthenticate = await auth.authenticate(
    //         localizedReason: 'Please authenticate to sign the message',
    //         options: const AuthenticationOptions(useErrorDialogs: false));
    //     if (didAuthenticate) {
    //       var signature = await NaclWin.signMessage(message, key);
    //       return signature;
    //     } else {
    //       throw SigningFailureException('Signing the message has failed.');
    //     }
    //   } on PlatformException {
    //     throw SigningFailureException('Signing the message has failed.');
    //   }
    //} else {
    var signature = await _channel
        .invokeMethod("signEd25519", {'uuid': uuid, 'message': message});
    if (signature != false) {
      return signature;
    } else {
      throw SigningFailureException('Signing the message has failed.');
    }
    //}
  } else {
    throw IncorrectUuidException(
        'There are no keys associated with this UUID saved on the device');
  }
}