read.cash Log in
@liwi more from that month

之前分享了 Web 3 聊天工具 chat.blockscan.com https://noise.cash/post/l76g6r0m 那就想 MetaMask 應該也可以有加解密的功能 一個使用情境就可以是 用公鑰發送加密訊息給錢包的主人 錢包主人在私鑰不露出的情況下用 MetaMask 解密 跟比特幣一樣 只要某地址簽署過交易從可從鏈上資料還原出公鑰 https://ethereum.stackexchange.com/questions/13778/get-public-key-of-any-ethereum-account MetaMask 也的確有 eth_decrypt 與 eth_getEncryptionPublicKey 兩個功能 https://docs.metamask.io/guide/rpc-api.html#unrestricted-methods 使用方式如下列說明範例: https://github.com/miguelmota/metamask-encryption-example/blob/master/public/main.js https://community.metamask.io/t/how-to-encrypt-message-by-metamask-encryptionpublickey/9746/2 實際開始作後卻發現 拿公鑰來加密的訊息 eth_decrypt 一直過不了 追到底後才發現 eth_getEncryptionPublicKey 並不是直接給出公鑰 而只是用該帳戶的亂度源產生: Requests that the user shares their public encryption key. Returns a Promise that resolve to the public encryption key, or rejects if the user denied the request. The public key is computed from entropy associated with the specified user account, using the nacl implementation of the X25519_XSalsa20_Poly1305 algorithm. 所以才叫 public encryption key 吧... eth_getEncryptionPublicKey 看起來就比較混淆 跟之前手作 BCH 交易送上鏈的時候 https://noise.cash/post/1jpnrm08 的感覺有點像 那就是 cryptography 相關的說明似乎都很 cryptic 阿阿阿阿阿 那如果還要另外跟對方要 public encryption key 才能發送加密訊息的話 那就沒什麼用了 就只是已知用火的非對稱加密而已 Smartify 有個我想做的功能是 Make Offer 那除了公開的出價以外 如果能有私下徵詢的方式我想應該也很不錯 所以本來想用公鑰作文章 但目前看來沒辦法在 MetaMask 的架構下做 用私鑰露出(or keystore file + paraphrase 輸入)的方式當然可以解決 但某種程度來說就失去了 Web3 錢包的意義 Electron Cash 的加解密功能就比較有用(介面也是做的很 cryptic) Smart Waifu 空投就做了很好的示範 (雖然後來改成我認為比較合乎使用邏輯的簽名方式來處理)

No comments yet

Log in to join in Reading is open to everyone. Replying needs an account.