0000: 5b 75 70 5d 28 73 71 75 69 64 2e 6d 64 29 20 5b [up](squid.md) [
0010: 62 61 63 6b 5d 28 73 71 75 69 64 2d 66 65 64 2e back](squid-fed.
0020: 6d 64 29 20 5b 6e 65 78 74 5d 28 73 71 75 69 64 md) [next](squid
0030: 2d 6c 69 74 65 72 61 74 75 72 65 2e 6d 64 29 0a -literature.md).
0040: 0a 23 20 44 75 6d 62 20 43 6f 6e 74 72 61 63 74 .# Dumb Contract
0050: 73 0a 0a 54 6f 20 6b 65 65 70 20 74 68 69 6e 67 s..To keep thing
0060: 73 20 73 69 6d 70 6c 65 2c 20 49 20 63 68 6f 73 s simple, I chos
0070: 65 20 74 6f 20 6e 6f 74 20 68 61 76 65 20 73 6d e to not have sm
0080: 61 72 74 20 63 6f 6e 74 72 61 63 74 73 3b 20 72 art contracts; r
0090: 61 74 68 65 72 20 74 68 65 0a 6f 70 70 6f 73 69 ather the.opposi
00a0: 74 65 3a 20 64 75 6d 62 20 63 6f 6e 74 72 61 63 te: dumb contrac
00b0: 74 73 2e 20 20 54 68 65 20 6d 61 69 6e 20 72 65 ts. The main re
00c0: 61 73 6f 6e 20 69 73 20 74 68 61 74 20 70 65 6f ason is that peo
00d0: 70 6c 65 20 64 6f 6e 27 74 20 75 6e 64 65 72 73 ple don't unders
00e0: 74 61 6e 64 0a 63 6f 6d 70 6c 69 63 61 74 65 64 tand.complicated
00f0: 20 63 6f 6e 74 72 61 63 74 73 20 69 6e 20 6c 65 contracts in le
0100: 67 61 6c 65 73 65 2c 20 61 6e 64 20 6d 75 63 68 galese, and much
0110: 20 6c 65 73 73 20 73 6f 20 69 6e 20 46 6f 72 74 less so in Fort
0120: 68 20 6f 72 20 4a 61 76 61 53 63 72 69 70 74 2e h or JavaScript.
0130: 0a 46 6f 72 20 6d 6f 73 74 20 66 69 6e 61 6e 63 .For most financ
0140: 69 61 6c 20 74 72 61 6e 73 61 63 74 69 6f 6e 73 ial transactions
0150: 2c 20 79 6f 75 20 64 6f 6e 27 74 20 6e 65 65 64 , you don't need
0160: 20 61 20 73 6d 61 72 74 20 63 6f 6e 74 72 61 63 a smart contrac
0170: 74 2c 20 61 6e 79 77 61 79 73 2e 0a 54 68 65 20 t, anyways..The
0180: 62 61 73 69 63 73 20 6f 66 20 61 20 63 6f 6e 74 basics of a cont
0190: 72 61 63 74 20 69 73 20 74 68 61 74 20 79 6f 75 ract is that you
01a0: 20 6f 66 66 65 72 20 73 6f 6d 65 74 68 69 6e 67 offer something
01b0: 20 61 6e 64 20 77 61 6e 74 20 73 6f 6d 65 74 68 and want someth
01c0: 69 6e 67 20 65 6c 73 65 0a 69 6e 20 65 78 63 68 ing else.in exch
01d0: 61 6e 67 65 2e 20 20 57 65 20 61 73 73 75 6d 65 ange. We assume
01e0: 20 66 6f 72 20 73 69 6d 70 6c 69 63 69 74 79 20 for simplicity
01f0: 74 68 61 74 20 61 6c 6c 20 74 68 69 6e 67 73 20 that all things
0200: 6f 66 66 65 72 65 64 20 6f 72 20 61 73 6b 65 64 offered or asked
0210: 20 66 6f 72 0a 61 72 65 20 72 65 63 6f 72 64 65 for.are recorde
0220: 64 20 69 6e 20 74 68 65 20 73 61 6d 65 20 42 6c d in the same Bl
0230: 6f 63 6b 43 68 61 69 6e 2e 0a 0a 23 23 20 41 73 ockChain...## As
0240: 73 65 74 73 20 61 6e 64 20 4f 62 6c 69 67 61 74 sets and Obligat
0250: 69 6f 6e 73 0a 0a 54 6f 20 61 6c 6c 6f 77 20 61 ions..To allow a
0260: 72 62 69 74 72 61 72 79 20 72 65 61 6c 20 77 6f rbitrary real wo
0270: 72 6c 64 20 67 6f 6f 64 73 20 74 6f 20 62 65 20 rld goods to be
0280: 72 65 70 72 65 73 65 6e 74 65 64 20 62 79 20 61 represented by a
0290: 20 74 6f 6b 65 6e 20 6f 6e 20 74 68 65 0a 42 6c token on the.Bl
02a0: 6f 63 6b 43 68 61 69 6e 2c 20 77 65 20 61 6c 6c ockChain, we all
02b0: 6f 77 20 70 65 6f 70 6c 65 20 74 6f 20 63 72 65 ow people to cre
02c0: 61 74 65 20 74 68 6f 73 65 20 61 73 20 66 75 74 ate those as fut
02d0: 75 72 65 20 61 73 73 65 74 73 2e 20 20 57 68 65 ure assets. Whe
02e0: 6e 20 74 68 65 20 66 75 74 75 72 65 0a 65 78 70 n the future.exp
02f0: 69 72 65 73 2c 20 74 68 65 20 63 72 65 61 74 6f ires, the creato
0300: 72 20 68 61 73 20 61 6e 20 6f 62 6c 69 61 74 69 r has an obliati
0310: 6f 6e 20 74 6f 20 64 65 6c 69 76 65 72 20 74 68 on to deliver th
0320: 61 74 20 61 73 73 65 74 20 74 6f 20 74 68 65 20 at asset to the
0330: 63 75 72 72 65 6e 74 0a 6f 77 6e 65 72 3b 20 69 current.owner; i
0340: 74 20 77 69 6c 6c 20 62 65 20 72 65 6d 6f 76 65 t will be remove
0350: 64 20 66 72 6f 6d 20 74 68 65 20 42 6c 6f 63 6b d from the Block
0360: 43 68 61 69 6e 20 61 66 74 65 72 77 61 72 64 73 Chain afterwards
0370: 2e 20 20 56 65 72 69 66 69 63 61 74 69 6f 6e 20 . Verification
0380: 6f 66 0a 61 63 74 75 61 6c 20 64 65 6c 69 76 65 of.actual delive
0390: 72 79 20 6f 66 20 74 68 61 74 20 61 73 73 65 74 ry of that asset
03a0: 20 6d 61 79 20 62 65 20 75 70 20 74 6f 20 73 6f may be up to so
03b0: 6d 65 20 6e 6f 74 61 72 79 20 6f 72 20 6f 74 68 me notary or oth
03c0: 65 72 20 61 72 62 69 74 65 72 2c 0a 75 73 75 61 er arbiter,.usua
03d0: 6c 6c 79 20 63 6f 6d 70 6c 61 69 6e 74 2d 62 61 lly complaint-ba
03e0: 73 65 64 20 28 69 2e 65 2e 20 74 68 65 20 61 72 sed (i.e. the ar
03f0: 62 69 74 65 72 20 69 73 20 6f 6e 6c 79 20 74 68 biter is only th
0400: 65 72 65 20 74 6f 20 72 65 73 6f 6c 76 65 20 63 ere to resolve c
0410: 6f 6e 66 6c 69 63 74 73 3b 0a 63 6f 6e 66 6c 69 onflicts;.confli
0420: 63 74 73 20 73 68 6f 75 6c 64 20 62 65 20 70 75 cts should be pu
0430: 62 6c 69 63 20 61 6e 64 20 6c 6f 77 65 72 20 74 blic and lower t
0440: 68 65 20 73 63 6f 72 65 20 6f 66 20 61 6e 20 61 he score of an a
0450: 73 73 65 74 20 63 72 65 61 74 6f 72 29 2e 20 20 sset creator).
0460: 46 75 74 75 72 65 0a 61 73 73 65 74 73 20 68 61 Future.assets ha
0470: 76 65 20 74 68 65 20 73 61 6d 65 20 66 6f 72 6d ve the same form
0480: 20 61 73 20 63 72 65 64 69 74 73 2c 20 74 68 65 as credits, the
0490: 79 20 63 72 65 61 74 65 20 74 77 6f 20 74 6f 6b y create two tok
04a0: 65 6e 73 2c 20 61 6e 20 61 73 73 65 74 20 61 6e ens, an asset an
04b0: 64 20 61 6e 0a 6f 62 6c 69 67 61 74 69 6f 6e 2e d an.obligation.
04c0: 20 20 42 6f 74 68 20 63 61 6e 20 62 65 20 74 72 Both can be tr
04d0: 61 64 65 64 2c 20 61 6e 64 20 77 68 65 6e 20 74 aded, and when t
04e0: 68 65 20 6f 62 6c 69 67 61 74 69 6f 6e 20 69 73 he obligation is
04f0: 20 66 75 6c 66 69 6c 6c 65 64 2c 20 61 73 73 65 fulfilled, asse
0500: 74 0a 61 6e 64 20 6f 62 6c 69 67 61 74 69 6f 6e t.and obligation
0510: 20 6d 65 65 74 20 65 61 63 68 20 6f 74 68 65 72 meet each other
0520: 20 61 67 61 69 6e 2c 20 61 6e 64 20 61 72 65 20 again, and are
0530: 61 6e 6e 69 68 69 6c 61 74 65 64 2e 0a 0a 4c 65 annihilated...Le
0540: 67 61 6c 20 74 65 6e 64 65 72 73 20 69 6e 73 65 gal tenders inse
0550: 72 74 65 64 20 69 6e 74 6f 20 74 68 65 20 42 6c rted into the Bl
0560: 6f 63 6b 43 68 61 69 6e 20 61 72 65 20 68 61 6e ockChain are han
0570: 64 6c 65 64 20 74 68 61 74 20 77 61 79 2c 20 74 dled that way, t
0580: 6f 6f 3a 20 41 20 62 61 6e 6b 0a 69 73 73 75 65 oo: A bank.issue
0590: 73 20 61 20 70 61 69 72 20 6f 66 20 61 73 73 65 s a pair of asse
05a0: 74 73 20 61 6e 64 20 6f 62 6c 69 67 61 74 69 6f ts and obligatio
05b0: 6e 73 2c 20 74 68 65 20 6f 62 6c 69 67 61 74 69 ns, the obligati
05c0: 6f 6e 20 73 74 61 79 73 20 61 74 20 74 68 65 20 on stays at the
05d0: 62 61 6e 6b 2c 20 74 68 65 0a 61 73 73 65 74 20 bank, the.asset
05e0: 69 73 20 73 6f 6c 64 20 66 6f 72 20 74 68 61 74 is sold for that
05f0: 20 6c 65 67 61 6c 20 74 65 6e 64 65 72 20 74 6f legal tender to
0600: 20 74 68 65 20 70 75 72 63 68 61 73 65 72 20 28 the purchaser (
0610: 74 68 65 20 6c 65 67 61 6c 20 74 65 6e 64 65 72 the legal tender
0620: 20 69 73 0a 74 72 61 6e 73 6d 69 74 74 65 64 20 is.transmitted
0630: 62 79 20 6e 6f 72 6d 61 6c 20 62 61 6e 6b 20 74 by normal bank t
0640: 72 61 6e 73 66 65 72 29 2e 20 20 54 68 65 20 70 ransfer). The p
0650: 75 72 63 68 61 73 65 72 20 63 61 6e 20 74 72 61 urchaser can tra
0660: 64 65 20 74 68 61 74 20 6c 65 67 61 6c 0a 74 65 de that legal.te
0670: 6e 64 65 72 20 77 69 74 68 20 6f 74 68 65 72 73 nder with others
0680: 2c 20 61 6e 64 20 69 66 20 79 6f 75 20 77 61 6e , and if you wan
0690: 74 20 74 6f 20 6c 65 61 76 65 20 74 68 65 20 42 t to leave the B
06a0: 6c 6f 63 6b 43 68 61 69 6e 2c 20 79 6f 75 20 73 lockChain, you s
06b0: 65 6c 6c 20 69 74 20 28 66 6f 72 0a 6e 6f 72 6d ell it (for.norm
06c0: 61 6c 20 62 61 6e 6b 20 74 72 61 6e 73 66 65 72 al bank transfer
06d0: 29 20 74 6f 20 6f 6e 65 20 6f 66 20 74 68 6f 73 ) to one of thos
06e0: 65 20 62 61 6e 6b 73 20 74 68 61 74 20 68 61 76 e banks that hav
06f0: 65 20 6f 62 6c 69 67 61 74 69 6f 6e 73 20 69 6e e obligations in
0700: 20 74 68 61 74 0a 63 75 72 72 65 6e 63 79 3b 20 that.currency;
0710: 74 68 65 79 20 61 72 65 20 6e 6f 77 20 66 72 65 they are now fre
0720: 65 20 74 6f 20 61 6e 6e 69 68 69 6c 61 74 65 20 e to annihilate
0730: 74 68 6f 73 65 20 6f 62 6c 69 67 61 74 69 6f 6e those obligation
0740: 73 2c 20 61 73 20 74 68 65 79 20 68 61 76 65 0a s, as they have.
0750: 66 75 6c 66 69 6c 6c 65 64 20 74 68 65 6d 2e 0a fulfilled them..
0760: 0a 4d 6f 72 74 67 61 67 65 73 20 61 6e 64 20 6c .Mortgages and l
0770: 6f 61 6e 73 20 77 69 74 68 20 69 6e 74 65 72 65 oans with intere
0780: 73 74 20 72 61 74 65 73 20 61 72 65 20 74 6f 6f st rates are too
0790: 20 63 6f 6d 70 6c 69 63 61 74 65 64 20 66 6f 72 complicated for
07a0: 20 61 20 64 75 6d 62 0a 63 6f 6e 74 72 61 63 74 a dumb.contract
07b0: 2c 20 77 68 69 63 68 20 69 73 20 61 20 67 6f 6f , which is a goo
07c0: 64 20 74 68 69 6e 67 2e 0a 0a 23 23 20 53 74 61 d thing...## Sta
07d0: 74 65 20 6f 66 20 61 6e 20 41 73 73 65 74 20 41 te of an Asset A
07e0: 63 63 6f 75 6e 74 0a 0a 41 6e 20 61 73 73 65 74 ccount..An asset
07f0: 20 61 63 63 6f 75 6e 74 20 63 6f 6e 74 61 69 6e account contain
0800: 73 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 s the following
0810: 73 74 61 74 65 3a 0a 0a 2a 20 41 20 68 61 73 68 state:..* A hash
0820: 20 6f 66 20 74 68 65 20 63 6f 6e 74 72 61 63 74 of the contract
0830: 20 74 68 61 74 20 6c 61 73 74 20 63 68 61 6e 67 that last chang
0840: 65 64 20 74 68 65 20 73 74 61 74 65 0a 2a 20 41 ed the state.* A
0850: 20 74 61 62 6c 65 20 6f 66 20 61 73 73 65 74 73 table of assets
0860: 20 61 6e 64 20 74 68 65 69 72 20 76 61 6c 75 65 and their value
0870: 73 20 28 68 6f 77 20 6d 61 6e 79 29 0a 2a 20 41 s (how many).* A
0880: 20 74 69 6d 65 73 74 61 6d 70 65 64 20 73 69 67 timestamped sig
0890: 6e 61 74 75 72 65 20 6f 66 20 61 6c 6c 20 74 68 nature of all th
08a0: 61 74 20 69 6e 20 63 61 6e 6f 6e 69 63 61 6c 20 at in canonical
08b0: 66 6f 72 6d 0a 0a 41 6e 20 61 73 73 65 74 20 61 form..An asset a
08c0: 63 63 6f 75 6e 74 20 69 73 20 61 64 64 72 65 73 ccount is addres
08d0: 73 65 64 20 62 79 20 69 74 73 20 70 75 62 6b 65 sed by its pubke
08e0: 79 2e 20 20 43 6f 6e 74 72 61 63 74 73 20 61 72 y. Contracts ar
08f0: 65 20 61 64 64 72 65 73 73 65 64 20 62 79 20 74 e addressed by t
0900: 68 65 69 72 0a 68 61 73 68 65 73 2e 0a 0a 41 20 heir.hashes...A
0910: 77 61 6c 6c 65 74 20 68 61 73 20 61 20 73 65 63 wallet has a sec
0920: 75 72 65 6c 79 20 63 72 65 61 74 65 64 20 72 61 urely created ra
0930: 6e 64 6f 6d 20 6e 75 6d 62 65 72 20 61 73 20 73 ndom number as s
0940: 65 65 64 20 74 6f 20 63 72 65 61 74 65 20 61 20 eed to create a
0950: 73 65 71 75 65 6e 63 65 20 6f 66 0a 73 65 63 72 sequence of.secr
0960: 65 74 20 6b 65 79 73 20 61 6e 64 20 74 68 65 69 et keys and thei
0970: 72 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 r corresponding
0980: 70 75 62 6b 65 79 73 2e 0a 0a 54 68 65 20 6d 65 pubkeys...The me
0990: 72 6b 6c 65 20 74 72 65 65 20 74 6f 20 63 61 6c rkle tree to cal
09a0: 63 75 6c 61 74 65 20 74 68 65 20 68 61 73 68 65 culate the hashe
09b0: 73 20 6f 66 20 61 20 62 6c 6f 63 6b 20 73 74 61 s of a block sta
09c0: 72 74 73 20 77 69 74 68 20 74 68 65 20 73 69 67 rts with the sig
09d0: 6e 61 74 75 72 65 73 0a 6f 6e 6c 79 3b 20 74 68 natures.only; th
09e0: 65 20 52 20 61 6e 64 20 53 20 76 61 6c 75 65 73 e R and S values
09f0: 20 6f 66 20 74 68 65 20 65 64 32 35 35 31 39 20 of the ed25519
0a00: 73 69 67 6e 61 74 75 72 65 20 61 72 65 20 78 6f signature are xo
0a10: 72 65 64 20 74 6f 20 63 6f 6d 70 72 65 73 73 20 red to compress
0a20: 6f 6e 65 0a 73 69 67 6e 61 74 75 72 65 20 74 6f one.signature to
0a30: 20 61 20 32 35 36 20 62 69 74 20 76 61 6c 75 65 a 256 bit value
0a40: 20 28 65 6e 6f 75 67 68 20 66 6f 72 20 74 68 65 (enough for the
0a50: 20 73 65 63 75 72 69 74 79 20 67 75 61 72 61 6e security guaran
0a60: 74 65 65 20 6f 66 20 74 68 65 0a 73 69 67 6e 61 tee of the.signa
0a70: 74 75 72 65 29 2e 0a 0a 41 20 63 68 61 69 6e 20 ture)...A chain
0a80: 61 6c 73 6f 20 63 6f 6e 74 61 69 6e 73 20 6d 65 also contains me
0a90: 74 61 64 61 74 61 20 28 65 2e 67 2e 20 61 73 73 tadata (e.g. ass
0aa0: 65 74 20 74 79 70 65 73 2c 20 70 65 72 6d 69 73 et types, permis
0ab0: 73 69 6f 6e 20 72 75 6c 65 73 2c 0a 67 72 61 6e sion rules,.gran
0ac0: 75 6c 61 72 69 74 69 65 73 20 6f 66 20 61 73 73 ularities of ass
0ad0: 65 74 73 29 2c 20 6d 65 74 61 64 61 74 61 20 69 ets), metadata i
0ae0: 73 20 73 74 6f 72 65 64 20 69 6e 20 61 20 44 56 s stored in a DV
0af0: 43 53 20 72 65 70 6f 73 69 74 6f 72 79 2c 20 61 CS repository, a
0b00: 6e 64 20 74 68 65 0a 63 75 72 72 65 6e 74 20 72 nd the.current r
0b10: 65 76 69 73 69 6f 6e 27 73 20 68 61 73 68 20 72 evision's hash r
0b20: 65 70 72 65 73 65 6e 74 73 20 74 68 61 74 20 6d epresents that m
0b30: 65 74 61 64 61 74 61 2e 20 20 55 70 64 61 74 65 etadata. Update
0b40: 73 20 63 61 6e 20 6f 6e 6c 79 20 62 65 20 63 68 s can only be ch
0b50: 65 63 6b 65 64 0a 69 6e 20 62 79 20 63 6f 6e 73 ecked.in by cons
0b60: 65 6e 73 75 73 2c 20 69 2e 65 2e 20 69 66 20 61 ensus, i.e. if a
0b70: 20 6e 65 77 20 76 65 72 73 69 6f 6e 20 69 73 20 new version is
0b80: 61 76 61 69 6c 61 62 6c 65 2c 20 73 69 67 6e 65 available, signe
0b90: 72 73 20 77 68 6f 20 61 63 63 65 70 74 20 74 68 rs who accept th
0ba0: 65 0a 6e 65 77 20 76 65 72 73 69 6f 6e 20 6f 66 e.new version of
0bb0: 20 74 68 65 20 6d 65 74 61 64 61 74 61 20 66 69 the metadata fi
0bc0: 72 73 74 20 74 72 79 20 74 6f 20 73 69 67 6e 20 rst try to sign
0bd0: 61 6e 64 20 63 68 65 63 6b 20 69 6e 20 74 68 65 and check in the
0be0: 20 6e 65 77 20 76 65 72 73 69 6f 6e 2c 0a 61 6e new version,.an
0bf0: 64 20 69 66 20 74 68 61 74 20 64 6f 65 73 6e 27 d if that doesn'
0c00: 74 20 72 65 61 63 68 20 61 20 63 6f 6e 73 65 6e t reach a consen
0c10: 73 75 73 2c 20 74 72 79 20 61 67 61 69 6e 20 77 sus, try again w
0c20: 69 74 68 20 74 68 65 20 6f 6c 64 20 76 65 72 73 ith the old vers
0c30: 69 6f 6e 2e 0a 0a 23 23 20 57 68 61 74 27 73 20 ion...## What's
0c40: 61 20 44 75 6d 62 20 43 6f 6e 74 72 61 63 74 3f a Dumb Contract?
0c50: 0a 0a 41 20 64 75 6d 62 20 63 6f 6e 74 72 61 63 ..A dumb contrac
0c60: 74 20 72 65 70 72 65 73 65 6e 74 73 20 74 68 65 t represents the
0c70: 20 73 74 61 74 65 20 74 72 61 6e 73 69 74 69 6f state transitio
0c80: 6e 20 6f 66 20 74 68 65 20 61 63 74 69 76 65 20 n of the active
0c90: 64 61 74 61 20 69 6e 20 74 68 65 0a 42 6c 6f 63 data in the.Bloc
0ca0: 6b 43 68 61 69 6e 20 74 6f 20 66 75 6c 66 69 6c kChain to fulfil
0cb0: 6c 20 74 68 61 74 20 63 6f 6e 74 72 61 63 74 2e l that contract.
0cc0: 20 20 41 20 63 6f 6e 74 72 61 63 74 20 69 73 20 A contract is
0cd0: 76 61 6c 69 64 20 69 66 20 69 74 20 70 72 65 73 valid if it pres
0ce0: 65 72 76 65 73 20 61 6c 6c 0a 74 68 65 20 74 72 erves all.the tr
0cf0: 61 6e 73 61 63 74 65 64 20 67 6f 6f 64 73 20 28 ansacted goods (
0d00: 61 6c 6c 6f 77 73 20 63 72 65 61 74 69 6f 6e 20 allows creation
0d10: 61 6e 64 20 61 6e 6e 69 68 69 6c 61 74 69 6f 6e and annihilation
0d20: 20 6f 66 20 61 73 73 65 74 73 2b 6f 62 6c 69 67 of assets+oblig
0d30: 61 74 69 6f 6e 73 2c 0a 61 6c 6c 20 6f 74 68 65 ations,.all othe
0d40: 72 20 76 61 6c 75 65 73 20 68 61 76 65 20 74 6f r values have to
0d50: 20 62 65 20 70 72 65 73 65 72 76 65 64 29 2e 20 be preserved).
0d60: 20 4f 62 6c 69 67 61 74 69 6f 6e 73 20 61 72 65 Obligations are
0d70: 20 6a 75 73 74 20 61 6e 6f 74 68 65 72 20 6e 61 just another na
0d80: 6d 65 20 66 6f 72 0a 61 6e 20 61 73 73 65 74 20 me for.an asset
0d90: 77 69 74 68 20 61 20 6e 65 67 61 74 69 76 65 20 with a negative
0da0: 76 61 6c 75 65 2e 0a 0a 43 6f 6e 74 72 61 63 74 value...Contract
0db0: 73 20 61 72 65 20 73 74 6f 72 65 64 20 61 73 20 s are stored as
0dc0: 73 68 6f 72 74 65 6e 65 64 20 66 6f 72 6d 73 20 shortened forms
0dd0: 6f 66 20 74 68 65 20 73 74 61 74 65 20 74 72 61 of the state tra
0de0: 6e 73 69 74 69 6f 6e 73 2c 20 6f 6e 6c 79 20 74 nsitions, only t
0df0: 68 6f 73 65 0a 76 61 6c 75 65 73 20 74 68 61 74 hose.values that
0e00: 20 63 68 61 6e 67 65 20 61 72 65 20 72 65 63 6f change are reco
0e10: 72 64 65 64 20 69 6e 20 61 20 66 6f 72 6d 20 74 rded in a form t
0e20: 68 61 74 20 69 73 20 62 79 20 64 65 73 69 67 6e hat is by design
0e30: 20 76 61 6c 69 64 2c 20 61 6e 64 20 6f 6e 6c 79 valid, and only
0e40: 0a 6e 65 65 64 73 20 63 68 65 63 6b 69 6e 67 20 .needs checking
0e50: 6f 66 20 74 68 65 20 73 6f 75 72 63 65 73 2e 20 of the sources.
0e60: 20 54 68 65 20 6e 65 77 20 73 74 61 74 65 73 20 The new states
0e70: 6e 65 65 64 20 61 20 76 61 6c 69 64 20 73 69 67 need a valid sig
0e80: 6e 61 74 75 72 65 20 6f 66 20 74 68 65 0a 72 65 nature of the.re
0e90: 73 70 65 63 74 69 76 65 20 6f 77 6e 65 72 2e 20 spective owner.
0ea0: 20 54 6f 20 65 78 65 63 75 74 65 20 61 20 63 6f To execute a co
0eb0: 6e 74 72 61 63 74 2c 20 61 6c 6c 20 73 6f 75 72 ntract, all sour
0ec0: 63 65 73 20 61 72 65 20 66 65 74 63 68 65 64 2c ces are fetched,
0ed0: 20 74 68 65 0a 74 72 61 6e 73 69 74 69 6f 6e 73 the.transitions
0ee0: 20 28 61 73 73 65 74 73 20 6d 6f 76 65 64 20 66 (assets moved f
0ef0: 72 6f 6d 20 6f 6e 65 20 61 63 63 6f 75 6e 74 20 rom one account
0f00: 74 6f 20 74 68 65 20 6f 74 68 65 72 29 20 61 72 to the other) ar
0f10: 65 20 70 65 72 66 6f 72 6d 65 64 2c 20 61 6e 64 e performed, and
0f20: 0a 74 68 65 20 73 69 67 6e 61 74 75 72 65 73 20 .the signatures
0f30: 28 64 65 73 74 69 6e 61 74 69 6f 6e 73 29 20 6f (destinations) o
0f40: 66 20 74 68 65 20 6e 65 77 20 73 74 61 74 65 73 f the new states
0f50: 20 61 72 65 20 63 68 65 63 6b 65 64 2e 0a 0a 43 are checked...C
0f60: 6f 6e 74 72 61 63 74 73 20 63 61 6e 20 62 65 20 ontracts can be
0f70: 6f 66 66 65 72 65 64 20 69 6e 20 6f 70 65 6e 20 offered in open
0f80: 66 6f 72 6d 2c 20 77 68 65 72 65 20 70 61 72 74 form, where part
0f90: 73 20 6f 66 20 74 68 65 20 74 72 61 6e 73 61 63 s of the transac
0fa0: 74 69 6f 6e 20 61 72 65 20 6c 65 66 74 0a 6f 70 tion are left.op
0fb0: 65 6e 20 74 6f 20 62 65 20 66 69 6c 6c 65 64 20 en to be filled
0fc0: 69 6e 2c 20 65 2e 67 2e 20 73 6f 75 72 63 65 20 in, e.g. source
0fd0: 6f 72 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 61 or destination a
0fe0: 64 64 72 65 73 73 65 73 2e 20 20 49 66 20 74 68 ddresses. If th
0ff0: 65 20 6f 70 65 6e 20 66 6f 72 6d 0a 63 6f 6e 74 e open form.cont
1000: 61 69 6e 73 20 61 20 64 65 73 74 69 6e 61 74 69 ains a destinati
1010: 6f 6e 2c 20 61 6e 64 20 74 68 65 20 72 65 6c 65 on, and the rele
1020: 76 61 6e 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e vant information
1030: 20 74 6f 20 75 70 64 61 74 65 20 69 74 20 69 73 to update it is
1040: 20 63 6f 6d 70 6c 65 74 65 64 0a 62 79 20 74 68 completed.by th
1050: 65 6e 2c 20 69 74 20 63 61 6e 20 62 65 20 61 70 en, it can be ap
1060: 70 65 6e 64 65 64 20 62 79 20 66 75 72 74 68 65 pended by furthe
1070: 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 73 20 77 r informations w
1080: 69 74 68 6f 75 74 20 6e 65 65 64 69 6e 67 20 61 ithout needing a
1090: 0a 73 69 67 6e 61 74 75 72 65 20 6f 66 20 74 68 .signature of th
10a0: 65 20 63 6f 6e 74 72 61 63 74 20 61 67 61 69 6e e contract again
10b0: 2e 0a 0a 54 6f 20 66 6f 72 6d 61 6c 69 7a 65 20 ...To formalize
10c0: 61 20 63 6f 6e 74 72 61 63 74 2c 20 53 6f 75 72 a contract, Sour
10d0: 63 65 73 20 61 72 65 20 77 72 69 74 74 65 6e 20 ces are written
10e0: 61 73 20 53 20 28 74 69 6d 65 73 74 61 6d 70 29 as S (timestamp)
10f0: 2c 20 64 65 73 74 69 6e 61 74 69 6f 6e 73 20 61 , destinations a
1100: 73 0a 44 20 28 6e 65 77 20 74 69 6d 65 73 74 61 s.D (new timesta
1110: 6d 70 20 2b 20 73 69 67 6e 61 74 75 72 65 29 2c mp + signature),
1120: 20 6f 62 6c 69 67 61 74 69 6f 6e 73 20 61 73 20 obligations as
1130: 4f 2c 20 61 73 73 65 74 73 20 61 73 20 41 2c 20 O, assets as A,
1140: 64 65 6c 74 61 20 61 6d 6f 75 6e 74 73 20 61 73 delta amounts as
1150: 0a 2b 20 6f 72 20 2d 20 28 67 69 76 65 20 6f 72 .+ or - (give or
1160: 20 74 61 6b 65 29 2c 20 61 6e 64 20 6e 75 6d 62 take), and numb
1170: 65 72 73 20 74 6f 20 73 65 6c 65 63 74 20 74 68 ers to select th
1180: 65 20 63 6f 72 72 65 63 74 20 73 6f 75 72 63 65 e correct source
1190: 20 69 66 20 75 6e 63 6c 65 61 72 0a 28 74 68 65 if unclear.(the
11a0: 20 6c 61 73 74 20 73 6f 75 72 63 65 20 69 73 20 last source is
11b0: 61 6c 77 61 79 73 20 74 68 65 20 61 63 74 69 76 always the activ
11c0: 65 20 6f 6e 65 29 2e 20 20 42 20 69 73 20 61 20 e one). B is a
11d0: 73 68 6f 72 74 63 75 74 20 66 6f 72 20 62 61 6c shortcut for bal
11e0: 61 6e 63 69 6e 67 20 61 6e 0a 61 73 73 65 74 2c ancing an.asset,
11f0: 20 61 6e 64 20 63 61 6e 20 62 65 20 75 73 65 64 and can be used
1200: 20 69 6e 73 74 65 61 64 20 6f 66 20 74 68 65 20 instead of the
1210: 6c 61 73 74 20 76 61 6c 75 65 20 6f 6e 20 74 68 last value on th
1220: 61 74 20 61 73 73 65 74 20 74 79 70 65 2e 20 20 at asset type.
1230: 41 6c 73 6f 2c 0a 70 72 65 76 69 6f 75 73 6c 79 Also,.previously
1240: 20 75 73 65 64 20 61 73 73 65 74 73 20 63 61 6e used assets can
1250: 20 62 65 20 73 65 6c 65 63 74 65 64 20 62 79 20 be selected by
1260: 6e 75 6d 62 65 72 2e 0a 0a 41 6c 6c 20 73 6f 75 number...All sou
1270: 72 63 65 73 20 73 70 65 63 69 66 79 20 74 68 65 rces specify the
1280: 20 64 61 74 65 20 6f 66 20 74 68 65 20 73 6f 75 date of the sou
1290: 72 63 65 20 73 74 61 74 65 2c 20 73 6f 20 74 68 rce state, so th
12a0: 61 74 20 61 20 63 6f 6e 74 72 61 63 74 20 63 61 at a contract ca
12b0: 6e 20 62 65 0a 70 65 72 66 6f 72 6d 65 64 20 6f n be.performed o
12c0: 6e 6c 79 20 6f 6e 63 65 20 e2 80 94 20 74 68 65 nly once — the
12d0: 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 64 61 74 destination dat
12e0: 65 20 6d 75 73 74 20 62 65 20 6c 61 74 65 72 20 e must be later
12f0: 74 68 61 6e 20 74 68 65 20 73 6f 75 72 63 65 20 than the source
1300: 64 61 74 65 2e 0a 0a 2a 20 43 6c 61 69 6d 65 64 date...* Claimed
1310: 20 6d 6f 6e 65 79 20 63 68 65 71 75 65 20 28 61 money cheque (a
1320: 6e 79 62 6f 64 79 20 77 68 6f 20 68 61 73 20 74 nybody who has t
1330: 68 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 63 he transaction c
1340: 61 6e 20 63 6c 61 69 6d 20 74 68 65 20 6d 6f 6e an claim the mon
1350: 65 79 3b 0a 20 20 72 65 71 75 69 72 65 73 20 74 ey;. requires t
1360: 72 75 73 74 20 74 6f 20 74 68 65 20 6c 65 64 67 rust to the ledg
1370: 65 72 20 6e 6f 64 65 20 74 68 61 74 20 61 63 63 er node that acc
1380: 65 70 74 73 20 74 68 65 20 63 68 65 71 75 65 29 epts the cheque)
1390: 3a 20 53 41 2d 44 53 41 2b 44 0a 2a 20 4d 6f 6e : SA-DSA+D.* Mon
13a0: 65 79 20 74 72 61 6e 73 66 65 72 20 28 6f 6e 6c ey transfer (onl
13b0: 79 20 74 68 65 20 64 65 73 69 67 6e 61 74 65 64 y the designated
13c0: 20 72 65 63 69 70 69 65 6e 74 20 63 61 6e 20 63 recipient can c
13d0: 6c 61 69 6d 20 74 68 65 20 6d 6f 6e 65 79 29 3a laim the money):
13e0: 20 53 41 2d 53 41 2b 44 31 44 0a 2a 20 43 72 65 SA-SA+D1D.* Cre
13f0: 61 74 69 6f 6e 20 6f 66 20 61 73 73 65 74 20 61 ation of asset a
1400: 6e 64 20 6f 62 6c 69 67 61 74 69 6f 6e 3a 20 53 nd obligation: S
1410: 41 2b 4f 42 44 0a 2a 20 54 77 6f 20 70 61 72 74 A+OBD.* Two part
1420: 79 20 70 75 72 63 68 61 73 65 3a 20 53 41 c2 b9 y purchase: SA¹
1430: 2b 41 c2 b2 2d 53 c2 b9 42 c2 b2 42 31 44 32 44 +A²-S¹B²B1D2D
1440: 0a 2a 20 54 77 6f 20 70 61 72 74 79 20 70 75 72 .* Two party pur
1450: 63 68 61 73 65 20 64 65 6c 69 76 65 72 79 3a 20 chase delivery:
1460: 53 41 2d 53 4f 42 31 44 32 44 20 28 61 6e 6e 69 SA-SOB1D2D (anni
1470: 68 69 6c 61 74 65 73 20 74 68 65 20 61 73 73 65 hilates the asse
1480: 74 29 0a 2a 20 42 69 64 2f 41 73 6b 20 69 6e 20 t).* Bid/Ask in
1490: 61 6e 20 65 78 63 68 61 6e 67 65 3a 20 53 41 c2 an exchange: SAÂ
14a0: b9 2b 41 c2 b2 2d 44 2c 20 66 69 6e 61 6c 69 7a ¹+A²-D, finaliz
14b0: 65 64 20 62 79 20 53 41 c2 b9 2b 41 c2 b2 2d 44 ed by SA¹+A²-D
14c0: 53 c2 b9 42 c2 b2 42 44 2e 20 4e 6f 74 65 20 74 S¹B²BD. Note t
14d0: 68 61 74 0a 20 20 62 69 64 73 2f 61 73 6b 73 20 hat. bids/asks
14e0: 69 6e 20 61 6e 20 65 78 63 68 61 6e 67 65 20 63 in an exchange c
14f0: 61 6e 20 62 65 20 6d 6f 72 65 20 63 6f 6d 70 6c an be more compl
1500: 69 63 61 74 65 64 20 77 68 65 6e 20 74 68 65 79 icated when they
1510: 20 61 72 65 20 6f 6e 6c 79 20 70 61 72 74 6c 79 are only partly
1520: 0a 20 20 66 75 6c 66 69 6c 6c 65 64 3b 20 74 68 . fulfilled; th
1530: 65 20 73 70 6c 69 74 74 69 6e 67 20 72 65 71 75 e splitting requ
1540: 69 72 65 73 20 61 63 74 69 6f 6e 20 62 79 20 74 ires action by t
1550: 68 65 20 62 69 64 64 65 72 3b 20 61 6e 64 20 61 he bidder; and a
1560: 6c 73 6f 20 6e 6f 74 65 20 74 68 61 74 0a 20 20 lso note that.
1570: 74 68 69 73 20 6b 69 6e 64 20 6f 66 20 62 69 64 this kind of bid
1580: 20 72 65 71 75 69 72 65 73 2c 20 6c 69 6b 65 20 requires, like
1590: 74 68 65 20 63 68 65 71 75 65 2c 20 74 72 75 73 the cheque, trus
15a0: 74 20 69 6e 20 74 68 65 20 6c 65 64 67 65 72 20 t in the ledger
15b0: 6e 6f 64 65 3b 20 62 75 74 0a 20 20 6c 65 73 73 node; but. less
15c0: 20 74 68 61 6e 3a 20 54 68 65 20 6c 65 64 67 65 than: The ledge
15d0: 72 20 6e 6f 64 65 20 63 61 6e 20 6f 6e 6c 79 20 r node can only
15e0: 62 75 79 20 66 6f 72 20 74 68 65 20 73 61 6d 65 buy for the same
15f0: 20 70 72 69 63 65 2c 20 6e 6f 74 20 73 74 65 61 price, not stea
1600: 6c 20 74 68 65 0a 20 20 6d 6f 6e 65 79 2e 0a 20 l the. money..
1610: 20 42 65 74 74 65 72 20 66 69 6e 61 6c 69 7a 65 Better finalize
1620: 20 74 68 65 20 63 6f 6e 74 72 61 63 74 20 77 69 the contract wi
1630: 74 68 20 74 68 65 20 6f 74 68 65 72 20 73 69 64 th the other sid
1640: 65 2e 0a 2a 20 41 75 63 74 69 6f 6e 20 6f 66 66 e..* Auction off
1650: 65 72 3a 20 53 41 c2 b9 2d 2c 20 61 75 63 74 69 er: SA¹-, aucti
1660: 6f 6e 20 62 69 64 3a 20 53 41 c2 b9 2d 53 c2 b9 on bid: SA¹-S¹
1670: 42 41 c2 b2 2d 44 2c 20 61 75 63 74 69 6f 6e 20 BA²-D, auction
1680: 63 6f 6e 63 6c 75 73 69 6f 6e 3a 0a 20 20 53 41 conclusion:. SA
1690: c2 b9 2d 53 c2 b9 42 41 c2 b2 2d 44 31 c2 b2 42 ¹-S¹BA²-D1²B
16a0: 44 2e 20 41 75 63 74 69 6f 6e 20 6f 66 66 65 72 D. Auction offer
16b0: 73 20 61 72 65 20 73 69 67 6e 65 64 20 77 69 74 s are signed wit
16c0: 68 20 61 6e 20 65 6e 64 2d 6f 66 2d 61 75 63 74 h an end-of-auct
16d0: 69 6f 6e 0a 20 20 62 65 67 69 6e 6e 69 6e 67 20 ion. beginning
16e0: 74 6f 20 69 6e 64 69 63 61 74 65 20 74 68 65 20 to indicate the
16f0: 74 69 6d 65 6f 75 74 2c 20 61 6e 64 20 74 68 65 timeout, and the
1700: 20 6f 66 66 65 72 69 6e 67 20 70 61 72 74 79 20 offering party
1710: 63 61 6e 20 73 65 6c 65 63 74 20 74 68 65 0a 20 can select the.
1720: 20 62 65 73 74 20 6d 61 74 63 68 2c 20 61 6c 6c best match, all
1730: 6f 77 69 6e 67 20 6f 74 68 65 72 20 61 6c 67 6f owing other algo
1740: 72 69 74 68 6d 73 20 61 73 20 6d 61 78 69 6d 75 rithms as maximu
1750: 6d 20 70 72 69 63 65 2c 20 74 6f 6f 2c 20 6f 72 m price, too, or
1760: 20 6f 74 68 65 72 0a 20 20 74 69 6d 65 6f 75 74 other. timeout
1770: 20 61 6c 67 6f 72 69 74 68 6d 73 20 74 68 61 6e algorithms than
1780: 20 74 68 65 20 66 69 78 65 64 20 64 65 61 64 6c the fixed deadl
1790: 69 6e 65 3b 20 65 2e 67 2e 20 31 35 20 6d 69 6e ine; e.g. 15 min
17a0: 75 74 65 73 20 61 66 74 65 72 20 6c 61 73 74 20 utes after last
17b0: 62 69 64 0a 20 20 6f 72 20 73 6f 2e 0a 0a 54 68 bid. or so...Th
17c0: 65 20 65 76 61 6c 75 61 74 69 6f 6e 20 6f 66 20 e evaluation of
17d0: 61 20 64 75 6d 62 20 63 6f 6e 74 72 61 63 74 20 a dumb contract
17e0: 69 73 20 72 61 74 68 65 72 20 65 61 73 79 3a 20 is rather easy:
17f0: 41 6c 6c 20 73 6f 75 72 63 65 73 20 61 6e 64 20 All sources and
1800: 64 65 73 74 69 6e 61 74 69 6f 6e 73 0a 6d 75 73 destinations.mus
1810: 74 20 62 61 6c 61 6e 63 65 20 28 69 2e 65 2e 20 t balance (i.e.
1820: 74 68 65 20 73 75 6d 73 20 6f 66 20 61 6c 6c 20 the sums of all
1830: 73 6f 75 72 63 65 73 20 77 69 74 68 20 74 68 65 sources with the
1840: 69 72 20 72 65 73 70 65 63 74 69 76 65 20 75 6e ir respective un
1850: 69 74 73 20 6d 75 73 74 20 62 65 0a 65 71 75 61 its must be.equa
1860: 6c 20 74 6f 20 74 68 65 20 73 75 6d 73 20 6f 66 l to the sums of
1870: 20 61 6c 6c 20 73 69 6e 6b 73 20 77 69 74 68 20 all sinks with
1880: 74 68 65 69 72 20 75 6e 69 74 73 29 20 61 6e 64 their units) and
1890: 20 61 6c 6c 20 64 65 73 74 69 6e 61 74 69 6f 6e all destination
18a0: 73 20 6d 75 73 74 0a 68 61 76 65 20 61 20 73 69 s must.have a si
18b0: 67 6e 61 74 75 72 65 20 66 6f 72 20 74 68 65 69 gnature for thei
18c0: 72 20 73 74 61 74 65 2e 20 20 54 68 65 20 63 6f r state. The co
18d0: 6e 74 72 61 63 74 20 6d 75 73 74 20 68 61 76 65 ntract must have
18e0: 20 73 69 67 6e 61 74 75 72 65 73 20 6f 66 20 61 signatures of a
18f0: 6c 6c 0a 64 65 73 74 69 6e 61 74 69 6f 6e 73 20 ll.destinations
1900: 69 6e 73 69 64 65 2c 20 62 75 74 20 74 68 65 20 inside, but the
1910: 73 69 67 6e 61 74 75 72 65 20 69 73 20 61 6c 6c signature is all
1920: 6f 77 65 64 20 74 6f 20 63 6f 76 65 72 20 6f 6e owed to cover on
1930: 6c 79 20 70 61 72 74 20 6f 66 20 74 68 65 0a 63 ly part of the.c
1940: 6f 6e 74 72 61 63 74 2e 20 20 41 73 20 61 6e 64 ontract. As and
1950: 20 4f 73 20 63 61 6e 20 62 65 20 63 72 65 61 74 Os can be creat
1960: 65 64 20 69 6e 20 70 61 69 72 73 20 6f 72 20 61 ed in pairs or a
1970: 6e 6e 69 68 69 6c 61 74 65 64 20 69 6e 20 70 61 nnihilated in pa
1980: 69 72 73 2c 0a 70 65 72 6d 69 73 73 69 6f 6e 20 irs,.permission
1990: 77 68 6f 20 69 73 20 61 6c 6c 6f 77 65 64 20 74 who is allowed t
19a0: 6f 20 63 72 65 61 74 65 20 64 65 70 65 6e 64 20 o create depend
19b0: 6f 6e 20 74 68 65 20 74 79 70 65 20 6f 66 20 61 on the type of a
19c0: 73 73 65 74 20 61 6e 64 20 6f 62 6c 69 67 61 74 sset and obligat
19d0: 69 6f 6e 0a 28 65 76 65 72 79 62 6f 64 79 20 69 ion.(everybody i
19e0: 73 20 61 6c 6c 6f 77 65 64 20 74 6f 20 61 6e 6e s allowed to ann
19f0: 69 68 69 6c 61 74 65 29 2e 0a 0a 53 6f 75 72 63 ihilate)...Sourc
1a00: 65 73 20 61 72 65 20 73 65 65 6e 20 61 73 20 73 es are seen as s
1a10: 65 6c 65 63 74 6f 72 20 28 61 20 73 6f 75 72 63 elector (a sourc
1a20: 65 20 69 73 20 61 20 70 6b 2b 74 69 6d 65 73 74 e is a pk+timest
1a30: 61 6d 70 29 2c 20 61 73 73 65 74 73 20 73 65 6c amp), assets sel
1a40: 65 63 74 20 74 68 65 0a 61 73 73 65 74 20 76 61 ect the.asset va
1a50: 6c 75 65 20 69 6e 20 74 68 65 20 73 6f 75 72 63 lue in the sourc
1a60: 65 2c 20 76 61 6c 75 65 73 20 6f 70 65 72 61 74 e, values operat
1a70: 65 20 6f 6e 20 74 68 61 74 20 61 73 73 65 74 2e e on that asset.
1a80: 20 20 44 65 73 74 69 6e 61 74 69 6f 6e 73 20 61 Destinations a
1a90: 72 65 0a 73 69 67 6e 61 74 75 72 65 73 20 61 6e re.signatures an
1aa0: 64 20 72 65 66 65 72 20 74 6f 20 74 68 65 20 63 d refer to the c
1ab0: 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 73 6f 75 orresponding sou
1ac0: 72 63 65 20 62 79 20 6e 75 6d 62 65 72 20 6f 66 rce by number of
1ad0: 20 6f 63 63 75 72 61 6e 63 65 20 e2 80 94 20 74 occurance — t
1ae0: 68 65 0a 73 6f 75 72 63 65 73 20 61 72 65 20 6e he.sources are n
1af0: 65 76 65 72 20 72 65 6f 72 64 65 72 65 64 2e 20 ever reordered.
1b00: 20 53 6f 75 72 63 65 73 20 61 72 65 20 77 72 69 Sources are wri
1b10: 74 74 65 6e 20 61 73 20 70 6b 2b 74 69 6d 65 73 tten as pk+times
1b20: 74 61 6d 70 2c 20 62 75 74 20 68 61 73 68 65 64 tamp, but hashed
1b30: 0a 69 6e 20 61 73 20 74 68 65 69 72 20 73 69 67 .in as their sig
1b40: 6e 61 74 75 72 65 2c 20 73 6f 20 79 6f 75 20 63 nature, so you c
1b50: 61 6e 20 6f 6e 6c 79 20 76 65 72 69 66 79 20 74 an only verify t
1b60: 68 65 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 73 he destination s
1b70: 69 67 6e 61 74 75 72 65 20 69 66 20 79 6f 75 0a ignature if you.
1b80: 61 63 74 75 61 6c 6c 79 20 68 61 76 65 20 63 68 actually have ch
1b90: 65 63 6b 65 64 20 66 6f 72 20 74 68 65 20 73 6f ecked for the so
1ba0: 75 72 63 65 20 73 74 61 74 65 20 69 6e 20 74 68 urce state in th
1bb0: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 e corresponding
1bc0: 6c 65 64 67 65 72 2e 0a 0a 23 23 20 4d 69 78 65 ledger...## Mixe
1bd0: 72 0a 0a 4e 6f 74 65 20 74 68 61 74 20 74 68 65 r..Note that the
1be0: 72 65 20 63 61 6e 20 62 65 20 61 6e 20 61 72 62 re can be an arb
1bf0: 69 74 72 61 72 79 20 61 6d 6f 75 6e 74 20 6f 66 itrary amount of
1c00: 20 70 61 72 74 69 63 69 70 61 6e 74 73 20 69 6e participants in
1c10: 20 6f 6e 65 20 63 6f 6e 74 72 61 63 74 2c 20 73 one contract, s
1c20: 6f 0a 69 74 20 69 73 20 70 6f 73 73 69 62 6c 65 o.it is possible
1c30: 20 74 6f 20 6d 65 72 67 65 20 63 6f 6e 74 72 61 to merge contra
1c40: 63 74 73 20 77 69 74 68 20 74 68 65 20 63 6f 6e cts with the con
1c50: 73 65 6e 74 20 6f 66 20 61 6c 6c 20 70 61 72 74 sent of all part
1c60: 69 63 69 70 61 6e 74 73 2e 20 20 49 66 0a 79 6f icipants. If.yo
1c70: 75 20 77 61 6e 74 20 74 6f 20 61 6e 6f 6e 79 6d u want to anonym
1c80: 69 7a 65 20 79 6f 75 72 20 61 63 63 6f 75 6e 74 ize your account
1c90: 2c 20 79 6f 75 20 6e 65 65 64 20 74 6f 20 64 69 , you need to di
1ca0: 73 74 72 69 62 75 74 65 20 74 68 65 20 76 61 6c stribute the val
1cb0: 75 65 20 69 6e 74 6f 0a 64 69 66 66 69 63 75 6c ue into.difficul
1cc0: 74 20 74 6f 20 74 72 61 63 6b 20 63 6f 69 6e 73 t to track coins
1cd0: 20 28 65 2e 67 2e 20 70 6f 77 65 72 73 20 6f 66 (e.g. powers of
1ce0: 20 74 77 6f 29 2c 20 61 6e 64 20 74 6f 20 64 6f two), and to do
1cf0: 20 73 6f 20 77 69 74 68 6f 75 74 20 62 65 69 6e so without bein
1d00: 67 0a 74 72 61 63 6b 65 64 2c 20 6d 61 6e 79 20 g.tracked, many
1d10: 6f 74 68 65 72 20 70 65 6f 70 6c 65 20 68 61 76 other people hav
1d20: 65 20 74 6f 20 64 6f 20 74 68 65 20 73 61 6d 65 e to do the same
1d30: 20 74 68 69 6e 67 2c 20 61 6e 64 20 64 6f 20 69 thing, and do i
1d40: 74 20 69 6e 20 74 68 65 20 73 61 6d 65 0a 62 69 t in the same.bi
1d50: 67 20 6d 65 72 67 65 64 20 63 6f 6e 74 72 61 63 g merged contrac
1d60: 74 2e 0a 0a 23 23 20 53 69 7a 65 20 6f 66 20 61 t...## Size of a
1d70: 20 74 72 61 6e 73 61 63 74 69 6f 6e 0a 0a 2a 20 transaction..*
1d80: 4f 70 63 6f 64 65 73 20 61 72 65 20 6f 6e 65 20 Opcodes are one
1d90: 62 79 74 65 20 28 74 68 65 72 65 20 61 72 65 6e byte (there aren
1da0: 27 74 20 74 68 61 74 20 6d 61 6e 79 29 3b 20 6c 't that many); l
1db0: 69 74 65 72 61 6c 73 20 61 72 65 20 62 79 74 65 iterals are byte
1dc0: 77 69 73 65 20 65 6e 63 6f 64 65 64 0a 20 20 61 wise encoded. a
1dd0: 6e 64 20 73 74 72 69 6e 67 73 20 68 61 76 65 20 nd strings have
1de0: 61 20 6c 65 6e 67 74 68 20 70 72 65 63 65 65 64 a length preceed
1df0: 69 6e 67 20 74 68 65 20 72 61 77 20 64 61 74 61 ing the raw data
1e00: 20 e2 80 94 20 73 65 65 0a 20 20 5b 63 6f 6d 6d — see. [comm
1e10: 61 6e 64 73 5d 28 63 6f 6d 6d 61 6e 64 73 2e 6d ands](commands.m
1e20: 64 29 0a 2a 20 53 6f 75 72 63 65 73 20 61 72 65 d).* Sources are
1e30: 20 38 2b 33 32 3d 34 30 20 62 79 74 65 73 20 73 8+32=40 bytes s
1e40: 74 72 69 6e 67 73 0a 2a 20 41 73 73 65 74 73 20 trings.* Assets
1e50: 61 72 65 20 61 6e 20 69 6e 74 65 67 65 72 20 28 are an integer (
1e60: 69 6e 64 65 78 20 69 6e 74 6f 20 74 68 65 20 73 index into the s
1e70: 65 74 20 6f 66 20 61 73 73 65 74 73 29 2c 20 61 et of assets), a
1e80: 6e 20 6f 70 74 69 6f 6e 61 6c 20 64 65 73 63 72 n optional descr
1e90: 69 62 69 6e 67 0a 20 20 73 74 72 69 6e 67 20 28 ibing. string (
1ea0: 6e 6f 74 20 6e 65 65 64 65 64 20 66 6f 72 20 61 not needed for a
1eb0: 20 63 75 72 72 65 6e 63 79 29 0a 2a 20 56 61 6c currency).* Val
1ec0: 75 65 73 20 61 72 65 20 36 34 20 62 69 74 20 69 ues are 64 bit i
1ed0: 6e 74 65 67 65 72 73 2e 20 20 46 6f 72 20 61 20 ntegers. For a
1ee0: 6c 65 67 61 6c 20 74 65 6e 64 65 72 2c 20 74 68 legal tender, th
1ef0: 65 20 73 63 61 6c 65 20 69 73 20 69 6e 20 63 65 e scale is in ce
1f00: 6e 74 73 2c 20 66 6f 72 0a 20 20 64 65 66 6c 61 nts, for. defla
1f10: 74 69 6f 6e 61 72 79 20 63 6f 69 6e 73 20 74 68 tionary coins th
1f20: 65 20 73 63 61 6c 65 20 63 61 6e 20 62 65 20 63 e scale can be c
1f30: 6f 6e 73 69 64 65 72 61 62 6c 79 20 6c 61 72 67 onsiderably larg
1f40: 65 72 2e 20 20 53 75 6d 73 20 61 72 65 20 61 6c er. Sums are al
1f50: 77 61 79 73 0a 20 20 6b 65 70 74 20 69 6e 20 31 ways. kept in 1
1f60: 32 38 20 62 69 74 73 2c 20 73 6f 20 66 6f 72 20 28 bits, so for
1f70: 72 65 61 6c 6c 79 20 6c 61 72 67 65 20 74 72 61 really large tra
1f80: 6e 73 61 63 74 69 6f 6e 73 2c 20 79 6f 75 20 63 nsactions, you c
1f90: 61 6e 20 75 73 65 20 64 6f 75 62 6c 65 0a 20 20 an use double.
1fa0: 76 61 6c 75 65 73 20 28 74 77 6f 20 36 34 20 62 values (two 64 b
1fb0: 69 74 20 69 6e 74 65 67 65 72 73 29 2e 0a 2a 20 it integers)..*
1fc0: 44 65 73 74 69 6e 61 74 69 6f 6e 73 20 61 72 65 Destinations are
1fd0: 20 73 69 67 6e 61 74 75 72 65 73 20 77 69 74 68 signatures with
1fe0: 20 74 69 6d 65 73 74 61 6d 70 20 61 6e 64 20 65 timestamp and e
1ff0: 78 70 69 72 61 74 69 6f 6e 2c 20 69 2e 65 2e 20 xpiration, i.e.
2000: 38 30 20 62 79 74 65 73 0a 20 20 73 74 72 69 6e 80 bytes. strin
2010: 67 73 2e 0a 0a 41 20 6d 69 6e 69 6d 61 6c 20 74 gs...A minimal t
2020: 72 61 6e 73 61 63 74 69 6f 6e 20 69 73 20 73 6f ransaction is so
2030: 6d 65 77 68 61 74 20 6c 65 73 73 20 74 68 61 6e mewhat less than
2040: 20 33 30 30 20 62 79 74 65 73 2c 20 61 6e 64 20 300 bytes, and
2050: 74 68 61 74 27 73 20 61 6c 72 65 61 64 79 0a 6e that's already.n
2060: 6f 6e 2d 65 6d 74 70 79 20 74 6f 20 6e 6f 6e 2d on-emtpy to non-
2070: 65 6d 70 74 79 20 61 63 63 6f 75 6e 74 2e 0a 0a empty account...
2080: 23 23 20 44 65 73 63 72 69 70 74 69 76 65 20 41 ## Descriptive A
2090: 73 73 65 74 73 0a 0a 4d 6f 6e 65 74 61 72 79 20 ssets..Monetary
20a0: 61 73 73 65 74 73 20 61 72 65 20 6a 75 73 74 20 assets are just
20b0: 75 6e 69 74 73 20 6f 66 20 61 20 63 75 72 72 65 units of a curre
20c0: 6e 63 79 3b 20 69 6e 74 65 72 63 68 61 6e 67 65 ncy; interchange
20d0: 61 62 6c 65 2c 20 73 75 6d 6d 61 62 6c 65 2c 20 able, summable,
20e0: 61 6e 64 0a 69 74 20 69 73 20 69 72 72 65 6c 65 and.it is irrele
20f0: 76 61 6e 74 20 77 68 6f 27 73 20 6f 62 6c 69 67 vant who's oblig
2100: 61 74 69 6f 6e 20 77 69 6c 6c 20 62 65 20 75 73 ation will be us
2110: 65 64 20 74 6f 20 66 75 6c 66 69 6c 6c 20 74 68 ed to fulfill th
2120: 65 20 63 6f 6e 74 72 61 63 74 2e 0a 0a 52 65 61 e contract...Rea
2130: 6c 20 77 6f 72 6c 64 20 61 73 73 65 74 73 20 6d l world assets m
2140: 61 79 20 6e 65 65 64 20 61 20 64 65 73 63 72 69 ay need a descri
2150: 70 74 69 6f 6e 2e 20 20 54 68 65 20 64 65 73 63 ption. The desc
2160: 72 69 70 74 69 6f 6e 20 68 6f 77 65 76 65 72 20 ription however
2170: 72 65 76 65 61 6c 73 20 61 0a 6c 6f 74 20 61 62 reveals a.lot ab
2180: 6f 75 74 20 74 68 65 20 74 72 61 6e 73 61 63 74 out the transact
2190: 69 6f 6e 2c 20 61 6e 64 20 74 68 65 72 65 66 6f ion, and therefo
21a0: 72 65 20 6d 75 73 74 20 62 65 20 65 6e 63 72 79 re must be encry
21b0: 70 74 65 64 2e 20 20 52 65 61 6c 2d 77 6f 72 6c pted. Real-worl
21c0: 64 20 61 73 73 65 74 73 0a 68 61 76 65 20 74 77 d assets.have tw
21d0: 6f 2d 70 61 72 74 79 20 74 72 61 6e 73 66 65 72 o-party transfer
21e0: 73 20 28 79 6f 75 20 63 61 6e 27 74 20 73 70 6c s (you can't spl
21f0: 69 74 20 72 65 61 6c 20 77 6f 72 6c 64 20 61 73 it real world as
2200: 73 65 74 73 29 2c 20 73 6f 20 61 20 44 48 45 20 sets), so a DHE
2210: 62 65 74 77 65 65 6e 0a 74 68 65 20 73 65 6e 64 between.the send
2220: 65 72 20 61 6e 64 20 72 65 63 65 69 76 65 72 20 er and receiver
2230: 76 61 75 6c 74 20 6b 65 79 20 69 73 20 73 75 66 vault key is suf
2240: 66 69 63 69 65 6e 74 2e 20 20 54 68 65 20 44 48 ficient. The DH
2250: 45 20 69 73 20 6d 69 78 65 64 20 77 69 74 68 20 E is mixed with
2260: 61 6e 20 49 56 0a 67 65 6e 65 72 61 74 65 64 20 an IV.generated
2270: 66 72 6f 6d 20 74 68 65 20 63 6f 6e 74 72 61 63 from the contrac
2280: 74 20 73 6f 20 66 61 72 2c 20 61 6e 64 20 74 68 t so far, and th
2290: 65 20 64 65 73 63 72 69 70 74 69 6f 6e 20 73 74 e description st
22a0: 72 69 6e 67 20 68 61 73 20 61 20 31 32 38 20 62 ring has a 128 b
22b0: 69 74 0a 48 4d 41 43 20 74 6f 20 63 68 65 63 6b it.HMAC to check
22c0: 20 74 68 61 74 20 74 68 65 20 64 65 63 72 79 70 that the decryp
22d0: 74 69 6f 6e 20 77 61 73 20 6c 69 6b 65 6c 79 20 tion was likely
22e0: 63 6f 72 72 65 63 74 2e 0a 0a 5b 75 70 5d 28 73 correct...[up](s
22f0: 71 75 69 64 2e 6d 64 29 20 5b 62 61 63 6b 5d 28 quid.md) [back](
2300: 73 71 75 69 64 2d 66 65 64 2e 6d 64 29 20 5b 6e squid-fed.md) [n
2310: 65 78 74 5d 28 73 71 75 69 64 2d 6c 69 74 65 72 ext](squid-liter
2320: 61 74 75 72 65 2e 6d 64 29 0a ature.md).