checkShare static method

Future<bool> checkShare()

Implementation

static Future<bool> checkShare() async {
  int sum;
  bool verified = true;

  for (int i = 0; i < secret.length; i++) {
    sum = 0;
    for (int j = 0; j < secret[i].length; j++) {
      sum = (sum + secret[i][j] * candidateArray[i][j]).toInt();
    }

    sum = sum % 2;

    if (sum != int.parse(bits.substring(i, i + 1), radix: 2)) {
      verified = false;
    }
  }

  if (verified == true) {
    print("Share Verified");
    privateImage = PropImage().generateRGB(privateShare, 1024, 512);
    String path = (await getApplicationSupportDirectory()).path;
    String filePath = '$path/Encrypted/Temp/PrivateShare.png';
    var png = image_lib.encodePng(privateImage);
    File(filePath).writeAsBytesSync(png);

    walletImage = PropImage().generateRGB(candidateShare, 1024, 512);
    String filePath_1 = '$path/Encrypted/Temp/PublicShare.png';
    var png1 = image_lib.encodePng(walletImage);
    File(filePath_1).writeAsBytesSync(png1);
  }
  return verified;
}