diff --git a/.changeset/lazy-taxis-attend.md b/.changeset/lazy-taxis-attend.md new file mode 100644 index 000000000000..f57c6bbb0ed0 --- /dev/null +++ b/.changeset/lazy-taxis-attend.md @@ -0,0 +1,9 @@ +--- +"@ledgerhq/hw-app-hedera": minor +"@ledgerhq/types-live": minor +"@ledgerhq/coin-hedera": minor +"@ledgerhq/coin-framework": minor +"@ledgerhq/live-env": minor +--- + +Allows for Hedera ECDSA Keys to be used diff --git a/libs/coin-framework/src/bridge/jsHelpers.ts b/libs/coin-framework/src/bridge/jsHelpers.ts index 9df4b3367c5e..c3d277a5953e 100644 --- a/libs/coin-framework/src/bridge/jsHelpers.ts +++ b/libs/coin-framework/src/bridge/jsHelpers.ts @@ -437,7 +437,7 @@ export const makeScanAccounts = log("scanAccounts", `scanning ${currency.id} on derivationMode=${derivationMode}`); let result: Result = derivationsCache[path]; - if (!result) { + if (!result || derivationMode == "hederaBip44Ecdsa") { try { result = await getAddressFn(deviceId, { currency, diff --git a/libs/coin-framework/src/derivation.ts b/libs/coin-framework/src/derivation.ts index bc2fcb9f60fa..9da1fe5ed539 100644 --- a/libs/coin-framework/src/derivation.ts +++ b/libs/coin-framework/src/derivation.ts @@ -152,10 +152,10 @@ const modes: Readonly> = Object.freeze({ overridesDerivation: "44'/501'/'", }, hederaBip44Ed25519: { - overridesDerivation: "44/3030", + overridesDerivation: "44/3030/0", }, hederaBip44Ecdsa: { - overridesDerivation: "44/3030", + overridesDerivation: "44/3030/1", }, cardano: { purpose: 1852, diff --git a/libs/coin-modules/coin-hedera/src/bridge/synchronisation.ts b/libs/coin-modules/coin-hedera/src/bridge/synchronisation.ts index af1a8ed5539a..2f958db4b66e 100644 --- a/libs/coin-modules/coin-hedera/src/bridge/synchronisation.ts +++ b/libs/coin-modules/coin-hedera/src/bridge/synchronisation.ts @@ -60,7 +60,6 @@ export const getAccountShape: GetAccountShape = async ( }; export const buildIterateResult: IterateResultBuilder = async ({ result: rootResult }) => { - console.log(rootResult.publicKey); const accounts = await getAccountsForPublicKey(rootResult.publicKey); const addresses = accounts.map(a => a.accountId.toString()); diff --git a/libs/coin-modules/coin-hedera/src/signer/getAddress.ts b/libs/coin-modules/coin-hedera/src/signer/getAddress.ts index 4772529ff725..e87586c901d4 100644 --- a/libs/coin-modules/coin-hedera/src/signer/getAddress.ts +++ b/libs/coin-modules/coin-hedera/src/signer/getAddress.ts @@ -6,12 +6,10 @@ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation"; const resolver = (signerContext: SignerContext): GetAddressFn => { return async (deviceId: string, { path, derivationMode }: GetAddressOptions) => { let publicKey = ""; - console.log(derivationMode); + publicKey = await signerContext(deviceId, signer => signer.getPublicKey(path)); if (derivationMode == "hederaBip44Ecdsa") { publicKey = await signerContext(deviceId, signer => signer.getPublicKey(path, true)); - console.log(publicKey); } - publicKey = await signerContext(deviceId, signer => signer.getPublicKey(path)); return { path, diff --git a/libs/ledgerjs/packages/hw-app-hedera/src/Hedera.ts b/libs/ledgerjs/packages/hw-app-hedera/src/Hedera.ts index 3d2bcb5f4fd3..4dbdc347d206 100644 --- a/libs/ledgerjs/packages/hw-app-hedera/src/Hedera.ts +++ b/libs/ledgerjs/packages/hw-app-hedera/src/Hedera.ts @@ -34,12 +34,9 @@ export default class Hedera { * @return the public key */ async getPublicKey(path: string, ecdsa?: boolean): Promise { - console.log("path: " + path); const bipPath = BIPPath.fromString(path).toPathArray(); const serializedPath = this._serializePath(bipPath); - //44/3030/0 - const p1 = 0x01; let p2 = 0x00; @@ -47,12 +44,8 @@ export default class Hedera { p2 = 1; } - console.log("getting key..."); - const response = await this.transport.send(CLA, INS.GET_PUBLIC_KEY, p1, p2, serializedPath); - console.log(response); - const returnCodeBytes = response.slice(-2); const returnCode = (returnCodeBytes[0] << 8) | returnCodeBytes[1]; @@ -60,7 +53,11 @@ export default class Hedera { throw new UserRefusedAddress(); } - return response.slice(0, 32).toString("hex"); + if (ecdsa) { + return response.slice(0, 33).toString("hex"); + } else { + return response.slice(0, 32).toString("hex"); + } } // TODO: the BOLOS app does not support anything but index #0 for signing transactions diff --git a/libs/ledgerjs/packages/hw-transport/src/Transport.ts b/libs/ledgerjs/packages/hw-transport/src/Transport.ts index ec8b0b21143d..d44d28217466 100644 --- a/libs/ledgerjs/packages/hw-transport/src/Transport.ts +++ b/libs/ledgerjs/packages/hw-transport/src/Transport.ts @@ -267,8 +267,6 @@ export default class Transport { } tracer.trace("Starting an exchange", { abortTimeoutMs }); - console.log("apdu: " + cla + " " + ins + " " + p1 + " " + p2 + " " + data); - console.log("p2: " + p2); const response = await this.exchange( // The size of the data is added in 1 byte just before `data` Buffer.concat([Buffer.from([cla, ins, p1, p2]), Buffer.from([data.length]), data]),