Blockchain Demonstration

Uludag University Blockchain
10 min readMar 24, 2022

--

What is Cryptology and Cryptography in Short

In order to understand the working logic of blockchain technology, it is necessary to briefly touch on what cryptology is.

Cryptology is the science of ciphers. It covers the procedure of encrypting various messages and writings according to a certain system, transmitting these messages to the recipient in a secure environment, and deciphering the transmitted message. Cryptography comes from the Greek words kryptos (hidden) and graphien (to write). It is the general name given to the methods used to make data incomprehensible to undesirable parties. Data encrypted with algorithmic and mathematical operations can be returned to its original state with the help of data structures called keys. Therefore, the data to be encrypted for the encryption process and the key data structure to be used for the encryption are required. Basically, two techniques are used for encryption.

1)Symmetric Key Encryption

In this technique, the same key data structure is used for encryption and decryption. Anyone who knows the key used for encryption can decrypt it.

2)Asymmetric Key Encryption

In this technique, the key used for encryption and the key used for decryption differ. There are two types of key data structures, Private and Public. Since the public key is created by applying intensive mathematical operations on the private key, obtaining the private key by using the public key requires very high computational power. With the public key, the data is encrypted and only the person who has the private key can decrypt the encrypted data. This is called ‘Public-key encryption’.

Visualizing the Blockchain

Secure Hash:

A hash is a fixed-length, unique string that identifies a piece of data. When the data is entered as input to the hash function, some mathematical operations are applied on it and it outputs a unique string. It is unidirectional. So it is almost impossible to find the original data from a fixed-length hash string. The only way is to check each possible data one by one with the Brute-Force method and continue until compliance is achieved.

Even the slightest change in the data leads to large changes in the hash string. This is called the Avalanche Effect.

(An example of the Avalanche Effect. Capitalizing or lowering a single letter can completely change the hash string.)

The quantity of the hash string may vary from algorithm to algorithm. For example, using the SHA256 (Secure Hash Algorithm) algorithm, every data is summarized as 256 bits. Although it is theoretically possible for different datasets to have the same hash string, there are 2²⁵⁶ possible hash strings according to the SHA256 algorithm. Therefore, the conflict situation can be ignored.

Hash pointers contain pointers to where the data is stored, as well as the hash string. This facilitates data validation and processing.

Block:

A Block consists of two basic structures: the Merkle Tree, which contains the data in the block, and the Block Header to check data integrity. The Merkle tree is an approach developed on the secure hash structure used to securely and quickly validate large datasets. In the Merkle Tree structure, a binary tree structure is created and the pieces in the data set are placed at the lowest level. Then, by producing a hash value in binary from the lowest level to the top, a single hash value (Merkle root value) is produced for the entire tree structure.

If this structure is simplified because it is necessary to go from the simplest to the most complex, the representation of a block will be as follows:

In its simplest form, a block has the number of the block, a Nonce which is defined as an arbitrary number that can only be used once in a cryptographic communication, and the hash of the block. This hash value actually indicates a problem, and the solution to the problem here is that in this example, the hash value starts with 4 zeros. Currently, the green background tells us that the Nonce value is suitable for the data (empty data) in the box, and it provides a hash value that solves the problem (Nonce value: 72608). As the nonce value changes, the hash value also changes.

When we change the data in the empty box, the value of Nonce cannot provide the appropriate hash string for this data and cannot solve the problem.

When we click on the ‘Mine’ button, the Nonce value starts from 1 and searches for a value until we provide the appropriate hash string for the ‘Arif’ data (Nonce value that solved the problem: 62195. Site’s software checked the hash strings which are changing with the Nonce up to 62195).

Blockchain:

In addition to being a sequential state of the above blocks, each block carries the hash string of the previous block in the section that says ‘prev’.

In this structure consisting of several blocks, the first block is called the ‘Genesis Block’ and cannot contain the hash string of the previous block. Representationally, the hash string of the previous block consists of zeros.

In case of no data in the boxes, the Nonce values ​​of the above blocks provided hash strings suitable for these data.

A data change in the first block changes the hash string in that block. In such a case, ‘Prev’ in the next block, that is, the part containing the hash string of the previous block also changes. Since the prev part changes, the value of Nonce sets the hash string of the block according to the changed hash string of the previous block. In this way, the hash string in that block also changes. In a chained fashion, all data becomes invalid.

To validate the ‘Arif’ data, we need to ‘Mine’ the second, third, and all other blocks again, since even if the first block has the appropriate Nonce value, there is a hash change in the second block and the current Nonce value cannot solve the problem. It is thanks to this structure that it becomes more difficult to change if the information is added on top of each other in the blockchain.

Distributed Blockchain:

All information in the blockchain structure is distributed and kept in a peer-to-peer form on all machines on a network open to participants. With this method, a permanent structure is established without the need for a singular institution and by eliminating the few risks created by the singularity.

A change in the 4th block of Peer B gives the same reaction as I mentioned in the blockchain structure. This structure, which includes a democratic system that assumes that this manipulated blockchain does not fit the majority and is considered invalid since the hash strings of blocks in the same numbered blocks in a different peer do not match, even if manipulated peer’s whole problems are solved. Thus this structure provides an even safer environment.

(The manipulated data in Peer B has been validated.)
(Although the problems of blocks 4 and 5 in Peer B are solved (Mined), the hash strings do not match with blocks 4 and 5 in other peers.)

Although the above problem is solved, which is caused by a change in block 4 of Peer B compared to other peers, the hash strings in blocks 4 and 5 are considered invalid because they do not match the hash strings in blocks 4 and 5 from other peers.

In addition, to detect the first manipulated block, it can be checked whether the current and previous hash strings owned by the majority, the same numbered block in the manipulated chain and the previous hash strings are the same. For example, in Peer B, the hash strings of blocks 4 and 5 do not match with blocks in other peers, but the hash strings in block 3 do. So it can be found that the 4th block after the 3rd block has been manipulated for the first time.

Since we can process data into these blocks, we can also process more complex data sets, namely data containing financial transactions.

Tokens:

In ‘Tokens’, which is a structure where we transform the above data into financial data, interpersonal financial transactions and money sent can be displayed.

In the example above, we can see that Ali sent $25 to Ahmet. So where does the data that Ali has $25 come from? According to this structure, people seem to be able to send each other any amount of money they want. Therefore, a new structure emerges with a slight change.

Coinbase:

In this structure, the information that Ali has money is kept in blocks. Thus, the money distributed becomes approved, changes hands and other people can make transactions on these coins.

Although these structures are secure, the fact that the transactions are signed by people provides two-layer security in a way.

Public/Private Keys:

Public and private keys enable Digital signature, which is an approach that is compatible with the concept of asymmetric encryption that we talked about at the beginning.

The formation of the private key and the public key is as follows. This private key does not have to be of a certain length. You can get a more random-looking private key by pressing the ‘Random’ button on the demo site whose link I have shared below.

In the digital signature part, we sign the data with our private key. The digital signature of the data is given to us as a seemingly random string.

The public key, the data itself, and anyone with a digital signature can verify this data. If it is verified, it is understood that the person who has the digital signature also has the relevant private key. Since the private key should not be shared, the person performing the transaction should be the person who signed the data. If we replace the data with financial data, we will have signed the financial transactions.

In this transaction, which was shown as $420.00 from our public key to someone else’s public key, we signed the data with the private key in the same way, and we were able to check whether this transaction was actually signed by us with the public key. Let’s see this on the blockchain.

The above example shows blocks 4 and 5 of a blockchain and includes all the structures we mentioned above. In addition to the Coinbase representation, there are the public keys of us and the person to whom the money is sent, and the signature created by us of this transaction.

Any changes we make here will both invalidate the block and fail to verify the signed transaction.

Even if the block’s problem is resolved, this behavior is considered invalid as the signature created for the transaction cannot verify the changed transaction. Thus, a highly secure structure is formed.

Briefly

In our article, I tried to show the blockchain and digital signature structure in its simplest form. From the links below, you can access the Blockchain Demo site developed by Anders Brownworth and the videos in which he explains these structures. Thank you for reading.

Arif Emre ABDUŞOĞLU

Sources:

https://andersbrownworth.com/blockchain/ — //Anders Brownworth Blockchain Demo

https://andersbrownworth.com/blockchain/public-private-keys/

— //Anders Brownworth Blockchain Demo: Public/Private keys & signing

https://youtu.be/_160oMzblY8 — // Blockchain 101 — Visual Demo/Anders Brownworth

https://youtu.be/xIDL_akeras — //Blockchain 101 — Part 2 — Public / Private keys & signing

https://youtu.be/M576WGiDBdQ — // Solidity, Blockchain, and Smart Contract Course — Beginner to Expert Python Tutorial/freeCodeCamp.org

Blockchain 101(Güncellenmiş versiyon) — Ahmet USTA, Serkan DOĞANTEKİN

https://en.wikipedia.org/wiki/Cryptography — // Cryptography

https://en.wikipedia.org/wiki/Cryptology — // Cryptology

https://en.wikipedia.org/wiki/Cryptographic_nonce — // Cryptographic nonce

https://en.wikipedia.org/wiki/Symmetric-key_algorithm — //Symmetric-key algorithm

https://www.thesslstore.com/blog/symmetric-encryption-101-definition-how-it-works-when-its-used/

— //How symmetric encryption works? When it’s used?

https://cheapsslsecurity.com/blog/what-is-asymmetric-encryption-understand-with-simple-examples/

— //What is asymmetric encryption, with examples

https://www.geeksforgeeks.org/blockchain-merkle-trees/ — //Merkle Tree Structure

--

--