Filecoin When creating a wallet, the private key does not match the address

90 views Asked by At
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);

get the private key and address

filAddress: f16ebk5pxt7e4jnwstipx4idlg6a2zxf6had6xhpq

privatekey: feefd45a6c43ed513c162aa023aeb95256e2fbca23d8de3d321f9b9be9f6aa2b

--

But in FilBox Wallet, f1ttae4urm7hyvplmcwelch37srdjb77tdi5kz2wy is the correct address

How can i modify my code to make the address correct?

0

There are 0 answers