%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% I, the copyright holder of this work, release this work into the
%% public domain. This applies worldwide. In some countries this may
%% not be legally possible; if so: I grant anyone the right to use
%% this work for any purpose, without any conditions, unless such
%% conditions are required by law.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[
  digital, %% The `digital` option enables the default options for the
           %% digital version of a document. Replace with `printed`
           %% to enable the default options for the printed version
           %% of a document.
%%  color,   %% Uncomment these lines (by removing the %% at the
%%           %% beginning) to use color in the digital version of your
%%           %% document
  table,   %% The `table` option causes the coloring of tables.
           %% Replace with `notable` to restore plain LaTeX tables.
  twoside, %% The `twoside` option enables double-sided typesetting.
           %% Use at least 120 g/m² paper to prevent show-through.
           %% Replace with `oneside` to use one-sided typesetting;
           %% use only if you don’t have access to a double-sided
           %% printer, or if one-sided typesetting is a formal
           %% requirement at your faculty.
  lof,     %% The `lof` option prints the List of Figures. Replace
           %% with `nolof` to hide the List of Figures.
  lot,     %% The `lot` option prints the List of Tables. Replace
           %% with `nolot` to hide the List of Tables.
  %% More options are listed in the user guide at
  %% <http://mirrors.ctan.org/macros/latex/contrib/fithesis/guide/mu/fi.pdf>.
]{fithesis3}
%% The following section sets up the locales used in the thesis.
\usepackage[resetfonts]{cmap} %% We need to load the T2A font encoding
\usepackage[T1,T2A]{fontenc}  %% to use the Cyrillic fonts with Russian texts.
\usepackage[
  main=english, %% By using `czech` or `slovak` as the main locale
                %% instead of `english`, you can typeset the thesis
                %% in either Czech or Slovak, respectively.
  english, german, russian, czech, slovak %% The additional keys allow
]{babel}        %% foreign texts to be typeset as follows:
%%
%%   \begin{otherlanguage}{german}  ... \end{otherlanguage}
%%   \begin{otherlanguage}{russian} ... \end{otherlanguage}
%%   \begin{otherlanguage}{czech}   ... \end{otherlanguage}
%%   \begin{otherlanguage}{slovak}  ... \end{otherlanguage}
%%
%% For non-Latin scripts, it may be necessary to load additional
%% fonts:
\usepackage{paratype}
\def\textrussian#1{{\usefont{T2A}{PTSerif-TLF}{m}{rm}#1}}
%%
%% The following section sets up the metadata of the thesis.
\thesissetup{
    date        = 2021/\05/\17,
    university  = mu,
    faculty     = fi,
    type        = mgr,
    author      = Kanitha Chim,
    gender      = f,
    advisor     = {Mgr. Marek Grác, Ph.D.},
    title       = {Blockchain in the public sector},
    TeXtitle    = {Blockchain in the public sector},
    keywords    = {blockchain, consensus, Ethereum, public sector, CKAN, open data},
    TeXkeywords = {blockchain, consensus, Ethereum, public sector, CKAN, open data},
    abstract    = {%
        Blockchain has been receiving a lot of attention for its potential to enable non-third-party involvement between financial transactions, its resistance to hacking, and its transparency characteristic. One of the most obvious and powerful use cases of blockchain is in the cryptocurrency ecosystem, namely Bitcoin and other alternative coins. Following the success of Bitcoin, many blockchain advocates are trying to explore the possible benefit of this technology in other areas as well. While there are many ongoing research directions, in this thesis, we want to explore the topic of blockchain in the public sector thoroughly.
        
        The primary goal of this thesis is to look closely at the current position of blockchain in the public sector, the hypothetical use cases, challenges and limitations, and the adoption procedures. We also propose the proof-of-concept of blockchain usage for open dataset integrity. To achieve this, we model the application to collaborate the open data API with the Ethereum blockchain.
        
        Three significant findings were discovered from the study. First, it is the preference of permissioned blockchain implemented for public sector applications. Second, we found that, despite the external novel blockchain use cases, there are uncertainties over the technology maturity, regulation, standardization, security, and this technology as a whole when implementing them. Finally, it is the pathway of blockchain adoption in the public sector compared to the private sector. Regarding our proposed proof-of-concept, we found that it is very effective and efficient for record consistency and large record comparison. One limitation is the capability to figure out the modification bits of data in case changes were captured.

    },
    thanks      = {%
      I would like to express my gratitude to my thesis advisor, Mgr. Marek Grác, Ph.D., for his overwhelming advice and support during the time of my thesis-writing process. In addition, I would like to thank my parents for supporting and motivating me to complete this research.
    },
    bib         = example.bib,
    %% Uncomment the following line (by removing the %% at the
    %% beginning) and replace `assignment.pdf` with the filename
    %% of your scanned thesis assignment.
    %%    assignment         = assignment.pdf,
}
\usepackage{makeidx}      %% The `makeidx` package contains
\makeindex                %% helper commands for index typesetting.
%% These additional packages are used within the document:
\usepackage{paralist} %% Compact list environments
\usepackage{amsmath}  %% Mathematics
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{url}      %% Hyperlinks
\usepackage{markdown} %% Lightweight markup
\usepackage{tabularx} %% Tables
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{listings} %% Source code highlighting

\usepackage[utf8]{inputenc}
\usepackage{xcolor}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\scriptsize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}


\usepackage{adjustbox}
% \lstset{
%   basicstyle      = \ttfamily,
%   identifierstyle = \color{black},
%   keywordstyle    = \color{blue},
%   keywordstyle    = {[2]\color{cyan}},
%   keywordstyle    = {[3]\color{olive}},
%   stringstyle     = \color{teal},
%   commentstyle    = \itshape\color{magenta},
%   breaklines      = true,
% }
\usepackage{floatrow} %% Putting captions above tables
\floatsetup[table]{capposition=top}
\begin{document}
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}

With the evolution of the web and the Internet over the past decades, schools, hospitals, businesses, and organizations are moving rapidly from traditional management to web-based or application-based management. The adoption of this technology plays an essential role in making our everyday life easier and more convenient. From the first web evolution as what we call web 1.0, which only provides plain text information accessible on the Internet, to the generation of web 2.0, which is famous for its platforms such as social media, email, e-commerce, and e-learning, this disruptive technology not only promotes modern life but also contributes immensely to the economy especially through the private and enterprise sector. 

Likewise, public sectors have also been taking advantage of the Internet$'$s evolution to enhance their working processes in many ways. For instance, the government has transformed itself into an electronic government to catch up with the tendency and provide efficient public services. Concerning public trustworthiness, the government has been trying to embrace the concept of open government. Through open government, transparency can be achieved by enabling citizens to access and interact with public resources such as public spending or incoming tax information. Even though data is shared with the public but it does not persist from any modification since it is controlled by individuals who might perform corrupted activities to serve their personal benefit. Thus, issues regarding corruption and lack of transparency in the public sector still cannot fully be resolved and remain the first priority in stepping toward a prosperous society.

Blockchain, an emerging technology introduced by pseudo name Satoshi Nakamoto \cite{nakamoto2012bitcoin}, is a distributed database aiming to provide an immutable and unhackable platform for its adopters. Blocks in the blockchain are linked together using cryptography hash. Each node stores a copy of the chain, and node participants locate everywhere making it defers from a single point of failure database. This technology promises to eliminate third-party management and instead uses the cryptographic algorithm to build trust among the participants. With its decentralized nature, blockchain ensures that no single node can control the others. Every decision is made through consensus protocols. Many applications have been implemented using blockchain and prove the benefits of this technology. However, it is undeniable that blockchain is mostly used for cryptocurrencies and financial transactions more than any other category.

In this research study, we wanted to assess the usage of blockchain in the public sector. We categorized our study into five main parts. Initially, we started by learning the theory of public resources and how they are aligned with the current technology. After understanding the public resource, we expanded to another chapter to thoroughly explore blockchain and find its connection to the public sector. Then, we formed the third chapter to analyze the state-of-the-art of blockchain adoption in the public sector. We took into account the potential areas of benefit and assessed the criteria of adoption. In addition, we examined the existing use cases to derive the benefit and possible challenges and limitations. From there, we formulated the proof of concept of blockchain for open dataset integrity. We grasped the opportunity of using the existing open dataset portal, CKAN, and injected the usability of Ethereum blockchain to validate such a use case. Finally, we assessed the result and discussed the overall output of the study.

\chapter{Public Resources}
\section{Overview of Public Resources}
Findlaw\cite{findlaw} defined public resources as "any property or asset owned by the state or any local agency, including, but not limited to, land, building, facilities, funds equipment, supplies, telephones, computers, vehicles, travel, and state-compensated time." Those resources are crucial assets kept in places to positively impact the government and public, such as innovation and development. Thus, managing public resources, precisely the record of the public resources, is essential to maintain the government$'$s goal in practical usage of the resources and to build trust among the public. In the following section, we will narrow down the study to focus on how public resources are managed and used by the government concerning public trustworthiness and transparency. Open government and other related indications were created to achieve transparency and trustworthiness from the public.

\section{Open Government}

The Organisation for Economic Co-operation and Development (OECD) \cite{oecd_2016} defined open government as "a culture of governance based on innovative and sustainable public policies and practices inspired by the principles of transparency, accountability, and participation that fosters democracy and inclusive growth." In short, the government is considered as an open government when it follows the three main principles: transparency, accountability, and participation. However, the definition and adoption of open government were practiced independently among countries. The OECD report found out that around 30\% of all the countries participating in their survey have implemented their own version of open government. Therefore a call for defining open government was established in order to implement open government initiatives successfully. The study then concluded the principles of open government as:

\begin{enumerate}
    \item \textbf{Transparency:} The information about the government$'$s performance, such as reporting official statements or investigating unknown subjects, traditional and social media must be gathered and spread publicly to elevate the public sector$'$s transparency and allow individuals to make decisions rationally regarding political or economic. 
    
    \item \textbf{Accountability:} To promote the merit of fair and democratic governance, the battle against systemic and petty corruption must occur. With the information available on newspapers, television, the Internet and social media, frauds are being watched and reduced.
    \item \textbf{Participation:} By providing a relaxed and free environment where citizens$'$ voices regarding their concerns are heard and taken into account, the government can design and step forward to good policies to serve the users, namely their citizens.
\end{enumerate}
Another study published in 2017 by European Commission \cite{eu_commission} tried to indicate the factors to either make or break the open government$'$s success by categorizing the key enablers, drivers, and open government barriers. Authentic sources and open data, reusable or shared solution building blocks, standards, and technical specifications were pointed as the critical digital enablers, illustrated in figure \ref{fig:digital_enabler}, for open government. Additionally, the drivers to achieve open government consist of democratic aspects, a better quality of service and enhanced user experience, high social benefits and public value, cost efficiency, economic growth and jobs, mobility, and demand from civil society and business associations. On the other hand, the barriers to achieve open government were identified as lack of leadership and financial resources, institutional vacuum, skills gap, uncertainties concerning sustainability and legal situation, along with vague standards and specifications.

The two main motivations of adopting open government are the journey to democracy and freedom of information, and economic prosperity. This is believed to be reached by initiating the proposal of open data to serve as a way for the government to be more open and transparent and the means of sharing data of the government to stimulate the growth of the information market \cite{6480069}.
As the governments try to follow the principles of open government, this also means that they are trying to make data available to the public - open data as mentioned above.
\begin{figure}[h!]
    \centering
    \includegraphics[width=10cm]{photos/open_government_40962.png}
    \caption{Digital enablers for Open Government (EU Commission \cite{eu_commission}, 2017)}
    \label{fig:digital_enabler}
\end{figure}

As stated by OECD \cite{oecd}, open government data(OGD) is a driving force to make government data accessible to all in the direction of popularizing transparency, accountability, and value as the main philosophy. Open data that can be used, reused, and redistributed openly by anyone and is constructed or authorized by the government is called open government data.

\subsection{What is open data?}

Open data is one key among all the keys stated as the digital enablers of open government. It is data that is available to the public without restriction and is free to use, reused, and redistributed by anyone. The characteristics of open data are availability and access, reuse and redistribution, and universal participation \cite{what_is_open_data?}. 
\begin{itemize}
    \item \textbf{Availability and Access:} the completed data must be available to the public, preferably on the Internet and in different convenient formats.
    \item \textbf{Reuse and Redistribution:} data must be conformed to be reused and redistribution and integrated with other data.
    \item \textbf{Universal Participation:} everybody, not limited to any groups or races, can utilize data freely for personal or business purposes.
\end{itemize}

Open data is very valuable to many individuals and organizations. Open data ranges from data about art and culture, data regarding science research, data associated with government finance, census statistics, climate, weather, or environment.

\subsection{How can governments open up their data?}

When considering open up the data, three rules should be kept in mind. First, try to keep it simple by beginning with the modest and uncomplicated dataset. Second, engage early and often engage by building a connection with the possible users to co-create future releases$'$ relevant services. Third, address common fears and misunderstandings by identifying all related questions, fears, or risks as soon as in the early stage. Then, applying the four essential steps to successfully opening up data: (1) choose a dataset, (2) apply for an open license, (3) make data available, and (4) make it discoverable, respectively \cite{how_to_open_up_data}.

\section{Comprehensive Knowledge Archive Network (CKAN)}

“CKAN is a tool for making open data websites \cite{ckan_2017}.” CKAN, an open-source data portal, assists the national and local governments, research associations, and organizations that work on collecting data to manage and publish those collections to the public. Integrating with CKAN, data are equipped with many available features such as search and preview using maps, graphs, and tables that are user-friendly to any type of user. 

In March 2006, the development of CKAN was established by Rufus Pollock, founder of Open Knowledge Foundation, and later was released for the first time in July 2007 \cite{ckan_history}. Open Knowledge Foundation (OKF), founded in 2004, is a nonprofit organization that is responsible for the development and maintaining of this project. One of the objectives of OKF is to develop, support and promote projects, communities and tools that foster and facilitate the creation, accessibility, and dissemination of knowledge. This objective is also the reason CKAN was built. It was built using Python and Javascript for the backend and frontend, respectively. PostgreSQL is the fundamental database engine, and the search function is brought by Solr. 

CKAN provides fully-featured core functionalities such as API, Datastore, Extend, Federate, Filestore, Geospatial, Metadata, Publish and manage data, Search and discovery, Themable and Visualization to manage open-source data portal and the solution to data management \cite{ckan_feature}. CKAN is proved to be reliable through the overwhelming number of users ranging from governments, organizations, and communities all over the world. Some examples of CKAN\’s adopters are the United States Government, Australian Government, Open Government of Canada, European Union Data Portal, and the Humanitarian Data Exchange. 

\chapter{Blockchain}

\section{Overview of Blockchain}
Satoshi Nakamoto, whose identification is unknown, published the paper ‘Bitcoin: A Peer-to-Peer Electronic Cash System’ in 2008 aiming to provide a distributed ledger for the transaction of electronic cash \cite{nakamoto2012bitcoin, blockchain_2018}. The concept has brought to us the disruptive technology called “Blockchain.” Blockchain consists of the list of records called blocks using cryptography to link together. Block carries information about the previous block or previous hash, its own hash, the transaction data, and the timestamp. 
From the book “Mastering Blockchain” \cite{bashir2018mastering}, blockchain is technically defined as a peer-to-peer, distributed ledger that is cryptographically secure, append-only, immutable and updateable only via consensus or agreement among peers.

\begin{itemize}
	\item \textbf{Peer-to-peer:} refer to as independent, no central network or third-party participation. Communication among peers is direct.
	\item \textbf{Distributed ledger:} Every peer in the network can access the ledger and hold a copy of the complete ledger
	\item \textbf{Cryptographically-secure:} cryptography purpose to achieve non-repudiation, data integrity, and data origin authentication has been applied to achieve security of the ledger
	\item \textbf{Append-only:} data in the blockchain is immutable and blocks are added in time and sequence ordered.
    \item \textbf{Updateable via consensus:} there is no central control over the modification of the ledger. To update the ledger, criteria defined by blockchain protocol must be strictly applied first and consensus among the network peers must be reached. 
\end{itemize}

Blockchain and Bitcoin are often misunderstood and mixed up together. Here is a brief comparison between Blockchain and Bitcoin \cite{uktn, bernard}. 

\begin{itemize}
    \item Blockchain is a technology of distributed databases, whereas Bitcoin is a cryptocurrency.
    \item Blockchain technology provides many usages. One example is how blockchain technology is implemented in Bitcoin.
    \item Blockchain values transparency while Bitcoin promotes anonymity. 
    \item Blockchain comes with many use cases other than monetary matters such as proprietary ownership, digital identification, or voting, while Bitcoin only performs in digital currency.
\end{itemize}

\section{Structure of Blockchain}

Blockchain is formed by block, chain, and network \cite{blockchain_dummie}. See figure \ref{fig:structure_blockchain}. 

\begin{itemize}
    \item \textbf{Block:} contains one or more transactions, the previous hash, own hash, timestamp, and the nonce. The transactions, the record of data which values are assigned to, interpret the meaning of data such as financial transactions. The previous hash and own hash are used to chain the current block to the previous block and the next block. As the name suggests, a Timestamp is the information of the period when a block is added to the blockchain. A nonce is the number used only once that miners are solving to reach the restriction level to get cryptocurrency reward.
    
    \item \textbf{Chain:} a one-way hash plays the role of connecting blocks together. It is a fingerprint of a block. Chain plays a role in attaching blocks together in time and sequential order. Blockchain uses the \textsf{Secure Hash Algorithm} \footnote{See  \url{https://doi.org/10.1007/0-387-23483-7_388}} to generate a hash.
    
    \item \textbf{Network:} every node stores the entire record of transactions in the blockchain. All nodes together form the network. Everyone can operate the node from anyplace in the world. Cryptocurrencies such as Bitcoin are used to reward node owners that participate in forming the full node. 
\end{itemize}

\begin{figure}[h!]
    \centering
    \includegraphics[width=10cm]{photos/blockchain_formation.png}
    \caption{Structure of Blockchain}
    \label{fig:structure_blockchain}
\end{figure}

\section{Types of Blockchain}
\subsection{Public Blockchains}
Public Blockchain refers to a blockchain that allows anyone to participate in the network. There is no permission required to join the network. Participants can access to read and write the transaction. Besides, they can engage in the process of reaching a consensus when confirming newly added blocks. In the public blockchain, no one has the ability to control the others and no one will be assigned as a trusted party. Public blockchains brought us the advantages of transparency, security, real decentralized structure, user empowerment, and immutability. However, public blockchains using proof-of-work require a significant amount of energy to maintain. It is also relatively slow and likely to encounter the problem of scalability. The real examples of public blockchains are Bitcoin and Ethereum. Alternative consensus mechanisms are being built to solve energy consumption problems. One among them is proof-of-stake which stresses miners$'$ capabilities from power to the number of coins held \cite{publicblockchain, public_blockchain, understanding_public_blockchain}.

\subsection{Private Blockchains}
Private blockchain, as its name suggests, is open to only selected participants. Permission is required to join the network. Only internal nodes can hold write access and contribute to the process of reaching consensus. The read permission can be either public or restricted. The concept of mining, proof of work, or remuneration is not applied to the private blockchain as everything is predefined. Because of the limited number of participants or nodes, a private blockchain is relatively fast. It is faster to reach consensus in a private blockchain. It is also easier to scale compared to the public blockchain.
Nonetheless, it is no longer conformed to the concept of decentralization. Trust and security is a significant issue for private blockchain. Ripple and Hyperledger are examples of private blockchains \cite{understanding_public_blockchain, publicvsprivate}.

\subsection{Hybrid Blockchains}
Hybrid blockchains take advantage of both public and private blockchain. The process can be accomplished either privately or publicly. Hybrid blockchains offer controlled access and freedom concurrently. The benefits of integrity, transparency, and security are still in place, even though hybrid blockchains are not open to everyone. Hybrid blockchains are implemented in many use cases such as Hybrid IoT, banking, and supply chain \cite{hybrid_blockchain}.

\begin{figure}[h!]
    \centering
    \includegraphics[width=10cm]{photos/public_private_hybrid_blockchain.png}
    \caption{Types of Blockchain (Applicature \cite{type_of_blockchain_image}, 2018)}
    \label{fig:my_label}
\end{figure}

\section{Blockchain Consensus Protocols}
Blockchain is a distributed ledger. Thus, there is no third-party involvement to help in the decision-making process and provide trust systems among the nodes. Instead, blockchain deploys the concept of a proofing mechanism which is commonly known as consensus protocols or algorithms. Using consensus protocols leads untrusting nodes to reach an agreement on the final state of data. The foolproof protocols must meet the following requirements \cite{bashir2018mastering}:

\begin{itemize}
    \item \textbf{Agreement} meaning that honest nodes must decide on the same value.
    \item \textbf{Termination}, which means honest nodes have to terminate the consensus process and reach a decision.
    \item \textbf{Validity} refers to the equivalent value carried by nodes compared to the honest node$'$s initial value.
    \item \textbf{Fault-tolerant} presents the ability to proceed with the process even with the engagement of a malicious node.
    \item \textbf{Integrity} proposes that a node can make a decision only once for every round of consensus.
\end{itemize}

Some of the most practiced consensus protocols are in the following:
\subsection{Proof-of-work}
Proof-of-work is one among many consensus algorithms. Proof-of-work is used to replace the central-party who plays a role as the decision-maker. Blockchain is distributed ledger, so there is no third-party involvement. Therefore, proof-of-work is needed to achieve the consensus among nodes in the blockchain. In addition, proof-of-work solves the problem of \textsf{“double-spending”} \footnote{See double-spending problem \url{https://ssrn.com/abstract=3090174}} in digital currency. When adding new blocks to the blockchain, the proof-of-work starts to perform. Miners execute the proof-of-work to guess the right \textsf{“nonce”} \footnote{See \url{https://en.bitcoinwiki.org/wiki/Nonce}} to create the hash that matches the \textsf{“target”} \footnote{ See \url{https://en.bitcoin.it/wiki/Target}} and solve the cryptographic puzzle. Generally, to meet the “target,” it takes about ten minutes. Miners who guess first will get the cryptocurrency reward. Though the concept seems flawless, problems such as high energy usage, \textsf{51\% attacks} \footnote{\url{https://academy.binance.com/en/articles/what-is-a-51-percent-attack}}, mining centralization are raised. Proof-of-work is used by well-known cryptocurrencies such as Bitcoin, Ethereum, Bitcoin Cash, Litecoin, and Monero \cite{proof-of-work}.

\subsection{Proof-of-stake}
Alternatively to proof-of-work, which uses computation power to reach a consensus mechanism, proof-of-stake requires validators to commit stake to attest blocks into the network. To become a validator, participants running nodes on the network have to stake a crypto deposit-defined amount of crypto on their account. Then, they will have a chance to be randomly selected to add the blocks. The block will be added only when enough attestations have been gathered. Rewards are offered to validators who manage to propose blocks and make attestations when they see the blocks. 
On top of rewarding the validator, penalties will take action regarding suspicious behavior of the validator. This way, it tightens the security throughout the network. Proof-of-stake clears up the concern in Proof-of-work such as accessibility, centralization, and scalability \cite{proof-of-stake}.

\subsection{Proof-of-authority}
Proof-of-authority is another alternative consensus mechanism aiming to solve the problem of scalability and computational power. Rather than using power or coin to reach consensus, it permits the privilege to a group of trusted authorized persons called validators. In proof-of-authority, validators are pre-defined and agreed upon to be qualified to approve transactions and blocks. This mechanism follows the \textsf{Byzantine Fault Tolerant algorithm} \footnote{See \url{http://pmg.csail.mit.edu/papers/osdi99.pdf}}. With the limited number of validators, proof-of-authority is very much capable of scalability. This consensus mechanism requires participants to confirm real identity, prove their reputation, or even criminal records to become validators. Proof-of-work is effective when applying in the permissioned blockchain, which is favored by enterprises where privacy is the main concern. For instance, Microsoft Azure is running on proof-of-authority \cite{github1, poa}. 


\subsection{Proof-of-activity}
Proof-of-activity is a consensus protocol that combines proof-of-work and proof-of-stake together to achieve a high protection level from 51\% attack or \textsf{Denial-of-Service attacks (DOS)} \footnote{ See \url{https://us-cert.cisa.gov/ncas/tips/ST04-015}}. The mechanism begins with the concept of proof-of-work. Miners compete to find new blocks with their computing power initially to move to the next process. Later, a proof-of-stake algorithm is applied. Validators will be randomly selected to sign a new block. Depending on the crypto stake they hold, as in the proof-of-stake, they are likely to win. The rewarded fee will be divided among the miner or attest and the validators. Though, proof-of-activity still required much energy. An example of a proof-of-activity implemented project is Decred \cite{proof-of-activity, proof_of_activity2}. 

\section{Smart contract}
Nick Szabo\cite{szabo_1994}, a computer scientist, proposed the idea of smart contracts in 1994. He defined it as computerized transaction protocols that execute the terms of a contract. Nick Szabo described the objectives of a smart contract as to serve everyday contract usage, reduce malicious incidents, and minimize third-party involvement. In a nutshell, a Smart Contract is a digital contract with predefined agreements or conditions. A smart contract is self-executing when the condition is met. It is distributed across the network of blockchain. A smart contract$'$s role is to eliminate the need for a controller and provide a trusting system among participants \cite{blockchain_ibm}. 

\section{Bitcoin}
Bitcoin is a digital currency introduced by Satoshi Nakamoto. Satoshi published the whitepaper in 2009 \cite{nakamoto2012bitcoin}, proposing the idea of creating a new monetary system that is built to enhance and solve the problem of existing financial infrastructure. Bitcoin is a cryptocurrency, and it does not have a physical coin. It is built to eliminate the central bank and reduce transaction fees. To establish trust among untrusted participants, bitcoin uses blockchain technology and proof-of-work. There are 21 million bitcoins to be mined, and it is expected to finish around the year 2140. Bitcoin works, in a nutshell, is the following; when transactions occur, miners compete to create blocks to push to the network. The winner will get the bitcoin rewards for about 12.5 bitcoins. The mining process takes about 10 minutes to complete using computational power devices. 

\section{Ethereum}
In 2013, Vitalik Buterin\cite{ether_yellow_paper} published the paper to introduce a relatively new blockchain technology, Ethereum. Ethereum was built around the motivation of becoming much more than a cryptocurrency transaction but to carry a decentralized approach to the internet world through blockchain technology. With Ethereum, anyone can create their own rules for ownership, transaction, and state transaction through smart contracts and easily deploy a decentralized application \cite{vitalik_blog}. 

Ethereum is designed following 5 philosophies \cite{white_paper_philosophy}:
\begin{itemize}
    \item \textbf{Simplicity:} the protocol is open to everyone and is simple to understand. The entire specification can quickly be followed and implemented. 
    \item \textbf{Universality:} Ethereum does not limit to any specific features. It provides a way that programmers can build any applications by defining smart contracts. Smart contracts can be created by using Ethereum’s internal Turing-complete scripting language.
    \item \textbf{Modularity:} Ethereum protocol is independent and modification friendly. Adjustment in one feature does not affect other features. 
    \item \textbf{Agility:} continuous research and look for the opportunity to improve.
    \item \textbf{Non-discrimination and non-censorship:} the protocol is designed to control safety but does not restrict any particular class of activity or operation.
\end{itemize}

\chapter{Blockchain adoption in the public sector}
\section{Potential areas of benefit}
\subsection{Managing data and digital assets}
Through public services, data is inserted, retrieved, updated, and deleted into the government database consecutively. Sensitive data is stored to make use of internally, while some other data is open to the public to promote innovation and transparency. While this data is vital for both government and citizens, it is also a target of criminal acts. Any minor modification could lead to loss of money, erroneous information, and chaos in a country since storing data in one place is identified as a so-called single point of failure. Data Breach incidents are a crucial issue that the government and private sector are trying to prevent from happening.  For example, a 2020 United States federal government data breach has caused so much loss and affected a number of involved organizations \cite{us_hack}. Therefore, continuous research, prototype, implementation, and blockchain integration in this area have been conducted. Governments have started to adopt the concept of blockchain technology to build foolproof applications to minimize and prevent future loss \cite{blockchain-potential}. 

\subsection{Public service registry}
When it comes to registering or transferring property assets, citizens have to proceed with many complicated steps. The process itself requires various involvements and paperwork results in time and cost consuming.  For instance, in Georgia, according to Forbes \cite{georgia_land_registry}, the public registration process regarding buying and selling land could take up to a day queuing and cost between \$50 and \$200. Deriving from such difficulty, we could see the opportunity of applying digital processes to ease the time and cost of the service. On top of that, including blockchain technology will ensure the security, integrity, and ability to trace property rights records.

\subsection{Electronic voting system}
Countries have been implementing an E-voting system to offer a convenient, private and trustworthy system for their citizens. E-voting is very beneficial for minimizing the government budget in election preparation and processes.  However, with centralized control, doubt still bothers the public. Integrating blockchain in electronic voting will ensure transparency and security among the public. Election transactions will be open to the public, ensuring no fraudulent activity is committed during the election.

\subsection{Digital identification}
Many countries have also been actively researching and deploying use cases of blockchain in digital identification. Significantly, the concerns over data breach and identity theft can happen on centralized databases as a single point of failure. Blockchain is believed to assist in overcoming the challenge of data loss, authentication, and validation of the differences of identity document types, especially cross-border handling documents. Stakeholders are also exploring the benefit of blockchain use cases in self-sovereign identity \cite{self-sovereign}.

\subsection{Tax compliance}
Implementing blockchain technology on top of tax compliance and collection signifies many ranges of potential. Both taxpayer and tax receiver, precisely citizens and government, will convey transparency and trustworthiness among one another. The government will be able to trace and monitor the citizen$’$s duty in paying taxes. Likewise, taxpayers will be informed about their tax share to the government and the government$’$s income tax as a whole. More than that, the government can even emphasize transparency via opening up the income tax transaction to the public. Besides, blockchain can be applied to VAT transactions as well. \textsf{Deloitte} \footnote{See \url{https://www2.deloitte.com/global/en.html}} proposed a proof of concept on how to achieve such things as in the following steps \cite{deloitte}:
\begin{enumerate}
    \item The client pays the invoice to the company
    \begin{itemize}
        \item At the same time, blockchain smart contracts calculate the invoice VAT and divide it into the non-VAT and VAT part
        \item The VAT is paid directly to the tax authority by the smart contract.
        \item The non-VAT part is transferred to the company$’$s account using a smart contract.
    \end{itemize}
    \item The company pays the suppliers invoice
    \begin{itemize}
        \item This is done via a smart contract: the company fills in the needed amount, and the smart contract performs the payments
        \item Simultaneously: the amount due is sent to the supplier, and the smart contract calculates VAT and sends it to the tax authorities. 
    \end{itemize}
\end{enumerate}

World Economic Forum also reported that about 73\% of their respondents during their research on “Deep Shift Technology Tipping Points and Societal Impact” called for the government$’$s initiative to collect tax through blockchain by 2025 \cite{wef}. 

\section{Assessing blockchain adoption procedure}
Blockchain is a relatively new technology and attracts much attention from everywhere, such as tech enthusiasts, startups, enterprises, organizations, and the government. However, no technology can promise to fit and provide benefits to all kinds of categories. With enthusiasm to dive into the technology and embrace this technology, it is advised to consider how well the technology fits the purpose and the need of one$'$s organization. Since blockchain is dwelling around the idea of shared databases, multiple party involvement, elimination of third parties, and transparency, one should first answer the relation between the end goal of their product and this technology$'$s purpose before taking steps to grasp it.

\subsection{Architectural Design}
Morgen E. Peck\cite{blockchain_decision2} created a list of questions to assess and evaluate whether or not blockchain is needed. There is a total of seven questions. Each question inquiries the feasibility regarding multiple party involvement, verification procedure, intermediaries cost and complexity, interaction, and transaction \cite{maturity_model}.
\begin{enumerate}
    \item \textbf{Does a traditional database meet your needs?}
    
    First, try to answer what kind of information one wants to store and what structure the data should be constructed. In addition, try to observe how complex or simple the structure of one$'$s organization data is. Specifically, differentiate whether the data is better off stored in traditional databases or blockchain databases. 
    Remember, blockchain is a distributed ledger that is based on a shared database and required involvement from different nodes to form the chain. Data are formed in the block consisting of multiple transactions. They are randomly grouped into blocks. On the other hand, a traditional relational database has been around for years, and it is matured in the market to fit the needs of many users and proved to be valuable.
    
    \item \textbf{Does it require more than one participant to be able to update data?}
    
    Blockchain requires more than one participant to make changes to the database to make this technology foolproof. How about your organization$'$s data? Is there a need for multiple writers$'$ acknowledgments to access and make changes to the data? Or perhaps, is there any external organization$'$s approval needed? 

    \item \textbf{Do you and all those updaters trust one another?}
    
    In the case of various participants being required to consent to any modification, can they be trusted? What happens if one person does not permit the other to perform any activity? Is there any noticed absence of trust? Blockchain suits well in an environment where users do not trust one another meantime, they need to act to reach the goal.
    
    \item \textbf{Is this database likely to be attacked or censored? Do you need redundant copies in multiple distributed computers?}
    
    Data varies greatly. Some data are very sensitive and require thorough treatment. While it is extensively crucial for the owners, it is likely to attract the attack correspondingly. One should assess the risk cost and effect on the single point of failure regarding their application and ready for the upcoming incident. If the situation cannot be efficiently solved by any other technology than blockchain, then it is worth considering integrating blockchain. 


    \item \textbf{Would all the participants trust a third party?}
    
    On the condition of having multiple writers, but there is a lack of trust in between, third parties are often involved. Observe the nature of the application whether or not it is all right to be involved by intermediation. Do the potential adopters and their users trust the third party? Can they identify any advantages or disadvantages of this third party? Which one weighs more? Blockchain has the capability to remove third-party involvement. Do they want to implement their application using blockchain to remove this impediment? Do they see exceptional benefit from removing the central party from their application?

    
    \item \textbf{Does the data need to be kept private?}
    
    Determine also the state of the data to figure out whether it is sensitive to the public or it should remain internally. Using a traditional database is moderately private. Although using blockchain, one can also accomplish the advantage of storing data publicly and privately through the permissioned and permissionless blockchain. 

    \item \textbf{Do you need to control who can make changes to the blockchain software?}
    
    When deciding to adopt blockchain, the option does not stop there. Basically, one can further decide whether to pick either the private, public, or even hybrid blockchain.  
\end{enumerate}

Eventually, if unable to conform to the above questions, blockchain might not be the best option for the application. Nevertheless, one can take into account the following choices: (1) Regular file storage, (2) A centralized database, (3) Master-slave database replication, and (4) Multiple databases.

In the case that decided to proceed with blockchain, first, define the rule of the application regarding transactions that the database permits. Also, work on who can be the trusted validators and what the distributed consensus approach is. Lastly, observe the one backing the assets of the shared ledgers \cite{blockchain_decision1}. 

\begin{figure}[h!]
    \centering
    \includegraphics[width=9cm]{photos/blockchain-decision.png}
    \caption{Decision making tree (M. E. Peck
    \cite{blockchain_decision2}, 2017)}
    \label{fig:decision_tree}
\end{figure}

\subsection{Technology readiness and Maturity level}
Even with the excitement of the new and disruptive tendency of blockchain technology, one should not overlook the level of maturity and the readiness of its nature before deciding to adopt it in their organization. Understanding the maturity level and the readiness of blockchain technology will provide \cite{kpmg_understand_maturity_level}:
\begin{itemize}
    \item clear insight into blockchain risks,
    \item measurement of the possibility of advancing from proof-of-concept to production,
    \item concrete action plans, and
    \item understanding of how to single out unique and validated models.
\end{itemize}

In Information Technology, maturity is assessed based on ISACA$'$s Capability Maturity Model \cite{cmm}, the international professional body for IT governance. To demonstrate the readiness of technology, ISACA leveled technology level as below:
\begin{enumerate}
    \item \textbf{Initial:} In this beginning stage, the process is uncertain. Operation is poorly controlled and reactive.
    \item \textbf{Managed:} The process is characterized for projects and is often reactive.
    \item \textbf{Defined:} The process is characterized by the organization and is proactive.
    \item \textbf{Quantitatively managed:} The process is measured and controlled.
    \item \textbf{Optimizing:} The focus is on the improvement of the process. 
\end{enumerate}
It is essential to know which level blockchain belongs to and prepare action plans regarding any future encounter. 

A global network of professional firms providing Audit, Tax, and Advisory services, KPMG\cite{kpmg_maturity_pdf} developed a Blockchain Maturity Model to identify the possible risks and their level to provide IT assessment in regard to blockchain implementation. In their ten days study, KPMG identified eight significant risks: Access and user management, Authorization and provisioning management, Data management, Interoperability, Scalability and performance, Change management, Privacy, and Security. Each risk was thoroughly assessed by forming and answering a group of maturity questions. The result shown in figure \ref{fig:maturity-score} indicates the position of the risk$'$s maturity aligned to the IT maturity level. The overall maturity score is 2, which is in the “Managed” level. In comparison, individual scores range from one to three. Continuous research and improvement are needed, especially in the area of Scalability \& performance and Change management.

\begin{figure}[h!]
    \centering
    \includegraphics[width=7cm]{photos/blockchain-maturity-level.png}
    \caption{Maturity score (KPMG
    \cite{kpmg_maturity_pdf}, 2018)}
    \label{fig:maturity-score}
\end{figure}

Another study on blockchain maturity model suggested categorizing the area to assess blockchain maturity to: (1)Network category, (2)Information system category which includes architecture, upgrading, integration, storage, scalability, maintenance, and business efficiency, (3)Computing methodology category, and (4)Privacy and security category. Each component is assigned to its maturity level as shown in the table \ref{tab:maturity_model} \cite{maturity_model}.

\definecolor{yellow}{RGB}{255, 204 ,60}
\definecolor{lightyellow}{rgb}{1, 1, 0.9}

\begin{table}[ht!]
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{llllll}
\hline
 &
  Initial &
  Managed &
  Defined &
  Quantitatively managed &
  Optimizing \\ \hline\rowcolor{lightyellow}
Network &
   &
  Network load &
  Reliability &
   &
   \\ \hline\rowcolor{yellow}
Information System &
  \begin{tabular}[c]{@{}l@{}}\rowcolor{yellow}Architecture\\ \rowcolor{yellow}Upgrading\\ \rowcolor{yellow}Integration\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}\rowcolor{yellow}Maintenance\\ \rowcolor{yellow}Storage\\ \rowcolor{yellow}Scalability\end{tabular} &
   &
  Business efficiency &
   \\ \hline\rowcolor{lightyellow}
\begin{tabular}[c]{@{}l@{}}\rowcolor{lightyellow}Computing\\ \rowcolor{lightyellow}methodology\end{tabular} &
  \rowcolor{lightyellow}Standardization &
  \begin{tabular}[c]{@{}l@{}}\rowcolor{lightyellow}Computational\\ \rowcolor{lightyellow}complexity\end{tabular} &
   &
   &
   \\ \hline\rowcolor{yellow}
\begin{tabular}[c]{@{}l@{}}\rowcolor{yellow}Security and\\ \rowcolor{yellow}Privacy\end{tabular} &
   &
   &
  Privacy &
  \begin{tabular}[c]{@{}l@{}}\rowcolor{yellow}Data security\\ \rowcolor{yellow}Transaction security\end{tabular} &
   \\ \hline
\end{tabular}
\caption{Blockchain maturity model (Wang, H., Chen, K. & Xu, D
\cite{maturity_model}, 2016)}
\label{tab:maturity_model}
\end{adjustbox}
\end{table}

\section{Case Studies: Blockchain for public sector}
\subsection{Identity registry}
\begin{enumerate}
    \item \textbf{Known Traveller Digital Identity (KTDI)}
    
    \textsf{Known Traveller Digital Identity (KTDI)} \footnote{See \url{https://ktdi.org/}} is an initial pilot project aiming to enhance security in the travel world and enable a globally accepted decentralized identity ecosystem. This project was established as the first global collaboration that compromises traveling identity integrity. The traveling industry has to prepare for the change as the statistics indicate that by 2030 international air arrival will reach about 1.8 billion passengers. 
    Seeing the challenge of cross-border movement and growing volume of travelers, which are potentially recognized as the increasing risk of unsafe travel, the World Economic Forum proposed this project in 2018 and called for a joint effort from interested stakeholders. The pilot project received participation from both the public and private sectors. That includes governments from the Netherlands and Canada, Accenture, airline companies, airport authorities, and many more. KTDI depends on decentralized technology. It makes use of cryptography, distributed ledger, self-manage trust, and verify identity. The decentralized platform for KTDI solution relies upon \textsf{Hyperledger Indy} \footnote{See \url{https://www.hyperledger.org/use/hyperledger-indy}} \cite{ktdi, accenture}.
    
    KTDI was designed into four layers focusing on cryptography trust and human trust \cite{wef_ktdi_01, wef_ktdi}. 
    \begin{itemize}
        \item \textbf{Cryptography trust}
        
        \textbf{Layer 1: Decentralized identifier networks}
        \begin{itemize}
            \item Consensus algorithm
            \item Nodes: node management, roles \& permissions, transaction management, transaction audit, stakeholder representation, state maintenance \& persistence
            \item Decentralized identifier: decentralized document, revocation registry, schema definitions, credential definition
        \end{itemize}
        \textbf{Layer 2: Decentralized identifier communication protocol (Agent-to-Agent)}
        This layer involves wallet and agents:
        \begin{itemize}
            \item Issuer wallet \& agent
            \item Holder wallet \& agent
            \item Verifier wallet \& agent
        \end{itemize}
        Each of which controls secure channel establishment, key generation, storage, backup, and recovery. The issuer has to create a schema while the verifier has to discover the schema.
        
        \item \textbf{Human trust}
        
        \textbf{Layer 3: Credential Exchange}
        \begin{itemize}
            \item The issuer takes care of verifiable credential creation, verifiable credential revocation
            \item Holder administers verifiable credential storage and selective disclosure zero-knowledge proofs
            \item Verifier resolves verifiable credential and examines proof validation
        \end{itemize}
        \textbf{Layer 4: Governance Frameworks}
    
    \end{itemize}
    
    The project requires agreement on the definition of widely-used credentials from stakeholders such as credit unions, banks, stores, healthcare providers, universities, or governments.

    This pilot project is under ongoing test and development. It is believed to yield a lot of impacts for the traveling industry. Partners are working diligently to launch further pilots and use cases to improve upon. 
\end{enumerate}

\subsection{Property registry}
\begin{enumerate}
    \item \textbf{National Agency of Public Registry(NAPR) in Georgia}
    
    Georgia is one among many countries whose citizens had been suffering from property disputes \cite{eurasianet}. Therefore, the country has been working continuously to improve the circumstance. The system$'$s goal is to strengthen property owner rights, enhance citizen$'$s trust in government and reinforce data security.
    
    \textsf{Bitfury Exonum} \footnote{see \url{https://exonum.com/index}} cooperated with the Republic of Georgia$'$s National Agency to create a blockchain-based system for land registry. The initiative leaves a good impression on many organizations. NAPR was recognized by many governments and stakeholders for its potential to enhance land register service. The system now consists of over 1.5 million titles of land registered on the blockchain. From pushing transactions to storing data, each process takes less than 3 minutes as they use a permissioned blockchain. NAPR can be accessed through this \href{https://naprweb.reestri.gov.ge/#/}{link}.
    
    As a result, Georgia has transformed the land registry process from 1-3 days to less than 3 minutes, decreased the transaction cost from \$80 to only \$8, eliminated the ten days waiting for property transfer to real-time, and enabled digital certificate storage on the public blockchain. Success stories in the land registry service of Georgia have led many countries to follow in their footsteps \cite{georgia_1, exonum_1}. 
    
    \item \textbf{BenBen}
    
    \textsf{BenBen} \footnote{See \url{http://www.benben.com.gh/}}, which is based in Ghana, saw the problem of “weak overburdened public sector registries” and the “conflicting land tenure system” as an intense issue. Because of that, official property transaction records are estimated to only about 20\%, while the other 80\% of land market records are assumed improperly registered or untraceable. Additionally, Ghana held over 50\% of land-related cases amongst their civil court. Therefore the central mission of BenBen is to provide modern land and real estate solutions. Benben embraces distributed technology as its core system to create trust and transparency in the land registration ecosystem. Blockchain anchoring mainly for digital fingerprint and Interplanetary File System, a peer-to-peer protocol network for distributed file system data storing and sharing, are the two core components. Correspondingly, BenBen offers mass data accessibility, verification of off-chain data, tenure interoperability, API integration, and consensus mechanism. A simple explanation of what BenBen is trying to solve is access to trusted land availability information, secure and traceable purchased transactions, bank loan connection, and record management \cite{benben_1, benben_2}. 

    BenBen founder Emmanuel Noah also addressed the need for the policy regulation between the authority and the technology provider to ensure safe adoption. Working closely with the regulator will reinforce the process. BenBen is believed to be a game-changer for Ghana’s land registry issues \cite{barclays}. 
    Massive Small published in their journal that more than 5000 properties in the capital of Ghana, Accra, were on BenBen already \cite{massive_small}. 

\end{enumerate}
\subsection{Tax compliance}
\begin{enumerate}
    \item \textbf{VAT Fraud Prevention prototype}
    
    VAT Fraud Prevention$'$s motivation using blockchain came from the concern in accordance with VAT infrastructure loophole, information asymmetry issues between tax administrators and taxpayers, and especially fraud in tax-related fields. For instance, EU countries all together were reported to have lost around EUR 150 billion on VAT and 50 billion of which was accounted for fraud. Seeing this problem, PWC, Vertex, and Microsoft joined hands to build a prototype for VAT Fraud prevention. Blockchain was adopted as a core component to resolve the raised issues. 
    On the technical side, Microsoft Blockchain Essentials solution and Microsoft Azure Blockchain Workbench were chosen. On the business side, PWC handles all the taxation consultation and expertise. The prototype consists of 3 phases:
    \begin{itemize}
        \item Phase 1: Information exchange 
        \item Phase 2: Real-time VAT 
        \item Phase 3: Introducing cryptocurrency
    \end{itemize}
    
    
    This prototype allows: 
    \begin{itemize}
        \item businesses from different countries to operate through invoice exchanging.
        \item two categories of the companies: Whitelisted and non-whitelisted. Each of which is systematized to a different workflow.
        \item Smart contracts to handle all VAT payments. VAT Payment will be settled automatically, conforming to the specified rules.
        \item transactions implementation on the banking system as banks will be members of the consortium.
    \end{itemize}
  
    Throughout their prototype construction, PWC, Vertex, and Microsoft made a recommendation for a public sector that intends to implement blockchain solutions to acknowledge the need to implement E-invoices, to use one depository, to use a split-payment method to isolate VAT amount from the transaction amount, and to create a Standard Audit File for Tax \cite{tax}.
\end{enumerate}
\subsection{Electronic voting system}
\begin{enumerate}
    \item \textbf{Voatz}
    
    \textsf{Voatz} \footnote{See \url{https://voatz.com/}} is a mobile application for electronic voting founded in 2015. It started from an idea into the actual application. Later it was adopted by many states. In 2017, Mac Warner, the Secretary of State in West Virginia, initiated the project to explore the convenient approach for voters under particular circumstances such as military, mobility difficulty, or emigrants. For instance, in 2016$’$s report, it was indicated that about 7\% of U.S. citizens were abroad. Therefore, a trip for voting is quite challenging for people in such a situation. Similar to the problems Voatz claimed to address, such as voter accessibility in terms of disability limitation, natural disaster, or an unusual situation like a pandemic,  West Virginia signed an agreement with Voatz for their near election.
    In 2018, after having been working closely with Voatz, West Virginia launched the application for their 2018 election. The statistics pinpoint the positive outcome of the approach as 98\% of West Virginians located in 24 countries submitted their ballot \cite{west_virginia}. 
    
    Voatz demonstrates the voting process in five phases (1) Request mobile voting, which requires citizens to ask permission to get the ballot, (2) Download Voatz app and register, (3) Verify identity through smart phone’s biometric, (4) Cast the vote, and (5) Verify the selection receipt with the post-election audit. Voatz runs on a permissioned blockchain using IBM HyperLedger. It incorporates a combination of technologies such as end-to-end encryption, blockchain storage, risk assessment \& audits, paper trail \& secure digital receipts, biometric verification, and data security \& privacy \cite{voatz_2020, voatz_security}. 
    
    Nevertheless, Voatz was spotted being criticized by security experts claiming that Voatz is insecure and overcomplicated. Auditors also confirmed encountering the vulnerabilities and other threats \cite{voatz_report, mit, audit, security_analyze}. Obviously, there are still many things to improve, but we should not neglect the stepping stone to accomplish complete trust, transparency, and traceability. The following is the overall metric declared by Voatz to showcase their success journey \cite{voatz_2021}. 
    
    \begin{itemize}
        \item 76 successful elections (till the end of 2020)
        \item 23 successful elections (in 2020) 
        \item 7 government elections
        \item 11 political party elections
        \item 5 private, non-political elections
        \item 76 successful elections (all time) 
        \item 30 counties in 5 U.S. states have piloted Voatz for governmental elections (all time)
        \item ~1.8 million voters served (in 2020)
        \item 201,937 via Voatz apps
        \item 1.6 million via Voatz APIs
    \end{itemize}
    
    \item \textbf{Follow My Vote}
    
    \textsf{Follow My Vote (FMV)} \footnote{See \url{https://followmyvote.com/}} is an online voting software implemented by using blockchain technology. FMV uses the permissioned blockchain, BitShares. The motivation behind this establishment is to digitalize the legacy voting system to provide convenience, cost-saving, and environmental friendliness. FMV partners with many relevant organizations who share the same passion for advocating truth and freedom for the ecosystem of technology enthusiasts continuously researching to make the world a better place. Their partners include CAVO, Virginia Tech, Open Source Initiative, SATE Development, and many more.

    FMV places a strong emphasis on the security and the backside of its technology and proudly announce their vision to achieve that through blockchain and cryptography. It addresses blockchain voting as an end-to-end process. Voters install the voting booth on their device, submit identity information, get verified, request a ballot, cast a vote, and finally submit the vote to the blockchain-based ballot box. Voters can re-submit their vote until the closing day. They also can audit the ballot without disclosing their identity. 
    FMV picked BitShares as their core blockchain system and Elliptic curve cryptography to create the key-pair for identity verification.  Additionally, FMV is a firm believer in transparency and openness. Their source code is open for public audit and contribution. Everyone can access their source code on \href{https://github.com/FollowMyVote}{GitHub} to dive into the deeper architecture of their application \cite{fmv}.

\end{enumerate}

\section{Challenges and limitation}
\subsection{Organization}
    \begin{itemize}
        \item \textbf{Regulation and governance}
        
        It is crucial to assess the impact of current regulation on blockchain applications before adopting it. 
        Even with the popularity over the years, blockchain is not under any specific rules or regulations. Likewise, it is relatively complex for the regulators to constitute rules for fast-growing technology advancement like blockchain. Understanding the technology is required to achieve regulation formation. 
        In the case of asset ownership, blockchain has a contradiction against the current fundamental economy and society as people favor enclosing such information \cite{regulation_challenge}. 
        Based on the Canadian blockchain consensus 2019 report, regulation is acknowledged as a hindrance to blockchain innovation. It emphasized that the current regulations favor the current holder rather than the disrupters \cite{regulation_challeng_01, deloitte_regulation}. 
        For the European case, it is also recommended to go through \textsf{GDPR} \footnote{See \url{https://gdpr.eu/what-is-gdpr/}} first before initiating any blockchain application connected to the user$'$s personal data.


        \item \textbf{Lack of standardization}
        
        Blockchain and its integration with the public sector are still in the early stage, which raises the concern regarding standardization. Ongoing study and initiative have been taken place to conduct blockchain standardization that could be easily adopted. Standardization organizations such as ISO, CEN-CENELEC, ETSI, and ITU are the guiding actors in addressing the blockchain standard’s issue. At the same time, organizations are expressing their primary demand in adopting the standard of blockchain. Without standardization, blockchain applications can be inefficient \cite{eu_bc_standard}. 
        While many stakeholders are working on constructing standardization, the below two categories should be taken into consideration \cite{bc_standard}. 
        
        \textbf{Consistent terminology and connection of various blockchain concepts}
        
        The notion of defining fundamental concepts and joining agreed on the blockchain’s terminology should be devoted to as early as possible to clarify the basic understanding across stakeholders. Issues in relation to identification, description, classification of blockchain aspects and concepts will be taken into account first followed by issues of kinds, properties, and component-blockchain connection. This was announced to be carried out by ISO. However, it is expected to be a perplexing and long way process.
        
       \textbf{Interoperability}
       
        Non-standardized application of blockchain has presented in the private and public organizations separately to adhere to its own rules and protocols, resulting in a fragmented ecosystem. This raised the concern over the missed opportunity of blockchain systems integration. Not being able to interoperate indicates the absence of opportunity to interconnect with various technology and especially the chance to adjoin other countries’ applications. 
        
        General standardization alone cannot comply with all the areas. Precisely, blockchain demands various standardizations. IEEE standards association also admitted the role of standardization in blockchain as a driving force in the continuous development and adoption of this technology. IEEE has recently published several standards for blockchain, specifically in the fields of cryptocurrency and data management. Additionally, IEEE is working on the development of blockchain standards in many more areas \cite{ieee_standard}.

        \item \textbf{Smart contract risks and limitation}
        
        Besides the advantages of a Smart Contract, some certain risks and limitations can create a significant issue if not utilized properly. Indeed, Smart Contract is just a combination of instructions written by programmers. Thus, the chance of software bugs is undeniable. Smart Contract is immutable; if buggy Smart Contract is deployed, the chance of losing money and resources stands in the way. Obviously, there is already a Smart Contract hack on Ethereum, making the hackers get away with over \$60 million. Another concern is the changes in the protocol in which Smart Contract is being deployed. Any upgrade might leave incompatibility and malfunctions. Although Smart Contract can be beneficial, real-world issues still stand in the way as automation cannot involve in the analysis of physical cases. In the case of using Smart Contract to deal with buy \& sell cars, there is no way a Smart Contract can verify the car$'$s condition \cite{deloitte_sm, sm_risk}.

    \end{itemize}

\subsection{Awareness and understanding}
    \begin{itemize}
        \item \textbf{Public perception}
        
        Blockchain is well-known through the success of disruptive Bitcoin. Bitcoin has played an essential role in drawing attention among people to discover blockchain further deep. However, with the relation of bitcoin regarding Internet scams, hackers, Internet black market like \textsf{Silk Road} \footnote{See \url{https://www.coindesk.com/company/silk-road}}, blockchain is mistaken as crime-related on the Internet. This misconception influences the initiation of blockchain applications and especially the trust from normal users. To unleash the full potential of this technology, stakeholders must actively initiate activities in restoring and clearing the misinterpret image of blockchain to gain trust from the public and increase human resources for this technology \cite{regulation_challeng_01, challenge_001, challenge_002}. 
        
        \item \textbf{Lack of adequate skill talents}
        
        Although blockchain has been around for a while, talents in this field are still lacking. In the public sector, insufficient blockchain talent can be a major concern. Delloite \cite{shortage} has pointed out the rise of talent shortage as a concern for the public sector. It also mentioned the challenges for the public sector in competing with the private sector to attract skilled employees. There is a massive demand for blockchain talents from both the public and private sectors as this technology keeps proliferating \cite{talent_demand}. This makes blockchain developers$'$ and advocates$'$ salaries high. Also, the problem can result from the complexity in the alignment of consensus mechanisms and use cases that make it difficult for people to comprehend. 
        Most of the blockchain in government use cases are established by the research team of giant tech companies. This indicates that public sectors are still behind private businesses. Governments, especially in a developing country, could set up an atmosphere where discussion over the blockchain is encouraged as well as forming a research team dedicated to blockchain. 

    \end{itemize}
    
\subsection{Resources}
    \begin{itemize}
        \item \textbf{Blockchain trilemma}
        
        Blockchain trilemma \cite{blockchain_trilemma} is the concept that is believed that blockchain applications can satisfy only two conditions among the three, which are scalability, security, and decentralization. Two of the most contradicting choices are between the scarification of either the full potential of scalability or decentralization. If we look at Bitcoin, it’s clear that the preferred choices are security and decentralization. Bitcoin has received a lot of concern over future scalability. The comparison of visa transactions versus Bitcoin transactions is a good example. It was pointed out that Visa can handle up to 65000 transactions for every second while Bitcoin can only do about seven transactions \cite{bitcoin_scale}. Scaling Bitcoin associates to the increase of block size hence requires miners to keep increasing their computational device. The ten minutes reserved for new block chaining intends to secure the network of blockchain. Reducing the block time interval will cause security deficiency. Some of the faster blockchain applications can be achieved by lowering decentralization nature, for example, the implementation of permissioned blockchain.  
        \begin{figure}[!h]
            \centering
            \includegraphics[width=7cm]{photos/blockchain-trilemma.png}
            \caption{Blockchain Trilemma}
            \label{fig:blockchain_trilemma}
        \end{figure}
        
        \newpage
        \item \textbf{Energy and resources consumption}
        
        The current most widely used consensus algorithm is proof-of-work. This consensus protocol requires miner nodes to equip their device with high capacity and keep their device on the whole time. Miners need a high volume of CPU, GPU, hard drive, etc. Those devices consume a significant amount of energy. A single bitcoin transaction consumes approximately 707.6 kilowatt-hours of energy, comparable to the amount of energy the U.S household utilized for 24 days \cite{energy_consumption}. However, ongoing researches and experiments are being conducted to solve this issue.
        
    \end{itemize}
 
\chapter{Proof of concept}
\section{The goal of the application}

The application is a proof-of-concept built to demonstrate how blockchain can be applied to one out of many use cases in the public sector. Along with the direction toward the government$'$s openness, we focus on exploring how blockchain can be applied to open government data. While delving into the concept of open government data, Comprehensive Knowledge Archive Network (CKAN), described in the first chapter of the public sector, was found widely used among the national, regional government, and organizations. We observe that many governments have implemented their own open data portal using CKAN. Seeing the already implemented open data distributed to the public, we would like to further enhance the integrity and trustworthiness of the dataset over time by incorporating it with the Ethereum blockchain.  This application will eliminate consumers$'$ doubt over the unnoticeable modification of the open data and present transparencies of the data. Furthermore, knowing that the dataset will be further uploaded to the Ethereum network, the data administrators will be cautious in performing any unauthorized data modification. Any modification from internal or external attacks will be noticeable. 

\section{Technologies}
The main programming languages used to implement this prototype are Python and Javascript. Additional libraries and modules are used for interacting with blockchain and external API. \\

\textbf{Hashlib}

Hashlib is a python module for secure hashes and message digests. The module provides various secure hashes and message digests algorithms such as SHA1, SHA224, SHA256, SHA384, SHA512, and RSA. In this prototype, we will use SHA256 to encrypt the dataset in advance of sending them to the Ethereum chain. \\

\textbf{Urllib}

Urllib is a python module for URL handling. Urllib includes its sub modules such as urllib.request, urllib.error, urllib.parse, and urllib.robotparser. We need Urllib in order to interact with CKAN API. \\

\textbf{Web3} 

\textsf{Web3} \footnote{See \url{https://web3py.readthedocs.io/en/stable/}} is a python library for communication with the Ethereum blockchain. Web3 allows functionalities such as sending transactions, smart contract communication, retrieving block data, and many more. Web3 is usually used for decentralized application development. It is derived from Web3.js. We will use web3, EthereumTesterProvider, and HTTPProvider.\\

\textbf{Flask}

\textsf{Flask} \footnote{See \url{https://flask.palletsprojects.com/en/1.1.x/}} is a python framework and is lightweight for web application development. Flask-restful is also used in the prototype to build REST APIs. \\

\textbf{Browserify}

\textsf{Browserify} \footnote{See \url{http://browserify.org/}} is used as an aid to make $require(‘module’)$ available on javascript clients. \\

\textbf{Metamask}

\textsf{Metamask} \footnote{See \url{https://metamask.io/}} is a cryptocurrency wallet and gateway to blockchain applications. It is used to interact with Ethereum blockchain wallet via a browser extension or mobile application. Anyone can set up their address to buy, sell, send or receive tokens. \\

\textbf{Etherscan}

\testsf{Etherscan} \footnote{See \url{https://etherscan.io/}} is a platform that allows users to explore blocks on the Ethereum network. It also performs analytics for transactions. Users can investigate the ongoing transactions on the network. \\

\textbf{Ethereum accounts}

Ethereum accounts enable users to control their ether(ETH) balance. With an Ethereum account, users can send and receive transactions. There are two types of accounts: externally-owned and contract accounts. Each of them can receive, hold and send ETH and tokens as well as interact with deployed smart contracts. 
\begin{itemize}
    \item Externally-owned: controlled by anyone with the private key
    \item Contract: governed by smart contract which was deployed to the network
\end{itemize}
We will use an externally-owned account in this prototype as we do not need to collaborate with smart contracts. \\

There are four elements in each account:
\begin{enumerate}
    \item nonce: indicates the number of transactions or the number of contracts, based on the account type, sent from the account.
    \item balance: indicates the number of Wei, denomination of ETH, owned by the account.
    \item codeHash: refers to the code of an account on the Ethereum virtual machine. codeHash is used in a contract account. In an externally-owned account, codeHash is an empty string. 
    \item storageRoot, also known as storage hash, is where contract data lives. 
\end{enumerate}

An account is formed by cryptography keys: public and private keys. To sign transactions, private key is involved. It is also used to form a public key but not vice-versa.\\

\textbf{Ethereum network}

There are two types of network on Ethereum, which are public and private. As its name suggests, a public network can be accessed by anyone from any place as long as there is an Internet connection. In contrast, a private network is reserved or isolated. In this context, we will use a public network. Ethereum provides two subsets of public networks: mainnet and testnets. Mainnet is the primary network where transactions occur. Testnets allow developers to test their smart contract code before actually deploying it to the mainnet. There are four testnets available: Görli, Kovan, Rinkeby, and Ropsten. The first three testnets run on proof-of-authority consensus mechanism while Ropsten runs on proof-of-work. We will use Rinkeby to test our proof-of-concept.\\

\textbf{Rinkeby}

\textsf{Rinkeby} \footnote{See \url{https://www.rinkeby.io/#stats}} is a public test network for Ethereum blockchain applications. It is a proof-of-authority network. It works with Geth clients only, and it has a block time of about 15 seconds. In the test network, Ether does not have any value, and it can be obtained by accessing the faucet following some instructions. Anyone can receive an Ether from Rinkeby faucet through this \href{https://faucet.rinkeby.io/}{link}. By deploying the app to the testnets, it allows developers to ensure the proper functionality of their app. It is essential to use the testnet with characteristics similar to that of the mainnet, for example, the consensus mechanism and the block time. In Ethereum, it is necessary to deploy the app to the testnet first. \\

\textbf{Go Ethereum(Geth)}

\textsf{Geth} \footnote{See \url{https://geth.ethereum.org/}} is an open-source Go implementation of Ethereum written in Go language. Geth is used to connect to the Ethereum mainnet or testnets. Ethereum accounts can be managed through Geth CLI. Users can deploy smart contracts or perform transactions through Geth. \\

\textbf{Infura}

\textsf{Infura} \footnote{See \url{https://infura.io/}} allows easier connection to Ethereum mainnet or testnets. It is a platform as a service for Ethereum networks. Without Infura, users have to set up a local Ethereum node or possess a private Ethereum node to test applications. Syncing with the network requires long initialization times without Infura. \\

\newpage
\textbf{CKAN}

\textsf{CKAN} \footnote{See \url{https://ckan.org/}} is an open-source data-management tool for establishing websites containing open data. It assists users in terms of publishing and managing data. Data on CKAN is published under the unit called “datasets.” Dataset consists of two components:
\begin{itemize}
    \item Metadata about data: refers to the title, publisher, date, formats, and license.
    \item Number of resources: contains detailed data. The data format can be anything from CSV, spreadsheet, XML, PDF, images, or links.  
\end{itemize}

\section{Architecture of the application}
This application takes advantage of the existing open data API, CKAN, one of the recognized tools used by governments and organizations worldwide. We will also use a public blockchain, Ethereum blockchain, to participate in the node and perform transactions. 

The flow of the prototype starts from receiving the input as a CKAN URL package list. First, we want to access the API to present to the user the choice of all dataset packages stored on the CKAN portal. There, users have the ability to interact with the storing and verifying process of an open dataset. Once users select the interesting package. In the background, we will download the dataset package and encrypt it. We have our own Ethereum address ready for sending transactions. Next, we will form a transaction hash, including the nonce, gas price, gas, target address, value, and data. We then sign the transaction to the blockchain through Infura. Transaction will be on the waiting list until the node confirms it. We also store the transaction addresses for later verification references. Verification can be done on the same web page provided or through a chrome extension. Users can select any package whose data is already pushed to blockchain to confirm its consistency on the web page. When in the verification step, the process of download and encryption will be performed once again. After that, we will use the new encrypted data to verify against the encrypted data on the blockchain. A similar process happens when trying to prove the package via chrome extension. On chrome extension, we only have to invoke the hashing and verifications API to retrieve the result. \\

\begin{figure}[h!]
    \centering
    \includegraphics[width=9cm]{photos/high-level.png}
    \caption{High Level Architecture}
    \label{fig:high-level-architecture}
\end{figure}

The application is structured into five layers:

\textbf{Blockchain}
\begin{itemize}
    \item Type of blockchain used: public blockchain
    \item Layer 1: consensus mechanism, which is proof-of-work
    \item Layer 2: smart contracts
\end{itemize}

\textbf{Connector}
\begin{itemize}
    \item Layer 3: public Ethereum node (Infura)
\end{itemize}

\textbf{Decentralized application}
\begin{itemize}
    \item Layer 4: Web3.py, python
    In this layer, we first
    \begin{itemize}
        \item fetch the data from CKAN API
        \item encrypt data into a hash set
        \item set up Ethereum account
        \item connect to public Ethereum node, which is Rinkeby testnet
        \item sign transaction and push
        \item retrieve and verify the transaction
    \end{itemize}
    
    \item Layer 5: Chrome extension
    \begin{itemize}
        \item fetch package name
        \item call verification API
        \item retrieve result
    \end{itemize}

\end{itemize}

\begin{figure}[h!]
    \centering
    \includegraphics[width=9cm]{photos/layers.png}
    \caption{Application Layers}
    \label{fig:application-layer}
\end{figure}

\section{Implementation steps}
Below are the two main implementation details that are picked only for blockchain-related to present. They are the transaction sending and verification part. 

\begin{enumerate}
    \item \textbf{Create account with Geth} \\
    To install Geth following this \href{https://geth.ethereum.org/docs/install-and-build/installing-geth}{instruction}.\\
    - Set up account using \href{https://geth.ethereum.org/}{Geth}: go to terminal and type: \emph{geth account new} \\
    
    \begin{lstlisting}[numbers=none, backgroundcolor=\color{white}]
    > geth account new
    INFO [05-16|12:31:22.449] Maximum peer count    ETH=50 LES=0 total=50
    INFO [05-16|12:31:22.449] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
    Your new account is locked with a password. Please give a password. Do not forget this password.
    Password: 
    Repeat password: 
    
    Your new key was generated
    
    Public address of the key:   0xDb46e442466395aCab349110c32e4D9A04E9faFE
    Path of the secret key file: /path/to/secret/key
    - You can share your public address with anyone. Others need it to interact with you.
    - You must NEVER share the secret key with anyone! The key controls access to your funds!
    - You must BACKUP your key file! Without the key, it's impossible to access account funds!
    - You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
    \end{lstlisting}
    
    - Listing accounts and its keystores location, go to terminal and type: \emph{geth account list} \\
    
    \begin{lstlisting}[numbers=none, backgroundcolor=\color{white}]
    > geth account list
    INFO [05-16|12:58:07.887] Maximum peer count    ETH=50 LES=0 total=50
    INFO [05-16|12:58:07.887] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
    INFO [05-16|12:58:07.895] Set global gas cap    cap=25000000
    Account #0: {e8a94362bdaf3755f01fc4deb10c9aa473be7803} keystore:/path/to/.ethereum/keystore/UTC--2020-12-06T19-24-47.837879272Z--e8a94362bdaf3755f01fc4deb10c9aa473be7803.json
    Account #1: {88803ff295d69be4732bda6832ed0c0aefc08b70} keystore:/path/to/.ethereum/keystore/UTC--2020-12-06T19-25-20.928641645Z--88803ff295d69be4732bda6832ed0c0aefc08b70
    \end{lstlisting}

    Later, we will need keystore to sign transaction.
    
    \item \textbf{Send transaction}
    
    The chunk below is divided into three main parts. Two Python modules were used: $Web3$ and $eth\textunderscore account$.
    
    First, we have to retrieve the private key by using the Keystore file we got while setting up the account via Geth in the above step. With the private key, we can access the account where we are authorized to sign the transaction. 
    
    Next, we need Infura to connect to the Rinkeby testnet. To get the endpoint, follow the instruction \href{https://blog.infura.io/getting-started-with-infura-28e41844cc89/}{here}. 
    
    We get everything ready to sign a transaction. Finally, specify the value of the five parameters. 
    \begin{itemize}
        \item nonce: Integer of the number of the transaction in the address
        \item gasPrice: the current price of the gas
        \item gas: gas limit that we are willing to pay for the transaction. The default value is 90000.
        \item to: specify the address where the transaction will be sent to
        \item value: the value of the transaction in Wei
        \item data: this will be our CKAN dataset hash
    \end{itemize}

    It will then return the transaction that is signed using a private key and wait to be sent in the further “sendRawTransaction” method.
    After sending, it takes around 15 seconds to see the transaction on the Rinkeby testnet.
    \begin{lstlisting}[language=Python, caption=Sign transaction \cite{github}]
from web3 import Web3, HTTPProvider
from eth_account import Account

def send_data(self, data):
    try:
       with open(config('private_key_file')) as keyfile:
           keyfile_json = keyfile.read()
       private_key = Account.decrypt(keyfile_json, config('PASSWORD'))
    except (ValueError, OSError) as e:
       sys.exit('Error loading private key: ' + str(e))

    account = Account.privateKeyToAccount(private_key)
  
    w3 = Web3(HTTPProvider('https://rinkeby.infura.io/v3/0c8c84ad8965460489bbdd389b3dd0fd'))
    signed_transaction = w3.eth.account.signTransaction({
       'nonce': w3.eth.getTransactionCount(account.address, 'pending'),
       'gasPrice': w3.eth.gasPrice,
       'gas': 30000,
       'to': config('ADDRESS'),
       'value': 0,
       'data': data
    }, private_key)

    try:
       return w3.eth.sendRawTransaction(signed_transaction.rawTransaction)
    except ethereum.exceptions.InsufficientBalance as e:
       print(str(e))
       return False
    return True
    \end{lstlisting}
    
    \item \textbf{Data verification}
    
    In this verification part, we first want to have the dataset hashed and keep the hash in one place. Then, we look up the hash value stored on the Ethereum blockchain using $getTransaction$. There, we make the comparison to see whether both hashes are equal. 
    \begin{lstlisting}[language=Python, caption=Data verification]
from web3 import Web3, HTTPProvider
from web3.middleware import geth_poa_middleware
from datetime import datetime

def verify_transaction(self, dataset_hashes, package, full_url):
    dataset_ids = list(dataset_hashes.keys())
    if len(dataset_ids) == 0:
        return
    
    header = str(binascii.hexlify(b"ckan2blockchain.1."), 'utf-8')
    header_len = len(header)//2
    entry_len = (len(dataset_ids[0]) + len(dataset_hashes[dataset_ids[0]]))//2
    entries_per_tx = (65536 - header_len)//entry_len

    for i in range(0, len(dataset_ids), entries_per_tx):            
        data = header + ''.join(x+dataset_hashes[x] for x in dataset_ids[i:i+entries_per_tx])

    with open('data1.json') as json_file:
        trx_hashes = json.load(json_file)
        trx_hash = trx_hashes[f'{full_url}'][0].get(package)

        self.w3.middleware_onion.inject(geth_poa_middleware, layer=0)

        if trx_hash:
            transaction = self.w3.eth.getTransaction(trx_hash)
            block_num = transaction.blockNumber
            block = self.w3.eth.getBlock(block_num)
            timestamp = block.timestamp

            if transaction:
                input_value = transaction.input[2:] if transaction.input.startswith("0x") else transaction.input
                result = (data == input_value)
                result_dict = {'block_num': block_num, 'trx_hash': trx_hash, 'timestamp': f'{datetime.utcfromtimestamp(timestamp)}', 'result': result}
                return result_dict
        else:
            result = {'result': 'Transaction not found!'}
            return result

    \end{lstlisting}
    
    Check out this \href{https://github.com/JaneSoo/ckan-to-blockchain-ui}{GitHub repository} for the web project. \\
    Check out this \href{https://github.com/JaneSoo/package-verification}{GitHub repository} for chrome extension project.
    
\end{enumerate}

\chapter{Result and discussion}
\section{Case studies}
\subsection{Technology stack}
Based on the case studies on the innovative blockchain applications for the public sector, we noted that each of them is implemented over the permissioned blockchain. The pilot project, Known Traveller Digital Identity, uses Hyperledger Indy provided by IBM. Exonum, which provides service of the blockchain land registry application for Georgia, runs on a permissioned blockchain and Byzantine Fault Tolerance consensus mechanism. The same goes for BenBen, which is brought by BigChainDB. The other two electronic voting applications are no different. Likewise, the proposed prototype of blockchain for VAT Fraud prevention will be implemented on Microsoft Azure permissioned blockchain. As a reminder, the permissioned blockchain requires authorization to participate in the consensus mechanism. 

Without in-depth case studies, we might overgeneralize the overall internal architecture of blockchain without knowing there are different types and consensus protocol involved. If we bring up the issue of blockchain trilemma, we can imply that the level of decentralization is being compromised in the permissioned blockchain. 

\subsection{Stakeholder`s perspective}
Regarding the view of the application, blockchain for property registry is being recognized globally from influential organizations and countries. Many countries are putting effort into incorporating blockchain for property registry use cases. Blockchain for identity management is still under ongoing assessment and experiment. On the subject of electronic voting, concern over the security loopholes was raised, especially the risk that voter identity might be revealed later. The loophole can be addressed from the voter’s devices which are not up-to-date or weak access control. Besides, voters might face a situation where they might be under coercion when voting from home or remote places through their devices. One workaround we can propose is to install the voting polls extensively under civilians to prevent threats. Another personal concern is over the ability to cast votes repeatedly until the end of the voting day. If the voting result were streaming publicly on the network, it would signal the parties over the prediction result that could lead to illegal activity.

\subsection{Derivation of blockchain position in public sector}
Despite the fact that blockchain, in general, is still maturing and many technical aspects belong to the initial and managed level of maturity assessment, private sectors and enterprises show great enthusiasm for this technology. Giant companies like IBM, Microsoft, Deloitte, PWC, KPMG, and many more have set up their own research department dedicated to the study of blockchain. Seminars and conferences were held to bring up stakeholders to brainstorm any possible usages extracting from the blockchain. Correspondingly, the public sector demonstrates almost equal interest in this technology. European Union, Georgia, Dubai, and many governments have been establishing initiatives and research centers dedicated to blockchain. While most developed countries can afford to split up resources and budget for blockchain, they still lack human resources in this area and put them in the position where they mostly subscribe to enterprise service providers. Apparently, all the blockchain applications mentioned in the case studies above were supplied by private tech companies/startups.
Meanwhile, regulation and standardization stand in the way of many blockchain use cases. Developing countries, on the other hand, are behind the current state of the blockchain. Public awareness is limited; therefore, blockchain talents are inaccessible. This almost contradicts the solution of blockchain technology that roughly aims to resolve the problems happening in developing countries. 

\section{Proof of concept}
For the purpose of verifying data, pushing hash to the blockchain is very efficient since no matter how large the data is the encrypted hash will be the same size. This reduces the concern regarding the size of the data, \textsf{gas} \footnote{Gas indicates the unit of computational effort demanded to successfully operate a transaction or execute a contract on the Ethereum blockchain. More info at \url{https://ethgasstation.info/blog/what-is-gas/}}, the \textsf{gas price} \footnote{Gas price is the cost per unit of gas in Gwei. Gwei is a denomination of the cryptocurrency ether (ETH).}, and other resources. With the hash generated from the expected non-changeable data, verification of the integrity of the data is easy and fast. Although, with one drawback, we cannot identify which part of the data is modified. Possibly, the entire data was modified since the concept of hash is one bit of change to make an entirely new hash. For that concern, we recommend back up the data from time to time. 

Sending hash to Ethereum blockchain is not free. For every transaction, there is a \textsf{fee} \footnote{The current hit fee is 0.003171 ETH per transaction. While during October 2020, the transaction fee was under 0.00085 ETH. See the price chart \url{https://charts.coinmetrics.io/network-data/#928}}.
\begin{equation}
    \textsf{Fee(Gwei)} = \textsf{total amount of gas used} \times \textsf{gasPrice}
\end{equation}

Remark that the price of gas is not fixed and varies according to how fast we want the transaction to process and the current crypto market. Hence, gas price is divided into three types: low, average, and high. See \href{https://etherscan.io/gastracker}{Gas Tracker} for current gas price.
For every transaction, the minimum gas limit is 21000. The gas limit can be increased as high as the senders are willing to pay. Based on the proposed gas, miners will decide if they want to select the transaction into their block. Only the actual amount of gas used will be charged. Accordingly if we multiply 21000 with the average gas price of 151 Gwei(at the time we calculate), We get 3150 000 Gwei equivalent to 0.00315 ETH. This \href{https://ethgasstation.info/calculatorTxV.php}{site} provides live estimation of transaction fee. 

In our proof of concept, we sent around 500 transactions to the Ethereum Rinkeby testnet. If we calculate the total price of 500 transactions, it will cost us around 1.575 ETH. It is hard to estimate the fee since the crypto market rises and falls irregularly in number or amount over time. Fortunately, the Ether in the testnet does not have value and can be acquired for free. Be reminded that the price shown on testnet defers from the actual transaction price on the mainnet.

If we compress the whole API to one transaction, it will cost us the amount of one transaction fee only. In addition, it is necessary to analyze the use case thoroughly to understand how often we will have to push transactions to the blockchain. Data to be pushed to the blockchain should be limited to rarely-change content.  

\begin{itemize}
    \item \textbf{Lesson learned}
    
    Based on the nature of our dataset, which can be anticipated as an annual report, pushing hash yearly to an existing Ethereum blockchain can be much cheaper than building a fresh new public blockchain for that. Additionally, retrieving transactions is available overtime for free of charge. The transaction fee estimation also varies according to the circumstances of the dataset in a particular city or country. 
    
    In association with the high frequency of sending transactions, if ETH price keeps fluctuating unpredictably, pushing data to the Ethereum network can be expensive. Therefore the government could implement its own blockchain and encourage its citizens to participate in the mining network. If it is a non-profit use case, there will be expected hesitation in being a participation network if the reward is not sufficiently enough. It also involves the frequency of pushing transactions. Will the data have to be pushed every day to the network, or will it be weekly, monthly, or yearly? The recurrence of transactions will also determine the nature of node participants since setting up a mining machine requires quite a lot of resources. 
    
    On top of that, the government has to assess the level of knowledge among their citizens by questioning whether their citizens are informed of this blockchain technology and capable of becoming potential miners if they pick public blockchain. 
    The government himself will also have to promote the technology internally and externally. Precisely, the government must have enough blockchain human resources of their own to advocate publicly. It will also lead to a large sum of initial cost and time-consuming.
\end{itemize}

\chapter*{Conclusion}
\addcontentsline{toc}{chapter}{Conclusion}
Blockchain proves itself worthy in many ways and can be applied on top of many loophole applications. Blockchain is even more invaluable when incorporating with the public sector since this technology shares great mutual value with the public sector, such as transparency. However, one should acknowledge that blockchain cannot be beneficial to every use case. Therefore, accessing the need and the correlation between the intended use case and the technology is preliminary mandatory. Besides, blockchain might not be handy when integrating with legacy systems or migrating existing architecture from legacy systems to blockchain technology-based systems. Blockchain is shining when applying to innovative use cases. 

Preceding to embrace blockchain for managing data assets, one should be aware that the existing block size in the Ethereum or Bitcoin blockchain is relatively tiny (20kb to 1Mb) to store raw data. It was designed that way for a specific purpose. Data might end up being stored extensively in various transactions and blocks. Thus, it makes it hard for large data storage.

There are many debates over blockchain immaturity and hesitation in adopting it. Some critics brought up the challenges and limitations of blockchain as arguments against this technology. On the bright side, there are no innovations that are self-maturing. One cannot just sit and wait for technology to become mature to adopt it. Continuous research, development, prototype, and use case experiments with trials and errors will pave the way for blockchain toward its maturity, just like how traditional database takes time to stabilize itself in the current market. .

\chapter*{Future work}
\addcontentsline{toc}{chapter}{Future work}
Since the proof-of-concept discussed in the above chapter was implemented independently and was not intended to work collaboratively with the administrator of the open API (CKAN), this plays a role only for individual examination and tracking of the data. This proof-of-concept can be further leveraged by integrating hand-in-hand with the CKAN open data administrator. The concept goes like this: when the CKAN administrator deploys data to the portal, there should be a backend implementation to push the hash directly to Ethereum. This way, there will be no time in between the exact date of pushing open data to CKAN and the time of pushing hash data to Ethereum. Also, to be more efficient, the application can be enhanced by incorporating functions of notification or alert. In a nutshell, the verification of open data against the hash on a blockchain can be done in the background as a scheduled job. Then, it will automatically update the result to the subscriber, informing if there are any data changes. If the concept is implemented, it will be beneficial. 

\appendix %% Start the appendices.
\chapter{Prototype}
\section{Web application}
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/retrieve-package.png}
    \caption{Package selection}
    \label{fig:application-layer}
\end{figure}
    
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/store-success.png}
    \caption{Package store}
    \label{fig:application-layer}
\end{figure}

\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/identical.png}
    \caption{Package verification - identical}
    \label{fig:application-layer}
\end{figure}

\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/not-identical.png}
    \caption{Package verification - not identical}
    \label{fig:my_label}
\end{figure}

\clearpage
\section{Chrome Extension}
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/extension1.png}
    \caption{Extension - package selection}
    \label{fig:application-layer}
\end{figure}
    
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/extension4.png}
    \caption{Extension - identical verification}
    \label{fig:application-layer}
\end{figure}

\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/extension2.png}
    \caption{Extension - not identical verification}
    \label{fig:application-layer}
\end{figure}

\clearpage
\section{Etherscan}
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/etherscan1.png}
    \caption{List of transactions}
    \label{fig:application-layer}
\end{figure}
    
\begin{figure}[h!]
    \centering
    \includegraphics[width=13cm]{photos/etherscan3.png}
    \caption{Detailed transaction}
    \label{fig:application-layer}
\end{figure}

\end{document}
