zold 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +1 -0
- data/README.md +16 -8
- data/Rakefile +1 -1
- data/bin/zold +1 -1
- data/lib/zold/amount.rb +11 -3
- data/lib/zold/commands/calculate.rb +5 -0
- data/lib/zold/commands/merge.rb +2 -2
- data/lib/zold/commands/pay.rb +12 -3
- data/lib/zold/commands/taxes.rb +3 -3
- data/lib/zold/node/emission.rb +3 -2
- data/lib/zold/node/entrance.rb +3 -3
- data/lib/zold/patch.rb +2 -1
- data/lib/zold/prefixes.rb +1 -1
- data/lib/zold/score.rb +3 -0
- data/lib/zold/tax.rb +22 -6
- data/lib/zold/txn.rb +4 -3
- data/lib/zold/version.rb +1 -1
- data/lib/zold/wallet.rb +7 -1
- data/test/commands/test_diff.rb +13 -15
- data/test/commands/test_merge.rb +25 -34
- data/test/commands/test_node.rb +2 -2
- data/test/commands/test_pay.rb +5 -10
- data/test/commands/test_taxes.rb +1 -1
- data/test/fake_home.rb +59 -0
- data/test/node/test_emission.rb +4 -6
- data/test/test_amount.rb +2 -2
- data/test/test_patch.rb +7 -9
- data/test/test_prefixes.rb +3 -4
- data/test/test_tax.rb +49 -6
- data/test/test_wallet.rb +9 -34
- data/wp/.gitignore +2 -1
- data/wp/Makefile +6 -1
- data/wp/main.bib +99 -0
- data/wp/wp.pdf +0 -0
- data/wp/wp.tex +296 -145
- data/zold.gemspec +1 -1
- metadata +9 -3
data/wp/wp.tex
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
\documentclass[11pt,oneside]{article}
|
2
2
|
\usepackage[utf8]{inputenc}
|
3
3
|
\usepackage[american]{babel}
|
4
|
-
\usepackage{
|
4
|
+
\usepackage{bookmark}
|
5
5
|
\usepackage{microtype}
|
6
|
-
\usepackage{mathpazo} % Palantino font
|
6
|
+
% \usepackage{mathpazo} % Palantino font
|
7
7
|
\usepackage{mdframed}
|
8
8
|
\usepackage{pgfplots}
|
9
|
+
\usepackage{hyperref}
|
10
|
+
\usepackage[style=authoryear,sorting=nyt,backend=biber,
|
11
|
+
hyperref=true,abbreviate=true,
|
12
|
+
maxcitenames=1,maxbibnames=1]{biblatex}
|
13
|
+
\renewbibmacro{in:}{}
|
14
|
+
\addbibresource{main.bib}
|
9
15
|
\usepackage{minted}
|
10
16
|
\setminted{fontsize=\small}
|
11
17
|
\setminted{breaklines}
|
@@ -17,90 +23,199 @@
|
|
17
23
|
\newcommand\dd[1]{\colorbox{gray!30}{\texttt{#1}}}
|
18
24
|
\usepackage{hyperref}
|
19
25
|
\hypersetup{colorlinks=true,allcolors=blue!40!black}
|
20
|
-
\pagestyle{empty}
|
21
|
-
\setstretch{1.1}
|
22
26
|
\setlength{\topskip}{6pt}
|
23
27
|
\setlength{\parindent}{0pt} % indent first line
|
24
28
|
\setlength{\parskip}{6pt} % before par
|
25
29
|
|
26
|
-
\title{\includegraphics[scale=0.05]{logo.png}\\Zold:
|
27
|
-
\author{Yegor Bugayenko\\\texttt{
|
30
|
+
\title{\includegraphics[scale=0.05]{logo.png}\\Zold: A Fast Cryptocurrency for Micro Payments}
|
31
|
+
\author{Yegor Bugayenko\\\texttt{yegor256@gmail.com}}
|
28
32
|
|
29
33
|
\begin{document}
|
30
34
|
\raggedbottom
|
31
35
|
|
32
36
|
\maketitle
|
33
37
|
\begin{abstract}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
In the last few years digital currencies successfully demonstrated
|
39
|
+
their ability to become an alternative financial instrument in many
|
40
|
+
different markets. Most of the technologies available at the moment are
|
41
|
+
based on the principles of Blockchain architecture, including the
|
42
|
+
dominating currencies like Bitcoin and Etherium. Despite its
|
43
|
+
popularity, Blockchain is not the only possible solution and is not the best
|
44
|
+
for fast micro-payments.
|
45
|
+
Zold is an \emph{experimental} alternative that enables distributed transactions between
|
46
|
+
anonymous users, making micro-payments financially feasible.
|
47
|
+
It borrows the ``proof of work'' principle from Bitcoin,
|
48
|
+
and suggests a different architecture for digital wallets maintenance.
|
39
49
|
\end{abstract}
|
40
50
|
|
41
|
-
\colorbox{yellow}{It's a draft! Don't show it to anyone yet.}
|
42
|
-
|
43
51
|
\section{Motivation}
|
44
52
|
|
45
|
-
Bitcoin, the first decentralized digital currency, was released in
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
Bitcoin, the first decentralized digital currency, was released in January 2009~\parencite{nakamoto2008}.
|
54
|
+
During a few following years ``a libertarian fairy tale'' and ``a simple Silicon Valley exercise in hype''
|
55
|
+
turned into ``a catalyst to reshape the financial system in ways that are more
|
56
|
+
powerful for individuals and businesses alike,'' according to \textcite{andreessen2014}.
|
57
|
+
At the moment, as~\textcite{van2014} claimed, ``the question is not whether Bitcoin has value; it already does.
|
58
|
+
The question is whether the efficiencies of a cybercurrency
|
59
|
+
like Bitcoin can be merged with the certainties of an honest central bank.''
|
60
|
+
|
61
|
+
The core component of Bitcoin is the Blockchain technology, which
|
62
|
+
``ensures the elimination of the double-spend problem, with the help
|
63
|
+
of public-key cryptography'' and ``coins are transferred by the
|
64
|
+
digital signature of a hash''~\parencite{pilkington2016}.
|
65
|
+
Very soon after the Bitcoin invention similar products were introduced,
|
66
|
+
which were also based on the principles of Blockchain, such as
|
67
|
+
Etherium~\parencite{buterin2013}.
|
68
|
+
|
69
|
+
Even though Blockchain is a sound solution of the double-spending
|
70
|
+
problem, there could be other solutions,
|
71
|
+
including different ``proof-of'' alternatives.%
|
72
|
+
\footnote{%
|
73
|
+
\url{https://goo.gl/aqzf2Q}:
|
74
|
+
``Proof-of-Burn'': instead of bringing the money together into computer equipment,
|
75
|
+
the owner burns the coins. Here the coins to the address where they are
|
76
|
+
irretrievable. By doing this, the owner gets a privilege to
|
77
|
+
mine on the system.
|
78
|
+
``Proof-of-Stake'': the coins exist from the start, and
|
79
|
+
the validators get a reward in the form of transaction fees.
|
80
|
+
``Proof-Of-Capacity'': one pays with the hard drive space. The more
|
81
|
+
is the hard drive space; the more is the probability of mining
|
82
|
+
the next block and earning a reward.
|
83
|
+
``Proof-of-Elapsed-Time'': one uses Trusted Execution Environment or TEE
|
84
|
+
to ensure a random looter production.
|
85
|
+
}
|
86
|
+
For example, \textcite{everaere2010} gave
|
87
|
+
a summary of them and introduced their own;
|
88
|
+
\textcite{boyen2016} described
|
89
|
+
``a truly distributed ledger system based on a lean graph of cross-verifying transactions'';
|
90
|
+
recently IOTA, a ``tangle-based cryptocurrency,'' was launched~\parencite{popov2017}.
|
91
|
+
|
92
|
+
Zold also is a decentralized digital currency that maintains its ledgers
|
93
|
+
at an unpredicable amount of anonymous and untrustable server nodes, trying to guarantee
|
94
|
+
data consistency. The architecture of Zold is not Blockchain-based.
|
95
|
+
The development of Zold was motivated by the desire to overcome
|
96
|
+
two obvious disadvantages of the majority of all existing cryptocyrrencies:
|
97
|
+
|
98
|
+
The first problem is that transaction processing is rather slow.%
|
99
|
+
\footnote{%
|
100
|
+
\url{https://goo.gl/sWiAWc}:
|
101
|
+
``Current rates for Bitcoin processing
|
102
|
+
speed is 7 transactions per second (tps) while Paypal handles
|
103
|
+
an average of 115 tps and the VISA
|
104
|
+
network has a peak capacity of 47,000 tps (though it currently needs 2000-4000 tps).''
|
105
|
+
}
|
106
|
+
\textcite{karame2012} says that ``Bitcoin requires tens of minutes to verify a transaction
|
107
|
+
and is therefore inappropriate for fast payments.''
|
108
|
+
It is inevitable, since
|
109
|
+
``processing speed is at odds with the security aspects of the underlying
|
110
|
+
proof-of-work based consensus mechanism''~\parencite{kiayias2015}.
|
111
|
+
|
112
|
+
The second problem, as noted by~\textcite{popov2017}, is that ``it is not easy to get rid
|
113
|
+
of fees in the blockchain infrastructure since they serve
|
114
|
+
as an incentive for the creators of blocks.''
|
115
|
+
As per~\textcite{moser2015}, ``Bitcoin users are encouraged to
|
116
|
+
pay fees to miners, up to 10 cents (of USD) per transaction, irrespective of the
|
117
|
+
amount paid'' which especially hurts when transaction amounts are smaller than a dollar.
|
118
|
+
Moreover, according to~\textcite{kaskaloglu2014},
|
119
|
+
``an increase in transaction fees of Bitcoin is inevitable.''
|
120
|
+
|
121
|
+
Thus, the speed is low and the processing fees are high.
|
122
|
+
Zold was created as an attempt to resolve these two problems
|
123
|
+
of existing Blockchain-based digital currencies.
|
64
124
|
|
65
125
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
66
126
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
67
127
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
68
128
|
\section{Principles}
|
69
129
|
|
70
|
-
\textbf{
|
71
|
-
|
72
|
-
|
73
|
-
|
130
|
+
\textbf{No General Ledger}.
|
131
|
+
Unlike \emph{all} other crypto currencies, there is no central ledger in Zold.
|
132
|
+
Each wallet has its own personal ledger.
|
133
|
+
All transactions in each ledger are confirmed by
|
134
|
+
\href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA signatures} of their owners.
|
135
|
+
|
136
|
+
\textbf{Proof of work}.
|
137
|
+
Similar to many other digital currencies---including Bitcoin, Etherium, Plancoin, Monero, Trinity, Plancoin, Dero,
|
138
|
+
and many others---Zold nodes find consensus by comparing the amount of CPU power invested
|
139
|
+
by each of them into finding hash suffixes, performing certain expensive and meaningless calculations.
|
140
|
+
|
141
|
+
\textbf{Root Wallet}.
|
142
|
+
Zold is a pre-mined%
|
143
|
+
\footnote{%
|
144
|
+
\url{https://goo.gl/QBhbcT}:
|
145
|
+
``A premine or instamine is where the developer or developers don't release
|
146
|
+
the crypto currency in what can be considered a fair manner.
|
147
|
+
Even Bitcoin can be considered to be instamined to a certain extent.
|
148
|
+
A premine is where a developer allocates a certain amount of currency
|
149
|
+
credit to a particular address before releasing the source
|
150
|
+
code to the open community.''
|
151
|
+
}
|
152
|
+
digital asset, similar to Ripple,%
|
153
|
+
\footnote{%
|
154
|
+
\url{https://goo.gl/XAtPH8}:
|
155
|
+
``When the Ripple network was created, 100 billion XRP was created.
|
156
|
+
The founders gave 80 billion XRP to the Ripple Labs. Ripple Labs
|
157
|
+
will develop the Ripple software, promote the Ripple payment system,
|
158
|
+
give away XRP, and sell XRP.''
|
159
|
+
}
|
160
|
+
Cardano,
|
161
|
+
Stellar,%
|
162
|
+
\footnote{%
|
163
|
+
\url{https://goo.gl/CnQQwA}:
|
164
|
+
``The stellar network started with 100 billion lumens.
|
165
|
+
There is a 1\% p.a. inflation, hence the current total of roughly 103.5 billion lumens.
|
166
|
+
About 18 billion lumens are on the market and the other
|
167
|
+
85 is held by the stellar development foundation.''
|
168
|
+
}
|
169
|
+
EOS, NEO, Loki,%
|
170
|
+
\footnote{%
|
171
|
+
\url{https://goo.gl/By5CR3}:
|
172
|
+
``Over 7 million Loki is held in escrow for the Founder,
|
173
|
+
Advisor, and Seed allocations. The Founder and Advisor allocations
|
174
|
+
follow a 12 month lockup schedule, where 25\% of each allocation is
|
175
|
+
released every 90 days following mainnet launch. The allocations
|
176
|
+
to Founders and Advisors are remuneration for services rendered to the
|
177
|
+
LAG Foundation Ltd. The Seed allocation follows a similar schedule, with a
|
178
|
+
30\% initial release and 20\% every 90 days until the final release of 10\%.''
|
179
|
+
}
|
180
|
+
and many others.
|
181
|
+
The only way to get ZLD is to receive it from someone else.
|
182
|
+
The root wallet belongs to the issuer and may have a negative balance,
|
183
|
+
which can grow according to a pre-defined restrictive formula.
|
184
|
+
All other wallets may only have positive balances.
|
185
|
+
|
186
|
+
\textbf{Taxes}.
|
187
|
+
Unlike many other payment systems, Zold doesn't require its users
|
188
|
+
to pay transaction fees. Instead, wallets have to pay regular ``taxes'' for the
|
189
|
+
service of their maintenances. Taxes amounts depend on the amount
|
190
|
+
of transactions in a wallet and the age of the wallet.
|
74
191
|
|
75
192
|
\textbf{No Trust}.
|
76
193
|
The network of communicating nodes maintains wallets of users.
|
77
194
|
Anyone can add a node to the network.
|
78
195
|
It is assumed that any node may contain corrupted data, either by mistake or intentionally.
|
79
196
|
|
80
|
-
\textbf{
|
81
|
-
|
82
|
-
and
|
83
|
-
|
84
|
-
\textbf{No General Ledger}.
|
85
|
-
There is no central ledger, each wallet has its own personal ledger.
|
86
|
-
All transactions in each ledger are confirmed by
|
87
|
-
\href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA signatures}
|
88
|
-
of their owners.
|
197
|
+
\textbf{Open Source}.
|
198
|
+
Zold is a command line tool. Its entire code base is open source
|
199
|
+
and hosted at the GitHub \href{https://github.com/yegor256/zold}{yegor256/zold}
|
200
|
+
repository.
|
89
201
|
|
90
202
|
\textbf{Capacity}.
|
91
203
|
One currency unit is called ZLD.
|
92
|
-
One ZLD by convention equals to $2^{
|
204
|
+
One ZLD by convention equals to $2^{32}$ \emph{zents} (4,294,967,296).
|
93
205
|
All amounts are stored as signed 64-bit integers.
|
94
|
-
Thus, the technical capacity of the currency is
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
206
|
+
Thus, the technical capacity of the currency is 2,147,483,648 ZLD (two billion).%
|
207
|
+
\footnote{%
|
208
|
+
To compare, the total supply of some crypto currencies is:
|
209
|
+
Bitcoin: 21m BTC,
|
210
|
+
Ethereum;: 100m ETH,
|
211
|
+
Ripple: 100b XRP,
|
212
|
+
Litecoin: 84m LTC,
|
213
|
+
Cardano: 31b ADA,
|
214
|
+
Stellar: 103b XLM,
|
215
|
+
NEO: 100m NEO,
|
216
|
+
Dash: 19m DASH.
|
217
|
+
}
|
102
218
|
|
103
|
-
\colorbox{yellow}{Let's compare each of these principles with other currencies and highlight similarities.}
|
104
219
|
|
105
220
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
106
221
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
@@ -111,8 +226,7 @@ The system consists of nodes (server machines), which maintain the data.
|
|
111
226
|
In order to guarantee data consistency among all distributed nodes
|
112
227
|
there has to be an algorithm of data segregation.
|
113
228
|
Corrupted data must be detected earlier and filtered out as quickly as possible.
|
114
|
-
Bitcoin introduced such an algorithm and called it \emph{proof of work}.
|
115
|
-
\colorbox{yellow}{link}
|
229
|
+
Bitcoin introduced such an algorithm and called it \emph{proof of work}~\parencite{nakamoto2008}.
|
116
230
|
|
117
231
|
Its fundamental principle is that each block of data must have a special
|
118
232
|
number attached to it, known as \emph{nonce}, which is rather difficult to calculate,
|
@@ -123,16 +237,15 @@ some data gets corrupted, the amount of CPU power a part of the network
|
|
123
237
|
decides to invest into its nonces calculation would be smaller than what
|
124
238
|
the other part of the network invests into legal data. The latter part
|
125
239
|
will quickly dominate the former and the nodes with corrupted data will
|
126
|
-
be ostracized and eventually ignored.
|
127
|
-
\colorbox{yellow}{let's make sure this text is correct and add a link}
|
240
|
+
be ostracized and eventually ignored~\parencite{nakamoto2008}.
|
128
241
|
|
129
242
|
Zold has borrowed this principle, although modified it. It also requires
|
130
243
|
its nodes to invest their CPU power into meaninless and repetative
|
131
244
|
calculations just to help us identify which part of the network they belong to:
|
132
|
-
corrupted or not. Each Zold node has to calculate its \emph{
|
245
|
+
corrupted or not. Each Zold node has to calculate its \emph{score},
|
133
246
|
which is as big as much CPU power the node has invested into its calculation.
|
134
247
|
|
135
|
-
Similar to Bitcoin nonces
|
248
|
+
Similar to Bitcoin nonces, Zold nodes repeatedly calculate cryptographic hashes,
|
136
249
|
looking for consecutive zeros inside them. First, in order to calculate a score,
|
137
250
|
a node makes the \emph{prefix}, which consists of four parts,
|
138
251
|
separated by spaces:
|
@@ -147,29 +260,28 @@ separated by spaces:
|
|
147
260
|
For example, the prefix may look like this:
|
148
261
|
|
149
262
|
\begin{minted}{text}
|
150
|
-
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@
|
263
|
+
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@abcdabcdabcdabcd
|
151
264
|
\end{minted}
|
152
265
|
|
153
266
|
Then, the node attempts to append any arbitrary text, which has to match
|
154
267
|
\dd{/[a-zA-Z0-9]+/} regular expression, to the end of the prefix and calculates
|
155
268
|
\href{https://en.wikipedia.org/wiki/SHA-2}{SHA-256 hash}
|
156
269
|
of the text in the hexadecimal format. For example, this would be the prefix
|
157
|
-
with the attached \dd{
|
270
|
+
with the attached \dd{16bda66} suffix:
|
158
271
|
|
159
272
|
\begin{minted}{text}
|
160
|
-
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@
|
273
|
+
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@abcdabcdabcdabcd 16bda66
|
161
274
|
\end{minted}
|
162
275
|
|
163
|
-
The hash of this text will be:
|
276
|
+
The hash of this text will be (pay attention to the trailing zeroes):
|
164
277
|
|
165
278
|
\begin{minted}{text}
|
166
|
-
|
279
|
+
5fa0681f220a2779b03b46456a19b38c0b635c1573dc01401dafee510000000
|
167
280
|
\end{minted}
|
168
281
|
|
169
282
|
The node attempts to try different sufficies until one of them produces
|
170
283
|
a hash that ends with a few tailing zeroes. The one above ends
|
171
|
-
with six zeroes
|
172
|
-
(it took three minutes to find it on 2.3GHz Intel Core i7):
|
284
|
+
with six zeroes.
|
173
285
|
|
174
286
|
When the first suffix is found, the score is 1. Then, to
|
175
287
|
increase the score by one, the next suffix has to be found, which
|
@@ -177,31 +289,34 @@ can be added to the first 64 characters of the previous hash
|
|
177
289
|
in order to obtain a new hash with trailing zeros, for example:
|
178
290
|
|
179
291
|
\begin{minted}{text}
|
180
|
-
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@
|
292
|
+
2018-05-17T03:50:59Z b2.zold.io 4096 THdonv1E@abcdabcdabcdabcd 16bda66 13d284b
|
181
293
|
\end{minted}
|
182
294
|
|
183
295
|
Produces:
|
184
296
|
|
185
297
|
\begin{minted}{text}
|
186
|
-
|
298
|
+
ce420bfdd2f6530db795e7ff4aa508bb0092735dd63d209da218cb78b000000
|
187
299
|
\end{minted}
|
188
300
|
|
189
301
|
And so on.
|
190
302
|
|
191
303
|
The score is valid only when the starting time point is earlier than
|
192
|
-
the current time, but not earlier than 24 hours ago. The strength of the score
|
304
|
+
the current time, but not earlier than 24 hours ago. The \emph{strength} of the score
|
193
305
|
is the amount of the trailing zeros in the hash. In the example above the
|
194
|
-
strength is six.
|
306
|
+
strength is six. The larger the strength, the more CPU power it takes to earn
|
307
|
+
the score. All nodes in the network must have the same strength of their scores.
|
308
|
+
|
195
309
|
|
196
310
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
197
311
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
198
312
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
199
313
|
\section{Wallets}
|
200
314
|
|
201
|
-
There is no central ledger in Zold, like many other digital currencies.
|
315
|
+
There is no central ledger in Zold, like in many other digital currencies.
|
202
316
|
Instead, each user has their own \emph{wallets} (any number of them) with their own ledgers inside.
|
203
317
|
Each wallet is an ASCII-text file with the name equal to the wallet ID.
|
204
|
-
For example, the wallet in the file \dd{12345678abcdef} may include
|
318
|
+
For example, the wallet in the file \dd{12345678abcdef} may include
|
319
|
+
the following text:
|
205
320
|
|
206
321
|
\begin{minted}{text}
|
207
322
|
zold
|
@@ -209,10 +324,10 @@ zold
|
|
209
324
|
12345678abcdef
|
210
325
|
AAAAB3NzaC1yc2EAAAADAQABAAABAQCuLuVr4Tl2sXoN5Zb7b6SKMPrVjLxb...
|
211
326
|
|
212
|
-
003a;2017-07-19T21:24:51Z;ffffffff9c0ccccd;Ui0wpLu7;98bb82c81735c4ee;For services;SKMPrVj...
|
213
|
-
003b;2017-07-19T21:25:07Z;ffffffffffa72367;xksQuJa9;98bb82c81735c4ee;For food;QCuLuVr4...
|
214
|
-
0f34;2017-07-19T21:29:11Z;0000000000647388;kkIZo09s;18bb82dd1735b6e9
|
215
|
-
003c;2017-07-19T22:18:43Z;ffffffffff884733;pplIe28s;38ab8fc8e735c4fc;For programming;2sXoN5...
|
327
|
+
003a;2017-07-19T21:24:51Z; ffffffff9c0ccccd; Ui0wpLu7; 98bb82c81735c4ee; For services;SKMPrVj...
|
328
|
+
003b;2017-07-19T21:25:07Z; ffffffffffa72367; xksQuJa9; 98bb82c81735c4ee; For food;QCuLuVr4...
|
329
|
+
0f34;2017-07-19T21:29:11Z; 0000000000647388; kkIZo09s; 18bb82dd1735b6e9; -;
|
330
|
+
003c;2017-07-19T22:18:43Z; ffffffffff884733; pplIe28s; 38ab8fc8e735c4fc; For programming;2sXoN5...
|
216
331
|
\end{minted}
|
217
332
|
|
218
333
|
Lines are separated by either CR or CRLF.
|
@@ -221,7 +336,7 @@ The header includes four lines:
|
|
221
336
|
|
222
337
|
\begin{enumerate}
|
223
338
|
\item Network name, \dd{[a-z]\{4,16\}};
|
224
|
-
\item Software version, \dd{[0-9]+(
|
339
|
+
\item Software version, \dd{[0-9]+(\\.[0-9]+)\{1,2\}} (\href{https://semver.org/}{semantic versioning});
|
225
340
|
\item Wallet ID, a 64-bit unsigned integer in hexadecimal format;
|
226
341
|
\item Public \href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA}
|
227
342
|
key of the wallet owner, in \href{https://en.wikipedia.org/wiki/Base64}{Base64}.
|
@@ -231,34 +346,30 @@ The ledger includes transactions, one per line. Each transaction line
|
|
231
346
|
contains fields separated by a semi-colon:
|
232
347
|
|
233
348
|
\begin{enumerate}
|
234
|
-
\item Transaction ID, an unsigned 16-bit integer, 4-symbols hex;
|
235
|
-
\item
|
236
|
-
\item
|
237
|
-
\item Payment prefix, 8-32 symbols;
|
238
|
-
\item Wallet ID of the beneficiary, 16-symbols hex;
|
239
|
-
\item
|
240
|
-
\item \href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA} signature,
|
349
|
+
\item \dd{id}: Transaction ID, an unsigned 16-bit integer, 4-symbols hex;
|
350
|
+
\item \dd{time}: date and time, in \href{https://en.wikipedia.org/wiki/ISO_8601}{ISO 8601} format, 20 symbols;
|
351
|
+
\item \dd{amount}: Zents, a signed 64-bit integer, 16-symbols hex;
|
352
|
+
\item \dd{prefix}: Payment prefix, 8-32 symbols;
|
353
|
+
\item \dd{bnf}: Wallet ID of the beneficiary, 16-symbols hex;
|
354
|
+
\item \dd{details}: Arbitrary text, matching \dd{/[a-zA-Z0-9 -.]\{1,512\}/};
|
355
|
+
\item \dd{signature}: \href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA} signature,
|
241
356
|
684 symbols in \href{https://en.wikipedia.org/wiki/Base64}{Base64}.
|
242
357
|
\end{enumerate}
|
243
358
|
|
244
359
|
Transactions with positive amount don't have signatures.
|
245
360
|
Their IDs point to ID fields of corresponding beneficiaries' wallets.
|
246
361
|
|
247
|
-
The
|
362
|
+
The \dd{prefix} is a piece of text randomly selected from the RSA key
|
363
|
+
of the beneficiary wallet. It is used for security reasons, in order
|
364
|
+
to make impossible ``wallet masquerading'' (pushing a new wallet with the
|
365
|
+
same ID, but a different key).
|
366
|
+
|
367
|
+
The combination \dd{id}+\dd{bnf} must be unique in the entire wallet.
|
248
368
|
|
249
369
|
The \href{https://en.wikipedia.org/wiki/RSA_(cryptosystem)}{RSA}
|
250
370
|
signature is calculated using the private key of the
|
251
371
|
wallet and the following fields of transaction, separated by spaces:
|
252
|
-
|
253
|
-
\begin{enumerate}
|
254
|
-
\item Wallet ID;
|
255
|
-
\item Transaction ID, an unsigned 16-bit integer;
|
256
|
-
\item Date and time, in ISO 8601 format;
|
257
|
-
\item Amount, a signed 64-bit integer;
|
258
|
-
\item Payment prefix;
|
259
|
-
\item Wallet ID of the beneficiary;
|
260
|
-
\item Details, matching \dd{/[a-zA-Z0-9 -.]{1,128}/}.
|
261
|
-
\end{enumerate}
|
372
|
+
\dd{bnf}, \dd{id}, \dd{time}, \dd{amount}, \dd{prefix}, \dd{bnf}, \dd{details}.
|
262
373
|
|
263
374
|
For example, this text may be used as a signing input:
|
264
375
|
|
@@ -266,21 +377,22 @@ For example, this text may be used as a signing input:
|
|
266
377
|
12345678abcdef 003a 2017-07-19T21:24:51Z ffffffff9c0ccccd Ui0wpLu7 98bb82c81735c4ee For services
|
267
378
|
\end{minted}
|
268
379
|
|
269
|
-
Each transaction takes
|
270
|
-
|
271
|
-
|
380
|
+
Each transaction takes 1284 symbols at most.
|
381
|
+
|
382
|
+
The order of transactions is not important, as long as their final balance is positive.
|
272
383
|
|
273
384
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
274
385
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
275
386
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
276
387
|
\section{Mining Formula}
|
277
388
|
|
278
|
-
The only way to get ZLD is to receive it from the \emph{root} wallet
|
389
|
+
The only way to get ZLD is to receive it from the \emph{root} wallet
|
390
|
+
with a system pre-defined ID \dd{0000000000000000}.
|
279
391
|
This wallet is the only one that may have a negative ballance.
|
280
392
|
However, to prevent an uncontrolled emission of ZLD, the balance
|
281
393
|
of this wallet must satisfy the formula:
|
282
394
|
|
283
|
-
$$
|
395
|
+
$$t = \frac{h}{24 \times 1024}; \quad z = 2^{63} \times (1 - 2^{-t}).$$
|
284
396
|
|
285
397
|
Here $h$ is the age of the root wallet in hours and $z$ is the maximum
|
286
398
|
amount of zents it can issue at that moment. The first
|
@@ -290,29 +402,15 @@ six years will look like this:
|
|
290
402
|
\hline
|
291
403
|
Year & ZLD & Share \\
|
292
404
|
\hline
|
293
|
-
1st &
|
294
|
-
2nd &
|
295
|
-
3rd &
|
296
|
-
4th &
|
297
|
-
5th &
|
298
|
-
6th &
|
405
|
+
1st & 470m & 22\% \\
|
406
|
+
2nd & 837m & 39\% \\
|
407
|
+
3rd & 1.1b & 52\%\\
|
408
|
+
4th & 1.3b & 63\% \\
|
409
|
+
5th & 1.5b & 71\% \\
|
410
|
+
6th & 1.7b & 77\% \\
|
299
411
|
\hline
|
300
412
|
\end{tabular}\end{center}
|
301
413
|
|
302
|
-
On a large perspective of 25 years total emission of ZLD will look
|
303
|
-
like this:
|
304
|
-
|
305
|
-
\vspace{\parskip}\begin{center}\begin{tikzpicture}
|
306
|
-
\begin{axis}[
|
307
|
-
axis lines=middle,
|
308
|
-
width=12cm,height=5cm,
|
309
|
-
xlabel={Age, in years},
|
310
|
-
ylabel={Billions of ZLD},
|
311
|
-
]
|
312
|
-
\addplot[domain=-0:25, samples=25]{2^(39-2048/(x*24*365)) / 1000000000};
|
313
|
-
\end{axis}
|
314
|
-
\end{tikzpicture}\end{center}
|
315
|
-
|
316
414
|
The limitation is hardwired in Zold software and can't be eliminated.
|
317
415
|
|
318
416
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
@@ -323,10 +421,8 @@ The limitation is hardwired in Zold software and can't be eliminated.
|
|
323
421
|
Each wallet must have to pay \emph{taxes} in order to be promoted by nodes.
|
324
422
|
The maximum amount of tax debt a node can tolerate is 1 ZLD. This means
|
325
423
|
that if the debt is smaller, all nodes must promote the wallet to their
|
326
|
-
remote nodes. If the debt is bigger, a node will
|
327
|
-
|
328
|
-
the network---only a limited amount of nodes will see it, unless the owner
|
329
|
-
manually pushes it to many nodes, which is an expensive operation.
|
424
|
+
remote nodes. If the debt is bigger, a node will reject the wallet,
|
425
|
+
which will make it impossible to make any new payments from it.
|
330
426
|
|
331
427
|
The amount of taxes to be paid is calculated by the following formula:
|
332
428
|
|
@@ -337,19 +433,26 @@ which is calculated as the difference in hours between the current time
|
|
337
433
|
and the time of the oldest transaction in the wallet.
|
338
434
|
$T$ is the total number of transactions in the wallet.
|
339
435
|
$F$ is the fee per transaction/hour, which is equal to 7.48 zents
|
340
|
-
(a one-year-old wallet with 4096 transactions
|
436
|
+
(a one-year-old wallet with 4096 transactions must pay approximately 16 ZLD taxes annually).
|
341
437
|
|
342
438
|
In order to pay taxes the owner of the wallet has to select any remote
|
343
439
|
node from the network, which has a score of 16 or more. Then, it has to
|
344
|
-
take the invoice from the score
|
345
|
-
|
346
|
-
|
347
|
-
|
440
|
+
take the invoice from the score, request the node to lock the score
|
441
|
+
for a minute, and send the payment of 1 ZLD or less
|
442
|
+
to that node. The score with exactly 16 suffixes
|
443
|
+
has to be placed into the details of the transaction,
|
444
|
+
prefixed by \dd{TAXES }.
|
445
|
+
|
446
|
+
The most active remote node will be selected as tax receiver.
|
447
|
+
It's up to the payer which node to select.
|
448
|
+
|
449
|
+
All tax payments inside a wallet must have unique scores.
|
450
|
+
Duplicate tax payments are ignored.
|
348
451
|
|
349
452
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
350
453
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
351
454
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
352
|
-
\section{
|
455
|
+
\section{Remote Nodes}
|
353
456
|
|
354
457
|
Each node maintains a list of \emph{remote nodes} (their host names and TCP port numbers),
|
355
458
|
their scores and their availability information. When the node is just installed,
|
@@ -359,6 +462,22 @@ to high-score nodes and the nodes with the highest availability.
|
|
359
462
|
Moreover, the node adds new elements to the list retrieving them from all
|
360
463
|
available remote nodes.
|
361
464
|
|
465
|
+
The built-in mechanism pays attention to the following factors of
|
466
|
+
remote node \emph{quality} (in order of importance):
|
467
|
+
|
468
|
+
\begin{enumerate}
|
469
|
+
\item Visibility: the payer has to know the node,
|
470
|
+
\item Availability: the amount of errors seen recently,
|
471
|
+
\item Knowledgeability: the amount of nodes this node is aware of,
|
472
|
+
\item Activity: the frequency of push requests the node originates,
|
473
|
+
\item Score: the one reported during the most recent handshake.
|
474
|
+
\end{enumerate}
|
475
|
+
|
476
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
477
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
478
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
479
|
+
\section{Fetch, Merge, and Propagate}
|
480
|
+
|
362
481
|
First, to see a wallet, it has to be \emph{fetched} from a number of remote
|
363
482
|
nodes. The nodes may provide different versions of the same wallet, either
|
364
483
|
because some data is corrupted or because modifications were made to the same
|
@@ -417,11 +536,11 @@ if it doesn't yet exist there.
|
|
417
536
|
\section{Pay and Push}
|
418
537
|
|
419
538
|
To send money from one wallet to another, the owner of the sending wallet
|
420
|
-
has to add a negative transaction to it
|
539
|
+
has to add a negative transaction to it and sign it with the private RSA key.
|
421
540
|
|
422
541
|
At any moment of time any node may decide to push a wallet to another node.
|
423
|
-
The accepts it, merges with the local version, and keeps locally.
|
424
|
-
\emph{promotes} the wallet to all known remote nodes.
|
542
|
+
The receiving node accepts it, merges with the local version, and keeps locally.
|
543
|
+
Then, it \emph{promotes} the wallet to all known remote nodes.
|
425
544
|
|
426
545
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
427
546
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
@@ -433,7 +552,9 @@ Each response has \dd{Content-Type},
|
|
433
552
|
\dd{Content-Length}, and \dd{X-Zold-Version}
|
434
553
|
HTTP headers.
|
435
554
|
|
436
|
-
\dd{GET /} is a home page of a node that returns
|
555
|
+
\dd{GET /} is a home page of a node that returns
|
556
|
+
JSON/\href{https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}{200}
|
557
|
+
response with the
|
437
558
|
information about the node, for example (other details may be added in
|
438
559
|
further versions):
|
439
560
|
|
@@ -451,7 +572,8 @@ further versions):
|
|
451
572
|
}
|
452
573
|
\end{minted}
|
453
574
|
|
454
|
-
\dd{GET /remotes} returns the list of remote nodes known by the node,
|
575
|
+
\dd{GET /remotes} returns the list of remote nodes known by the node,
|
576
|
+
in JSON/\href{https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}{200}:
|
455
577
|
|
456
578
|
\begin{minted}{json}
|
457
579
|
{
|
@@ -462,7 +584,8 @@ further versions):
|
|
462
584
|
]
|
463
585
|
}\end{minted}
|
464
586
|
|
465
|
-
\dd{GET /wallet/<ID>} returns the content of the wallet
|
587
|
+
\dd{GET /wallet/<ID>} returns the content of the wallet, in
|
588
|
+
JSON/\href{https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}{200}:
|
466
589
|
|
467
590
|
\begin{minted}{json}
|
468
591
|
{
|
@@ -474,7 +597,7 @@ If the wallet is not found, a
|
|
474
597
|
\href{https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5}{404}
|
475
598
|
HTTP response is returned.
|
476
599
|
|
477
|
-
If the client provided the MD5 hash of the wallet content in the
|
600
|
+
If the client provided the pre-calculated MD5 hash of the wallet content in the
|
478
601
|
\href{https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26}{\dd{If-None-Match}}
|
479
602
|
HTTP header and it matches with the hash of the
|
480
603
|
content the node contains, a
|
@@ -516,20 +639,26 @@ on the wallets coming in? If the node doesn't accept a push request,
|
|
516
639
|
its availability rating decreases and other nodes will stop paying
|
517
640
|
taxes to it.
|
518
641
|
|
519
|
-
\subsection{To
|
642
|
+
\subsection{To Advertise Other Nodes}
|
520
643
|
|
521
|
-
What is the incentive to
|
644
|
+
What is the incentive to advertise other remote nodes via the \dd{/remotes} RESTful
|
522
645
|
entry point and why can't a node always return an empty list, expecting its clients
|
523
646
|
to always pay taxes to it? The software automatically prioritizes remote
|
524
647
|
nodes by the amount of remote nodes it promotes. The longer the list a node
|
525
648
|
returns, the higher its chance to be at the top of the list.
|
526
649
|
|
527
|
-
\
|
650
|
+
\subsection{To Promote Wallets}
|
651
|
+
|
652
|
+
What is the incentive to promote wallets to remote nodes, spending network
|
653
|
+
traffic for this operation? Each node ranks its remote nodes also by the
|
654
|
+
amount of push requests they send. Thus, in order to stay on top of the lists
|
655
|
+
each node is interested to push wallets further.
|
656
|
+
|
528
657
|
|
529
658
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
530
659
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
531
660
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
532
|
-
\section{Threats}
|
661
|
+
\section{Threats \& Responses}
|
533
662
|
|
534
663
|
It is obvious that a distributed system that consists of anonymous nodes
|
535
664
|
even theorecially can't be 100\% safe, reliable, secure and trustworthy.
|
@@ -538,7 +667,7 @@ to mitigate all critical threats and make the system ``reliable enough.''
|
|
538
667
|
This Section summarizes the most import of those threads and explains
|
539
668
|
how Zold responds to them.
|
540
669
|
|
541
|
-
\subsection{Double Spending}
|
670
|
+
\subsection{Double Spending Attack}
|
542
671
|
|
543
672
|
It is possible to submit the same spending transaction to the same wallet
|
544
673
|
and then push it to two different nodes in different parts of the network.
|
@@ -552,6 +681,28 @@ one, and one of the transactions will be rejected from the wallet, after
|
|
552
681
|
a number of merge operations in all nodes of the network. The receiver of the
|
553
682
|
money must be careful and always to the full fetch (from as many
|
554
683
|
|
555
|
-
\
|
684
|
+
\subsection{51\% Attack}
|
685
|
+
|
686
|
+
A group of nodes can combine their CPU power in order to win the consensus
|
687
|
+
algorithm and add fraudulent incoming transactions to a wallet.
|
688
|
+
The fetching node will trust the wallet ``as is'' and will think that the
|
689
|
+
balance of the wallet is larger than it actually is.
|
690
|
+
|
691
|
+
This may happen, but a fetching node may always re-validate the entire wallet,
|
692
|
+
by checking RSA signatures of all transactions. This will take some time, but will
|
693
|
+
provide an extra guarantee to the client.
|
694
|
+
|
695
|
+
\subsection{Fraudulent Tax Refunds}
|
696
|
+
|
697
|
+
Some nodes may resell their scores to their affiliated tax payers, and they
|
698
|
+
refund them some amount of taxes back. This will be profitable both for
|
699
|
+
the tax payers, since they will pay less taxes, and for the node owners,
|
700
|
+
since they will receive the payments anyway.
|
701
|
+
|
702
|
+
This scenario is indeed possible, but it is assumed that since tax payments are
|
703
|
+
supposed to be made in small increments and automatically, the majority of
|
704
|
+
clients won't be interested in this fraudulent scheme.
|
705
|
+
|
706
|
+
\printbibliography%
|
556
707
|
|
557
708
|
\end{document}
|