Introduction
Recently I went to a Blockchain conference to get some understanding of cryptocurrency which I am totally ignorant of. I came across the concept of “hashes” which are sent from one block to another in order to indicate the integrity of the data sent. It reminded me of the CRC16/32 used in data transmission to achieve the same end.
CRC Error Detection & Correction
![](https://jeremyclark.ca/wp/wp-content/uploads/2022/11/channel_errors.jpg)
In a previous post I examined FEC & CRC for error detection and correction on a telecommunications channel (Ref.1). Figure 1 illustrates this on an HF radio link. A data frame contains FEC bits and a CRC. The FEC bits allow for error correction up to a certain limit. The CRC examines all the bits in the frame to see if there was any change. If there is a difference then an error(s) occurred and a NAK is sent back to the transmit end to resend the data.
CRC Cyclic Redundancy Check is an error detecting code used in digital transmission (Ref.2). For instance AIS uses CRC-16 (ITU-R M.1371-5). SHA or Secure Hash Algorithm is designed to give a unique signature to a block of data such as seen in Blockchain (Ref.3). The algorithm is designed from a cryptographic point of view to make it extremely difficult to reverse the procedure and determine a possible message from the signature or have two different messages giving the same signature.
Blockchain Concept
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/blockchain.jpg)
Figure 2 shows a simple Blockchain model as used say in Bitcoin. Each block contains data and the hash of this data. It also contains the hash of the previous block’s data. If the data received from the previous block is corrupted in any way then the hashes won’t match. BitCoin uses the hash algorithm SHA256.
SHA Calculation Scilab/Octave
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/hash_scilab-2.jpg)
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/sha256_hw_scilab1.jpg)
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/sha256_hw_octave-1024x178.jpg)
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/program-1024x822.jpg)
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/sha256_si5351_scilab.jpg)
![](https://jeremyclark.ca/wp/wp-content/uploads/2024/12/sha256_si5351_octave-1024x132.jpg)
There are various type of hash functions available and these are listed in Figure 3. Open Source mathematics programs like Scilab (Ref.4) and GNU Octave (Ref.5) handle these functions. Figure 4 shows SHA256 in Scilab and Figure 5 in Octave. Note the different order of arguments, but exactly the same result. The answer is a fixed 64 character string. Each hex character can be represented by 4bits (0000=0, 1000=8, 1111=15=f), so this represents a 256bit signature. Figures 4/5 show simple signatures for a text message and Figure 7/8 for an Arduino program.
GNURadio Companion Basics Course:
https://clarktelecommunications.thinkific.com/courses/gnuradio_basics
Please send your comments, questions and suggestions to:
contact:
![YouTube Channel](https://jeremyclark.ca/wp/wp-content/uploads/2020/01/youtube.jpg)
References
#1. – “FEC Forward Error Correction on GNU”
https://jeremyclark.ca/wp/telecom/fec-forward-error-correction-on-gnu-radio/
#2. – “Cyclic Redundancy Check”
https://en.wikipedia.org/wiki/Cyclic_redundancy_check
#3.- “SHA Secure Hash Algorithm”
https://en.wikipedia.org/wiki/SHA-2
#4. – “Scilab”
https://www.scilab.org/
#5. – “GNU Octave”
https://octave.org/