Zhai - 2019 - J. - Phys. - Conf. - Ser. - 1168 - 032077
Zhai - 2019 - J. - Phys. - Conf. - Ser. - 1168 - 032077
Zhai - 2019 - J. - Phys. - Conf. - Ser. - 1168 - 032077
Sheping Zhai1,2, Yuanyuan Yang1*, Jing Li1, Cheng Qiu1 and Jiangming Zhao1
1
School of Computer Science & Technology, Xi’an University of Posts &
Telecommunications, Xi’an, Shaanxi, 710121, China
2
Shaanxi Key Laboratory of Network Data Analysis and Intelligent Processing,
Xi’an,Shaanxi, 710121, China
*
Corresponding author’s e-mail: [email protected]
1. Introduction
Blockchain is a distributed database with features of decentralized, traceable, non-tamperable, secure
and reliable features. It integrates P2P (Peer-to-Peer) protocol, digital encryption technology,
consensus mechanism, smart contract and other technologies together. Abandoning the maintenance
mode of the traditional central node and adopting the method of mutual maintenance by multiple users
to realize the information supervision among multiple parties, thereby ensuring the credibility and
integrity of the data. The blockchain platform can be divided into public chain, private chain and
alliance chain. All nodes in the public chain can join or withdraw freely; the private chain strictly
limits the qualification of participating nodes; the alliance chain is jointly managed by several
participating institutions. Bitcoin was proposed by Nakamoto in 2008[1], which is the most successful
case of digital currency, and is also the most typical application of blockchain. In addition, the
blockchain has expanded its unique application value in many aspects and has shown its potential to
reshape society.
As a representative of distributed database, blockchain stores all user transaction information on the
blockchain, which has high requirements for the security performance of blockchain. Blockchain is a
decentralized peer-to-peer network. Nodes do not need to trust each other and there is no central node.
Therefore, transactions on the blockchain also need to ensure the security of transaction information
on unsecured channels and to maintain the integrity of transactions. It can be seen that cryptography
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
technology occupies the most central position in the blockchain. In blockchain, cryptography
technology is mainly used to protect user privacy and transaction information, and ensure data
consistency, etc.[2] This paper briefly introduces the cryptographic techniques such as hash algorithm,
asymmetric encryption algorithm and digital signature, also elaborates the blockchain infrastructure,
the blockchain structure, bitcoin address, digital currency trading and other technologies of blockchain,
and also explains how cryptography technology protects privacy and transaction maintenance in the
blockchain in detail.
2. Blockchain infrastructurs
According to Melanie Swan, founder of the Blockchain Science Institute, blockchain technology has
experienced two phase, the first one is the blockchain 1.0 phase of multi-technology portfolio
innovation represented by Bitcoin, the second one is the blockchain 2.0 phase represented by
Ethereum, which is transferred by digital assets. Typical applications of blockchain technology mainly
include Bitcoin, Ethereum, Hyperledgers, etc. Although the implementations are different, there are
many commonalities in the overall architecture. As shown in Table 1, the blockchain platform can be
divided into five levels: network layer, consensus layer, data layer, contract layer and application
layer.
The data layer mainly uses the block data structure to ensure the integrity of data storage. Each
node in the network encapsulates the data transactions received over a period of time into a
time-stamped data block and links the block to the current longest main blockchain for storage. This
layer involves the main techniques of block storage, chain structure, hash algorithm, Merkle tree, time
stamp and so on.
The consensus layer mainly includes a consensus mechanism, which enables each node to reach a
consensus on the validity of block data in the decentralized system[2]. The consensus mechanism
mainly has PoW, PoS, PBFT and SBFT. The smart contract that is mainly included in the contract
layer is the basis of the blockchain programmable feature. The computerized program that can
automatically execute the contract terms is stored in the blockchain in the form of code and data sets.
Smart contracts, driven by time or events, are executed by blockchain nodes in a distributed manner.
All relevant terms are coded, automatically settled, and triggered by signatures or other external data
messages. The network layer includes various data transmission protocols and verification
mechanisms. The blockchain is a typical P2P network. All nodes are connected through a planar
topology and have no central nodes. Any two nodes can be freely traded, and any node can join or
leave the network at any time. The P2P protocol in the blockchain is mainly used for information
transmission between nodes. The application layer mainly includes Bitcoin, Ethereum and
Hyperledger and so on. Bitcoin is mainly for digital currency transactions. Ethereum adds
2
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
decentralized applications based on digital currency. Hyperledger do not support digital currency
transactions, mainly are enterprise-level blockchain applications.
Prev Hash Nonce ... Prev Hash Nonce Prev Hash Nonce ...
3
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
solution random number, Merkle root, and timestamp. The block body contains a list of transactions
for storing transaction information.
Prev Hash: The block hash is a key segment of the blockchain. This field is the hash value of the
data information of the previous block, and all the blocks on the chain are sequentially connected.The
resulting longest main chain from the creation of the block to the current block is finally formed. Each
block not only has the location information of the previous block, but also can verify the integrity of
the data contained in the block according to the previous block hash value.
Nonce: The header information of each data block contains a random number, and the initial value
is 0. The node running the bitcoin mining machine continuously performs a SHA256 operation on the
overall data of the block. When the SHA256 value calculated by the current random number does not
meet the requirements, then the random number is increased by one unit, and the SHA256 operation is
continued. Until the SHA256 value is less than the current data block SHA256 value, then a new data
block is generated and the P2P network accepts the new data block. Therefore, the process of
generating a new block is actually a process of calculating the SHA256 value and comparing it with
the target value. This process of bitcoin data block generation is called Proof of Work.
Timestamp: The blockchain technique requires that the node must have a timestamp in the current
data block header to indicate the write time of the block data. The blocks on the main chain are
arranged in chronological order. The timestamp can be used as a proof of the existence of block data,
helping to form a blockchain database that is not tamperable and unforgeable.
Target: The target is to make the computing power of the entire network approximately the
difficulty level required to generate a block every 10 minutes. The target is automatically recalculated
by the blockchain network based on the results of the past two weeks. The target is determined by the
SHA256 value in the block. The SHA256 value in the control block header should fall within the
controllable range target range to increase or decrease the target.
Merkle Root: The Merkle Tree is a hash binary tree originally proposed by the famous
cryptographer Merkle to quickly verify the integrity of large-scale data. As shown in Figure 2, the
Merkle tree typically contains the transaction database for the block, the root hash of the block header,
and all branches along the underlying block data to the root hash. The Merkle tree operation usually
groups the data of the block and inserts the generated new hash value into the Merkle tree. Until the
last root hash is left and recorded as the Merkle root of the block header, it is finally constructed into a
tree structure. Bitcoin uses a double SHA256 hash function, which is to pass two SHA256 hash
operations on the original data of arbitrary length, and use 256-bit binary digits for unified storage and
identification.
Merkle Root
H(A~D)
H(AB) H(CD)
4
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
Random
Private key
(256 bit)
Pub-Key Hash
SHA256 4 byte Base58 Address
Base58
Secp256k1 (20 byte)
Check code
Figure 3. Bitcoin address generation process.
Generating a Bitcoin private key essentially selects a number between 1 and 2256, and it is
necessary to ensure that the result of the selection is unpredictable or non-repeatable. Bitcoin uses the
random number generator of the operating system to generate a 256-bit random number as a private
key, and multiplies the randomly generated private key k by the defined generation point G on the
curve to obtain another point on the curve. That is, the corresponding public key K. The elliptic curve
relies on the discrete logarithm problem. The relationship between k and K is fixed, but it can only be
a single operation, that is, K is obtained from k, and k is difficult to obtain from K. The generation of
currency addresses uses different algorithms on different platforms.
Bitcoin uses the SHA256 and RIPEMD160 double hashes to derive the bitcoin address; Ethereum
uses the Keccak256 algorithm to generate the Ethereum address[10]. In Bitcoin, the public key K is
used as input, and its SHA256 hash value is calculated. Recalculate the RIPEMD160 hash value to get
a 160-bit number as the public key hash. Finally, the public key hash is Base58 encoded to form a
bitcoin address. Base58 is a widely used encoding format, not only for Bitcoin, but also for other
crypto currencies, which combines effective compression, easy reading, and error diagnosis. Bitcoin
uses Base58Check in Base58 encoding. A 4-byte error check code is added to the encoded data to
effectively check for errors in the transcription.
5
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
6
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
consistency and security of the entire network blockchain data. Each node needs to rely on its own
power to solve the SHA256 calculation problem, that is, to find a suitable random number Nonce, so
that the SHA256 hash value of the block header original data is smaller than the setting value of the
difficulty target in the block header: H (n || h) ≤ t .
H is the SHA256 hash function; n is the random number Nonce; h is the block header data, mainly
including the previous block hash, Merkle root, etc.; t is the difficulty target, the smaller the t value,
the harder the n value is found; The node that is first found can obtain the accounting rights of the new
block. The consensus process of PoW in the blockchain network is as follows:
Each new transaction is broadcast to all nodes in the blockchain network.
In order to construct a new block, each node collects all transactions received since the previous
block was generated, and calculates the Merkle root of the block header based on these
transactions.Increase the Nonce of the block header from 0 to 1, until the twice SHA256 hashe value
of the block header are less than or equal to the set value of the target.
The whole network node participates in the calculation at the same time. If a node first finds the
correct random number, the node will obtain the new block's billing rights and mining reward, and
broadcast the block to the entire network.
After receiving the new block, the other nodes verify the validity of the transaction and the
random number Nonce in the block. If correct, the block is added to the local blockchain, and the next
block is built based on the block. .
With the development of blockchain technology and the emergence of various competitive
currencies, researchers have proposed various mechanisms that can be reached without relying on
computing power. For example, PoS and DPoS, as well as some distributed consistency algorithms,
such as PBFT, Raft, etc., these consensus mechanisms have their own advantages and disadvantages,
and the application scenarios are also different.
7
CISAT 2018 IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1168 (2019) 032077 doi:10.1088/1742-6596/1168/3/032077
algorithm does not have an effective method to crack this series of algorithms, once it is cracked, the
privacy and security of all data in the blockchain will no longer exist.
In future research, it is necessary to develop a coin-rich mechanism under the protection of
cryptography mechanisms, and to minimize the performance requirements.A more secure and reliable
cryptographic encryption algorithm is needed to improve the security of the blockchain.
8. Conclusion
This study introduces the main applications of cryptography in the blockchain and analyzes existing
problems. Firstly, starting from the blockchain infrastructure, the blockchain technology is simplified.
Secondly, the cryptography technology is introduced to elaborate the blockchain. Finally, the existing
security problems in the blockchain are analyzed. It shows that digital encryption technology runs
through the blockchain system and is the core technology of the blockchain system. This paper
emphasizes that the research of cryptography plays a decisive role in the development of blockchain,
and prospects the future research direction of blockchain technology.
References
[1] Nakamoto, S. (2008) Bitcoin: A peer-to-peer electronic cash system. Consulted., 165: 55-61.
[2] Zhu, Y., Gan, G.H., Deng, D. (2016) Security Research in Key Technologies of Blockchain.
Information Security Research., 12: 1090-1097.
[3] Liu, X.F. (2017) Research on blockchain performance improvement of Byzantine fault-tolerant
consensus algorithm based on dynamic authorization. Zhejiang University.
[4] Wang, X., Lai, X., Feng, D. (2005) Cryptanalysis of the Hash Functions MD4 and RIPEMD.
Advances in Eurocrypt., 3494: 1-18.
[5] Shen, Y., Wang, G. (2017) Improved preimage attacks on RIPEMD-160 and SHA-160. Ksii
Transactions on Internet & Information Systems., 12: 727-746.
[6] Wang, H.Q., Wu, T. (2017) Cryptography in Blockchain. Journal of Nanjing University of Posts
and Telecommunications., 37: 61-67.
[7] Yuan, Y., Wang, F. (2016) Current Status and Prospects of Blockchain Technology
Development. Acta Automatica Sinica., 42: 481-494.
[8] Miyaji, A. (1994) Elliptic Curves Suitable for Cryptosystems. Ieice Transactions on
Fundamentals of Electronics Communications & Computer Sciences., 77: 98-105.
[9] He, P., Yu, G., Zhang, Y.F. (2017) Prospective review of blockchain technology and application.
Computer Science., 44: 1-7.
[10] Zhai, S.P., Li, Z.Z. (2018) The data block chain of the key technologies Consistency. Computer
Technology and Development., 8: 1-6.
[11] An, Q.W. (2017) Research and application of key technologies for decentralized transactions
based on blockchain. Donghua University.