> For the complete documentation index, see [llms.txt](https://metchain.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metchain.gitbook.io/docs/algorithm/algorithm-3.md).

# Algorithm 3

The proof of work function, parameterized by q, D and hash functions H(·), G(·). The input is (x, C).

1. function pow(x, C)
2. if C = ε then . Determine proof of work instance
3. s <- 0
4. else
5. hs 0 , x0 , ctr0 i <- head(C)
6. s <- H(ctr0 , G(s 0 , x0 ))
7. end if
8. ctr <- 1
9. B <- ε
10. h <- G(s, x)
11. while (ctr ≤ q) do
12. if (H(ctr, h) < D) then
13. B <- hs, x, ctri
14. break
15. end if
16. ctr <- ctr + 1
17. end while
18. C <- CB . Extend chain
19. return C
20. end function

### Algorithm 3 Explained:

Two essential security characteristics of the Bitcoin backbone protocol; the common prefix and the chain quality property were taken into account in \[above and algorithms 2 and 3]. If they remove a few blocks from the tail, the common prefix property assures that two trustworthy participants have the same understanding of the blockchain. On the other hand, the chain quality feature makes sure that chains from honorable players don't include long stretches of hostile blocks. These characteristics are defined as predicates over the random variable created by adding the viewpoints of all par- ties, which is represented by the notation view H(.)Π,A,Z (k, q, z).
