---
# System prepended metadata

title: the bitcoin algorithm
tags: [Templates, ' Talk']

---

---
title: the bitcoin algorithm
tags: Templates, Talk
description: View the slide with "Slide Mode".
---

# the bitcoin algorithm

<!-- Put the link to this slide here so people can follow -->
slide: https://hackmd.io/@amirulabu/thebitcoinalgorithm

---

## Who am I?

- a guy
- bitcoin hodler (a story for another time)

---

# what is bitcoin?

---

- bitcoin: virtual currency
- Bitcoin: decentralised network and systems that manages bitcoin
    - decentralised ledger
    - transactions linked by blockchain
    - incentive for people maintaining the network

---

# what is a ledger?

---

![](https://i.ibb.co/ChKJCRw/maxresdefault.jpg)

---

![](https://i.ibb.co/nz3pDbp/cjdxaccfgctgpo8xwf0p6828d-centralized-vs-decentralized-ledger-full.png)

---

# what is blockchain?

---

a system that link blocks of data using their hash

Hashes are cryptographic codes created by special algorithms.

demo 1: https://xorbin.com/tools/sha256-hash-calculator

---

```
data: Epstein didn't kill himself
previous hash: 0000
```

## block 1

---

```
data: Area 51 contains cat girls
previous hash: d11f69bfc9457b4b768511c73fec8e3fd240aec47e36088ed4416dbc86554505
```

## block 2

---

```
data: Antarctica is where they store the aliens
previous hash: 
9c6bab6c7bc1f7f63a2631eab2caae78f9df0eed0d5f2dbe123649454872f4bf
```

## block 3

---

![](https://i.ibb.co/93rxz7T/Screenshot-2020-10-21-at-8-29-47-AM.png)

---

![](https://i.ibb.co/VS8q4F4/Screenshot-2020-10-21-at-8-30-02-AM.png)

---

![](https://i.ibb.co/smHJ5W9/Screenshot-2020-10-21-at-8-30-17-AM.png)

---

# what is a bitcoin mining?

---

- a way to incentivise people maintaining the network

---

remember this?

```
data: Antarctica is where they store the aliens
previous hash: 
9c6bab6c7bc1f7f63a2631eab2caae78f9df0eed0d5f2dbe123649454872f4bf
```

---

now you need to answer a quiz to submit the block

```
data: Antarctica is where they store the aliens
quiz-answer: 12312
previous hash: 
9c6bab6c7bc1f7f63a2631eab2caae78f9df0eed0d5f2dbe123649454872f4bf
```

---

# what is a SHA-256?

---

- A one-way hash can be generated from any piece of data, but the data cannot be generated from the hash. 

<a href="https://imgbb.com/"><img src="https://i.ibb.co/3cCfdrP/9604874-orig.jpg" alt="9604874-orig" border="0"></a>

---

# what is exactly bitcoin mining?

---

to answer the quiz, is to find what alphanumeric combination to produce the hash with n-zeros in front

demo 2: https://xorbin.com/tools/sha256-hash-calculator

```
data: Antarctica is where they store the aliens
quiz-answer: 12312 
previous hash: 
9c6bab6c7bc1f7f63a2631eab2caae78f9df0eed0d5f2dbe123649454872f4bf
```

---

- https://analysis.null.place/how-do-the-bitcoin-mining-algorithms-work/#form4

---

# what are other applications using cryptographic hash function?

---

![facebook login page](https://www.acunetix.com/wp-content/uploads/2016/11/facebook-login.png)

---

# how is password stored in the database?

---

demo 3: https://xorbin.com/tools/sha256-hash-calculator

```
hunter2
```

---

# why can't we store the password as-is?

---

- in case that a person gets access to the database, they can get the password

https://security.blogoverflow.com/2011/11/why-passwords-should-be-hashed/

---

# end 🎉

---

### Wrap up

- bitcoin uses cryptographic hash function as a way to make transactions immutable
- bitcoin also uses cryptographic hash function as a way to identify people doing work algorithmically 
- saving password in a database also uses cryptographic hash function to encrypt password

---

### Thank you! :sailboat: 

---

# bonus: why SHA-256 is not preferred for passwords anymore

---

https://security.stackexchange.com/questions/133239/what-is-the-specific-reason-to-prefer-bcrypt-or-pbkdf2-over-sha256-crypt-in-pass
