signResponse method

Future<Status> signResponse({
  1. required RequestTransactionPayloadRes initiateTransactionResponse,
  2. required String imagePath,
  3. required ECPrivateKey privateKey,
  4. required RubixServiceClient stub,
  5. required bool onlyPrivateKey,
})

Implementation

Future<Status> signResponse(
    {required RequestTransactionPayloadRes initiateTransactionResponse,
    required String imagePath,
    required ECPrivateKey privateKey,
    required RubixServiceClient stub, required bool onlyPrivateKey}) async {
  var requestId = initiateTransactionResponse.requestId;
  var hashbase64 = initiateTransactionResponse.hash;
  var base64decode = base64.decode(hashbase64);
  if (onlyPrivateKey == false) {
    var hash = utf8.decode(base64decode);
    var imgSign = await GenerateSign().genSignFromShares(imagePath, hash);
    var imgSignBytes = Dependencies().bitstreamToBytes(imgSign);
    var imgSignHash = Dependencies().calculateHash(imgSign);
    var signContent = Uint8List.fromList(imgSignHash.codeUnits);
     var response = await stub.signResponse(HashSigned(
      id: requestId,
      pvtSign: KeyPair().keySignature(signContent, privateKey),
      imgSign: imgSignBytes));
  print("Sign Response:${response}");
  return response;
} else {
  var response = await stub.signResponse(HashSigned(
      id: requestId,
      pvtSign: KeyPair().keySignature(base64decode, privateKey),
      imgSign: []));
  print("Sign Response:${response}");
  return response;
}

}