FILCOIN私钥和标准(ETH)私钥相互转换Java

/ Java / 0 条评论 / 1600浏览

// 标准私钥转FIL私钥 private static String convertOriginKeyToLotusKey(String originKey) { String encode = Base64.encode(HexUtil.decodeHex(originKey)); HashMap<String,String> map = new HashMap<>(); map.put("Type", "secp256k1"); map.put("PrivateKey", encode); String json = JSON.toJSONString(map); return HexUtil.encodeHexStr(json); } // FIL私钥转标准私钥 private static String convertLotusKeyToOriginKey(String lotusKey) { String decodeHexStr = HexUtil.decodeHexStr(lotusKey); JSONObject jsonObject = JSONObject.parseObject(decodeHexStr); String privateKey = jsonObject.getString("PrivateKey"); return HexUtil.encodeHexStr(Base64.decode(privateKey)); }