Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Last active April 17, 2020 07:37
Show Gist options
  • Save pinheadmz/7a54354f528d4db2f7dd09c3d75319ad to your computer and use it in GitHub Desktop.
Save pinheadmz/7a54354f528d4db2f7dd09c3d75319ad to your computer and use it in GitHub Desktop.
## PREHEAD
----------
nonce (4 bytes)
|
| timestamp (8 bytes)
| |
| | padding (20 bytes) prevBlock (32 bytes) treeRoot(32 bytes) commitHash(32 bytes)
⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀
( <-- 32 bytes --> ) |
V
subHash (32 btyes) maskHash (32 bytes)
HASH( ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ )
| \
| \
V version(4 bytes) \
| \
extraNonce(24 bytes) reservedRoot(32 bytes) witnessRoot(32 bytes) merkleRoot(32 bytes) | bits(4 bytes) \
HASH( ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀ ⚀⚀⚀⚀ ) |
V
prevBlock AGAIN (32 bytes) mask (32 bytes, random)
HASH( ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ )
## SHAREHASH
------------
left = HASH(PREHEAD) (64 bytes) padding (32 bytes) right = HASH(PREHEAD + 8 bytes padding) (32 bytes)
HASH( ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ )
## PoW FUNCTION
---------------
shareHash: ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ (32 bytes)
XOR'ed ^
mask: ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ (32 bytes)
=
powHash: ⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀⚀ (32 bytes)
if (powHash < target ) {return true;}
## BLOCK HEADERS
----------------
size: data:
4 nonce
8 timestamp
32 prevBlock
32 treeRoot
24 extraNonce
32 reservedRoot
32 witnessRoot
32 merkleRoot
4 version
4 bits
32 mask
236 TOTAL
*** padding is deterministically generated:
padding(i) = this.prevBlock[i % 32] ^ this.treeRoot[i % 32]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment