File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1032,19 +1032,20 @@ In theory calculating the block hash is as easy as:
1032
1032
# # pseudo-code
1033
1033
header = " ..." # 80 bytes (binary)
1034
1034
d1 = sha256( header )
1035
- d2 = sha256( d2 )
1035
+ d2 = sha256( d1 )
1036
1036
d2.to_s # convert 32-byte (256-bit) binary to hex string
1037
1037
# => "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
1038
1038
```
1039
1039
1040
1040
Note: Classic bitcoin uses a double hash, that is,
1041
- for even higher security the hash gets hashed twice with the SHA256 algorithm.
1041
+ for even higher security the hash gets hashed twice with the SHA256 algorithm
1042
+ e.g. ` sha256(sha256(header)) ` .
1042
1043
1043
1044
In practice let's deal with the different byte order conversions
1044
1045
from big endian (most significant bit first)
1045
1046
to little endian (least significant bit first) and back again.
1046
1047
1047
- Tip: Read more @ [ Endianness @ Wikipedia] ( https://en.wikipedia.org/wiki/Endianness ) .
1048
+ Tip: Read more about [ Endianness @ Wikipedia] ( https://en.wikipedia.org/wiki/Endianness ) .
1048
1049
1049
1050
1050
1051
Let's put together the (binary) 80-byte header using the
You can’t perform that action at this time.
0 commit comments