/// <summary> /// Validate a document for hospital signature and patient accuracy /// </summary> /// <param name="patient"></param> /// <param name="document"></param> /// <param name="signedMessage"></param> /// <param name="publicKey"></param> /// <returns>DocumentValidationResult</returns> public DocumentValidationResult ValidateDocument(long patientId, Document document, string signedMessage, string publicKey) { var forPateient = document.PatientId == patientId; RSACryptoServiceProvider importedKey = _signatureService.ImportPublicKey(publicKey); var hospitalSigned = _signatureService.VerifySignature(document.ToJson(), signedMessage, importedKey.ExportParameters(false)); return(new DocumentValidationResult(forPateient && hospitalSigned, hospitalSigned, forPateient)); }