diff --git a/src/main/java/irita/sdk/key/EthSecp256k1KeyManger.java b/src/main/java/irita/sdk/key/EthSecp256k1KeyManger.java index f31ff40..18182ea 100644 --- a/src/main/java/irita/sdk/key/EthSecp256k1KeyManger.java +++ b/src/main/java/irita/sdk/key/EthSecp256k1KeyManger.java @@ -33,7 +33,7 @@ public KeyInfo toKeyInfo(BigInteger privKey) { @Override public String toAddr(byte[] publicKey) { - ECPoint pubKey = CURVE.getCurve().decodePoint(Hex.decode(publicKey)); + ECPoint pubKey = CURVE.getCurve().decodePoint(publicKey); return pubKeyToAddress(pubKey); } diff --git a/src/main/java/irita/sdk/key/KeyEnum.java b/src/main/java/irita/sdk/key/KeyEnum.java index 75c5524..247c6fd 100644 --- a/src/main/java/irita/sdk/key/KeyEnum.java +++ b/src/main/java/irita/sdk/key/KeyEnum.java @@ -5,9 +5,7 @@ import proto.cosmos.crypto.sm2.Keys; import java.util.NoSuchElementException; -import java.util.function.BiFunction; import java.util.function.Function; -import java.util.stream.Stream; /** * @author : ori @@ -58,6 +56,23 @@ public enum KeyEnum { return new byte[]{}; } }), + + ETH_SECP256K1_PUB_KEY("/ethermint.crypto.v1.ethsecp256k1.PubKey", proto.ethermint.crypto.ethsecp256k1.Keys.PubKey.class, AlgoEnum.ETH_SECP256K1, o -> { + try { + return o.unpack(proto.ethermint.crypto.ethsecp256k1.Keys.PubKey.class).getKey().toByteArray(); + } catch (InvalidProtocolBufferException e) { + e.printStackTrace(); + return new byte[]{}; + } + }), + ETH_SECP256K1_PRIV_KEY("/ethermint.crypto.v1.ethsecp256k1.PrivKey", proto.ethermint.crypto.ethsecp256k1.Keys.PrivKey.class, AlgoEnum.ETH_SECP256K1, o -> { + try { + return o.unpack(proto.ethermint.crypto.ethsecp256k1.Keys.PrivKey.class).getKey().toByteArray(); + } catch (InvalidProtocolBufferException e) { + e.printStackTrace(); + return new byte[]{}; + } + }), ; private final String typeUrl; diff --git a/src/test/resources/config.properties b/src/test/resources/config.properties index d4be985..3db45dd 100644 --- a/src/test/resources/config.properties +++ b/src/test/resources/config.properties @@ -3,7 +3,7 @@ address = iaa1ytemz2xqq2s73ut3ys8mcd6zca2564a5lfhtm3 node_uri = http://testnet.bianjie.ai:26657 grpc_addr = testnet.bianjie.ai:9090 chain_id = testing -ws_addr = ws://47.100.192.234:26657/websocket +ws_addr = ws://testnet.bianjie.ai:26657/websocket project_id = project_key = \ No newline at end of file