-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignDoc_old.sol
More file actions
29 lines (21 loc) · 843 Bytes
/
Copy pathSignDoc_old.sol
File metadata and controls
29 lines (21 loc) · 843 Bytes
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
pragma solidity ^0.6.9;
contract StoreDocument {
mapping (bytes32 => bool) documentProof;
function submit(string memory document) public {
bytes32 signedDocument = signDoc(document);
storeDocumentProof(signedDocument);
}
function signDoc(string memory document) private pure returns (bytes32) {
return sha256(abi.encodePacked(document));
}
function storeDocumentProof(bytes32 signedDocument) private {
documentProof[signedDocument] = true;
}
function checkDocument (string memory document) public view returns (bool) {
bytes32 signedDocument = signDoc(document);
return hasProof(signedDocument);
}
function hasProof(bytes32 signedDocument) private view returns (bool) {
return documentProof[signedDocument];
}
}