From 9e745b60607f26619b46228e307419af365f51d9 Mon Sep 17 00:00:00 2001 From: Fernando Theirs Date: Mon, 22 Nov 2021 14:35:09 +0100 Subject: [PATCH 1/4] update googletest tag --- cmake/gtest/CMakeLists.txt.gtest.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/gtest/CMakeLists.txt.gtest.in b/cmake/gtest/CMakeLists.txt.gtest.in index 202d3c3d..cd4ae6c7 100644 --- a/cmake/gtest/CMakeLists.txt.gtest.in +++ b/cmake/gtest/CMakeLists.txt.gtest.in @@ -6,7 +6,7 @@ project(googletest-download NONE) include(ExternalProject) ExternalProject_Add(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master + GIT_TAG release-1.11.0 SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" CONFIGURE_COMMAND "" From 3b213b3009f1e7395de258b9cc0140b71f8005c6 Mon Sep 17 00:00:00 2001 From: Fernando Theirs Date: Mon, 22 Nov 2021 14:36:16 +0100 Subject: [PATCH 2/4] initialize variable --- deps/ledger-zxlib/app/common/view.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deps/ledger-zxlib/app/common/view.c b/deps/ledger-zxlib/app/common/view.c index 2496f4f6..6fda9e4b 100644 --- a/deps/ledger-zxlib/app/common/view.c +++ b/deps/ledger-zxlib/app/common/view.c @@ -70,6 +70,7 @@ void h_paging_init() { viewdata.itemIdx = 0; viewdata.pageIdx = 0; viewdata.pageCount = 1; + viewdata.itemCount = 0xFF; } bool h_paging_can_increase() { @@ -185,6 +186,11 @@ zxerr_t h_review_update_data() { return zxerr_no_data; } + if (viewdata.viewfuncGetItem == NULL) { + zemu_log_stack("h_review_update_data - GetItem==NULL"); + return zxerr_no_data; + } + char buffer[20]; snprintf(buffer, sizeof(buffer), "update Idx %d/%d", viewdata.itemIdx, viewdata.pageIdx); zemu_log_stack(buffer); From 5cd627ace96489fe202e20d3e86a2e8af1aba2c3 Mon Sep 17 00:00:00 2001 From: juditortiz10 Date: Tue, 20 Feb 2024 16:24:08 +0100 Subject: [PATCH 3/4] Porting src javascript files to typescript --- app/src/apdu_handler.c | 3 +- deps/ledger-zxlib | 2 +- tests_zemu/tests/eth_tests.test.ts | 14 ++-- tests_zemu/tests/multisig.test.ts | 10 +-- tests_zemu/tests/standard.test.ts | 106 ++++++++++++++--------------- 5 files changed, 65 insertions(+), 70 deletions(-) diff --git a/app/src/apdu_handler.c b/app/src/apdu_handler.c index 741d0c0d..852c5145 100644 --- a/app/src/apdu_handler.c +++ b/app/src/apdu_handler.c @@ -41,7 +41,6 @@ static uint32_t msg_counter = 0; void extractHDPath(uint32_t rx, uint32_t offset, uint32_t path_len) { - if ((rx - offset) < sizeof(uint32_t) * path_len) { THROW(APDU_CODE_WRONG_LENGTH); } @@ -383,7 +382,7 @@ handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) break; default: - THROW(APDU_CODE_COMMAND_NOT_ALLOWED); + THROW(APDU_CODE_COMMAND_NOT_ALLOWED); break; } CHECK_APP_CANARY() diff --git a/deps/ledger-zxlib b/deps/ledger-zxlib index 9e9cb2b2..df81cb76 160000 --- a/deps/ledger-zxlib +++ b/deps/ledger-zxlib @@ -1 +1 @@ -Subproject commit 9e9cb2b21fdf94a6b1f7d71ee6f89ca8101712ce +Subproject commit df81cb767d464995327218f0fb92eaa2dd3b4db3 diff --git a/tests_zemu/tests/eth_tests.test.ts b/tests_zemu/tests/eth_tests.test.ts index 40217f38..a14252fe 100644 --- a/tests_zemu/tests/eth_tests.test.ts +++ b/tests_zemu/tests/eth_tests.test.ts @@ -94,23 +94,21 @@ describe.each(models)('ETH', function (m) { await sim.start({...defaultOptions, model: m.name,}); const app = new FilecoinApp(sim.getTransport()); const msg = data.op - + // Put the app in expert mode await sim.toggleExpertMode(); - const testcase = `${m.prefix.toLowerCase()}-eth-sign-${data.name}` - let eth = new Eth(sim.getTransport()) - // eth pubkey used for ETH_PATH: "m/44'/60'/0'/0'/5" // to verify signature const EXPECTED_PUBLIC_KEY = '024f1dd50f180bfd546339e75410b127331469837fa618d950f7cfb8be351b0020'; // do not wait here.. - const signatureRequest = app.signETHTransaction(ETH_PATH, msg, null); + + const signatureRequest = app.signETHTransaction(ETH_PATH, msg.toString('hex'), null); // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()); @@ -151,11 +149,11 @@ describe('EthAddress', function () { console.log(resp) - console.log(resp.publicKey.toString('hex')) + console.log(resp.publicKey.toString()) console.log(resp.address) - expect(resp.publicKey.toString('hex')).toEqual(EXPECTED_ETH_PK); - expect(resp.address.toString('hex')).toEqual(EXPECTED_ETH_ADDRESS); + expect(resp.publicKey.toString()).toEqual(EXPECTED_ETH_PK); + expect(resp.address.toString()).toEqual(EXPECTED_ETH_ADDRESS); } finally { await sim.close(); diff --git a/tests_zemu/tests/multisig.test.ts b/tests_zemu/tests/multisig.test.ts index d2e2acf6..a53c5643 100644 --- a/tests_zemu/tests/multisig.test.ts +++ b/tests_zemu/tests/multisig.test.ts @@ -59,8 +59,8 @@ describe.each(models)('Multisig', function (m) { const pkResponse = await app.getAddressAndPubKey(PATH_TESTNET); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here so we can get snapshots and interact with the app const signatureRequest = app.sign(PATH_TESTNET, txBlob); @@ -72,13 +72,13 @@ describe.each(models)('Multisig', function (m) { let resp = await signatureRequest; console.log(resp, m.name, name) - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index d6bfa7d7..bc16197c 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -56,9 +56,9 @@ describe('Standard', function () { console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); - expect(resp).toHaveProperty("test_mode"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); + expect(resp).toHaveProperty("testMode"); expect(resp).toHaveProperty("major"); expect(resp).toHaveProperty("minor"); expect(resp).toHaveProperty("patch"); @@ -77,8 +77,8 @@ describe('Standard', function () { console.log(resp) - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); const expected_address_string = "f1mk3zcefvlgpay4f32c5vmruk5gqig6dumc7pz6q"; const expected_pk = "0425d0dbeedb2053e690a58e9456363158836b1361f30dba0332f440558fa803d056042b50d0e70e4a2940428e82c7cea54259d65254aed4663e4d0cffd649f4fb"; @@ -111,8 +111,8 @@ describe('Standard', function () { const resp = await respRequest; - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); const expected_address_string = "f1mk3zcefvlgpay4f32c5vmruk5gqig6dumc7pz6q"; const expected_pk = "0425d0dbeedb2053e690a58e9456363158836b1361f30dba0332f440558fa803d056042b50d0e70e4a2940428e82c7cea54259d65254aed4663e4d0cffd649f4fb"; @@ -137,8 +137,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureRequest = app.sign(PATH, txBlob); @@ -150,13 +150,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -178,15 +178,15 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureResponse = await app.sign(PATH, invalidMessage); console.log(signatureResponse); - expect(signatureResponse.return_code).toEqual(0x6984); - expect(signatureResponse.error_message).toEqual("Data is invalid : Unexpected data type"); + expect(signatureResponse.returnCode).toEqual(0x6984); + expect(signatureResponse.errorMessage).toEqual("Data is invalid : Unexpected data type"); } finally { await sim.close(); } @@ -208,8 +208,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here so we can get snapshots and interact with the app const signatureRequest = app.sign(PATH, txBlob); @@ -221,13 +221,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -235,7 +235,6 @@ describe('Standard', function () { } }); - test.concurrent.each(models)('sign proposal -- unsupported method', async function (m) { const sim = new Zemu(m.path); try { @@ -249,15 +248,15 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureResponse = await app.sign(PATH, invalidMessage); console.log(signatureResponse); - expect(signatureResponse.return_code).toEqual(0x6984); - expect(signatureResponse.error_message).toEqual("Data is invalid : Unexpected data type"); + expect(signatureResponse.returnCode).toEqual(0x6984); + expect(signatureResponse.errorMessage).toEqual("Data is invalid : Unexpected data type"); } finally { await sim.close(); @@ -282,8 +281,8 @@ describe('Standard', function () { await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()); let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x6984); - expect(resp.error_message).toEqual("Data is invalid : Unexpected data type"); + expect(resp.returnCode).toEqual(0x6984); + expect(resp.errorMessage).toEqual("Data is invalid : Unexpected data type"); } finally { await sim.close(); } @@ -302,8 +301,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here so we can get snapshots and interact with the app const signatureRequest = app.sign(PATH, txBlob); @@ -315,13 +314,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -342,8 +341,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureRequest = app.sign(PATH, txBlob); @@ -354,13 +353,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -384,8 +383,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureRequest = app.signRemoveDataCap(PATH, txBlob); @@ -396,13 +395,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -433,11 +432,10 @@ describe('Standard', function () { const txBlob = Buffer.from("8bd82a582500017112209fe4ccc6de16724f3a30c7e8f254f3c6471986acb1f8d8cf8e96ce2ad7dbe7fb1a012a174ff555011eaf1c8a4bbfeeb0870b1745b1f57503470b71165501dfe49184d46adc8f89d44638beb45f78fcad259071636c69656e745f6465616c5f6c6162656c1a05f5e1001a0bebc2004044001ea7ad40", 'hex') - const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureRequest = app.signClientDeal(PATH, txBlob); @@ -448,13 +446,13 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -483,8 +481,8 @@ describe('Standard', function () { const pkResponse = await app.getAddressAndPubKey(PATH); console.log(pkResponse); - expect(pkResponse.return_code).toEqual(0x9000); - expect(pkResponse.error_message).toEqual("No errors"); + expect(pkResponse.returnCode).toEqual(0x9000); + expect(pkResponse.errorMessage).toEqual("No errors"); // do not wait here.. const signatureRequest = app.signRawBytes(PATH, txBlob); @@ -495,14 +493,14 @@ describe('Standard', function () { let resp = await signatureRequest; console.log(resp); - expect(resp.return_code).toEqual(0x9000); - expect(resp.error_message).toEqual("No errors"); + expect(resp.returnCode).toEqual(0x9000); + expect(resp.errorMessage).toEqual("No errors"); // Verify signature const pk = Uint8Array.from(pkResponse.compressed_pk); const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signature_der)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { From 6f678f8087e8c7881bb2c1111ab6618558334b9e Mon Sep 17 00:00:00 2001 From: juditortiz10 Date: Fri, 23 Feb 2024 18:06:15 +0100 Subject: [PATCH 4/4] Fixing review findings --- tests_zemu/tests/multisig.test.ts | 4 ++-- tests_zemu/tests/standard.test.ts | 38 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tests_zemu/tests/multisig.test.ts b/tests_zemu/tests/multisig.test.ts index a53c5643..763c9aee 100644 --- a/tests_zemu/tests/multisig.test.ts +++ b/tests_zemu/tests/multisig.test.ts @@ -76,9 +76,9 @@ describe.each(models)('Multisig', function (m) { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index bc16197c..e60e8bb3 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -84,7 +84,10 @@ describe('Standard', function () { const expected_pk = "0425d0dbeedb2053e690a58e9456363158836b1361f30dba0332f440558fa803d056042b50d0e70e4a2940428e82c7cea54259d65254aed4663e4d0cffd649f4fb"; expect(resp.addrString).toEqual(expected_address_string); - expect(resp.compressed_pk.toString('hex')).toEqual(expected_pk); + + const compressedPk = resp.compressedPk ?? Buffer.alloc(0) + expect(compressedPk.toString('hex')).toEqual(expected_pk) + } finally { await sim.close(); @@ -118,7 +121,10 @@ describe('Standard', function () { const expected_pk = "0425d0dbeedb2053e690a58e9456363158836b1361f30dba0332f440558fa803d056042b50d0e70e4a2940428e82c7cea54259d65254aed4663e4d0cffd649f4fb"; expect(resp.addrString).toEqual(expected_address_string); - expect(resp.compressed_pk.toString('hex')).toEqual(expected_pk); + + const compressedPk = resp.compressedPk ?? Buffer.alloc(0) + expect(compressedPk.toString('hex')).toEqual(expected_pk) + } finally { await sim.close(); } @@ -154,9 +160,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -225,9 +231,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -318,9 +324,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -357,9 +363,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -399,9 +405,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -450,9 +456,9 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk) + const pk = Uint8Array.from(pkResponse.compressedPk ?? []) const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally { @@ -497,10 +503,10 @@ describe('Standard', function () { expect(resp.errorMessage).toEqual("No errors"); // Verify signature - const pk = Uint8Array.from(pkResponse.compressed_pk); + const pk = Uint8Array.from(pkResponse.compressedPk ?? []); const digest = getDigest(txBlob); - const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER)); + const signature = secp256k1.signatureImport(Uint8Array.from(resp.signatureDER ?? [])); const signatureOk = secp256k1.ecdsaVerify(signature, digest, pk); expect(signatureOk).toEqual(true); } finally {