FAQ Q106: How to store a digital fingerprint (hash) of a message or file on the tangle?

Digital fingerprints are similar to human fingerprints: they are unique for given content (or human). Digital fingerprints are created using a cryptographic hash function, totangle uses the hash function SHA256. The hash functions are one-way only: It is very easy and quick for anyone to calculate the hash value of any content but the opposite process is impossible. It is also practically impossible to create different content whose digital fingerprint will be the same as that of the original content. Storing a digital fingerprint on a distributed ledger (tangle, blockchain) is very useful to prove beyond any doubt that given content already existed on given date and that the content has not since been tampered with. Anybody can very easily re-generate the hash of given content to make sure this is the case.

Totangle can create a digital fingerprint of any field in the trigger event OR it can create a digital fingerprint of a file whose URL is sent in the trigger event. Totangle will first download the file and then it will generate the hash value. Note that the maximum file size is 5MB.

In this tutorial we'll create a rule which will store on the Tangle digital fingerprints of our photos. The data source will be a Google Spreadsheet (although we could use a wide choice of data sources). This way we can prove to the world that given photo was first uploaded to the Internet by us. The resulting transaction on the Tangle (with a timestamp) will be the proof. Once the Totangle rule is configured, the only thing necessary will be to create a new row in a Google Sheet. Totangle will take care of the rest.

In the blue menu on the left, go to Rules and add a new rule. Choose Google Sheets as the trigger.

Then, click the blue button to allow Totangle to access your Google account.

Choose the Google account which has access to your spreadsheet.

The next screen will tell you which access type is requested. The View metadata access is needed so that we can fetch the list of your Google Sheet spreadsheets and the View and manage spreadsheets access is needed to read from and write to your chosen spreadsheet.

Now, click once again on the Google Sheets trigger in the rule configuration:

Let's take a look at the actual spreadsheet. Note that you must use the first (default) sheet and the data must start in the first row (column labels in row 1 and data rows in rows 2 and higher).

Now in the first row add two label columns: photo URL and transaction status. The first column will include the URLs of the photos and the second column is needed by Totangle so it knows when the export must be performed (you must type send when a row is ready) and once the transactions is created this column will include the Totangle transaction ID for your reference.

Now, select the spreadsheet document to be used. When you do this, you'll see the list of columns read. Indicate which column is the status column, in the case of this tutorial, it's called Transaction status.

Submit the configuration screen, then skip the second step of the configuration (filters) and in the third step select the IOTA tangle action. This will open the IOTA tangle configuration screen. Transaction type should be set to Data transaction (JSON) so that each column can be sent separately in the JSON format. You will also need to name the JSON fields sent, let's add fields: photo-url and digital-signature.

In the fourth step, you need to map the trigger fields (columns in the spreadsheet) to the JSON fields which will be sent in the data transaction on the tangle. Use the tags $(...) which will be replaced with the spreadsheet data or other information, such as current timestamp or the Totangle transaction ID. You can also specify any other text you wish or put multiple tags in a single field. In this case the most important field is digital-signature whose value we'll set to $(sha256_url:$(photo_url)). The $(photo_url) tag simply fetches the value of the photo_url trigger event field and the tag $(sha256_url:xxx) downloads the contents of the file whose URL is specified in place of xxx and calculates the SHA256 hash.

Now, we need to activate the new rule and then let's do a simple test. In the Google Sheet, let's add a data row. Remember to set the last column (transaction status) to send only after all other columns are filled out.

After a few minutes the transaction should be sent and you'll see the Totangle transaction ID (HGE in the example below) in place of the word send:

Note that if you quickly add multiple data rows, only a single record will be sent at a time, so e.g. 10 records will take over an hour to be sent.

Here's the resulting transaction in the tangle. You'll find the transaction hash by clicking on the transaction ID in the transaction log.

Please see Q107 if you want to find out how to sign a message or file and store the digital signature in the tangle.
Back to Frequently Asked Questions