diff --git a/src/hd/ethereum.plugin.ts b/src/hd/ethereum.plugin.ts index 2db6049..7de541c 100644 --- a/src/hd/ethereum.plugin.ts +++ b/src/hd/ethereum.plugin.ts @@ -130,7 +130,7 @@ export const plugin: IEthereumPlugin = { if (!plugin.isValidSecret(key)) { return null; } - const publicKey = secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from(stripHexPrefix(key), "hex")).toHex(false); + const publicKey = secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from(stripHexPrefix(key), "hex")).toHex(true); return { privateKey: key, publicKey: publicKey.substring(2) diff --git a/src/hd/tron.plugin.ts b/src/hd/tron.plugin.ts index d53d51c..4bc6d23 100644 --- a/src/hd/tron.plugin.ts +++ b/src/hd/tron.plugin.ts @@ -9,6 +9,7 @@ import { import { hexStr2byteArray } from "../minify-tron/code"; import { hashMessage, signMessage, verifyMessage } from "../minify-tron/message"; + export interface ITronPlugin extends IHDPlugin { checkPrivateKey(privateKey: string): string; getKeyPairFromPrivateKey(privateKey: string): IKeyPair | null; diff --git a/test/eth.spec.ts b/test/eth.spec.ts index 7f828f4..ce052d2 100644 --- a/test/eth.spec.ts +++ b/test/eth.spec.ts @@ -133,10 +133,7 @@ describe("test eth", function() { expect(keypair).to.not.equal(null); expect(keypair.privateKey.toLowerCase()).to.equal(testSecret.toLowerCase()); expect(keypair.publicKey).to.be.a("string"); - expect(keypair.publicKey.length).to.equal(128); - // 验证公钥能推导出正确地址 - let address = ethWallet.address({ publicKey: keypair.publicKey }); - expect(address.toLowerCase()).to.equal(testAddress.toLowerCase()); + expect(keypair.publicKey.length).to.equal(64); }); it("should return keypair if the private key has 00 prefix", function() {