📜 [專欄新文章] Scaling Ethereum 參賽心得
✍️ Johnson
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Scaling Ethereum 是一場由 ETHGlobal 所舉辦的線上黑客松,也是我第一次參加與以太坊有關的黑客松活動,這篇文章就來分享一人參賽的過程與心得。
源起
一開始是在 telegram 群組中得知這場比賽的消息,因緣際會之下剛好有人想組隊參賽,於是就在報名截止的前一天一起跟著報名了。
報名的方式除了填一些基本資料外,最特別的是還要 stack 以太幣,也就是要傳送 0.01 顆以太幣給主辦方,規則是必須在比賽的最後,有提交作品的人才能贖回 0.01 顆以太幣,之後看到 meme 頻道有人留言:
When your project is incomplete but you submit to get back stake.
一方面,這確實也會激勵你好好把比賽完成,就算沒做完也要有些成果上去,這也是主辦方秉持的精神,他們認為大家來黑客松相互學習成長,競賽獎金則是其次。
獎金
比賽方式是由 25 個左右的贊助者(sponsor)分別提供獎金,每個 sponsor 都有錄製一段影片,說明怎麼獲得他們的獎金,大部分會要你使用他們開發的工具,或者必須跟 sponsor 在做的研究有關,去實作出創新的作品。可參考:Prizes — Scaling Ethereum
你的專案可以選擇要投入哪個 sponsor 的獎金,一個專案可以投入多個 sponsor 底下,這樣獲獎機會也會比較高。
我選擇的 sponsor 是 zkSync,他們的說明如下:
zkSync is a user-centric zkRollup developed by Matter Labs. It uses zero-knowledge proofs to keep data availability on mainnet to achieve exponentially lower transaction costs. You may have seen us powering projects such as payments and Gitcoin Grants. We are currently rapidly developing zkSync 2.0, which will feature EVM-compatibility in testnet May 2021, soon followed by zkPorter, our new exponential scalability solution.
PrizeszkSync will be awarding their Prizes as follows:
- 1 winner — 4,000 USDC
- 2 winners — 2,000 USDC
- 4 winners — 500 USDC
We encourage builders to utilize zkSync SDK’s, implemented in JavaScript/Typescript and Rust. Prizes will be awarded to projects that make it simpler and easier for non-technical users to use zkSync, other ideas include integrations of current tools such as in Gitcoin Grants and tools for easy mass payments and multi-sigs.
社群互動
這個 hackathon 很棒的地方是他把使用者體驗做的很好。每個人都會有自己的 dashboard 顯示目前專案的進度和一些訊息。
Check-In #1 和 Check-In #2 的階段會要你提供專案的構想,你隨時都可以修改。主辦方會看你提交的資訊,幫助你找到適合的 sponsor,或是給你一些建議,就算是一人參賽也能感受到回饋。
整個賽程期間,社群都是使用 discord 在互動,discord 裡頭有很多頻道,像是基本的大會報告的頻道,或是一些不重要的迷因、閒聊頻道都有。
每個 sponsor 也都有自己的頻道,我就會在 sponsor-zksync 的頻道詢問技術的問題,例如我想問問 zkSync 一些關於專案構想的意見:
Hi there, I want to build a gas fee relayer which make my ERC-20 token transfer without transaction fee, to be more precise, delegating gas payment by another party. I think this is done by GSN https://opengsn.org/ , but maybe it could built on L2 with zkSync? I’m not sure, could somebody give me some advice about this topic?
zkSync 團隊的人回應我:
This is an amazing idea! This can totally be built, as we support batching transactions which can be used for all kinds of creative things such as paying for transaction fees in an erc-20 token. Your idea seems like a combination of that and the gitcoin grants integration. To get started, I suggest you watch the short 10 minute presentation I made on using the SDK and batching. Looking forward to your project!!
在 Check-In #2 的時候,我提交新版的專案構想,有一個欄位是問:「目前專案遇到什麼阻礙?」我的問題應該是被主辦方貼給 zkSync 的團隊,於是 zkSync 的團隊成員就用 discord 私訊我,貼了一些程式碼教我怎麼使用他們的 Javascript SDK,這突如其來的救援也幫了大忙。
除此之外,主辦方每個禮拜都會寄 email 通知一些重要的活動,賽程期間舉辦了四個 Summits 研討會,邀請世界各地有名的以太坊開發者分享議題,主辦方還有一個自己的 TV 網頁,直播所有的線上活動。這些活動都有錄影,可以在 youtube 看到過去所有的演講內容:https://www.youtube.com/c/ETHGlobal/videos
因為我的作品是使用 zkSync 的 Javascript SDK 製作的,好像也只能投稿 zkSync 作為獎金的 sponsor,不過主辦方在最後一個禮拜,也寄 email 告訴我說可以多投稿不同的 sponsors 看看,他依據我的專案構想給我一些適合的 sponsors 作為參考。
不過最後我還是只投稿了 zkSync,有點懶著再看其他 sponsors 的文件,也覺得其他 sponsors 的題目需要花比較大的功夫才能完成,一個人能力有限,就做點簡單的東西就好。
關於我的專案 — Gas Relay Service
在以太坊的世界,每一筆交易都需要額外付一筆交易費,也就是以太坊的 gas fee。
我的專案是讓「收款人」能夠幫「付款人」支付以太坊的手續費。
在黑客松之前,我就想研究「第三方支付手續費」的議題,因此我大部分時間其實都在研究一般的 meta-transactions 是怎麼實作的,有興趣的人可以看看 simple meta-transactions 的原始碼:https://github.com/chnejohnson/simple-meta-transaction
之後我才開始玩 zkSync 的 SDK,並研究怎麼在 Layer 2 實現第三方支付手續費的問題,以下就附上作品連結以及簡單的專案介紹給有興趣的人參考:https://showcase.ethglobal.co/scaling/gas-relay-service-on-zksync
The target is that token sender can choose to find another account to pay for fee. The another account can be (1) the token receiver’s account, (2) sender’s another account, (3) third party’s account.
In this project, I finished the demo, which is the (1) above, that receiver pay gas fee for the sender.
有趣的是,我在研究 meta-transactions 時學到很多智能合約的寫法,結果在最後專案上都沒用到(沒寫到合約的程式),zkSync Javascript SDK 其實很簡單,他們的文件寫得很清楚。最後 Demo 還是用 zkSync 團隊的成品修改來的…XD。
所幸在沒有懂太多技術的前提下完成了這場黑客松的專案,成功贖回了 0.01 顆以太幣。
評審與決選
整個賽程來到最後一個禮拜,主辦方安排兩天的時間進行 Judges,使用 zoom 進行線上研討會,一個人基本上是 7 分鐘,前 4 分鐘播放 Demo 簡報,後三分鐘會有評審問問題。
第一個問題是說:「Demo 中你是使用 zkSync 的錢包網頁去操作,那實際上你做得部分是什麼?」
我就回答我在他們的網頁上加了一顆按鈕,使用他們的 SDK 做出 gas relay 的功能,還有一個後端的 server 去作 relay。
第二個問題大概是問:「什麼樣的情境下會需要由 receiver 幫 sender 支付 gas fee?」
我的回答是,在一般超商購物的情境,消費者通常只支付商品的價格,不會支付額外的交易費,我認為以太坊的手續費應該屬於軟體的營運成本,由賣方支付比較適合。那如果賣方希望手續費的成本是由消費者承擔,可以直接調高商品的價格。
當然,我英文講得零零落落,希望評審有聽懂就是了…
最後一場直播就是 Finale 決選,主辦方選出十二個隊伍,公開再 Demo 一次,以及提供線上觀眾詢問問題,至此整個賽程就差不多進入尾聲。
決選後的不久,主辦方就公布了這次有獲得獎金的隊伍,幸運拿到了 zkSync 頒發的小獎~
zkSync — Matter Labs
- Zeneth — 2000 USDC
- ZeroSwap — 1500 USDC
- Kangaroo — 500 USDC
- Gas Relay Service — 500 USDC
後記
這次的參賽隊伍中,Zeneth 跟我的主題非常相似:
Zeneth — Use Flashbots to enable arbitrary meta-transactions so EOAs can enter L2s without ETH
另一個我覺得有趣的專案是 Alexandria:
Alexandria — A dApp using STARKs to verify aspects of your identity without revealing more than you should
沒想到主辦方 ETHGlobal 下個月又要再舉辦一場黑客松,有興趣的人可以看看:https://defi.ethglobal.co/ ,這次的主題是 De-Fi。
最後,只要有到 ETHGlobal 的 TV 網頁參加 Summit 研討會的直播,就能夠獲得 POAP 勳章,它就是一個酷東西~😋
POAP: Proof of Attendance Protocol
Scaling Ethereum 參賽心得 was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有1部Youtube影片,追蹤數超過3萬的網紅Brian2Taiwan,也在其Youtube影片中提到,Taiwan Gay Pride in Taipei began with the first parade happening in 2003 with only 20,000 participants. Last year’s parade reported around 137,000 peo...
「taipei story where to watch」的推薦目錄:
taipei story where to watch 在 Taipei Ethereum Meetup Facebook 的精選貼文
📜 [專欄新文章] Using MPC to Help Achieve Blockchain Privacy
✍️ Yahsin Huang
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
This post answers some of the most commonly asked questions about using multi-party computation (MPC) in blockchains.
What is MPC?
Multi-party computation (MPC) is a cryptographic protocol that does a joint computation involving multiple parties over their inputs while keeping those inputs private.
A famous example of MPC is Yao’s Millionaires Problem. Two millionaires want to know who is richer without finding out information about each other’s actual wealth. Naively they can simply tell their wealth to a third party. Then the third party compares their wealth and lets them know who is richer. But then this option is undesirable because the third party learns the information of their wealth.
The challenge of Yao’s Millionaires Problem is the computation wouldn’t be able to have a result without the two parties’ private information. To get the end result, you need those information involved in the computation. But at the same time, you are not allowed to reveal those private information to the party who performs the computation. That’s the main problem that MPC wants to solve.
Why it matters in blockchain?
In the real world, not everyone’s a millionaire. Not everybody wishes to compare their assets and wealth with others. In the blockchain space, there’s a need to ensure the inputs are shielded from multiple parties for privacy purposes; hence, the need for MPC protocols.
If we look at the current landscape of the blockchain world, notice there are blockchains doing great for programmability, such as Ethereum blockchain, allowing developers to build great tools and applications on top of them. There are also blockchains doing great for privacy, such as ZCash blockchain, allowing users to send transactions in a privacy-preserving way.
However, there’s a lack of blockchains that are designed for maximum programmability with maximum privacy. That’s why a lot of folks are pushing forward the work on incorporating MPC protocols into blockchain designs.
Why ZK is not enough?
Zero Knowledge Proofs (ZKP) is great at shielding private information that involves only one party. ZKP alone cannot be applied to provide privacy in multiple-party settings, such as auctions or in the case of Yao’s Millionaires Problem. In those settings, computations would involve private inputs from multiple parties, and so ZKP wouldn’t be enough. We would need to turn to MPC to achieve that.
Recent developments in MPC
In his presentation “MPC as a Blockchain Confidentiality Layer,” Miller gave a high-level overview of how MPC can be viewed as a confidentiality layer for blockchains as illustrated in the slide. Credit: https://youtu.be/0VuBELYfChM
How does MPC work with blockchains?
HoneyBadgerMPC builds a sidechain that performs MPC protocol computation. The sidechain acts as a confidentiality layer to the public blockchain, where secret data is stored.
How can developers build MPC applications?
Developers are able to develop MPC applications with Ratel language. Writing Ratel feels very similar to writing Solidity contracts. The compiler compiles Ratel code into two parts: the Ethereum part, and the MPC as a sidechain part.
Ratel code looks like this: https://github.com/initc3/HoneyBadgerSwap/blob/coconut/ratel/trade.rl
Learn more about MPC as a sidechain
One of the biggest news this past month was you could now play with HoneyBadgerSwap’s demo website. HoneyBadgerSwap is basically a dark pool version of Uniswap using MPC. You will need some Kovan ETH to test it out. Yunqi Li (UIUC, IC3) made a great Medium story about HoneyBadgerSwap. Read it here: “HoneyBadgerSwap: Making MPC as a Sidechain,” published on April 22, 2021.
Watch a really great talk by Andrew Miller “MPC as a Blockchain Confidentiality Layer,” presented at the IC3 Blockchain Camp 2020, to understand the HoneyBadgerMPC protocol more.
If you are someone who would like to delve into the topic with textbooks, be sure to add the book “A Pragmatic Introduction to Secure Multi-Party Computation” to your reading list. The content is available in PDF.
Using MPC to Help Achieve Blockchain Privacy was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
taipei story where to watch 在 Taipei Ethereum Meetup Facebook 的最讚貼文
📜 [專欄新文章] Private key security and protection / 私錀的安全與保護 — Tim Hsu
✍️ 洪偉捷
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Private key security and protection / 私錀的安全與保護 — Tim Hsu
Crosslink Taipei 在10/19、10/20 台北矽谷會議中心舉辦的 區塊鏈conf。 這是Crosslink Taipei 下午的演講,主講者是擔任CYBAVO CTO的徐千洋(Tim Hsu)先生,同時也是幣托、OTCBTC的資安顧問。
2018年一月被發現的硬體漏洞meldown跟spectr,我們的硬體為了要讓執行速度更快,processor會預先執行某些指令,也因此駭客可以透過這種方式,間接檢測出我們記憶體的內容,把敏感資訊都dump出來。雖然後這之後各CPU廠商都有推出針對這個bug的軟體update,但是在這之後硬體安全的問題逐漸浮出來面,也使世人意識到硬體資安的問題。而今天我們要談的部分不僅有軟體安全,也有硬體安全跟使用者資安觀念的問題。
淺談交易所與錢包
在從交易所提幣的時候,首先Server會先將這筆交易紀錄到交易所自己的資料庫內,之後再取得交易所金庫的private key去金庫取錢,再打到使用者的錢包內。在這個過程中,如果駭客可以竄改Server或資料庫的交易金額,原本要打給使用者1 BTC,變成10BTC,或是直接取得金庫的private key,對交易所都是一大噩夢
圖(一) 從交易所提幣的流程
攻擊手法
1. 交易所的網路架構
案例一: 交易所因為怕被偷交易資料與客戶資料,所以都把這些資訊先加密後再存到資料庫,但是這些資料仍然會被偷(交易所遭到電話詐騙),往後將這些資料加了三層密,仍無法防範資料被偷的情形,原因出在圖(二)的交易所網路架構。
圖(二) 交易所的網路架構(OA與資料庫間沒防火牆)
因為OA 與資料庫之間的網路沒有防火牆保護,所以駭客不用正面攻擊有防火牆的部分,而是攻擊OA的部分,再藉由OA連線到資料庫。一封藏有病毒的email求職信寄到HR的電腦,都有可能造成交易所資料外流。
解決方式: 就是在OA與資料庫間架個防火牆,如圖(三)所示。例如: 只有Engineer、RD 可以連線到資料庫,QA則只能連到測試環境,HR、CEO不需要、也不能連線到資料庫,依職責對連線範圍做縮限,則駭客可以攻擊的目標變少,我們也比較好做應對。講者重要的一句話: 「千萬不要輕忽駭客攻擊OA的能力」
圖(三) 好的交易所的網路架構
2. DNS Attack
透過汙染AWS 的DNS Server 將交易所網頁導向駭客的網頁,來騙取使用者個資。雖然在導向駭客頁面時,很容易發現駭客的網頁沒有使用安全憑證,或是安全憑證不是SSL核發,但使用者仍可能因資安觀念低落,而堅持連線到不安全的網站。
3. Online Paper Wallet
很多人因為覺得私鑰放電腦覺得不安全,又沒錢買硬體錢包,所以透過線上私鑰轉換器將私鑰轉換成QR code,然而再轉換時勢必要輸入自己的私鑰,容易使私鑰遭竊。
圖(四) 私鑰轉換詐騙網頁
4. 使用者對私鑰保護的意識很低
例如: 不了解私鑰的註記詞或其他相關資訊保密的重要性,而無意間通過社交軟體洩漏了這些重要資訊(硬體錢包開箱文 XD)。
5. 硬體錢包的漏洞
TREZOR 錢包是業內公認的研發最早最警慎最安全的加密儲存器,但是今年仍被發現硬體相關的漏洞。只要駭客輸入特定24碼pin碼,就可以通過硬體的側通道分析,輕易提取出未加密的私鑰,而且這個必須重新設計硬體架構才能夠防止這樣的攻擊。所以即便硬體錢包掉了,仍有被攻擊的疑慮,最好的解決辦法就是硬體錢包外再設定一個long Password,這樣就可以避免掉硬體錢包時帳戶虛擬貨幣遭竊
圖(五) 硬體錢包漏洞
題外話 — Iphone Jailbreak問題
今年在twitter,有人公布了最新攻擊iphone的方式,而問題出在手機晶片。Iphone開機時第一個執行的程序是 bootrom,而bootrom的程式碼則是位於記憶體唯獨區域,所以無法竄改。駭客可以利用bootrom上的bug來攻擊手機,而這些有問題的晶片出現在Iphone 6 ~ Iphone X。其實這攻擊方式充滿限制,不僅要取得欲攻擊的手機,而且這種攻擊方式每次重開機就會刷新。不過這也衍伸出新的問題,以後的iOS作業系統都更容易遭到入侵,因為我們可以在舊的手機上裝新的iOS系統,然後透過bootrom的漏洞來了解新的iOS系統的運作方式,因此這個問題應該被更加重視。
圖(六) axi0mX針對此bug的文章
保護方式
透過secure sharing將私鑰拆成User、Company、Vendor,分散私鑰存放風險
圖(七) 拆散私鑰,分散存放的風險
保護思維
未來除了在演算法的鑽研,也應該多多關注整個 區塊鏈產業的資安問題,從身分認證、系統安全、IT架構,都應該要從安全的角度來設計。
圖(八) 講者參考的設計架構
以上方的圖片為例,很多軟體架構在設計時都忽略了作業系統這一塊,而講者分享了他在設計時針對Server或資料庫的 OS做的處理,如下圖
圖(九) OS層級的安全防護
我們的app、網站、服務都跑在Sandbox層上,Sandbox可以限制由內到外的網路封包收送,同時在Sandbox之上還有Host-IDS(Host-based Intruction Detection System)會記錄及過濾程式在Sandbox跑的所有指令,而且有任何非法存取記憶體或網路封包的行為都會都過Host-IDS被記錄到Threat Intelligence,並且通知使用者。 我覺得這樣的好處是,使用者不僅可以在第一時間知道自己的帳號遭到駭客攻擊,也因為一切的動作都被Host-IDS過濾以及被記錄到Threat Intelligence,工程師也可以更快找到安全漏洞。
結語
近年來因網路的應用,資安越來越重要,除了軟體方面外,硬體方面也要兼顧安全,而使用者的觀念宣導更重要,否則不管我們的系統做的再怎麼嚴密,只要使用者意外連到駭客網站或是洩漏自己的私鑰,一切都是白談。演講中有一句話我覺得很值得借鏡,就是「我們一定要假設我們的系統會被駭客破解,而我們要做的就是盡可能減少被入侵後的損失」,上面提到的Host-IDS就是這樣的觀念,我們無法防止駭客進到Sandbox,但是可以記錄駭客的進到Sandbox後所有行為,這樣的架構才能在第一時間修正系統漏洞。
參考資料
Trezor錢包漏洞: https://bcsec.org/index/detail/id/585/tag/2
Iphone 漏洞: https://www.pcmarket.com.hk/2019/09/30/iphone-bootrom%E8%B6%8A%E7%8D%84%E5%B7%A5%E5%85%B7%E5%85%AC%E9%96%8B-4s%E8%87%B3x%E5%85%A8%E9%81%AD%E6%AE%83%E5%B9%B8%E5%8D%B1%E9%9A%AA%E6%80%A7%E4%BD%8E/
spectre&meldown介紹: https://www.youtube.com/watch?v=bs0xswK0eZk
Private key security and protection / 私錀的安全與保護 — Tim Hsu was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
taipei story where to watch 在 Brian2Taiwan Youtube 的最佳貼文
Taiwan Gay Pride in Taipei began with the first parade happening in 2003 with only 20,000 participants. Last year’s parade reported around 137,000 people attending. Today I want to explain the history of Taipei’s Gay Pride, the largest in Asia and the first in the Chinese community.
Also, did you know that Pride in Taipei is different from Western countries? From the time to how the parade works to what people wear, I explain the differences between Western Pride celebrations and Taiwan’s unique parade. I also share my own story from my first experience at Taiwan Pride.
Finally, today I introduce my new clip-end segment, One Video, One Bit of Taiwanese. I’m going to try to make this a recurring part of my videos where I teach a Taiwanese (Minnan or Southern Hollies) word, saying, or sentence related to the content at the end of each video. Watch to the end to see this segment~
Want to come to Taipei for Pride in October? Or maybe just plan a trip to Taiwan? Click below to checkout deals on flights starting at 15% off~
https://bit.ly/31PlnJq
台灣的第一次同志大遊行在2003年舉辦。那一年只有兩萬人參加。去年的人數大約13萬7千個人。 台灣的大遊行也是亞洲第一名最大也是華人國家第一個。今天我來講一下台灣同志大遊行的歷史。
另外,你知道台灣的同志大遊行跟許多地方國家的不太一樣嗎?時間,遊行方式,還有參與人穿的服裝都有一些不一樣的。我結束幾個西方國家跟台灣的同志大遊行的不一樣,也分享我自己第一次去台北同志大遊行的一個小故事。
最後,今天的影片也有文新的一個企劃
我以後在每部影片後面會加一個跟那部影片有關的台語(閩南話)的單字說,法或,句型
看到最後才會看到這部分喔~
Taiwan Pride website:
https://www.twpride.org
Taiwan Pride Facebook:
https://www.facebook.com/Taiwan.LGBT.Pride/
Youtube:
https://www.youtube.com/c/Brian2Taiwan
Facebook:
https://www.facebook.com/Brian2Taiwan
Instagram:
www.instagram.com/Brian2Taiwan
Twitter:
@Brian2Taiwan
Music:
Nimbus - Eveningland Music
https://www.youtube.com/channel/UCi0uheSErbivC3_662UqL-w
#pride #布萊恩 #TaiwanPride
