The document signing process is an important process in many business use cases that guarantees the creation of binding obligations between two or more parties.
Typically, digital signature online services such as DocuSign or Adobe Sign are used as trusted third-parties to prove the authenticity. Therefore, all documents are stored on their third-party servers to be validated.
The PDF specification includes security features including password protection, digital signatures and encryption. These digital signatures are added to the PDF to verify who created and encrypted the document. PDF documents created with TX Text Control can be easily digitally signed which is explained in this article:
But depending on the algorithm that is used, it is not challenging to sabotage the protection.
Using Blockchain to Validate Documents
The blockchain technology can be used to store any data in a block. Basically, a blockchain is a data structure that invalidates previous entries automatically and the integrity can be easily proofed.
In this sample project, we implemented a very basic blockchain to store a checksum of a PDF that has been created using TX Text Control. The implemented blockchain contains a challenge, but is not distributed. Even without a distributed ledger, this technology can be used to validate documents. The Blockchain class consists of a list of Block objects. The Block object itself stores our data (an MD5 checksum and additional data), a time stamp, the previous hash and the current hash. Based on this linked list, every block can be validated by comparing the hash of the previous block with the current hash.
The hash itself is mined and is calculated based on the time stamp, the previous block hash, the data itself and a value called nonce. A nonce ("number only used once") is a number added to the block hash that, when rehashed, meets the difficulty level restrictions.
When starting the sample project, you have two options: Sign Document and Validate Document.
In a first step, a random document needs to be signed using the TX Text Control DocumentViewer for ASP.NET MVC. The signature is created:
And the document is signed:
After all signatures are done, the document needs to be submitted:
When the document has been successfully submitted, it is getting stored on the blockchain using an HTTP endpoint. The document gets loaded into a temporary ServerTextControl and exported as PDF. If a blockchain exists for this document, it is opened and a new block is added with the MD5 checksum. The document and the unique document ID is returned to the client:
The returned document can be downloaded by the user and the validation view is opened automatically. The Unique Document ID is pre-filled into the text box. After clicking Choose File, choose the previously downloaded PDF document (the name of the file is the unique document id) and click Validate Document.
The HTTP endpoint ValidateDocument accepts a PDF document and the unique document ID to validate the document based on the last block in the blockchain. It creates an MD5 checksum of the uploaded PDF document and compares it with the stored checksum in the blockchain. If the values are equal, the uploaded document has not been manipulated and is therefore considered to be valid.
You can try this last validation step by uploading a different or manipulated PDF document. You will see that the document won't be validated:
The whole process is visualized in the following diagram:
A blockchain can be used to store document checksums to validate a document. The blockchain always contains information about the most current version of an uploaded or signed document. The game changing advantage is that documents must not be stored on third-party servers to be validated.
You can download this sample application from our GitHub repository.