We started to recognize that the critical elements inside a blockchain are the transaction, the blocks, the nodes and the ledger. However, let’s start from the beginning: what is a transaction inside a blockchain?
The key concept is that transactions are stored inside a hashed block, which “contains” the information of the current block and the hash of the previous one. That’s why it’s called “chain”: the block hash is unalterably connected to the previous one, so a block is immutably connected to the previous one, with everything it is stored inside.
Nodes (the “Consensus” or the “proof of ..”) work inside the blockchain, validating it, keeping it safe, sharing it inside the distributed network. The blockchain, therefore, is the totality of the blocks firmly connected, chained together.
Speaking about the transaction
As above mentioned, every block contains the transactions, which can be considered as the “data” constituting the “shared databases” composing the ledger of the blockchain (Distributed Ledger Technology).
The transactions can be shaped in different ways, according to the rules (governance) of a blockchain; due to the general transaction coding rules, these are structured in this way: there is the sending user, the description of the transaction and finally the receiving user. Both users have access to their cypher keys, besides obviously their Wallet (digital wallet).
Structure of the transaction: cypher keys
“Cipher keys” are the essential elements to open and run transactions. These aren’t hard to understand: every user creates his/her “digital wallet” right when he/she decides to join the blockchain to use it.
This wallet has the same function as a concrete one, with the difference of being digital. Imagine having access to an app on your smartphone or to your home banking system. Right, to safely use this app on a blockchain (both from a personal computer and a smartphone), you are given two cypher keys: one private, one public.
These aren’t physical keys, but cypher keys, digital ones, that is a series of alphanumeric codes. Both are essential because both have a specific function. For every couple of keys, the system creates a public address which is frequently linked to a QR code, that is a kind of barcode which can be used by smartphone cameras to ease some procedures.
For convenience, it is frequently stated that the public key is the recipient address when it is an alphanumeric code which is automatically calculated by the hash function of the public key. So, technically speaking, a user can automatically obtain his/her public address from his public key. This process is meant to enhance even more the security.
The private key is the one that is not to be shared with anyone (shortly you’ll understand why), while the public key is the one that can be shared with everyone. Their use is easy to describe: the user that creates the transaction will sign it with its private key; he/she will include the recipient public key.
The private key (in the preceding that will be shortly described) has a signing function, thanks to this you (that have the private key) assure that you initiated the transaction and consequently approved it.
That’s what happens:
- Irene has a document that wants to share via blockchain with Alessio. She will access the software to create the transaction and share the material for a monetary fee (coin, cryptocurrency). She creates the transaction, inserting the document and eventual details; she will include her digital signature because she has to demonstrate to everybody that she is the owner of the paper she’s selling;
- She creates the digital signature: firstly, she hashes the document; then uses her private key to cypher the hash; that’s why the ciphered hash is called digital signature. Technically speaking, these coding actions are not handmade by the user but are automatically generated by the system.
- Alessio accepts to pay the fee for Irene’s document, the transaction between Irene and Alessio comes to life;
And that’s how another significant advantage of the blockchain comes to life: the user can verify the transaction and its digital signature, he/she doesn’t need to trust it blindly, he/she can simply use the mathematical instruments that the blockchain provides.
- Alessio can verify the digital signature if he wants because it is allowed by the transaction: Alessio can decrypt Irene’s digital signature using her public key. The outcome is the hash of the document (Hash A);
- Alessio can apply the same algorithm to the received, and the output will be the has of the received text (Hash B);
- Finally, Alessio can buy both hashes (Hash A and B) to be sure that the transaction has not been altered.
In essence: users use their private key to make fundamental actions, but they never share it: in this way the private key is not available to malicious users, so the digital signature is kept safe.
Once that the transaction has been secured, it’s safety can be audited by comparing two figures:
- The hashing value of the ciphering between the digital signature and the public key, or Hash A;
- The hash value of the data inside the transaction (the file, image or document), or Hash B;
Now such transaction goes into the block while waiting for it to be filled up to its capacity, then closed and secured.