Week 0xB II
Crypto
struct
s00000000 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000020 00 00 00 00 3B A3 ED FD 7A 7B 12 B2 7A C7 2C 3E ....;£íýz{.²zÇ,>
00000030 67 76 8F 61 7F C8 1B C3 88 8A 51 32 3A 9F B8 AA gv.a.È.ÈŠQ2:Ÿ¸ª
00000040 4B 1E 5E 4A 29 AB 5F 49 FF FF 00 1D 1D AC 2B 7C K.^J)«_Iÿÿ...¬+|
00000050 01 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070 00 00 00 00 00 00 FF FF FF FF 4D 04 FF FF 00 1D ......ÿÿÿÿM.ÿÿ..
00000080 01 04 45 54 68 65 20 54 69 6D 65 73 20 30 33 2F ..EThe Times 03/
00000090 4A 61 6E 2F 32 30 30 39 20 43 68 61 6E 63 65 6C Jan/2009 Chancel
000000A0 6C 6F 72 20 6F 6E 20 62 72 69 6E 6B 20 6F 66 20 lor on brink of
000000B0 73 65 63 6F 6E 64 20 62 61 69 6C 6F 75 74 20 66 second bailout f
000000C0 6F 72 20 62 61 6E 6B 73 FF FF FF FF 01 00 F2 05 or banksÿÿÿÿ..ò.
000000D0 2A 01 00 00 00 43 41 04 67 8A FD B0 FE 55 48 27 *....CA.gŠý°þUH'
000000E0 19 67 F1 A6 71 30 B7 10 5C D6 A8 28 E0 39 09 A6 .gñ¦q0·.\Ö¨(à9.¦
000000F0 79 62 E0 EA 1F 61 DE B6 49 F6 BC 3F 4C EF 38 C4 ybàê.aÞ¶Iö¼?Lï8Ä
00000100 F3 55 04 E5 1E C1 12 DE 5C 38 4D F7 BA 0B 8D 57 óU.å.Á.Þ\8M÷º..W
00000110 8A 4C 70 2B 6B F1 1D 5F AC 00 00 00 00 ŠLp+kñ._¬....
In this paper, we propose a solution to the double-spending problem using a peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions
A chain of digital signatures
struct
.
Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin
$ pwd
~/crypto/bigrsa
$ make # featuring libgmp because I'm scared of prime generation
gcc bigrsa.c biggmp.c -std=c89 -Wall -Wextra -Werror -Wpedantic -O2 -lgmp -o bigrsa -lgmp
gcc bigkey.c biggmp.c -std=c89 -Wall -Wextra -Werror -Wpedantic -O2 -lgmp -o bigkey -lgmp
$ ./bigkey
$ echo "CD pays PC n buckerinos" > m.txt # home persona -> work persona
$ ./bigrsa -d m.txt c.txt # -d as we sign with private key
$ cat c.txt # this will be unprintable
8�s4�������}���9�xh�/��1�␦8��v����̃�[M�����]�'3�>Vv
$ ./bigrsa -e c.txt n.txt
$ cat n.txt # will be original message
CD pays PC n buckerinos
$ ../shainc/shainc m.txt # just happen to have a sha256 around
f7208b993f0ad6a7277dee1bf4bb5478a57562c76e5bf18e011d6729f91caaa8 m.txt
$ ../shainc/shainc n.txt
f7208b993f0ad6a7277dee1bf4bb5478a57562c76e5bf18e011d6729f91caaa8 n.txt
The problem of course is the payee can’t verify that one of the owners did not double-spend the coin.
The solution we propose begins with a timestamp server
Each timestamp includes the previous timestamp in sits hash, forming a chain, with each additional timestamp reinforcing the ones before it.
merkle.h
<times.h>
shainc
or sha256sum
nonce
.
$ echo "CD-1>PC0" > tx.txt; ./shainc tx.txt
280f2529f42dc8164b8d630b33f691a3c44eacf426e2ee3cd36f8613ad2b6ee5 tx.txt
$ echo "CD-1>PC1" > tx.txt; ./shainc tx.txt
ce6f47257405beddf0c4aff37e097a58b4c676c632da4f3b2f72a7ca47d96045 tx.txt
$ echo "CD-1>PC2" > tx.txt; ./shainc tx.txt
487fc3985769aa0763a21cc61b2006180d5d78676d58693e91e2da771d5af936 tx.txt
...
$ echo "CD-1>PCE" > tx.txt ; ./shainc tx.txt
e2cd4224f6f6d64684ce4f31587ac1d14eca59390604168f5bde9390861692d3 tx.txt
$ echo "CD-1>PCF" > tx.txt ; ./shainc tx.txt
741f4fee0582ccb44db1503f8e3f326b2ae6c4ee94c3d0f31427e933b40a9fc0 tx.txt
The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it.
If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains.
To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour.
New transactions are broadcast to all nodes
Each node collects new transactions into a block.
When a node finds a proof-of-work, it broadcasts the block to all nodes.
Nodes accept the block only if all transactions in it are valid and not already spent.
Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.
n-2
is known accepted, n-1
is likely accepted but there may be candidates, n
is currently being mined.struct
s