VIETNAM NATIONAL UNIVERSITY - HO CHI MINH CITY HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY FACULTY OF COMPUTER SCIENCE AND ENGINEERING BK TP.HCM BACHELOR OF ENGINEERING THESIS AN HIERARCHICAL DETERMINISTIC WALLET USING ED25519 SIGNATURE SCHEMA COMPUTER SCIENCE COMMITTEE 1 Supervisors: Dr. Nguyen An Khuong. Phan Son Tu, B. Nguyen Tien Thinh.
Students: Nguyen Nguyen Phuong 1712726 Nguyen Dinh Thang 1752503 Ho Chi Minh City, December 2021 A萎K"J窺E"SW渦E"IKC"VR0JEO E浦PI"JñC"ZÊ"J浦K"EJ曳"PIJ C"XK烏V"PCO ////////// A瓜e"n壱r"/"V詠"fq"/"J衣pj"rj¿e VT姶云PI"A萎K"J窺E"DèEJ"MJQC MJQC< MJ"("MV"Oƒ{"v pj PJK烏O X影"NW一P"èP"V渦V"PIJK烏R D浦"OðP< MJOV Ej¿"#< Ukpj"xk‒p"rjVk"fƒp"vぜ"p {"x q"vtcpi"pjXv"eてc"dVp"vjw{xv"vt·pj J窺"XÉ"VçP< PIW[右P"PIW[çP"RJ姶愛PI OUUX< 3934948 J窺"XÉ"VçP< PIW[右P"AîPJ"VJ溢PI OUUX< 3974725 PIÉPJ< MJOV N閏R< ENE/M4239 30"A亥w"8隠"nw壱p"ƒp<"ÐC"Jkgtctejkecn"Fgvgtokpkuvke"Ycnngv"hqt"Gf4773;Ñ *Pijk‒p"e泳w"rjƒv"vtk吋p x "rj¤p"e医r"zƒe"8鵜pj"f詠c"vt‒p"n逢嬰e"8欝"ej英"m "Gf4773;+ 40"Pjk羽o"x映"*{‒w"e亥w"x隠"p瓜k"fwpi"x "u嘘"nk羽w"dcp"8亥w+< /"Uvwf{"gnnkrvke"ewtxg"et{rvqitcrj{."uvwf{"Gfyctfu/ewtxg"Fkikvcn"Ukipcvwtg"Cniqtkvjo *GfFUC+ /"Uvwf{"dnqemejckp"vgejpqnqi{ /"Uvwf{"et{rvq"ycnngv /"Fgukip"C"Jkgtctejkecn"Fgvgtokpkuvke"Ycnngv"hqt"Gf4773; /"Korngogpv"c"rtqvqv{rg"qh"vjg"Fgukipgf"Jkgtctejkecn"Fgvgtokpkuvke"Ycnngv"hqt"Gf4773; 50"Pi {"ikcq"pjk羽o"x映"nw壱p"ƒp<"3712;14243 60"Pi {"jq p"vj pj"pjk羽o"x映<"3513414243 70"J丑"v‒p"ik違pi"xk‒p"j逢噂pi"f磯p< Rj亥p"j逢噂pi"f磯p< 3+ VU0 Piw{宇p"Cp"Mj逢挨pi. Mjqc"MJ(MV"Oƒ{"v pj J逢噂pi"f磯p"mk院p"vj泳e"p隠p"v違pi 4+ MU0"Rjcp"U挨p"V詠. Fguectvgu"Pgvyqtm J逢噂pi"f磯p"m "vjw壱v P瓜k"fwpi"x "{‒w"e亥w"NXVP"8«"8逢嬰e"vj»pi"swc"D瓜"o»p0 Pi {"00000000"vjƒpi"2;0"p<o"4243 EJ曳"PJK烏O"D浦"OðP IK謂PI"XKçP"J姶閏PI"F郁P"EJëPJ *M#"x "ijk"t "jが"v‒p+ *M#"x "ijk"t "jが"v‒p+ RIU0"VU0"Jw pj"V逢運pi"Piw{‒p Piw{宇p"Cp"Mj逢挨pi RJYP"FÉPJ"EJQ"MJQC."Dし"OðP< Pi逢運k"fw{羽v"*ej医o"u挨"d瓜+< A挨p"x鵜< Pi {"d違q"x羽< Ak吋o"v鰻pi"m院v< P挨k"n逢w"vt英"nw壱p"ƒp< VT姶云PI"A萎K"J窺E"DèEJ"MJQC E浦PI"JñC"ZÊ"J浦K"EJ曳"PIJ C XK烏V"PCO MJQC"MJ"("MV"Oè["VëPJ A瓜e"n壱r"/"V詠"fq"/"J衣pj"rj¿e //////////////////////////// Pi {"42"vjƒpi"34"p<o"4243 RJK蔭W"EJ遺O"D謂Q"X烏"NXVP *F pj"ejq"pi⇔ぜk"j⇔ずpi"fdp+ 30"J丑"x "v‒p"UX< Piw{宇p"Piw{‒p"Rj逢挨pi x Piw{宇p"A·pj Vj逸pi OUUX< 3934948 x 3974725 Pi pj"*ejw{‒p"pi pj+<"MJOV 40"A隠"v k<"ÐC"Jkgtctejkecn"Fgvgtokpkuvke"Ycnngv"hqt Gf4773;Ñ *Pijk‒p"e泳w"rjƒv"vtk吋p"x "rj¤p"e医r"zƒe"8鵜pj"f詠c"vt‒p"n逢嬰e"8欝"ej英"m "Gf4773;+ 50"J丑"v‒p"pi逢運k"j逢噂pi"f磯p< Piw{宇p"Cp"Mj逢挨pi 60"V鰻pi"swƒv"x隠"d違p"vjw{院v"okpj< U嘘"vtcpi< 33: U嘘"ej逢挨pi< 29 U嘘"d違pi"u嘘"nk羽w U嘘"j·pj"x胤< U嘘"v k"nk羽w"vjco"mj違q< 63 Rj亥p"o隠o"v pj"vqƒp< Jk羽p"x壱v"*u違p"rj育o+ 70"V鰻pi"swƒv"x隠"eƒe"d違p"x胤< /"U嘘"d違p"x胤< D違p"C3< D違p"C4< Mj鰻"mjƒe< /"U嘘"d違p"x胤"x胤"vc{ U嘘"d違p"x胤"vt‒p"oƒ{"v pj< 80"Pj英pi"逢w"8k吋o"ej pj"e栄c"NXVP< Vjg"vjguku"ku"gcu{"vq"tgcf"*cnvjqwij"kv"ku"pqv"ygnn"ytkvvgp+."vjg"cwvjqtu"jcxg"xgt{"iqqf ugnh/uvwf{"cdknkv{"vq"eqorngvg"vjku"fkhhkewnv"vjguku Vjg"cwvjqtu"jcxg"gzegnngpv"wpfgtuvcpfkpiu"qh"gnnkrvke"ewtxg"et{rvqitcrj{."cpf"dnqemejckp vgejpqnqi{0"Gurgekcnn{."vjg{"ctg"rtqhkekgpv"kp"Uqncpc"dnqemejckp Vjg"cwvjqtu"jcxg"iqqf"gpikpggtkpi"umknnu"kp"fgxgnqrkpi"dnqemejckp/tgncvgf"u{uvgo Vjg"u{uvgo"ku"fgukipgf"vq"dg"uecncdng"hqt"ocp{"dnqemejckpu Korngogpvgf"u{uvgo"cntgcf{"jcu"wugt"kpvgthceg"cpf"CRK 90"Pj英pi"vjk院w"u„v"ej pj"e栄c"NXVP< Vjg"u{uvgo"ku"pqv"fgegpvtcnk¦gf"gpqwij0 Vjg"vjguku"jcu"pqv"{gv"korngogpvgf"vjg"dcuke"hwpevkqpu"qh"c"ycnngv"uwej"cu"ugpfkpi"cpf tgegkxkpi"vqmgpu."dwv"qpn{"jcu"vjg"hwpevkqp"qh"etgcvkpi"ycnngvu."cpf ejgemkpi"dcncpeg :0"A隠"pij鵜<"A逢嬰e"d違q"x羽 槮 D鰻"uwpi"vj‒o"8吋"d違q"x羽 Mj»pi"8逢嬰e"d違q"x羽 ;0"O瓜v"u嘘"e¤w"j臼k"UX"rj違k"vt違"n運k"vt逢噂e"J瓜k"8欝pi< c0"Yj{"Gfyctf"ewtxgu"ctg"cnuq"gnnkrvke"ewtxgu"cnvjqwij"vjgkt"hqtou"fq"pqv"eqpvckp"vgtou"qh fgitgg"5"kp"xctkcdg zA d0"Yjcv"ctg"vjg"vtcfg/qhhu"kh"yg"wug"KRHU"vq"tgrnceg"vjg"egpvtcnk¦gf"enkgpv/ugtxgtA e0"Cu"yg"ctg"uvknn"wukpi"uqog"nkdtctku"uwej"cu"DKR54."korngogpvgf"wukpi"Uger47;m3."fq vjg{"ghhgev"qp"vjg"ugewtkv{"qt"rgthqtocpeg"qp"{qwt"u{uvgoA 320"Aƒpj"ikƒ"ejwpi"*d茨pi"ej英<"ik臼k."VD+< Ik臼k Ak吋o<":0:132 M#"v‒p"*ijk"t "j丑"v‒p+ Piw{宇p"Cp"Mj逢挨pi VT姶云PI"A萎K"J窺E"DèEJ"MJQC E浦PI"JñC"ZÊ"J浦K"EJ曳"PIJ C" XK烏V" PCO KHOA KH & KT MÁY TÍNH A瓜e"n壱r"- V詠"fq"- J衣pj" rj¿e ---------------------------- Ngày 26 tháng 12 p<o 2021 RJK蔭W"EJ遺O" D謂Q"X烏"NXVP *F pj"ejq"pi⇔ぜk"j⇔ずpi"fdp1rjVp"dkうp+ 30"J丑"x "v‒p"UX< - Nguy宇p" Piw{ên Ph逢挨pi (1712726) - Nguy宇p" Aình Th逸pi" *3974725+ MSSV: Ngành (chuyên ngành): Khoa h丑e"Oáy tính 40"A隠"v k< A hierarchical deterministic wallet for ED25519 50"J丑"v‒p"pi逢運k" j逢噂pi" f磯p1rj違p" dk羽p< Nguy宇p" Vk院p" Vj鵜pj 60"V鰻pi" swƒv"x隠"d違p" vjw{院v" okpj< U嘘"vtang: U嘘"ej逢挨pi< U嘘"d違pi" u嘘"nk羽w U嘘"j·pj" x胤< U嘘"v k" nk羽w" vjco" mj違q< Rj亥p" o隠o" v pj" vqƒp< Jk羽p" x壱v" *u違p"rj育o+ 70"V鰻pi" swƒv"x隠"eƒe"d違p"x胤< - U嘘"d違p"x胤< D違p" C3< D違p" C4< Mj鰻"mjƒe< - U嘘"d違p"x胤"x胤" vc{ U嘘"d違p"x胤"vt‒p" oƒ{" v pj< 80"Pj英pi" 逢w"8k吋o" ej pj" e栄c"NXVP< - The thesis was written coherently. - For the thesis, students studied and developed a prototype of a hierarchical deterministic wallet for ED25519 (a type of elliptic curves that is used in elliptic-curve cryptography, one of the strongest public-key cryptographic system known today), which has not been well developed yet.
- Cryptography protocols used for the wallets were discussed carefully in the thesis with full of details. - Students showed excellent comprehension of cryptography and the underlying mathematics as well as good programming skills. 90"Pj英pi" vjk院w" u„v"ej pj" e栄c"NXVP< - Minor typos appear quite frequently in the thesis. - Lack of discussion of the advantages/disadvantages of using HD wallets and the comparison with the currently existing HD wallets.
:0"A隠"pij鵜<" A逢嬰e"d違q"x羽"Z D鰻"uwpi" vj‒o" 8吋"d違q"x羽"¸ Mj»pi" 8逢嬰e"d違q"x羽"¸ ;0"5"e¤w"j臼k" UX"rj違k" vt違"n運k" vt逢噂e"J瓜k" 8欝pi< a. What is the main difference between a HD wallet for SECP256K1 and a HD wallet for ED25519? b. What are the difficulties in adapting BIP32 protocol to the ED25519 case? c. 320"Aƒpj" ikƒ" ejwpi" *d茨pi" ej英<" ik臼k."VD+< Gi臼k Ak吋o" <""""""""9.8/10 M#"v‒p"*ijk" t "j丑"v‒p+ Commitment We commit that the work in this dissertation was carried out following the requirements of the university’s regulations and has not been submitted for any other academic orga- nizations.
Except where indicated by specific reference in the text, the works are our own. Ho Chi Minh City, December 2021 Acknowledgement The completion of this study could not have been possible without the guidance and expertise of our supervisors. We would like to express our sincere gratitude to professor Nguyen An Khuong for his patience, motivation, and the immense amount of knowledge he led us to. No matter how many times we let him down because of our unprofessional result, he is still calm and continues to support us.
We also want to thank the special supports from Mr. Phan Son Tu, who share with us valuable knowledge about the blockchain industry application while letting us work in his office. Besides that, we would like to show our appreciation to families and friends, who have greatly supported and encouraged us in this thesis and university life. 3 Abstract On the Internet, most of the financial applications apply the public key cryptography to verify users’s identities, manage their digital assets, authenticate and authorize them, etc.
In a blockchain environment, this model is crucial to keep the system works, since there are no intermediaries nor the central database for management. However; the user has to keep track of a lot of key pairs for each asset and this is not efficient. To solve this problem, we use an hierarchical deterministic wallet (HD wallet), which can derive hundreds of child wallets from a single master key-pair. Currently, there are already multiple protocols for an HD wallet for Secp256k1 while those for Ed25519 are neither well-known nor well developed.
In this thesis, we will try to analyze and build an HD wallet for Ed25519 signature schema. Contents Acknowledgement 1 Abstract 3 List of figures 7 List of tables 9 Chapter 1 INTRODUCTION 11 1.3 Scope of the study .2 Hierarchical deterministic wallet. 20 Chapter 3 PROTOCOLS AND RELATED WORKS 37 3. 64 Chapter 4 SYSTEM DESIGN 67 4.2 The hierarchical deterministic web wallet .2 The hierarchical deterministic web wallet .2 The hierarchical deterministic web wallet.
114 Chapter 7 CONCLUSION AND DISCUSSION 117 7. 119 Bibliography 121 List of Figures 2.1 Example of BIP32 key tree with depth 3 .2 Example of the extended private key .3 Master Extended Key generation Process .4 Normal Extended Private Key generation process .5 Normal Extended Public Key generation process .6 Hardened Extended Private Key generation process .7 Relation in BIP32 normal derivation protocol .8 Master Extended Key generation Process .9 Hardened Extended Public Key generation process .10 Multiply process of Ed25519 .11 Master key generation process .12 Private keypair derivation process .13 Public keypair derivation process .14 Random secret seed generation process .15 Example path of BIP44 .16 Example tree of wallets from given path .1 General library structure .3 Example of web wallet flow .4 HD web wallet tree .5 Between users and Wallet provider .6 Between users and blockchain networks .7 Between users and Address service .9 General JSON object of a Wallet .1 Typescript library structure .2 COMPONENTS JSON example .3 Different implementation in Montgomery Ladder .4 Overview of entire system .6 Create wallet page .7 Import wallet page. 106 8 LIST OF FIGURES 5.9 Transaction and search .1 Testcase results with mocha .2 Test airdrop with Solana .3 Test balance with Solana .4 Test transaction with Solana .5 Transaction detail on Solana Explorer .6 Coins transfered details. 113 List of Tables 4.1 Use case list .2 Use case: Create new wallet.3 Create new child wallet.4 Delete wallet from the browser.6 Modify addresses in the database.
86 1 Introduction In this chapter, we are going to discuss the overview of the wallet we are creating. Thus, we are going to present the objectives, scope, and structure of this thesis.3 Scope of the study .1 Overview At the moment, blockchain is a robust trend in financial technology. Blockchain is ate- chnology that enables truthless digital currencies transaction without intermediaries. It helps to prevent the double-spending and solve the censorship problem in traditional fi- nance.
Similar to a transaction in a bank, you need to sign it to provide the proof of identity. In the blockchain system, you use a digital signatures schema. The private key is kept private and used to sign the transaction, while the public key is accessible by ev- eryone, used to verify the signature. The sender can also use your public key as a public address to send cryptocurrency.
The pair of keys is preserved and managed by using a cryptocurrency wallet, or crypto wallet for short. Some people may call it a digital wallet, but that is not entirely cor- rect. A digital wallet (e-wallet) such as Momo and Paypal can hold users’s digital assets (government-issued currency) and link to their credit/debit cards. The banks apply the online banking service and allow the digital wallet to connect to users’s accounts, which means users are required to sign up the service first to use a digital wallet and they have to transfer indirectly through the banking system.
On the other hand, crypto wallet has access to users’s crypto assets, and can help them to transfer cryptocurrencies directly because the blockchain system does not required a trusted third party nor any intermedi- ary. All the transfer process takes in terms of minutes, no matter how far it is from you to the receiver. With some lightning-fast consensus like the Proof of History blockchain, it took less than 10 seconds. In the case of digital wallets or bank accounts, you have to wait for days before your transaction is confirmed, and it even worse when you decide to transfer to another country/state or cross-bank.
The bank does have a solution for this problem (NAPAS, Visa, MasterCard,.) but you have to pay an extra fee for the service no matter how much you spend. That is why rather than the traditional stock markets, people are more likely to invest in the decentralized system since they have to stay home due to the COVID pandemic. The cryptocurrency still has some more advantages to traditional finance, but for the scope of our thesis, we won’t include them here. Another difference is that, crypto wallet does not hold any of users’s private information such as phone number, name, ID card, etc (also know as KYC).
Therefore; users’s information is protected and will not be leaked even if the crypto wallet got hacked. In practical, the investors do not invest in a single market. They love to split their funds and put their money into multiple projects because one of the famous investment rule is “Don’t put all your eggs in one basket”. However; a crypto wallet creates a different key pair to sign for each transaction and each crypto wallet is connect to only one platform.
The users have to create multiple wallet for each market, and they have to keep track of the used key pairs for both backing up and avoiding key leakage. This is inconvenience for both advanced users and investors since hundreds of transactions are made and hundreds of markets launch per day. Also, crypto wallet or digital wallet, they are still online applications that rely on the Internet. An advanced user acknowledges that the blockchain system and the internet is not a safe place.
Both of the wallets are vulnerable to common attacks such as man-in-the- middle attack, phishing, social engineering, and more. These attacks are hard to prevent because they focus on the human factor: the users’s awareness. In addition, blockchain INTRODUCTION 13 system is a collection of digital signature, which reckons the digital signature algorithm (DSA). If users lost their private key, or the cryptography behind the DSA is broken, all of their assets are gone and there are no way to retrieve those assets because blockchain system holds no personal information about the users.2 Objectives To solve the first problem, we choose to work on an hierarchical deterministic wallet (HD wallet).
The HD secret key derivation and transfer protocol allow creating a huge amount of child keys from parent keys in a hierarchy. Crypto wallets using the HD protocol are called HD wallets. HD wallet helps the users to manage multiple child wallets and backup easier. If a child wallet is lost, the other child wallets remain safety when the parent keys are not leaked.
For the second problem, the main reason why we brought it up is that we found the standard digital signature algorithm (ECDSA) used in the blockchain system has a flaws since 2009 [1] so the need for a higher-security signature is vital. What catches our eyes is the Ed25519 digital signature schema.