Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hd/ethereum.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/hd/tron.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions test/eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down