How private key and public key are matched?

Nyein Chan Ko Ko
4 min readMar 26, 2024

နောက်ပိုင်းမှာ ဈေးတွေပြန်တက်လာတာနဲ့အတူတူ တဖြည်းဖြည်းနဲ့ web3 company တွေကလည်း main stream ဘက်ကို တိုးလာပြီ။

web3 ဘက်ကို စပြီးလေ့လာသင့်၊ blockchain တွေနဲ့ လုပ်လို့ရတာတွေ အများကြီးရှိနေကြောင်းပြောမိတော့..

ကိုယ်သေချာ မတွေးဖူးတဲ့ မေးခွန်းတစ်ခုကြားရတယ်။

ကျနော်တို့ က Cryptocurrency ပိုက်ဆံအိတ် တွေသုံးတယ်ဆိုတော့ ၊

အဲဒီ private key နဲ့ public key (wallet address) တွေကို ကိုက်မကိုက် ဘယ်သူစစ်ပေးတာလဲ၊ ဘယ်နေရာမှာ key တွေကိုသိမ်းထားတာလဲတဲ့။

wallet company တွေဆီမှာလား။ ဗဟိုထိန်းချုပ်ထားတဲ့ database တွေထဲမှာလားဆိုပြီး.

IT ဘက်က ဘရိုက မေးတယ်။

သေချာ ပြန်ဖတ်ကြည့်လိုက်တော့ .မှ ရေးရေးလေး နားလည်သလိုလိုရှိတယ်။

Cryptocurrency တွေနဲ့ပတ်သက်ရင် နည်းပညာအပိုင်းရှိသလို၊ Trading (ရောင်းဝယ်/ရင်းနှီးမြုပ်နှံတဲ့အပိုင်း) လည်း သက်သက်စီရှိပါတယ်။

ဒီတစ်ခါတော့ နည်းပညာအပိုင်းကို ပြောပြပါ့မယ်။

ပထမဆုံးသိဖို့ကတော့ Cryptocurrency ပိုက်ဆံအိတ်သော့ တွေကို ဘယ် ဗဟို ဆာဗာထဲမှာမှ မသိမ်းထားပါဘူး။ ဒီနေရာမှာ အရောင်းအဝယ်လုပ်ပေးတဲ့ Exchange တွေကိုထည့်မပြောပါဘူး။ Exchange တွေပေါ်မှာရှိတဲ့ Crypto တွေက သူတို့က သူတို့ ပိုက်ဆံအိတ် ထဲမှာ သိမ်းပေးထားတာပါ။ ကိုယ့် ဘာသာ သိမ်းထားရတာမဟုတ်ပါဘူး။

ပထမဆုံး Trust wallet တို့ Metamask တို့ကိုသုံးပြီး ကိုယ့်ဘာသာ wallet တစ်ခုကို စတည်ဆောက်လိုက်တာနဲ့ ဒီ Wallet App တွေကနေပြီး တော့ Random ထုတ်ထားတဲ့ binary နံပါတ် အကြီးကြီး တစ်ခုကိုထုတ်ပေးပါတယ်။ အဲဒီ နံပါတ်အကြီးကြီးကို အပိုင်းပိုင်းဖြတ််ပြီးတော့ 0 ကနေ 2048 ပါတဲ့ ဂဏန်း 12 ခုအဖြစ်ကို ပြောင်းတယ်။ အဲဒီ 12 ခုကိုမှ အထူး သတ်မှတ်ထားတဲ့ အင်္ဂလိပ် စာလုံး 2048 လုံးနဲ့ ပြန်တွဲစပ်ပြီး

လူမှတ်လို့လွယ်မယ့် အင်္ဂလိပ် စာလုံး 12 ကနေ 24 လုံးထိပါတဲ့ seed phrase အဖြစ် ပြန်ပေးပါတယ်။ အဲဒီ seedphrase 2048 လုံးကို BIP 39 လို့ခေါ်ပြီး Bitcoin Improvement Proposal ထဲမှာပါဝင်ပါတယ်။

အဲဒီ seed phrase က ကိုယ့်ရဲ့ wallet ကိုဖွင့်မယ့် သော့ဖြစ်ပါတယ်။

Private key ထွက်လာပြီဆိုရင် တစ်လမ်းသွား cryptography algorithm တွေကိုသုံးပြီးတော့ သူ့အတွက် ဖြစ်လာမယ့် Public key (သို့မဟုတ် ပိုက်ဆံအိတ် လိပ်စာ) ကို ပိုက်ဆံအိတ် တွေကနေ ထုတ်ပေးပါတယ်။ အဲဒီနေရာမှာသုံးတဲ့ algorithms တွေက Elliptic Curve Cryptography (ECC) သို့မဟုတ် the RSA algorithm. လို့ခေါ်ပါတယ်။ ဒီ algorithms တွေက Private key သိရင် Public key ကို ပြန်ထုတ်နိုင်အောင် လုပ်ဆောင်နိုင်ပေမယ့်လို့ Public key ကနေ private key ကို Reverse ထွက်အောင်တော့ မလုပ်နိုင်ပါဘူး။

ဒီနေ့ခေတ် အဆင့်အမြင့်ဆုံး ကွန်ပျူတာတွေနဲ့ ပြန်ဖြေရင်တောင် မဖြစ်နိုင်အောင် ပြုလုပ်ထားတဲ့ algorithm တွေဖြစ်ပါတယ်။

Wallet လိပ်စာတွေကိုတော့ hash version အနေနဲ့ အများ ပို့လို့ ဖတ်လို့ လက်ခံလို့ရအောင်ထုတ်ပေးပါတယ်။

Cryptocurrency တစ်ခုခုကိုပို့တော့မယ်ဆိုရင် ပေးလေ့ရှိတဲ့ QR code, သို့မဟုတ် အက္ခရာနဲ့ နံပါတ်ပါတဲ့ စာကြောင်းရှည်ကြီးဟာ လိပ်စာပါပဲ။ etc 10xxdfdxdfxxxxxxxx

ဒီ private ကီးကော Public key လိပ်စာကိုကော ဘယ်နေရာမှာမှ တွဲပြီး သိမ်းထားတာမရှိပါဘူး။

ဒီကီးနှစ်ခုက ကိုက်မကိုက်စစ်ပေးနိုင်တဲ့ တစ်ခုတည်းသော အရာက Cryptographic algorithm ပဲရှိပါတယ်။

ဒါကြောင့် wallet တွေထဲမှာ အဲဒီ algorithm တွေပဲပါပါတယ်။ ကိုယ်က seed phrase ရိုက်လိုက်ရင် ဒါကို cryptography နဲ့ ပြန်ဖြေပြီး public key ကိိုထုတ်ပါတယ်။ဒီ တော့မှ public key ပေါ်မှာတွဲပြီးတည်ရှိနေတဲ့ ကိုယ့်ရဲ့ Cryptocurrency တွေကို မြင်ရတာဖြစ်ပါတယ်။

တကယ်တမ်း သိမ်းထားဖို့လိုတာက Apple ,organge, computer စတဲ့ အင်္ဂလိပ်စာလုံး မျိုးလေး ၁၂ လုံးသာဖြစ်လို့ ဒါကို စာရွက်ပေါ်ချရေးထားရင်လည်းရသလို၊ လုံခြုံရေးခံထားတဲ့ hardware wallet လေးတွေထဲလည်းထည့်လို့ရပါတယ်။

(၁)၊ ဒါဆို အဲဒီ စာလုံး ၁၂ လုံးကို random ရိုက်ကြည့်ပြီးတော့ wallet တွေကို ခိုးယူဖို့မဖြစ်နိုင်ဘူးလား။

အဲလိုရိုက်မယ်ဆိုရင် တစ်လုံးစီတိုင်းအတွက် ဖြစ်နိုင်တဲ့ စာလုံးက 2048 လုံး ရှိပါတယ်။ 2048 **12 ဆိုရင်
`5444517870735015415413993718908291383296` ကြိမ် ကြိုးစားဖို့လိုပါလိမ့်မယ်။ အချို့တွေက အဲဒီလိုလုပ်ဖို့ကြိုးစားရင်တောင် ခုနောက်ပိုင်း wallet တွေမှာ ဘယ်နှစ်ကြိမ် ကြိုးစားရင် ဆက်ဝင်လို့မရတော့ဘူးဆိုတဲ့ နည်းပညာတွေ ပါလာလို့ မဖြစ်နိုင်ပါဘူး။ နောက်ထပ် လုံခြုံရေးအဆင့်တစ်ခုအနေနဲ့ passcode. တွေလည်းပါနိုင်သေးတယ်။

(၂) wallet တစ်ခု မှာ ဖန်တီးလိုက်လို့ ဒီ wallet မှာပဲ သုံးလို့ရမယ်ဆိုတာလည်းမဟုတ်ပါဘူး။ သူတို့က ကြားခံသက်သက်ပါပဲ။ ကိုယ့်ရဲ့ seed phrase (private key) သာရှိရင် ဘယ် wallet ကမဆိုပြန်ပြီး login ဝင်လို့ရပါတယ်။ ဒီ private key တွေကိုလည်း Wallet ရဲ့ ဆာဗာတွေဆီကို ပို့တာမျိုး မလုပ်နိုင်ကြပါဘူး။ တရားဝင် Wallet တွေမှာဆိုရင် ယူဆာရဲ့ ကီးကို စက်ထဲမှာပဲ ဝှက်စာစနစ်နဲ့သိမ်းထားပြီး သူတို့ ဆာဗာဆီကိုဘာမှမပို့အောင် လုပ်ထားကြပါတယ်။ Wallet အတုတွေကတော့ ကိုယ့် key တွေကိုမသွားနိုင်ပါတယ်။

English

Recently, cryptocurrency prices started climbing again, and alongside this trend, web3 companies are gradually moving into the mainstream. This sparks a thought: it’s about time we dive into web3 and blockchain technologies, considering there’s so much we can do with them. This got me pondering a question I hadn’t really thought about before. When we use cryptocurrency wallets, who checks if the private and public keys (wallet addresses) match up? And where are these keys stored? Are they with wallet companies or in some centrally controlled databases? An IT buddy asked me this.

After giving it some more thought, it kind of makes sense. Talking about cryptocurrencies, there’s both a technical aspect and a trading aspect to it. This time, let’s focus on the technical side.

First off, cryptocurrency wallet keys aren’t stored in any central server.

Here, I’m not talking about exchanges that handle our transactions. Cryptos on exchanges are stored in their wallets, not ours.

The moment you set up your own wallet using something like Trust Wallet or Metamask, these wallet apps generate a lengthy binary number randomly. This number is then split into 12 to 24 segments, ranging from 0 to 2048, and converted into a list of English words, known as a seed phrase, thanks to a system called BIP 39, part of the Bitcoin Improvement Proposal. This seed phrase is essentially the key to unlocking your wallet.

Upon generating a private key, cryptographic algorithms kick in to produce a corresponding public key (or wallet address) from the wallet apps. The algorithms used here could be Elliptic Curve Cryptography (ECC) or the RSA algorithm. These algorithms are designed so that while the private key can generate the public key, the reverse isn’t possible even with today’s most advanced computers.

Wallet addresses are shared in a hashed version, making them widely transmissible and readable. Whenever you’re sending a cryptocurrency, the long string of letters and numbers, which could also be a QR code, is essentially the address. And know this: the private key and the public key address are never stored together anywhere. The only thing that can match these keys is the cryptographic algorithm itself, which is embedded in the wallets. When you input your seed phrase, the algorithm decrypts it to output your public key, allowing you to see your cryptocurrencies tied to that public key.

In reality, all you need to keep safe is a list of 12 English words like Apple, orange, computer, etc., which can be written down on paper or stored in a secure hardware wallet. One might wonder, can’t someone just randomly guess these 12 words and access wallets? With 2048 possible words for each slot, you’d need to try 5,444,517,870,735,015,415,413,993,718,908,291,383,296 times. Even attempts with the most advanced technology today can’t crack it, especially since wallets could implement additional security layers like passcodes.

Moreover, creating a wallet doesn’t mean you can only use it within that wallet. They’re just intermediaries. If you have your seed phrase (or private key), you can log into any wallet. These private keys aren’t sent to the wallet’s servers; genuine wallets keep your key encrypted on your device only and don’t send anything to their servers. Phony wallets, however, can’t access your keys.

--

--

Nyein Chan Ko Ko

Medical doctor ,Seasoned programmer, Data enthusiast . Interested in AI, blockchain, politics , health. MB,.BS, MSc Healthcare Informatics