Author

Topic: Blockchain Basic: Number System | Random Number | Hash Function (Read 357 times)

legendary
Activity: 3472
Merit: 10611
"byte" is indeed the right term, don't worry too much about it.
i'm just adding a little bit of additional information that could be useful to have in mind in case you encounter the term somewhere. it caused me some confusion the first time i saw the term "octet string" as i thought it is something different than a "byte array".

Do you think that this thread will help understand the basic and most neglected part of the blockchain? I am trying my best to understand and find some resources to study blockchain in a step by step process. Am I on the right path?

I've decided to study blockchain because it is somehow connected to my course. I also want to be one of the members here who has a very deep understanding in the philosophical and technical aspect of bitcoin and its network.

Thanks for inspiring!

when you say blockchain it is referring to such a broad range of topics with cryptography being the dominating topic. so with the topics you listed here you seem to be in the right path mainly Hash functions and Asymmetric Cryptography topics. these could cover the basics then you can move on to how bitcoin is using all that in its Proof of Work algorithm (for mining), in its creation of the chain, and how it uses ECDSA in creating signatures and security that comes with that. and finally a more advanced topic could be the bitcoin script language.
member
Activity: 532
Merit: 36
There is gold in volatility..
Detailed computer mathematical breakdown.

Since you've explain concepts like, binary, hexadecimal , decimal, bit and byte, I'll suggest you explain related mathematical concepts such as:
1. Integer
2. Strings
3. Functions
4. Megabyte, gigabyte, terabytes
3. The hash function.

This will help many. Thanks for your effort.
legendary
Activity: 2366
Merit: 2054
So we can make private key bitcoin [Hexadecimal] using random binary number [256 bits], then using bitaddress.org tool for converting Hex privkey into Private Key WIF Compressed, also we can see public key Bitcoin.

Binary to Hexadecimal has an exact formula, we can converting using excel (spreadsheet) and windows calculator.
Windows calculator only has 64 bits, so we have 4 steps to do 256 bits. I have already made a tutorial how to converting Binary into Hexadecimal.

[1]. How to Flip Binary into Hex Private Key Using Excell or Spreadsheet
[2]. Converting Binary into Hexadecimal using calculator
legendary
Activity: 1904
Merit: 1563
"byte" is indeed the right term, don't worry too much about it.
i'm just adding a little bit of additional information that could be useful to have in mind in case you encounter the term somewhere. it caused me some confusion the first time i saw the term "octet string" as i thought it is something different than a "byte array".

Do you think that this thread will help understand the basic and most neglected part of the blockchain? I am trying my best to understand and find some resources to study blockchain in a step by step process. Am I on the right path?

I've decided to study blockchain because it is somehow connected to my course. I also want to be one of the members here who has a very deep understanding in the philosophical and technical aspect of bitcoin and its network.

Thanks for inspiring!
legendary
Activity: 3472
Merit: 10611
As a newbie and a starter in learning blockchain, this may seem a little technical and quite hard to understand if one is lacking programming skills and other related computer science background. During our last discussion recently, this was the clearest explanation I've ever had about the definition of byte which is 8 bits and till' now I still believe that this is the right term.

"byte" is indeed the right term, don't worry too much about it.
i'm just adding a little bit of additional information that could be useful to have in mind in case you encounter the term somewhere. it caused me some confusion the first time i saw the term "octet string" as i thought it is something different than a "byte array".
legendary
Activity: 1904
Merit: 1563
Very useful tips sir , i been strugling reading convertions from my old school before its all thumbs up  Smiley

Thank you so much, actually there are lots of in-depth explanation regarding these topics on the internet. This is just a guide on how you can easily understand the basic of blockchain.

Very well made, i mean its going to the basics but basics of basics, that many people overlooks as not needed and they skip ahead.
Lots of work done, nicely shown, keep it up. You will benefit this community and learn yourself a lot this way.
Again, good job! Smiley

Thank you so much @Velkro, you know it gives me a boost to continue what I am doing right now. Thank you for the kind words and inspiration, much appreciated.

I would like to thank you for the detailed and in-depth explanation.
I have some suggestions if you don't mind:
- explain what a one way function is.
- give examples of different hash functions and how secure they are.
- replace the md5 example with a more secure function like sha256. It may be confusing as md5 is not used by the blockchain technology.

Can't wait to read your topic about encryption  Smiley


Hello @khaled0111, also thank you for those words of affirmation. Very much appreciated.

I'll try to study those lesson first to avoid giving false information, this technology is very vast and it is not easy to understand in just one night but I'll try my best to self learn these complex topics and share these to the public.

technically it is called an "octet" and an array of them is called an "octet string". apparently there is a programming language or two that have a different definition for a "byte". if you look at most documentations (eg. the RFC docs, NIST standards,...) they all use the term "octet".
but since the popular programming languages have a variable type called byte that is the same as an octet we commonly use the term byte to describe 8-bits.

As a newbie and a starter in learning blockchain, this may seem a little technical and quite hard to understand if one is lacking programming skills and other related computer science background. During our last discussion recently, this was the clearest explanation I've ever had about the definition of byte which is 8 bits and till' now I still believe that this is the right term.

I've done a little research in Stack overflow and as I have understood, the octet is always 8 bits which is obviously from octo means 8 while the byte size differs according to its hardware, which means byte is sometimes has a size of 8 bit or in some cases 16 bits.

I need a lot of understanding to these basic terminologies I think and is very overwhelming. Thank you very much @pooya87

in practice we don't generate any random numbers using any RNG in ECDSA. instead we use a deterministic random number which is a number derived from combining 2 random sources: the private key + message hash being signed.
in fact when you only use RNG once per wallet nowadays (to create a seed for your deterministic wallet) then everything else from creating new keys to signing transactions is deterministic.

Honestly, this is way beyond my understanding but I'll try my best to understand every concept from scratch up to the very complex part of these algorithms. Its pleasure that you noticed my thread @pooya87. Thank you.

legendary
Activity: 3472
Merit: 10611
Quote
A binary number of 8 bits is called a byte. (1 byte = 8 bits)
technically it is called an "octet" and an array of them is called an "octet string". apparently there is a programming language or two that have a different definition for a "byte". if you look at most documentations (eg. the RFC docs, NIST standards,...) they all use the term "octet".
but since the popular programming languages have a variable type called byte that is the same as an octet we commonly use the term byte to describe 8-bits.

Quote
Upon doing my research, it is somehow connected to the bitcoin’s cryptographic algorithm Elliptic Curve Digital Signature Algorithm (ECDSA).
in practice we don't generate any random numbers using any RNG in ECDSA. instead we use a deterministic random number which is a number derived from combining 2 random sources: the private key + message hash being signed.
in fact when you only use RNG once per wallet nowadays (to create a seed for your deterministic wallet) then everything else from creating new keys to signing transactions is deterministic.
newbie
Activity: 9
Merit: 0
Very interesting information that could be useful for everyone who'd take the opportunity to read and understand everything you've posted so far. I'm also awaiting updates to this thread as you add and provide additional info or requests from community members here. Kudos!
legendary
Activity: 2702
Merit: 3045
Top Crypto Casino
I would like to thank you for the detailed and in-depth explanation.
I have some suggestions if you don't mind:
- explain what a one way function is.
- give examples of different hash functions and how secure they are.
- replace the md5 example with a more secure function like sha256. It may be confusing as md5 is not used by the blockchain technology.


Can't wait to read your topic about encryption  Smiley
legendary
Activity: 2296
Merit: 1014
Very well made, i mean its going to the basics but basics of basics, that many people overlooks as not needed and they skip ahead.
Lots of work done, nicely shown, keep it up. You will benefit this community and learn yourself a lot this way.
Again, good job! Smiley
newbie
Activity: 2
Merit: 0
Very useful tips sir , i been strugling reading convertions from my old school before its all thumbs up  Smiley
legendary
Activity: 1904
Merit: 1563
Good Day Everyone, I hope you are having a fantastic day today.

I am a  freshman Computer Engineering student in the Philippines and I decided to create a thread wherein I will use bitcointalk as a means of sharing my knowledge that I absorbed during my stay in the University and from the knowledge I consume when I am doing a self – study about the technicalities of bitcoin and its network. I am not a native English speaker but I will try to explain the technical terms and the concept clearly and concise as much as possible, so please bear with me.

I am posting a sequential lesson in this thread and I'll try to edit or reply in my own thread whenever I learned something that I think is very beneficial for newbies to know and to avoid multiple creation of threads. This way I can just simply add and link them to an overview section below.

Why I am creating this thread:

  • To assess the knowledge that I absorb if it is correct or not. This thread was created mainly because I wanted to share my knowledge as well as to be corrected by someone if there are some misconceptions that I had explained. It is for the benefit of everyone to learn proper knowledge, to distinguish what information must be learned and what not.

  • To give value into the community, there are people in this community who has a very large contribution and it makes me inspired to educate newbies and to contribute for the betterment of the forum. I just wanted to be like those people who dedicate their life into the crypto-space. So fuckin amaze how they can explain this technology with ease.

  • To personally understand the concept, I am having a hard time to fully understand the concept if I am not writing or typing it to the computer. So I decided to share it here to make the knowledge intact inside my brain, and to discipline myself about teaching other people the correct knowledge about Bitcoin.

  • I think it is important for us to know the foundation of every complex algorithm that we see in every news portal in crypto - space, and how bitcoin works inside the network. Learning how to walk before running is a good way to  help prepare ourselves in contributing in this vast technology.




TOPIC OVERVIEW


Topic 1: Number System
Topic 2: Understanding the concept of Random Number
Topic 3: Hash Function




Topic 1: Number System

  • Decimal (base 10) – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Binary (base 2) – 0, 1
  • Hexadecimal (base 16) – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. | A = 10; B = 11; C = 12; D = 13; E = 14; F = 15

BINARY NUMBERS

  • A Binary Number is made up of only 0's and 1's. There is no 2, 3, 4, 5, 6, 7, 8 or 9 etc
  • A single binary digit (like "0" or "1") is called a "bit" (binary digit)
  • For example 1101010 is 7 bits long.
  • A binary number of 8 bits is called a byte. (1 byte = 8 bits)
  • Two bytes has 16 bits, three bytes has 24 bits
  • Binary numbers are used mainly in computers.
  • Binary system is also called base – 2 numeral system. Because it only consists of 0 and 1.

DECIMAL NUMBERS

  • Decimal number only consists of 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
  • Based on wiki, “decimal” comes from the latin word “decimus” which means 10.
  • Mainly used by humans.
  • Decimal System is also called Base – 10 numeral system. Because it only consists of 10 digits from 0 - 9

HEXADECIMALS NUMBERS

  • Hexadecimal numbers consists of 16 sysmbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
  • Mainly used by humans and computers.
  • The latin word hexa means 6 while the decimus which is the latin word for decimal means 10 thus when combined meaning 16.
  • Examples: 1D8A, 8B2F
  • Hexadecimals number are commonly prefixed by “0x” to avoid being mistaken to be a decimal number. Example: 0x1D8A, 0X8B2f, 0x9486.
  • Hexadceimal is also called Base – 16 numeral system



CONVERSION FROM BINARY TO DECIMAL AND HEXADECIMAL NUMBER





CONVERSION FROM DECIMAL TO BINARY AND HEXADECIMAL NUMBER




Conversion steps from decimal to binary
1.   Divide the number by 2.
2.   Get the integer quotient for the next iteration.
3.   Get the remainder for the binary digit.
4.   Repeat the steps until the quotient is equal to 0.

Conversion steps from decimal to hex:
1.   Divide the number by 16.
2.   Get the integer quotient for the next iteration.
3.   Get the remainder for the hex digit.
4.   Repeat the steps until the quotient is equal to 0.

IMPORTANT NOTE: I used pen and paper to at least give an example on how I manually convert these problems. It is a very tedious work if I will use graphic editing tools to represent the computation.



CONVERSION HEXADECIMAL TO BINARY AND DECIMAL NUMBERS






References and resources:
https://www.rapidtables.com/
https://www.mobilefish.com/home/welcome/welcome.html




Topic 2: Understanding the concept of Random Number
return to index

Note that the next lesson is just an introduction of the importance and concept of random number in blockchain technology. Random number is a very complex lesson for a beginner to understand so I am trying my best to explain it clearly. You can use the title of the lesson to further research on the said topic.

What is Random Number

  • Based on my research and using the common sense Random numbers are numbers which are randomly generated like playing a dice, throwing a coin and shuffling of playing cards.
  • Computers can generate Pseudo Random Number Generator (PRNG).
  • A PNRG uses a “seed” as input and a mathematical function which generates a random number.
  • The seed is a relative small number and the generated random number is usually a large number. See the example below to in order for this concept to make sense.
  • In the Blockchain and cryptography random numbers are commonly used to generate public and private keys and can also be used in online gambling

Why random number is significant in blockchain technology?

  • Random numbers are vital because it is a key for a strong digital security. As per my understanding it is obvious that generating an unpredictable numbers can strengthen the encryption which makes sense since one of the key features of blockchain is immutability.
  • It strengthens the security of the transactions.

Upon doing my research, it is somehow connected to the bitcoin’s cryptographic algorithm Elliptic Curve Digital Signature Algorithm (ECDSA).  I won’t explain this algorithm much further since I am still lack of knowledge to understand this kind of cryptography. This algorithm is google – able, so you can find a lot of the information on the internet.

The most common example for this type of generating a random number is called Mid – Square Hashing or Middle Square Algorithm wherein it basically explains how a random number can produce a much larger numbers that can be used of hashing. However this is just an example and this type of hashing algorithm is not used in blockchain technology. Here are the two examples that I found on the internet.

Code:
Suppose a 4-digit seed is taken. seed = 3685
Hence, square of seed is = 3685 * 3685 = 13579225
Now, from this 8-digit number, any four digits are extracted (Say, the middle four).
So, the new seed value becomes seed = 5792
Now, square of this new seed is = 5792* 5792= 33547264
Again, the same set of 4-digits is extracted.
So, the new seed value becomes seed = 5472

Code:
Suppose a 4-digit seed is taken. seed = 3685
Hence, square of seed is = 3685 * 3685 = 13579225  Random number 5792
Multiply the result by itself:
Hence, square of seed is 13579225 * 13579225 = 184395351600625  Random number 5792 5351
Repeat steps until generated random number has your desired number of digits

The random number is equivalent to the middle value of the square seed.


References and resources:
https://www.geeksforgeeks.org/mid-square-hashing/
https://thirtyk.com/2018/07/18/blockchain-random-numbers/
https://www.mobilefish.com/home/welcome/welcome.html




Topic 3: Hash Function
return to index

What is Hash Function? - A function that takes input value, and from that input creates an output value based from the input value.

It can convert a string or a data of any size and outputs a hash. A hash is usually displayed as a hexadecimal number.


A small change in a string of text or data will output different hash


There is also some instances that two different data can produce the same hash. This is called “Hash Collision”..


However, According to Stack Exchange, the hash function can also be considered as “Hash Collision resistant ” when there is a difficulty in finding 2 data or input that has the same hash output



* - not collision resistant

References and sources:
https://www.pelock.com/products/hash-calculator
https://en.wikipedia.org/wiki/List_of_hash_functions#Cryptographic_hash_functions
https://crypto.stackexchange.com/questions/8509/why-crypto-hash-functions-must-be-collision-resistant-and-how-to-find-resistant
Jump to: