Have you read this? It is sort of technical, and goes into How is difficulty calculated?
and How is difficulty stored in blocks?
https://en.bitcoin.it/wiki/Difficulty
re your comment about nonces: The nonce is not the difficulty. In the example below, I'm trying to find a sha256 that starts with 0. On my imaginary blockchain, a proof-of-work that starts with a single 0 is good enough. Notice that I don't change anything but the number after foo
. The number after foo can be thought of as the nonce. It's just some thing I change to get a new proof-of-work.
[I] ➜ ~ echo -n "foo" | shasum -a 256
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae -
[I] ➜ ~ echo -n "foo1" | shasum -a 256
bb4eca334f61af3b67b5d528907d30285151610200539302f4c8cabe66225b53 -
[I] ➜ ~ echo -n "foo2" | shasum -a 256
4963bd713a7eb1bce458868b0c8472bdc8bc5929a7892a92dd24344aea92093d -
[I] ➜ ~ echo -n "foo19" | shasum -a 256
06651ba147df6422edcd47690fd3d68795bc59636f37f10b67a94fa70fe1fdbb - yay
Compare that with miners on the bitcoin blockchain. Currently they have to find a sha256 hash that starts with 19 0's. e.g: 00000000000000000006d31a10b4190a8f86c93189debe87a4d1fff54fbd5b23