iT邦幫忙

0

區塊鍊相關:Filecoin創建離線錢包失敗,錢包地址該如何創建?

  • 分享至 

  • xImage

想詢問加密何處出錯了,地址不正確,要如何修改才能與線上錢包相符?

import org.bitcoinj.core.ECKey;
import org.bitcoinj.crypto.MnemonicCode;
import org.bitcoinj.crypto.MnemonicException;
import ove.crypto.digest.Blake2b;
ECKey ecKey = new ECKey();
byte[] privKeyBytes = ecKey.getPrivKeyBytes();
byte[] pubKey = ecKey.getPubKey();
if (privKeyBytes == null || privKeyBytes.length < 1) {
	throw new RuntimeException("create wallet error");
}

Blake2b.Digest digest = Blake2b.Digest.newInstance(20);
String hash = HexUtil.encodeHexStr(digest.digest(pubKey));

String pubKeyHash = "01" + HexUtil.encodeHexStr(digest.digest(pubKey));

Blake2b.Digest blake2b3 = Blake2b.Digest.newInstance(4);
String checksum = HexUtil.encodeHexStr(blake2b3.digest(HexUtil.decodeHex(pubKeyHash)));

String filAddress = "f1" + Base32.encode(HexUtil.decodeHex(hash + checksum)).toLowerCase();
String privatekey = HexUtil.encodeHexStr(privKeyBytes);
log.info("filAddress " + filAddress);
log.info("privatekey " + privatekey);

計算出的地址和私鑰
https://ithelp.ithome.com.tw/upload/images/20220729/20134031EFw9waGKSs.png
filAddress: f16ebk5pxt7e4jnwstipx4idlg6a2zxf6had6xhpq
privatekey: feefd45a6c43ed513c162aa023aeb95256e2fbca23d8de3d321f9b9be9f6aa2b

到FilBox錢包測試計算出的私鑰
結果現在錢包顯示地址為:
https://ithelp.ithome.com.tw/upload/images/20220729/20134031S1oNlo1hcX.png

程式加密要如何修改才能讓計算出來的filAddress與線上錢包相符?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答