[PYTHON] A little deeper story about blockchain, ticking the digital world

The end of the year is approaching, and it's time to feel the passage of time, for better or for worse. Modern people are busy with time, but humans and time are closely related.

By the way, blockchain is evaluated in various ways, such as being tamper-proof and decentralized, but it can also be seen as "creating the flow of time in the digital world." I talked about this topic at the event I took the other day, but I will summarize it again at Qiita! Some problem happened If you click the above image, you can watch the digest of what you saw when you took the stage on youtube!

Time is deep

When did the concept of time come into being in the first place? According to one theory, it was born in Egypt around 3500 BC, more than 5000 years ago. It seems that the shadows created by the sun were used to divide the day into expressing the time until the sun rose and set. Egypt at that time was also a place where the year was 365 days a year, and it was also an important turning point in human history.

By the way, the unit of 1 second we are using now uses the state transition of the element cesium. In addition, Greenwich Mean Time is the standard time around the world. We can see that many people have tried to measure and define accurate "time" so far.

The flow of time itself cannot be seen by the human eye. Therefore, since ancient times, we have expressed the flow of time by marking at regular intervals. We have visualized the flow of time using a great many tools and concepts such as the location of shadows, the position of stars, and the time of day.

Digital world time

The story so far has been in the real world. From a different perspective, what about the digital world? In the digital world, information flew at the "speed of light" and was able to connect people. However, because it is easy to copy and paste data, it is easy to lose track of which data is correct.

Therefore, I think that it would be better to arrange the data in the order in which they were created and organize them according to the passage of time in the same way as in the real world. Even if you know who has what and how much at a certain timing, you can maintain the uniqueness of the data if you can guarantee that the state is only at that timing later and earlier.

Blockchain has created a way to arrange data in this way over time in a decentralized network without administrators. That is why it has become possible to handle "currencies" where information about who has how much is important, and "ownership" about who had them at that time on a digital decentralized network.

Specifically, we have achieved this by linking various technologies, but the ** hash function ** plays an important role among them.

Chain hash functions

Functions called hash functions are very often used on the blockchain. In the blockchain, we created a flow of time by devising and using hash functions.

Hash function?

To put it simply, the hash function is to "convert the input data into data of a certain length and output it".

For example, if you apply the characters Qiita to the hash function, the data will be `` `b352ef02eddfbe535b1a502a7753987ed139b2db30f215d7a793462d69e1570b. qiita bestThen388e0bb2085247e440e97f9f0cfab7aac6e05c4032c3763c33ac17b0d8d50da4```is.

In addition, if the input data changes even a little, the data that comes out will change significantly. If you change the uppercase letter of Qiita to lowercase and make it `` `qiita, it will be e54e4c85c3aab2dfe3782e6bee5742d39899e227edc1b437d7fd30b1f1f7c3a8```.

Hash value comparison


Qiita    ---> b352ef02eddfbe535b1a502a7753987ed139b2db30f215d7a793462d69e1570b
Qiita is the best---> 388e0bb2085247e440e97f9f0cfab7aac6e05c4032c3763c33ac17b0d8d50da4
qiita    ---> e54e4c85c3aab2dfe3782e6bee5742d39899e227edc1b437d7fd30b1f1f7c3a8

Moreover, there is a one-to-one relationship between the input value and the output value, and only one output value can be associated with one input value. Also, it is not possible to back-calculate the input value from the output hash value.

Hash chain

You can do interesting things with this hash function with some ingenuity.

Let's do it for a moment. First, try hashing an appropriate word with a function. This time, let's set it to `Tokyo Station`. This hash value is here. b1da97b0d5652c7498c02f717fa6be043b6b519f801732f8f4c0d7cafd41153e

Next, we will hash `Shinagawa Station`, but we will devise something there. The idea is to combine it with the hash value created earlier and hash it. In other words, `` b1da97b0d5652c7498c02f717fa6be043b6b519f801732f8f4c0d7cafd41153e Shinagawa Station . At the end, there is a proper ``` Shinagawa station `. Hashing this will result in 11ca45f31c305dce198643dbde9bc9981d4763d578f4aa3cac459a820bbdcac4. One of the features of the hash function was that it outputs data of the same length, but it has the same length.

Let's do it in the same way at Shin-Yokohama` `. If you combine the hash value `` `11ca45f31c305dce198643dbde9bc9981d4763d578f4aa3cac459a820bbdcac4 with `` Shin-Yokohama and hash it, it will be `fc2acfecbd366054ee1a547108a8399133399b22e55d0123715efefdc173b4b.

I think it will be easier to understand why the hash function was used in this way by looking at the figure below. hashchain.jpeg Like this, the hash value is calculated using the previous data, and the hash value is used for further calculation in the next data. As a result, there are dependencies on the context of the data.

So, in this case, it can be said that Tokyo station is in front of Shinagawa station, Shin-Yokohama station is behind Shinagawa station, and nothing else is possible. It's unlikely that Tokyo Station will come next to Shin-Yokohama Station.

Blockchain "created the flow of time in the digital world"

The blockchain expresses the flow of time by connecting hashes like a chain as described above. In Satoshi Nakamoto's paper, which summarizes the basic concept of blockchain, the keyword Timestamp appears throughout, and the hash function is used there.

In reality, it functions as a blockchain technology as a whole by linking various technologies such as consensus algorithms, digital signatures, and elliptic curve cryptography to improve security and authenticity. blockchain-component.jpeg

Time goes by... The flow of time cannot be rewound. Past failures, present negligence, future anxieties, and time are sometimes cruel to everyone. But the passage of time is also equal. When you think about time, it makes you wonder how to live now.

Let's end with the quote of the late Steve Jobs.

Your time is limited. So don't waste your life on someone else's life. Don't get caught up in dogma (doctrinal, common sense, existing theory). Because it is living as a result of the thoughts of others. Make sure that the opinions of others do not drown out your inner voice like noise. And most importantly, have the courage to believe in your heart and intuition.

Recommended Posts

A little deeper story about blockchain, ticking the digital world
A little addictive information about Cliff, the CLI framework
A story about changing the master name of BlueZ
A story about how to deal with the CORS problem
A little more about FIFO
After researching the Python library, I understood a little about egg.info.
A refreshing story about Python's Slice
A sloppy story about Python's Slice
A story about using Python's reduce
The story of writing a program
A story about remodeling Lubuntu into a Chromebook
A story about machine learning with Kyasuket
A story about Python pop and append
The story of blackjack A processing (python)
A story about a 503 error on Heroku open
A note about doing the Pyramid tutorial
The story of Django creating a library that might be a little more useful