> For the complete documentation index, see [llms.txt](https://davidjosearaujo.gitbook.io/online-courses/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davidjosearaujo.gitbook.io/online-courses/blockchain-security/consensus-algorithm-security/attacking-proof-of-work.md).

# Attacking proof of work

## Security Assumptions

* The **hash function used in the algorithm should be secure**, meaning it is a one-way function and has collision resistance.
* The difficulty level should be set appropriately to ensure that the difficulty of finding a valid block header is proportional to the hash rate of the network.
* The majority of miners in the network are assumed to be honest.

## Violation of Security Assumptions

* If the hash function is not secure, a miner who discovers this fact can gain an unfair advantage.
* If the **difficulty level is set too high**, it could lead to a denial of service attack where **blocks are not being created**.
* If the difficulty level is set **too low, an attacker could create a malicious version of the blockchain** that becomes longer than the legitimate one.
* If the majority of miners are dishonest, the proof of work algorithm fails.

## Vulnerabilities

* **51% Attack**: If an attacker controls more than 50% of the network's hash power, they can potentially manipulate the blockchain by creating a longer chain of blocks.
* **Denial of Service Attacks**: If the difficulty level is set too high, it can prevent the creation of new blocks, causing a denial of service.
