Keccak256 From Scratch in 200 Lines of Kotlin (Because Web3j Was 8 MB)
A developer created a lightweight implementation of the Ethereum hash function Keccak256 in Kotlin. This was done to avoid the large size of the Web3j library, which is over 8 MB, while the developer's APK is only 4.5 MB. The new implementation consists of 200 lines of code and has zero dependencies beyond what Android provides natively.
- ▪The developer aimed to build a native Ethereum wallet without relying on external applications like MetaMask.
- ▪Web3j's size was a significant concern, prompting the developer to create a custom solution.
- ▪The entire crypto layer, including Keccak256, RLP encoder, and ECDSA wrapper, is under 50 KB.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3934022) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Alexandre Lasly Posted on May 19 Keccak256 From Scratch in 200 Lines of Kotlin (Because Web3j Was 8 MB) #kotlin #ethereum #crypto #android Web3j is 8 MB. My APK is 4.5 MB. So I wrote the Ethereum hash function from scratch. Why Not Just Import Web3j? I was building a native Ethereum wallet inside an Android Capacitor app. The goal: sign transactions without MetaMask, without WalletConnect, without any external app.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).