- Run node server
# build source code
cd cmd/node
go build
# run node grpc server (default port: 5566)
./node run -p ${PORT}
- Run node client
# run node grpc client related cmd (default server: "127.0.0.1:5566")
# add tx (default from/to: random string)
./node addtx -h
./node addtx -s ${SERVER} -from ${FROM} -to ${TO} -v ${VALUE}
# list related status
./node list -h
./node status -h
# more info
./node -h
- (optional) Run node grpc gateway
# run node grpc gateway
cd cmd/node_gateway
go build
./node_gateway -grpc ${SERVER} -p ${PORT}
# add tx
curl --location --request POST 'http://localhost:7788/tx/add' \
--header 'Content-Type: application/json' \
--data-raw '{
"from": "0x71a0DF94Dd9c9390Cf5e0BD87190F111cd55C325",
"to": "0x0F86Cd82Ff4BA6FbB1655F44EA26b93d150E11E0",
"value": 100
}'
# list balances
curl http://127.0.0.1:7788/balance/list
# list blocks
curl http://127.0.0.1:7788/block/list
# get node status
curl http://127.0.0.1:7788/node/status
-
什麼是公私鑰? 公鑰私鑰運作場景是什麼? 什麼是簽名?
- 公鑰(Public key): 能被廣泛的發佈與流傳
- 私鑰(Private key): 不公開, 被妥善保管
- 運作場景:
運作原理是傳送方與接收方在傳送之前,先把彼此的公鑰傳給對方,當傳送方要傳送時,就用接收方的公鑰將訊息加密,接收方收到加密訊息後,再用自己的密鑰解開,這樣即使有心人拿到公鑰,只要沒拿到接收方的私鑰,也還是無法解密訊息。 - 數位簽章(Digital Signature):
- 由來: 假設有人在網路上找到了接收方的公鑰,假造一封有病毒的訊息,再用接收方公鑰加密傳過去,這樣接收方一打開不就傻傻中計了嗎?!
- 用途: Double Confirm了,也就是傳送方除了使用接收方的公鑰加密外,也使用自己的私鑰對該封加密訊息的Hash簽名
-
對稱式與非對稱式加密有何不同?
- 對稱式加密- 傳送方與接收方的加解密皆使用同一把密鑰
- 非對稱式加密- 傳送方與接收方加解密用不同密鑰, 雙方皆存在一鑰匙 (公鑰+私鑰)
-
什麼是 Challenge-Response Authentication?
- 其中一方提出問題,另一方必須提供有效答案才能進行身份驗證
-
什麼是多簽 (Multisignature)? 比特幣的多簽地址是什麼?
-
多簽 Multisignature
一種特定類型的數位簽章,而此類型的簽名將允許兩個以上用戶作為一組來簽署文檔。因此,多重簽名則通過多個單一簽名的組合來產生。 -
Creating a Multisignature Address with Bitcoin-Qt
- Gather (or generate) 3 bitcoin addresses (RPC cmd: getnewaddress or getaccountaddress)
- Get their public keys. (RPC cmd: validateaddress)
- Then create a 2-of-3 multisig address using addmultisigaddress; e.g.
# addmultisigaddress returns the multisignature address. > bitcoind addmultisigaddress 2 '["1st pubkey","2nd pubkey","3rd pubkey."]'
-
-
什麼是 Hash 函數? 有什麼特性? 什麼是 Proof of Work (PoW)?
- Hash Function
主要是將不定長度訊息的輸入,演算成固定長度雜湊值的輸出,且所計算出來的值必須符合兩個主要條件:- 由雜湊值是無法反推出原來的訊息
- 雜湊值必須隨明文改變而改變
- Proof of Work (PoW)
一種對應服務與資源濫用、或是阻斷服務攻擊的經濟對策。一般是要求使用者進行一些耗時適當的複雜運算,並且答案能被服務方快速驗算,以此耗用的時間、裝置與能源做為擔保成本,以確保服務與資源是被真正的需求所使用
- Hash Function
- Reference:
- Compare the difference between account/UTXO based models.
Account | UTXO (Unspent Transaction Output) | |
---|---|---|
原理 | 保存了世界狀態,鏈的狀態一般在區塊中以 StateRoot 和 ReceiptRoot 等形式進行共識交易只是事件本身,不包含結果,交易的共識和狀態的共識本質上可以隔離的. | 交易只是代表了 UTXO 集合的變更. 每個交易消耗之前交易生成的 UTXO 然後生成新的 UTXO, 帳戶的餘額即所有屬於該地址的未花費 UTXO 集合. |
優點 | * 擁有自身狀態 * 批量交易的成本較低 |
*交易無法被重放 * 無狀態的,更容易並發處理 |
缺點 | * 交易之間沒有依賴性,需解決重放問題. * 對於實現閃電網絡/雷電網絡,Plasma 等,用戶舉證需要更複雜的 Proof 證明機制,子鏈向主鏈進行狀態遷移需要更複雜的協議 (?!) |
* 當 Input 較多時,見證腳本也會增多。而簽名本身是比較消耗 CPU 和存儲空間的 |
- How to ensure transaction order in an account based model?
- Ethereum 使用了在 Account 中增加 nonce 的方式,每筆交易對應一個 nonce,nonce 每次遞增。這種方式雖然意在解決重放的問題,但是同時引入了順序性問題,同時使得交易無法並行。例如在 Ethereum中,用戶發送多筆交易,如果第一筆交易打包失敗,將引起後續多筆交易都打包不成功。
- What is transaction/block?
- Why is setting block generation time necessary?
- When to update the account balance?
-
UTXO
- https://medium.com/%E4%B8%80%E5%80%8B%E5%AE%B9%E6%98%93%E5%81%A5%E5%BF%98%E7%9A%84%E5%A4%A7%E5%AD%B8%E7%94%9F/%E4%BB%80%E9%BA%BC%E6%98%AFutxo-40b62e73c84d
- https://ithelp.ithome.com.tw/articles/10216976
- https://kknews.cc/zh-tw/tech/g92mrem.html
- https://ethereum.stackexchange.com/questions/326/what-are-the-pros-and-cons-of-ethereum-balances-vs-utxos
- https://eth.wiki/en/fundamentals/design-rationale
-
比特幣 區塊鏈 幾種交易標準詳解 P2PKH、P2PK、MS、P2SH加密方式
-
可替代性(fungibility)
-
什么是Plasma?Plasma Cash?
-
coinbase
-
cosmos
-
blockchain database
-
github
- https://github.com/yeasy/blockchain_guide
- https://github.com/izqui/blockchain
- https://github.com/Jeiwan/blockchain_go
- https://github.com/tendermint/tendermint
- https://github.com/web3coach/the-blockchain-bar
- https://github.com/ethereum/go-ethereum.git
- https://github.com/ZtesoftCS/go-ethereum-code-analysis/blob/master/go-ethereum%E6%BA%90%E7%A0%81%E9%98%85%E8%AF%BB%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md
- https://github.com/miguelmota/ethereum-development-with-go-book/tree/master/code
-
others
- https://www.freecodecamp.org/news/build-a-blockchain-in-golang-from-scratch/
- https://www.guru99.com/blockchain-tutorial.html
- https://medium.com/@mycoralhealth/code-your-own-blockchain-in-less-than-200-lines-of-go-e296282bcffc
- https://applicature.com/blog/blockchain-technology/blockchain-code-examples
- https://arxiv.org/pdf/2003.14271.pdf
- https://cypherpunks-core.github.io/ethereumbook_zh/07.html
- https://fullstacks.org/materials/ethereumbook/07_transactions.html
- https://ithelp.ithome.com.tw/articles/10216297
- https://learnmeabitcoin.com/technical/block-header
- https://medium.facilelogin.com/the-mystery-behind-block-time-63351e35603a