BA Livio Sgier
BA Livio Sgier
Burkhard Stiller
Livio Sgier
Zurich, Switzerland
Student ID: 12-918-702
–
B ACHELOR T HESIS
University of Zurich
Department of Informatics (IFI)
Binzmühlestrasse 14, CH-8050 Zürich, Switzerland
Bachelor Thesis
Communication Systems Group (CSG)
Department of Informatics (IFI)
University of Zurich
Binzmühlestrasse 14, CH-8050 Zürich, Switzerland
URL: http://www.csg.uzh.ch/
Abstract
Ein Finanzdienstleister entwickelte für seine Kunden ein Bonus Programm, welches einen
Anreiz bietet seine Kreditkarten zu benutzen. Die Kunden sammeln mit jedem Kauf vir-
tuelle Punkte, welche gegen Gutscheine und Coupons bei registrierten Partnern einge-
löst werden können. Der Nachteil dieser Vorgehensweise ist die zentralisierte Position
des Dienstleisters. Um neue Partner in das Programm einzubinden, benötigt es massge-
schneiderte Verträge. Der Umfang dieser Arbeit besteht aus der Entwicklung einer neuen
Kryptowährung namens Bazo (Esperanto: Basis), welche das traditionelle System ersetzt.
Bazo Tokens können als vereinheitlichtes Bezahlsystem benutzt werden und verhindern
somit die Beschränkung auf Gutscheine und Coupons. Das neue System erlaubt auch die
Direktzahlung unter Kunden sowie zwischen Partnern und Kunden. Dies führt zur Di-
sintermediation des Finanzdienstleisters und somit zur Reduktion von administrativem
Aufwand.
Bazo ist eine Kryptowährung basierend auf Blockchain Technologie. Es erlaubt die Er-
stellung von neuen Benutzerkonten und das Transferieren von Bazo Tokens zwischen Be-
nutzerkonten. Bazo wurde mit speziellem Augenmerk auf Skalierbarkeit und Einfachheit
entwickelt. Der spezifische Anwendungsfall erfordert ein geschlossenes System: Neue Be-
nutzer werden explizit eingeladen und Bazo Tokens können zentral ausgestellt werden.
Der Nebeneffekt eines zentralen Elements dieser Art ermöglicht zusätzliche Flexibilität in
Bezug auf das dynamische Ändern von System Parametern.
A financial service company based in Zurich developed a bonus program that incentivizes
customers to use its credit cards. Customers collect virtual points with every purchase
using a card issued by the company which can then be exchanged for gift cards and
coupons of registered partners. A downside of this approach is the centralized position of
the company. In order to include a new partner into the program, time-consuming and
tailored contracts need to be drafted. The scope of this thesis is the development of a new
cryptocurrency, called Bazo (Esperanto: base; foundation) that substitutes the traditional
system. Bazo coins can be used as a unified payment medium, avoiding the restriction to
exclusively crafted gift cards and coupons. The new system also offers the possibility for
direct payments between partners and customers and among customers themselves. This
leads to a disintermediation of the company, thereby reducing administration overhead.
Bazo is a blockchain-based cryptocurrency that supports the creation of new accounts
and the transfer of funds on the blockchain. It has been designed for scalability and
simplicity. Bazo’s use case necessitates central elements to deal with invite-only and
money issuance requirements of the system. The side effect of a central element is added
flexibility that is leveraged to dynamically change system parameters in case of system
failures or unforeseeable circumstances without the need for a hard fork.
i
ii
Acknowledgments
I would like to thank my supervisor, Dr. Thomas Bocek, for the interesting conversations,
his continuous assistance and inputs throughout this work. It has been a great pleasure
and inspiration to work with someone as passionate and bright as Thomas.
I would also like to thank Bedrija Hamza for his supervision. He was always very helpful
and provided many useful inputs to this thesis.
Besides my supervisors, I would also like to thank Prof. Dr. Burkhard Stiller, the head
of the Communication Systems Research Group, for giving me the opportunity to work
on such an interesting topic.
iii
iv
Contents
Abstract i
Acknowledgments iii
1 Introduction 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Design 7
3.3 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
v
vi CONTENTS
4 Implementation 15
4.2 Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.3 Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.4 Consensus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.4.1 Proof-of-Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.6.1 Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.6.2 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.7 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.8 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5 Evaluation 33
6 Future Work 35
6.3 Checkpointing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Abbreviations 45
List of Figures 45
A Message Types 49
B Installation Guidelines 51
C Contents of the CD 55
viii CONTENTS
Chapter 1
Introduction
Blockchain-related applications have gained a lot of attention from academia and industry
in recent times. Gartner’s Strategic Technology Trends for 2017 ranked blockchain among
the top 10 trends [1]. The Guardian news outlet speculates whether blockchain is the
most important IT invention of our age [2] and the Swiss media outlet NZZ boldly claims
that the invention of blockchain is as significant as the Internet [5].
Blockchain-based cryptocurrencies emerged with the invention of Bitcoin, whose white
paper was published in October, 2008 [6]. Since then, cryptocurrencies are on the rise. At
the time of writing, 1058 digital assets are listed with a combined market capitalization
of 140 $bn1 . New cryptocurrencies emerge on a weekly basis, each with their own set
of features and potential use cases. Therefore, it is of no surprise that companies in the
finance industry are keen on familiarizing with the potential of this new technology.
One such company is a financial service provider based in Zurich. This thesis emerged
out of a collaboration effort between them and the Communication Systems Group of
the University of Zurich. This financial service provider developed a bonus program that
incentivizes customers to use its credit cards by issuing virtual points for every conducted
purchase with these cards. The virtual points can in turn be used to buy gift cards
and coupons from registered partners on a centralized marketplace offered by the service
provider. The scope of this thesis consists of the development of a cryptocurrency, called
Bazo (Esperanto: base; foundation), that substitutes the traditional system.
1.1 Motivation
The traditional bonus system has several drawbacks. Tailored contracts need to be drafted
among the company and all included partners. Furthermore, the central role of the com-
pany as an intermediary leads to administration work by maintaining a marketplace. The
goal of this thesis is to design a system that overcomes these disadvantages. A blockchain-
based cryptocurrency brings the advantage to use a unified payment medium that drasti-
cally lower the contract complexities between the company and the partners. Additionally,
1
Source: coinmarketcap.com as of August 15, 2017
1
2 CHAPTER 1. INTRODUCTION
the cryptocurrency can be used for direct payments among peers, which leads to the disin-
termediation of the company, thereby reducing administration and maintenance overhead.
Familiarizing with blockchain technology, specifically cryptocurrencies, by witnessing the
technology in action, can pave the way for further potential business applications.
The remainder of this thesis is structured as follows: Chapter 2 familiarizes the reader with
blockchain technology and explains the traditional bonus system. Chapter 3 is concerned
with the design of Bazo, based on the given requirements. In Chapter 4 implementation
and practical topics are elaborated. An evaluation of Bazo is conducted in Chapter 5,
which is followed by Chapter 6 about future work. A summary and conclusions are drawn
in Chapter 7.
Chapter 2
The following section introduces blockchain technology and explains the different technical
components as well as key differences among well-known instances of cryptocurrencies. It
is followed by a section about the traditional bonus system and its workings among the
different stakeholders.
3
4 CHAPTER 2. BACKGROUND AND RELATED WORK
Table 2.1: Comparison of Bazo and popular cryptocurrencies and smart contracts
protocol. PoW allows a miner to prove to another miner that a certain amount of com-
putational resources have been utilized. One such example is the repeated calculation of
a cryptographic hash function with differing inputs until the output is less than a defined
value. Other consensus protocols, such as Practical Byzantine Fault Tolerance (PBFT)
[10] used in the Hyperledger blockchain [11], Raft [12] or Proof-of-Stake (PoS) remain an
active research area [13].
The peer-to-peer communication network has a significant impact on the stability of the
system. First, decentralization of network participants is important for the prevention
of 51% attacks [6]. Additionally, any latency between block broadcasting and reception
leads to potential blockchain forks, making the system vulnerable to double-spending at-
tacks [14]. Furthermore, it is also important to distinguish between public and private
blockchains. Public blockchains (e.g., Bitcoin and Ethereum) allow any user to freely
join and leave the network, whereas private blockchains have stricter control over who is
authorized to participate in the network. Reasons for a shift towards private blockchains
include regulatory compliance, enhanced security, privacy guarantees as well as improved
efficiency [3].
To incentivize usage of issued credit cards, the company launched a system that trans-
fers virtual points to the customer account. These virtual points can be collected and
exchanged for exclusive offers on the company’s website or within an app. The tradi-
tional system as it is in place now can be seen in Figure 2.1. There are three actors: the
company, partners and customers. The relationship among the actors are as follows:
2.2. TRADITIONAL BONUS SYSTEM 5
Partners – Customers The customers can then use their purchased gift cards or coupons
as a means of payment directly in the partner’s store.
6 CHAPTER 2. BACKGROUND AND RELATED WORK
Chapter 3
Design
This chapter outlines the design of Bazo based on the given requirements. The sections
discuss the benefits of using a cryptocurrency-based system over the traditional system,
the trade-offs regarding different data models and the motivation for an account-based
model for Bazo. Furthermore, the design aspects for all Bazo entities, e.g., accounts,
transactions and blocks, are explained.
Chapter 2 described the traditional bonus system in place and the relationships among
all stakeholders. The traditional system exposes the following weaknesses:
Administration Overhead The company has to draft tailored contracts with every
partner.
Intermediation The intermediary role of the company and the central marketplace leads
to more administration and maintenance work.
Limited customer awareness Many customers are not aware of the existence of the
bonus program and can therefore not profit.
Unified payment medium Instead of being restricted to exclusively crafted gift cards
and coupons, Bazo coins can be used as a unified payment medium. This reduces
the complexities of the individual contracts among the company and the partners.
7
8 CHAPTER 3. DESIGN
Direct payments Customers do not need to exchange virtual points for gift cards, but
can use Bazo coins as a direct payment method. This leads to the disintermediation
of the company, followed by less administrative and maintenance work. Customers
can also exchange Bazo coins among themselves.
The simplified notion of UTXO-based models is as follows: A transaction has one or more
inputs and one or more outputs. The input is a list of past transaction outputs, each
defining the amount of coins and the address to which the coins were transferred. The
output is analogous: It consists of one or more addresses and the amount of coins to
transfer to each of them. A user U wishing to send an amount of X coins to a defined
address combines past transaction outputs (that listed U as the recipient) with a total
sum of at least X coins and lists as output the address(es) of choice. In case the total sum
amounts to more than X, the user U can add a second output entry with the difference
pointing to an address to which U is in possession of the private key. The benefit of this
approach is parallel transaction processing. If a user includes several different outputs from
3.2. DATA MODEL 9
past transactions, they can all be processed in parallel. However, this comes at a cost.
In order to validate a transaction, all past transactions have to be saved which prevents
memory optimizations1 . Furthermore, the optimal choice of combining past transactions
is not trivial [4]: A naive approach combines the smallest available transaction outputs
until the sum gets equal or larger than the spending amount. However, this can cause the
transaction to get very large and expensive if the fees are relative to the transaction size
(e.g., in Bitcoin). On the other hand, the benefit of this naive approach is the consolidation
of small transaction outputs, which decreases the number of UTXOs a wallet has to handle,
which in turn boosts performance. To optimize these trade-offs, several heuristics based
on the desired design goals have to be considered which increases the complexity of the
implementation logic.
Address The address of the account is the public key of an elliptic curve key pair.
Balance The balance represents the amount of Bazo coins residing in the account.
Transaction Counter The transaction counter is used to prevent replay attacks. This
counter is incremented in the sender’s account for every transaction that involves
the transfer of coins.
1
The Bitcoin blockchain amounts to more than 123 GB at the time of writing.
10 CHAPTER 3. DESIGN
3.3 Transactions
Transactions are the basic building blocks for every state change in the system and the
basis for blocks, a higher-level construct. The common denominator for all transaction
types is a declaration of a fee and a signature. The fee payment is an incentive for the
miner to include the transaction in the next block. The higher the fee payment, the
faster a transaction gets validated if rational miners are assumed. The signature serves
the purpose of authentication. The creator digitally signs the transaction with his or her
private key. Bazo supports three transaction types which are described in the following
subsections.
Participants in the system can not join the Bazo system voluntarily. Before a user can
engage in the transfer of coins, a registered account is required. The account creation
transaction type serves this purpose. A new account is initialized with a balance of 0
coins. This type consists of the following parameters:
Address The public key of the newly created account. The corresponding private key
needs to be handed over to the user off-chain.
The transaction gets validated if the signature was signed with the private key of a root
account. Account creation transactions are referred to as AccTx for the rest of the thesis.
The transferring funds transaction type transfers Bazo coins from one account to another,
more precisely the subtraction of coins from the sender account and the addition to the
receiver account. The following fields make up this transaction:
From/To The hashes of the public keys of both the sender’s and the receiver’s accounts.
3.3. TRANSACTIONS 11
A transaction of this type is validated if the following conditions are met: The transaction
was signed with the private key of the sender, the sender’s account balance is equal or
larger than the amount spent and the transaction counter of the transaction and the state
match.
Several memory optimizations were discussed during the course of the thesis. In order to
minimize the overall size for this transaction, the transaction size can be compressed the
following way: Instead of using the full hashes of the sender and receiver accounts, only
the first n bytes are used. The remaining 32 - n bytes of both hashes are XORed with
the first 32 - n bytes of the signature. This compression leads to recalculations in the
validation of the transaction in case of conflicts in the first n bytes of an address hash, but
decreases the overall transaction size relative to n. For n = 8, the transaction size shrinks
from 149 to 101 bytes. While this approach is technically feasible and was successfully
tested, it obstructs the modularity of the system because the hash of the transaction can
only be calculated by accessing the state. This led to a strong coupling among different
packages. In light of the negative effects on the design it was decided to not use this
optimization technique.
Transferring funds transactions are referred to as FundsTx for the rest of the thesis.
The rationale behind this transaction type is that system parameters can be changed
without a hard fork. Bad design decisions during development and unforeseeable circum-
stances can thus be corrected. The following system parameters are subject to change:
Block Size This parameter stands for the maximum block size (in bytes). Received
blocks that are larger than this parameter get rejected by the miners.
Difficulty Interval For stability reasons the difficulty of the PoW should be relative to
the hashrate of the Bazo system. This parameter indicates the amount of blocks
that are to be validated before a new target value is calculated.
Block Interval The block interval is a time parameter that describes how much time
(in seconds) shall pass between two blocks.
Fee Minimum To incentivize miners for their mining work, the minimum fee that a
transaction needs to pay can be set.
Block Reward To further boost miner incentives, an additional block mining reward
can be set with this parameter.
As with the account creation transaction type, a transaction of this type is only valid if
was signed by a root account. System parameters transactions are referred to as ConfigTx
for the rest of the thesis.
12 CHAPTER 3. DESIGN
3.4 Blocks
Transactions themselves do not change the state of the system directly when they are
broadcast and received in the system. Instead, they are combined in a block and the
validation of blocks lead to the state changes. The main reason for having blocks instead
of just transactions is system stability and consensus. Committing state changes on
transactions directly upon their arrival and validation leads to an increased likelihood
of chain forks relative to the transaction throughput. As an example, Bitcoin [7] has
a fixed block interval of 10 minutes on average, Litecoin [15] (a Bitcoin fork) uses a
less conservative measure of 2.5 minutes on average and Ethereum [8] adds new blocks
to the blockchain every 15.4 seconds on average2 . The trade-off can be stated as follows:
Increasing the interval for state changes leads to transaction validation delay but decreases
the likelihood for chain forks, while decreasing the interval leads to faster transaction
validation with the increased chance of potential chain forks.
A block in Bazo consists of the following fields:
Hash The block hash acts as a unique identifier of blocks within the blockchain.
Previous Hash This value is equal to the identifier of the previous block in the blockchain.
Nonce The nonce is set to a value such that the resulting hash fulfills the PoW require-
ments.
Timestamp Refers to the block creation time (seconds elapsed since January 1, 1970
UTC).
Beneficiary The address hash of the account that receives fee payments and the block
reward.
2
Source: https://etherscan.io/chart/blocktime
3.4. BLOCKS 13
A block is considered valid and appended to the blockchain if the following conditions are
met:
All included transactions must be structurally valid and their sequential execution
must lead to legal state changes (according to Section 3.3.1, 3.3.2 and 3.3.3)
The block must belong to the longest chain at the time of validation.
The timestamp of the block must be within a predefined timerange of the validation
time.
The block size must not be larger than the current block size parameter.
The root hash of the merkle tree is included in the block itself. This provides two ad-
vantages: Block integrity and transaction verification. Because all transactions in the
block are part of the merkle root hash calculation, it is neither possible to add or remove
transactions to or from the block nor to change the ordering of the transactions inside the
block without not also changing the merkle root. However, the integrity property can also
be accomplished by hashing every transaction without a tree structure. The advantage
of the tree structure is faster verification. Consider Figure 3.3 as an example: A user
wants to know whether his or her transaction K was included in a block. To verify the
inclusion of the transaction as part of the merkle root, the following nodes are requested
from other peers in the network in sequential order: HL , HIJ , HM N OP and HABCDEF GH .
The nodes HKL , HIJKL , HIJKLM N OP and finally the root hash are recalculated based on
the received nodes. If the hash function is pre-image resistant (non-invertible) [18], it is
practically impossible to send fake nodes and not changing the root hash of the recalcu-
lations. Therefore, if the recalculated root matches the merkle root hash of the block, the
transaction is in the block (this process is also referred to as finding a merkle proof for
a given transaction hash). The opposite case, however, is not true: If the merkle root
hash does not match, it is not certain that the transaction was not in the block because
nothing prevents malicious peers from sending bogus tree nodes when being queried for a
merkle path.
Implementation
The following sections cover several implementation details about the Bazo system. First,
a high-level overview of the software architecture is presented, followed by the closer
examination of the storage and network layer. The consensus protocol is then explained in
more detail. Furthermore, it is explained how Bazo deals with the problem of transaction
malleability. A miner application programming interface (API) definition for future client
applications follows. Then, Bazo’s concurrency system is elaborated before finishing the
chapter with explaining the testing approach for the Bazo miner application.
The mining software is modular with special emphasis on high cohesion and loose coupling.
The responsibilities are logically split according to well-defined components. Figure 4.1
shows the package-level granularity of the architecture and the interconnection among
the packages. The following paragraphs describe the high-level design of the packages and
their context within the application.
The Protocol package consists of all building blocks for Bazo. It defines a transaction
interface, allowing an abstract treatment of transactions. The package also includes the
structure, encoding, decoding and hashing of all transactions types, blocks and accounts.
The responsibilities of the Miner package is everything related to mining operations. Tasks
include the validation and consolidation of incoming transactions into blocks, the creation
and validation of blocks, the calculation of the PoW and the building of the merkle tree.
The validation logic of blocks is also handled in the Miner package. Also, the blockchain as
a whole is maintained which includes tasks such as rollback operations and state changes.
These responsibilities require access to all Bazo models in the Protocol package. In order
to broadcast and request transactions and blocks to and from the network and to signal
storage-related operations, access to the P2P and the Storage packages is required.
Networking operations are implemented in the P2P package. This includes the connec-
tion setup and maintenance to other peers in the Bazo network. Additionally to the
15
16 CHAPTER 4. IMPLEMENTATION
broadcasting, requesting and receiving of transactions and blocks, several services run to
maintain system health and enable time synchronizations. The package interacts with the
Storage module to read and write Bazo elements that are requested and received by other
network participants. It also accesses the Protocol package to encode, decode and hash
transactions and blocks.
The Storage package manages memory-related tasks. Bazo was first implemented as an in-
memory application but a disk-based key/value database was added to increase scalability.
The encoding before writing to the storage and the decoding after reading from storage as
well as generating the hash as a key for all Bazo elements requires access to the Protocol
package. The lower-level functionality of the storage is implemented with the external
BoltDB package.
BoltDB [19] is an embedded key/value database with the goal of providing a simple,
fast and reliable database for projects that do not require a full database server such
as Postgres or MySQL. It has been designed with simplicity as a top design priority,
consisting of an API that is small and focuses on getting and setting values.
4.2 Storage
This section deals with all storage-related properties of the Bazo system. Firstly, the
motivation for a key/value storage paradigm is discussed. Secondly, the storage hierarchy
and the need for disk-based storage is explained.
4.2. STORAGE 17
The storage paradigm used in Bazo is a key/value-based system. The key represents the
hash and the value is the payload of the Bazo element being stored. A key/value tuple T
can be formalized as follows:
The calculation of a block hash deviates from Equations 4.2 and 4.3. This is because the
PoW is encoded in the block hash itself. Thus, the hash calculation cannot be the hash
function applied over the concatenation of all block fields. A formal description of the
block hash calculation follows in Section 4.4.1.
The technical reasons for choosing this paradigm are unique identification, scalability and
data integrity. The hash function for every Bazo element was chosen that it is practically
impossible for two distinct objects to have the same hash value. Transaction types for
which equal transactions exist (e.g., FundsTx ; Account A sends Account B an amount of
X Bazo coins multiple times in a row), an additional Transaction Counter (cf. Section
3.3.2 and 3.3.3) field is included in the hash calculation to achieve a unique hash for all
transactions. The uniqueness property prevents against replay attacks and simplifies the
software logic, because incoming transactions and blocks that match an already verified
and validated transaction hash in storage can simply be rejected.
The storage paradigm improves scalability. This is due to the fact that the transaction
themselves are not included in a block, they are only referenced by their hash which is
32 bytes long. The storage savings in case of a AccTx with a fixed size of 169 bytes
is substantial with a factor of more than 5. This compression allows more transactions
to be included in a block. Another factor is reduced redundancy: Because the payload
of transactions are broadcast prior to a block that includes them, it is not necessary to
include transaction payloads in blocks as well. In case new miners join the system, all
unknown transactions included in received blocks are requested from the network before
the block can be validated.
To use cryptographic hashes provides the additional property of data integrity. It is im-
possible for any attacker to change the contents of a transaction without also changing
18 CHAPTER 4. IMPLEMENTATION
its hash. Another desirable property is that a hash is unique for the semantics of a
transaction, e.g., there must not be differing transaction hashes for two equivalent state
transitions. A bug in the Bitcoin system makes it possible for an attacker to modify the
transaction signature and thus creating a different transaction hash without changing its
validity. This bug is referred to as Transaction Malleability [21] and is solved in Bazo (cf.
Section 4.5).
Bazo was first developed as an in-memory solution, keeping all data in volatile storage.
However, to increase scalability and to protect against system failures, a disk-based storage
solution was incorporated. Bottlenecks and time-critical parts of the system were analyzed
to decide which data is mapped to which storage medium.
In-Memory
A cache is implemented to store frequently used data to boost performance and make
operations critical to mining faster. The state of the system consisting of all accounts is
stored in random-access memory (RAM). Thus, verifying blocks with a large amount of
FundsTxs becomes significantly faster. In case of bootstrapping the system and download-
ing the history of potentially thousands of blocks from neighboring peers, incorporating an
in-memory storage solution leads to a substantial difference in verification time. Storing
the state in RAM is technically feasible, because the memory footprint of a single account
is fixed at 76 bytes, e.g., it takes 1 gigabyte of storage to store more than 13 million Bazo
accounts. Because Bazo is an invite-only blockchain and account creation needs to be
authorized, this number is highly unlikely to be surpassed.
Additionally to keeping all accounts in-memory, all transactions that were received but not
validated by a block (open transactions) are kept in RAM as well. There are two reasons
for this. Firstly, open transactions will be reused in the near future and will be evicted
from RAM as soon as they have been successfully validated. Thus, there is an upper
bound on memory used, limited by the block interval (cf. Section 3.3.3) multiplied by
the average transaction frequency. Secondly, mining blocks can be seen as a competition
among miners. The first miner to broadcast a valid block receives the block reward and
the transaction fees of all transactions included in this particular block. Therefore, it
is advantageous to increase the throughput of adding open transactions to a new block
and start to calculate the PoW. The difference in delay is relative to the number of open
transactions.
Disk-based
Whenever a block is successfully validated, all transactions in the block and the block
itself are written to disk. This increases scalability and fault-tolerance. All data that is
4.3. NETWORKING 19
kept in RAM is bound by system parameters and the properties of Bazo (e.g., private
blockchain). On the other hand, the blockchain itself grows in time as new blocks are
periodically generated even in the absence of transactions, i.e., there is no upper bound
in terms of memory consumption. Thus, storing historical blockchain data on disk-based
storage makes Bazo more scalable. It also increases fault tolerance as data stored in RAM
is lost in case of power outages or other system failures.
The following disk-based key/value storage systems were evaluated: RocksDB [34], Badger
[36], Kyoto Cabinet [35] and BoltDB [19]. Kyoto Cabinet and RocksDB are both written in
the C++ programming language, which require Cgo to run within the Go programming
language, negatively impacting performance for reasons explained in [36]. There exist
bindings for Go, but they have little community support and are not well tested. The
decision between Badger and BoltDB was made in favor of BoltDB because of better
community support, simplicity and interoperability.
BoltDB provides buckets, which are a collection of key/value pairs within a database.
Bazo employs different bucket to logically split the data:
Open Blocks Blocks that were received but not validated, i.e. open blocks, are stored in
this bucket. The reason to store open blocks on disk and not in RAM is to simplify
the bootstrapping process, which will be explained in detail in Section 4.3.1.
Closed Blocks All validated blocks that are part of the valid blockchain from the miner’s
perspective, are stored in this bucket.
Closed FundsTx /AccTx /ConfigTx A distinct bucket for all closed transactions of
each type exists. The reason to use a different bucket for each type is simplified
decoding.
4.3 Networking
All communication channels in Bazo are based on the Transmission Control Protocol
(TCP) [22]. Every miner listens on port number 8000 for incoming connections. The
implemented communication paradigm is asynchronous, e.g., requests are non-blocking.
The following subsections elaborate on the implementation details of the communication
package, covering the peer-to-peer network, the syntax and semantics of Bazo messages
as well as the different connection and message types.
Every Bazo message that is transmitted over the network includes a header and an optional
payload, as depicted in Figure 4.2. The header has a constant size of 5 bytes and consists
of the following fields:
Length The length of a Bazo message (excluding the header itself) is encoded in a 4
bytes integer and the encoded number refers to the amount of bytes of the following
payload. This allows a maximal payload of roughly 4.3 gigabytes in size.
Msg Type The message type is the description of the message and its payload. Messages
can generally be split into requests, responses and broadcasts. A total of 256 distinct
message types are possible with an encoding of 1 byte.
The payload contains the actual data of the message. Its contents are Bazo elements such
as blocks and transactions or other administration-related messages (e.g., neighbor lists of
connected miners, timestamps etc.). The full list of messages can be found in Appendix
A.
4.3. NETWORKING 21
Bazo is split into two applications with different functionalities. The miner application
is responsible for verifying and validating transactions and blocks, communicating with
other miners in the network to reach consensus and accepting new connections. The sys-
tem is fed with new transaction data by the client application. The API offered by the
miner for client connections is described in detail in Section 4.6.
The network connection types among the two applications are handled differently in Bazo.
Connections are possible among miners themselves, between miners and clients. Because
the client application does not validate nor broadcast transactions and blocks, it does
not listen to incoming connections. Therefore, clients do not connect to other clients.
Figure 4.3 shows the connection workflow from the perspective of a miner. Every miner
is listening for incoming connections. The signature for a miner to identify himself is to
send an initial message with Msg Type = MINER PING. The receiving miner responds
with a message with Msg Type = MINER PONG and both parties add the connection
to their internal miners list, which is a list of all miner connections. However, whether
the receiving end concludes the handshake depends on the miner’s internal miners list. If
a threshold for the maximum amount of miner connections is reached, the connection is
dropped.
There is no branching from the client’s perspective: As soon as the connection is es-
tablished, the message consisting of the payload is sent from client to miner and upon
receiving the response, the connection is closed.
22 CHAPTER 4. IMPLEMENTATION
4.4 Consensus
4.4.1 Proof-of-Work
The Bazo consensus protocol is PoW-based. For a new block to be accepted by the
network, it needs to fulfill certain requirements, which have been elaborated in Section
3.4. One requirement is a valid PoW, which acts as proof that miners utilized a certain
amount of computational power on average in the generation of the block. The PoW
employed in Bazo is to compare the SHA3-256 hash function applied to the concatenation
of g(block) and the nonce field against a defined difficulty level. The function g(block)
is defined in Equation 4.4: It is the SHA3-256 hash function applied to a subset of the
blocks’ fields. It excludes the nonce field, which is needed for the calculation of the PoW,
it also omits all transaction data because they are represented in the merkle root.
Equation 4.5 evaluates to boolean true or false, depending on whether the inequality is
fulfilled or not. The parameter target refers to the amount of leading zero bits in the
resulting hash.
The final block hash is defined in Equation 4.6 as the hash function applied to the con-
catenation of g(block) and the nonce. The block hash is valid if it passes the inequality
test of Equation 4.5.
The target value is dynamically recalculated based on the system parameters difficulty
interval and block interval. It is assumed that the hash function SHA3-256 provides the
necessary randomness that makes it impossible to guess whether a position within a hash
is a binary zero or one before calculating the hash. The probability that a randomly
calculated hash X has target leading zeros is thus:
24 CHAPTER 4. IMPLEMENTATION
This can be modeled as a Geometric Distribution with the success probability p = 2−target .
Thus, the expected amount of failures before a success is E(X) = (1 − p)/p.
After the number of blocks specified in the difficulty interval parameter have been added
to the blockchain, the target is recalculated, based on the ratio of the measured average
block interval and the parameter block interval.
The PoW requirement described in the previous section states a condition a block must
fulfill to be accepted as a valid block. However, this is not sufficient to achieve consensus
because it is not yet determined which chain is valid in case of forks. There are two
options to deterministically encode rules for the valid chain:
1. Number of blocks: A miner takes the first received block that fulfills all conditions
as the valid blockchain and rejects all blocks belonging to a chain that is not longer
in terms of total amount of blocks.
2. Total amount of work: If a block is received that belongs to a chain which is not
longer in terms of total amount of blocks but the chain utilized more computational
work to produce all blocks, this chain is used as the valid chain. This is evaluated by
comparing the numerical representation of the block hashes and taking the smaller
number.
Using the first heuristic leads to the fact that transactions in the last block are less likely
to be invalidated by a future block, because miners stop mining operations on a competing
block as soon as they receive a valid block that belongs to a chain which is longer than
the current chain. Assume for example that the average time between two blocks is 5
minutes. If the total amount of work is used as a heuristic, a miner has an incentive to
continue mining after receiving a block and the chances of finding a block with slightly
larger difficulty in the next 5 minutes is high. The miner can set the same target difficulty
in its PoW calculation and the chances that the calculated hash shows a higher level of
difficulty is 50%. To increase this likelihood further, the miner can use a slightly larger
difficulty parameter in its PoW calculation. On the flip side, however, implementing the
heuristic of the total amount of blocks has the disadvantage of a temporary chain fork
in the case when two or more blocks were mined and broadcast in different parts of the
network at around the same time. The higher likelihood that a transaction in a valid
block remains valid outweighs the risk of a temporary chain fork, which is the reason that
the total amount of blocks heuristic is implemented in Bazo.
In case a peer missed one or more blocks (the whole blockchain in case of a bootstrap), he
or she needs to be able to synchronize and request missing blocks and their contents from
4.5. TRANSACTION MALLEABILITY 25
the network. The pseudocode in Algorithm 1 takes as input a new block and determines
the longest chain while handling the case of missing blocks.
The current chain is initialized to the list of all blocks starting from the genesis block to
the last and current block. The while loop (lines 2–8) iterates through the chain backwards
to find the common ancestor. In case the block is missing from the internal storage, it is
requested from the network. If a previous block cannot be requested it is assumed to be
inexistent and the algorithm stops. If, however, a common ancestor is found (in case of
a rollback, the genesis block), a current branch consisting of the list of blocks that range
from the ancestor to the current block and a new branch that consists of all blocks that
range from the ancestor to the new block are built (lines 10–11). If the current branch
is larger or equal than the new branch, the algorithm stops (lines 12–14). Otherwise, all
blocks are rolled back in the opposite direction (lines 15–16) and the new chain is built,
validating block by block from the new branch (line 17). One possible case of execution
is pictured in Figure 4.5 in which a new block is part of a chain that counts more blocks
than the current chain and gets thus accepted as the new valid chain.
The Bazo system consists of two applications that interact with each other, namely the
miner application which validates transactions and blocks and the client application that
interacts with the Bazo system by creating transactions. A clearly defined API definition
is thus needed that can be implemented by future client applications.
4.6. MINER-CLIENT API 27
4.6.1 Network
Before sending the transaction into the network, connections with miners need to be estab-
lished. Theoretically, it is enough to connect to just a single miner to send the transaction
to. The miners themselves have an incentive to broadcast all incoming transactions to
the network because all transaction need to be known by all miners if they are included
in a block that needs to be validated by the network. However, to increase the likelihood
that transactions get disseminated and eventually end up in a block, connections to more
miners can be established.
Two following two IP addresses are bootstrapping servers that act as an entry point for
all miner and client applications:
1 9 2 . 4 1 . 1 3 6 . 1 9 9 −− Primary IP Address
1 3 . 8 0 . 1 5 1 . 1 3 5 −− Secondary IP Address
Bootstrapping servers listen to incoming TCP connections on port number 8000. If more
miner IP addresses are needed, a request is made to either of the IP addresses with the
syntax depicted in Figure 4.6. The encoding for all messages is Big Endian. Msg Type =
0x1F corresponds to the NEIGHBOR REQ type (cf. Appendix A).
The subsequent response is a list of IP:Port tuples formatted according to Figure 4.7. At
this point only IPv4 addresses are supported. However, this is extendable by prepending
the number of each version type (e.g., IPv4 and IPv6) before listing the addresses of each
type.
28 CHAPTER 4. IMPLEMENTATION
Upon receiving the response to the IP neighbor request (Msg Type = 0x29 ), the IP
addresses can be extracted in the format which are encoded as 6 bytes. The IP address is
encoded in the first 4 bytes as IPA.IPB.IPC.IPD. The port number is 2 bytes in size and
encoded as PortA.PortB. Subsequent connections can then be established to the received
IP:Port tuples.
4.6.2 Transactions
Regular users can send exactly one transaction type, namely FundsTx, which consists of
the following fields:
type FundsTx s t r u c t {
Header byte
Amount u i n t 6 4
Fee uint64
TxCnt u i n t 3 2 // T r a n s a c t i o n Counter
From [ 3 2 ] byte
To [ 3 2 ] byte
Sig [ 6 4 ] byte // S i g n a t u r e
}
The semantics of the fields were explained in Section 3.3.2. The signature is calculated
by concatenating all fields until To (the hash of the receiver account) and hashing it with
the SHA3-256 hash function. The first element of the signature pair is stored in the first
32 bytes and the second element is stored in the last 32 bytes the Sig array. All fields are
then sequentially encoded in Big Endian order and packed into a Bazo message depicted
in Figure 4.8. The length of a FundsTx is fixed at 149 (0x95) bytes and the message type
for broadcasting a FundsTx is 0x01.
Transaction verification by means of a merkle path (cf. Section 3.4.1) and specific imple-
mentation details are mentioned in Section 6.
4.7. CONCURRENCY 29
4.7 Concurrency
The Bazo miner application is inherently concurrent. This section introduces the con-
current structure that is important to understand the underlying workflows. The Go
programming language has a rich support for concurrency using goroutines and channels.
On a high-level, a goroutine is a function that is capable of running concurrently with
other functions. The first routine is implicit and consists of the main function itself. A
new goroutine is called by prepending the function name with the go keyword.
Channels in the Go programming language are the connections between two or multiple
goroutines and provide means of synchronization. The concurrency model in which values
are passed between independent goroutines is called Communicating Sequential Processes,
this is in contrast to the memory sharing in the Shared Memory Multithreading model
which is implemented with threads in mainstream programming languages [30].
In Bazo, communication and synchronization among different packages is handled with
channels, whereas memory sharing is used in the networking package (cf. Section 4.3).
Figure 4.9 depicts the different goroutines in a running application and the packages they
originate from:
Calculating PoW This is the initial goroutine that is implicitly started with the main
function. Calculating a valid PoW is done constantly.
Broadcast Service Whenever a miner clears blocks and transactions for broadcast, a
service iterates through all connected neighbors and channels the data to the differ-
ent goroutines.
Network Health Service Connections might drop due to various reasons. This gorou-
tine observes all maintained connections and establishes new connections when the
number of neighbors fall below a predefined threshold.
Time Service This service periodically broadcasts the local time to each connected
miner. Time synchronization is needed to reach consensus on the validity of recorded
timestamps in new blocks.
Listener This goroutine is the entry point for all miners and clients. It listens to all
incoming TCP connections on port number 8000. As soon as a new connection is
established, a new goroutine is spawned.
New Connection Each new connection is handled by its own goroutine. As explained in
Section 4.3, connections to other miners are kept open (up to a predefined threshold)
while connections to clients are aborted after the reception of a message.
4.8 Testing
The Bazo miner application was thoroughly tested across all packages, leading to a good
overall code coverage. The chosen testing approach differs between packages, the following
list explains the specific approaches for each package.
Protocol Tests in this package covered the serialization and deserialization of all Bazo
entities, e.g., accounts, transactions and blocks. Simple variable assignments, triv-
ial if conditions and the functions concerned with a textual representation of the
respective entities are not tested. The test coverage of this package is 86.1%.
P2P The P2P package handles all networking-related tasks of Bazo. Code that interfaces
with other packages cannot be properly tested with unit tests. The same is true for
dynamic networking tests, leading to a coverage of 42.1%. Interconnection among
different packages as well as the parts involving dynamic networking are to be tested
with integration tests.
4.8. TESTING 31
Miner The unit tests in this package cover the core functionality of Bazo, e.g., the veri-
fication and validation of transactions and blocks, the formation of a chain and its
state changes, rollbacks in case of chain forks, difficulty adaptations relative to the
networking hash power, PoW logic and merkle tree calculation. Trivial cases and
code that interfaces with the networking package, e.g., fetching unknown transac-
tions or blocks from the network, were not tested. Test coverage for this package is
75.1%.
Storage The unit tests written for this package cover both in-memory and disk-based
storage operations for all read, write and delete operations of accounts, transactions
and blocks. Testing low-level read and write operations for disk-based storage has
been done extensively by BoltDB itself [19] and is not repeated. Test coverage for
this package is 87.5%.
32 CHAPTER 4. IMPLEMENTATION
Chapter 5
Evaluation
Security considerations directly influenced the design of the Bazo protocol and a range of
attacks are mitigated by the employed countermeasures. The following section describes
the attack scenarios and what countermeasures are installed in Bazo to mitigate them,
specifically: Sybil attacks [37], replay attacks [38] and denial of service attacks [39]. Fur-
thermore, the implications of quantum computers and the potential weaknesses in the
cryptographic hash function SHA3 are discussed.
In computer security, a sybil attack [37] refers to the forging of identities in a peer-to-
peer network with the aim of gaining an advantage or causing system malfunctioning.
The design of Bazo’s consensus protocol, specifically its PoW, renders multiple identities
useless, because the average hash rate of a miner is the hash rate of a single system
divided by the amount of hashing operations or identities that are being used. However,
multiple identities can be used to occupy the connection list of other miners. Attackers
can then stop broadcasting transactions and blocks to those miners which can lead to peer
isolation. Malicious peers of this kind are not actively detected, but the fact that joining
peers connect to random peers in the network and that connection lists of miners have an
upper limit in the number of connections makes it more difficult to force peer isolation.
A related attack, called 51% attack, takes place, when malicious peers control more than
50% of the network hash rate. They can then rewrite history which leads to double
spending attacks and a financial gain for the attackers. Because the network hash rate
is not directly controllable and an inherent part of a PoW consensus protocol, protection
against a 51% attack is difficult.
Replay attacks [38] are a form of network attacks with the goal of maliciously repeating
data transmissions. For example, assume that Alice wants to send 10 Bazo coins to
user Bob. Bob can then just repeatedly rebroadcast the same transaction, effectively
draining the account balance of user Alice. In Bazo, this is protected by rejecting duplicate
transaction hashes. A block is not validated if it consists of two identical transactions or
33
34 CHAPTER 5. EVALUATION
a transaction that has been validated in a previous block. In the case that Alice wants
to replay this transaction, she has to include the transaction counter (cf. Section 3.3.2)
of her account in the transaction, leading to a different hash value for every subsequent
transaction.
Denial of Service (DoS) [39] attacks aim to make a peer or the network as a whole un-
available by disrupting it. The most common example is to flood the victim or the system
with a large amount of traffic. Bazo mitigates this by only broadcasting valid transactions
and blocks at most once and limiting the number of connected peers.
Another rising threat is the development of quantum computers. Many asymmetric cryp-
tosystems (including ECDSA used in Bazo) are not quantum-resistant, which means that
the encryption can be broken in a reasonable amount of time by computing the private
key from the public key [40]. It would then be possible to crack the private keys of Bazo’s
root accounts, thereby allowing the attacker to issue an unbounded amount of money,
which would pose unsurmountable challenges. Designing quantum-proof blockchains is
an ongoing research topic [41, 42].
Future Work
The consensus mechanism employed in Bazo is a classical PoW which is very similar to
Bitcoin’s consensus mechanism. PoWs that are based on the exhaustive enumeration of
a target hash value promote the employment of application-specific integrated circuits
(ASICs) which can be cheaply produced to achieve very high hash rates, easily outpower-
ing general-purpose graphics processing units. This leads to mining centralization, which
is counter to the core philosophy of decentralization. Ethereum developed its own PoW
consensus model, called EthHash [32], whose goal is to be ASIC-resistant. However, a big
drawback in every PoW consensus model is energy consumption. Proof-of-Stake (PoS)
aims to overcome the high energy consumption disadvantage that is inherent to PoW
consensus models. In PoS systems, the creator of the next block is chosen in a way that
the chances that an account’s block is chosen depends to its funds (i.e., stake). A larger
stake leads to statistically more valid block creations [31].
Replacing the existing PoW in Bazo with PoS has the advantage of reduced electricity.
Also, due to the private nature of the Bazo network, limiting accounts to less than 50%
of the total amount of Bazo coins (which makes a 51% attack in PoS feasible) can be
controlled and implemented whereas control over the hashrate of the miner is lacking.
In order for a miner to validate transactions and blocks, state access is needed, e.g., all
accounts in the Bazo system need to be accessible. To respond to transactions and block
requests, the blockchain history needs to be stored as well. Section 3.2.2 introduced the
possibility to remove past transactions. This allows a miner to still participate in the
validation of transactions and blocks with significantly less storage requirements.
Another optimization in terms of memory consumption is the simplified payment verifica-
tion (SPV), a term coined by Bitcoin [7]. It allows clients to verify whether transactions
were successfully included in a block without knowing the blockchain history. Section 3.4.1
35
36 CHAPTER 6. FUTURE WORK
introduced the concept of a merkle proof. In order to be certain that a client transaction
is recorded in the blockchain, two conditions have to be met:
To implement SPV In Bazo, the block structure needs to be refined according to Figure
6.1. All transaction-specific data is removed and the new structure is called SPV Block.
It is fixed in size at 146 bytes. For the miner to support Merkle path requests, the storage
structure has to be adapted to save the transaction hash alongside the merkle root hash
of the block it was validated in to reduce search costs. The same optimization technique
of erasing blockchain history can also be applied to have an upper bound on storage
consumption. The introduction of bloom filters [33] for privacy-enhancing futures are a
logical next step.
6.3 Checkpointing
lost. Even though resyncing is fast because blocks and transactions are already stored on
disk, the time to finish the process increases correspondingly with the blockchain length.
Block checkpointing assures that block validation and rollbacks are atomic operations.
This protects the system in the event of a system failure during multiple state updates.
A similar point discussed in Section 3.2.2 is the upper bound of blockchain memory
consumption to lower the barriers of entry for miners. However, there must be miners
that store all transactions since the genesis block to respond to requests from new miners
that validate the blockchain from the beginning. An interesting research question is
whether and how snapshots can be issued as transactions on the blockchain such that old
transactions can be effectively erased from all miners.
38 CHAPTER 6. FUTURE WORK
Chapter 7
Bazo can be seen as a suitable system to substitute the traditional bonus system in
place. The built-in modularity of the system offers many interesting ways to extend it by
including other incentivization programs by other companies, each offering an exchange
rate to Bazo coins. However, given the implications of successful exploitation, rigorous
reviews need to be conducted before running Bazo in production. Also, resources should
be invested in formally verifying security-related parts of Bazo.
39
40 CHAPTER 7. SUMMARY AND CONCLUSIONS
Bibliography
[3] S. Cocco and G. Singh: Top 6 technical advantages of Hyperledger Fabric v1.0
for blockchain networks, https://www.ibm.com/developerworks/cloud/library/cl-
top-technical-advantages-of-hyperledger-fabric-for-blockchain-networks/index.html,
March, 2017, accessed 18th August, 2017.
[10] M. Castro and B. Liskov: Practical Byzantine Fault Tolerance, In Proceedings of the
1999 Operating Systems’ Design and Implementation, OSDI ’99, pp. 173–186, New
Orleans, LA, USA, February, 1999.
41
42 BIBLIOGRAPHY
[13] R. Pass, L. Seeman, and A. Shelat: Analysis of the blockchain protocol in asyn-
chronous networks, In Proceedings of the 2017 International Conference on the The-
ory and Applications of Cryptographic Techniques, EUROCRYPT ’17, pp. 643–673,
Paris, France, May, 2017.
[21] C. Decker and R. Wattenhofer: Bitcoin Transaction Malleability and MtGox, In Pro-
ceedings of 19th European Symposium on Research in Computer Security, ESORICS
’14, pp. 313–326, Wroclaw, Poland, September, 2014.
[23] Q. Lv, P. Cao, E. Cohen, K. Li and S. Shenker: Search and replication in unstruc-
tured peer-to-peer networks, In Proceedings of the 16th international conference on
Supercomputing, ICS ’02, pp. 84–95, New York, NY, USA, June, 2002.
[28] E. Lombrozo, J. Lau and P. Wuille: BIP 141: Segregated Witness (Consensus layer),
https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki, December, 2015,
accessed 18th August, 2017.
[29] National Institute of Standards and Technology (NIST): emphDigital Signature Stan-
dard (DSS), http://csrc.nist.gov/publications/fips/fips186-3/fips 186-3.pdf, June,
2009, accessed 18th August, 2017.
[33] B. Bloom: Space/time trade-offs in hash coding with allowable errors, Communica-
tions of the ACM, Vol. 13, Issue 7, pp. 422–426, New York, NY, USA, July 1970.
[34] Facebook: RocksDB: A Persistent Key-Value Store for Flash and RAM Storage,
https://github.com/facebook/rocksdb, accessed 18th August, 2017.
[37] J. Douceur: The Sybil Attack, In Proceedings of the First International Workshop on
Peer-to-Peer Systems, IPTPS ’01, pp. 251–260, Cambridge, MA, USA, March, 2002.
[43] M. Stevens: Attacks on Hash Functions and Applications, PhD Thesis, Leiden Uni-
versity, Amsterdam, June, 2012.
Abbreviations
45
46 ABBREVIATONS
List of Figures
47
48 LIST OF FIGURES
Appendix A
Message Types
Every message sent among peers consists of a header, as shown in Figure 4.6, and an
optional payload. The header of a message consists of the length and the message type of
the Bazo message. The message type is parsed by the receiver and processed accordingly.
Table A.1 shows all available message types.
Message Numeric
Description
Type Representation
FUNDSTX BRDCST 1 Broadcast FundsTx
ACCTX BRDCST 2 Broadcast AccTx
CONFIGTX BRDCST 3 Broadcast ConfigTx
BLOCK BRDCST 4 Broadcast block
FUNDSTX REQ 10 Request a FundsTx from a miner
ACCTX REQ 11 Request an AccTx from a miner
CONFIGTX REQ 12 Request a ConfigTx from a miner
BLOCKTX REQ 13 Request a block from a miner
ACC REQ 14 Request an account from a miner
FUNDSTX RES 20 Respond with a FundsTx to the requester
ACCTX RES 21 Respond with an AccTx to the requester
CONFIGTX RES 22 Respond with a ConfigTx to the requester
BLOCK RES 23 Respond with a block to the requester
ACC RES 24 Respond with an account to the requester
NEIGHBOR REQ 30 Request a list of neighbors from a miner
NEIGHBOR RES 40 Respond a list of neighbors to the requester
TIME BRDCST 50 Broadcast local time
MINER PING 100 Initiate miner connection handshake
MINGER PONG 101 Respond to miner connection handshake
NOT FOUND 110 Respond with error to the requester
Table A.1: Message types and their corresponding descriptions
49
50 APPENDIX A. MESSAGE TYPES
Appendix B
Installation Guidelines
In order to start the miner application, Go (version 1.8.3 or higher) needs to be installed.
The newest version can always be fetched from the following website:
h t t p s : // g o l a n g . o r g / d l /
After downloading Go, the environment variables GOROOT and GOPATH need to be
set to the corresponding paths.
To get the miner application and all necessary libraries, the following command needs to
be executed on the command line:
go g e t g i t h u b . com/ l i s g i e / b a zo m in er
Upon successfully downloading the miner application and all additional libraries, the
miner application can be started with the following command:
ba zo m in er < d a t a b a s e f i l e . db> < l i s t e n i n g port>
The application consists of two arguments: database file.db points to the storage location
of the disk-based key/value store. listening port indicates the port the application listens
on for incoming miner and client connections.
Several log files are created at startup of the application which are dynamically written
to and are stored in the logs folder.
To download the client application, execute the following command on the command line:
go g e t g i t h u b . com/ l i s g i e / b a z o c l i e n t
51
52 APPENDIX B. INSTALLATION GUIDELINES
The Bazo client lets a user issue transactions by supplying the necessary arguments for
each transaction type on the command line. For a transaction to be successfully validated,
it needs to be signed with a private key (this is true for both root and regular user
accounts). The keys are stored in regular files and the filename is supplied as an argument.
All signatures in Bazo are based on the elliptic curve digital signature algorithm (ECDSA),
a digital signature algorithm based on elliptic curve cryptography. An ECDSA key pair
consists of a public key and a private key. The private key is used to sign a transaction
and the public key is used for signature verification. Listing B.1 shows an example of a
key file:
The first two lines make up the public key, the last line is the private key. For transferring
funds, only the public key is necessary, the third line can thus be omitted when creating
a transaction of this type.
header Value = 1 creates a new root account, value = 2 removes a root account.
fee The fee to be paid for the transaction. Must be larger or equal than the Minimum
Fee system parameter.
privKey Points to the key file of a root account (the transaction is invalid if it is signed
by a non-root account).
keyOutput File location that stores the keypair belonging to the newly created Bazo
account.
B.2. CLIENT APPLICATION 53
fee The fee to be paid for the transaction. Must be larger or equal than the Minimum
Fee system parameter.
txCnt This integer parameter is linked to the sender account and needs to be increased
with every newly created funds transfer transaction (starting at 0).
fromHash The key file of the sender account (only public key needed).
toHash The key file of the receiver account (only public key needed).
privKey Key file of the sender account (will most likely point to the same location as
<fromHash >, private key needed).
fee The fee to be paid for the transaction. Must be larger or equal than the Minimum
Fee system parameter.
txCnt The transaction counter. Won’t be checked, this is just to force a new hash for
the same transaction.
privKey Points to the key file of a root account (regular users are not allowed).
Appendix C
Contents of the CD
Intermediate Presentation
Final Presentation
55