Skip to content

Commit

Permalink
Merge pull request #114 from bianjieai/ori/eth_signer
Browse files Browse the repository at this point in the history
1. add function to parse tx signer who using eth_secp256k1.
  • Loading branch information
prolenking authored Nov 17, 2022
2 parents bc84012 + f78f199 commit 9391d10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/irita/sdk/key/EthSecp256k1KeyManger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
19 changes: 17 additions & 2 deletions src/main/java/irita/sdk/key/KeyEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

0 comments on commit 9391d10

Please sign in to comment.