Skip to content

Commit

Permalink
Bugfix LIVE 11903 fix btc sign message hex (#6642)
Browse files Browse the repository at this point in the history
* fix: btc signmessage return hex

* fix: changeset

* fix: btc signmessage unit test
  • Loading branch information
hzheng-ledger authored Apr 12, 2024
1 parent fca871f commit 0db1bf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-doors-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/coin-bitcoin": minor
---

fix bitcoin signmessage return from base64 to hex
11 changes: 6 additions & 5 deletions libs/coin-modules/coin-bitcoin/src/hw-signMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe("signMessage", () => {
getWalletPublicKey: jest.fn(),
signMessage: jest.fn().mockResolvedValue({
v: 1,
r: "RRRRRSSSSSRRRRRSSSSS",
s: "SSSSSRRRRRSSSSSRRRRR",
r: "407c9da9dadf23a2d7e863f51aa3512fe3c86619f1d57b16e5d0659155e83888",
s: "207c9da9dadf736839484733637aba12fe3c86619f1d57b16e5d0659155e8388",
}),
splitTransaction: jest.fn(),
createPaymentTransaction: jest.fn(),
Expand All @@ -34,10 +34,11 @@ describe("signMessage", () => {
expect(signature).toEqual({
rsv: {
v: 1,
r: "RRRRRSSSSSRRRRRSSSSS",
s: "SSSSSRRRRRSSSSSRRRRR",
r: "407c9da9dadf23a2d7e863f51aa3512fe3c86619f1d57b16e5d0659155e83888",
s: "207c9da9dadf736839484733637aba12fe3c86619f1d57b16e5d0659155e8388",
},
signature: "IA==",
signature:
"20407c9da9dadf23a2d7e863f51aa3512fe3c86619f1d57b16e5d0659155e83888207c9da9dadf736839484733637aba12fe3c86619f1d57b16e5d0659155e8388",
});
});
});
Expand Down
4 changes: 1 addition & 3 deletions libs/coin-modules/coin-bitcoin/src/hw-signMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export const signMessage =
signer.signMessage(account.freshAddressPath, hexMessage),
)) as BitcoinSignature;
const v = result["v"] + 27 + 4;
const signature = Buffer.from(`${v.toString(16)}${result["r"]}${result["s"]}`, "hex").toString(
"base64",
);
const signature = `${v.toString(16)}${result["r"]}${result["s"]}`;
return {
rsv: result,
signature,
Expand Down

0 comments on commit 0db1bf8

Please sign in to comment.