-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignDoc.sol
More file actions
51 lines (43 loc) · 1.87 KB
/
Copy pathSignDoc.sol
File metadata and controls
51 lines (43 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pragma solidity ^0.6.9;
contract SignDocument {
mapping (bytes32 => bool) documentProof;
mapping (string => string) reportInfos;
mapping (string => bytes32) patientReport;
function submit(
string memory patientId,
string memory patientSignature,
string memory doctorSignature,
string memory entitySignature,
string memory reportIdentifier,
string memory document) public {
bytes32 signedDocument = signDoc(document);
storeDocumentProof(patientId, patientSignature, doctorSignature, entitySignature, reportIdentifier, signedDocument);
}
function signDoc(string memory document) private pure returns (bytes32) {
return sha256(abi.encodePacked(document));
}
function storeDocumentProof(
string memory patientId,
string memory patientSignature,
string memory doctorSignature,
string memory entitySignature,
string memory reportIdentifier,
// EncryptionKey
bytes32 signedDocument) private {
string memory infos = string(abi.encodePacked(patientId, patientSignature, doctorSignature, entitySignature, reportIdentifier));
reportInfos[patientId] = infos;
patientReport[patientId] = signedDocument;
documentProof[signedDocument] = true;
}
// User patientID + signature to get the report hash + entitySignature and use it to search for the report
function checkReport (string memory document) public view returns (bool) {
bytes32 signedDocument = signDoc(document);
return hasProof(signedDocument);
}
function getReportInfos (string memory patientId) public view returns (bytes32) {
return patientReport[patientId];
}
function hasProof(bytes32 signedDocument) private view returns (bool) {
return documentProof[signedDocument];
}
}