From 02629adbfdda37aa3562565ef6f8e43f1f43a17b Mon Sep 17 00:00:00 2001 From: fwaszkiewicz <fabianwaszkiewicz09@gmail.com> Date: Fri, 14 Mar 2025 14:57:31 +0100 Subject: [PATCH 1/3] Add test for insufficient weight in authority trace --- .../detailed/custom_chain_online_tx.ts | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts b/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts index 08643763d..03cc6115f 100644 --- a/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts +++ b/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts @@ -596,6 +596,187 @@ test.describe('Wax chain tests to cover Online Transaction flow', () => { ]); }); + test('Should be able to get authority trace for insufficient weight transaction', async ({ waxTest }) => { + const retVal = await waxTest(async({ wax }) => { + const chain = await wax.createHiveChain(); + + const sourceTx = chain.createTransactionFromJson({ + "ref_block_num": 18628, + "ref_block_prefix": 1429804722, + "expiration": "2025-03-14T12:37:20", + "operations": [ + { + "type": "transfer_operation", + "value": { + "from": "guest4test4", + "to": "alice", + "amount": { + "amount": "1", + "precision": 3, + "nai": "@@000000021" + }, + "memo": "This is a test transfer" + } + } + ], + "signatures": [ + "1fd37b180bb46ed8fa6139d5f18521800ab19b7725d7fe337673c1033047371c4019fbabc0798b60d1cb0354439e5d67af5b82d1b4f262303fec0aa4905ddc5835" + ] + }); + + const tx = await chain.createTransaction(); + + const trace = await tx.generateAuthorityVerificationTrace(false, sourceTx); + + console.log(JSON.stringify(trace)); + + return trace; + }); + + expect(retVal).toStrictEqual({ + "collectedData": [ + { + "finalAuthorityPath": { + "processedEntry": "guest4test4", + "processedRole": "owner", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + }, + "matchingSignatures": [] + } + ], + "finalAuthorityPath": [ + { + "processedEntry": "guest4test4", + "processedRole": "owner", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + } + ], + "rootEntries": [ + { + "processedEntry": "guest4test4", + "processedRole": "active", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 2, + "visitedEntries": [ + { + "processedEntry": "guest4test1", + "processedRole": "active", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 1, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM8gQN2KodMgmVqTEY372XzZyEUpceKpLWU6igr39MF3D7Qv3Rqo", + "processedRole": "active", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 1, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "guest4test8", + "processedRole": "active", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 1, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + } + ], + "weight": 1 + }, + { + "processedEntry": "guest4test4", + "processedRole": "owner", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + } + ], + "rootEntry": { + "processedEntry": "guest4test4", + "processedRole": "owner", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + }, + "verificationStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + } + }); + }); + test('Should catch private key leak using online transaction interface during explicit online validation', async ({ waxTest, config }) => { const retVal = await waxTest(txSecurityLeakBody, mirrornetSkeletonKey, config!, false); expect(retVal.detectedLeakError).toStrictEqual({ -- GitLab From cd981a7877beb7ce67816178f7405954997cfd34 Mon Sep 17 00:00:00 2001 From: fwaszkiewicz <fabianwaszkiewicz09@gmail.com> Date: Fri, 21 Mar 2025 10:10:31 +0100 Subject: [PATCH 2/3] Add tests for multisig authority trace root entires --- .../detailed/custom_chain_online_tx.ts | 445 ++++++++++++++++++ 1 file changed, 445 insertions(+) diff --git a/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts b/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts index 03cc6115f..bc0f3f831 100644 --- a/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts +++ b/ts/wasm/__tests__/detailed/custom_chain_online_tx.ts @@ -777,6 +777,451 @@ test.describe('Wax chain tests to cover Online Transaction flow', () => { }); }); + test('Should be able to get authority trace root entires for multi signature transaction', async ({ waxTest }) => { + const retVal = await waxTest(async({ wax }) => { + const chain = await wax.createHiveChain(); + + const sourceTx = chain.createTransactionFromJson({ + "ref_block_num": 808, + "ref_block_prefix": 1359279161, + "extensions": [], + "expiration": "2024-08-02T12:09:03", + "operations": [ + { + "type": "vote_operation", + "value": { + "voter": "ecency", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "ecency.stats", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "esteem.app", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "good-karma", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "esteemapp", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + } + ], + "signatures": [ + "1f4141e7645dd2bdcdb2001baea165e668a6f9c2a366f6fd2f3e9d878f071f5eb052509eb666b80c1e0daaa7fdec36e3de827087dcd3015c8672b536ddddbc5726", + "20223edff229382e67031d993c13d26062ab4d33c45ede7aced7f1e432d6b6d57a4fd68eae708f562a9644ee08ea447fa354febe34aa8ba14a434c66adc753774f", + "20286bd3b0ad2ecb01488ce866361b4fcd53b1f3dac41962496986fdf89c89c20a0e86f8dd2669ed14b6dafc3e0bb0d24ec54a794ee6c0b563275a22a122992ac1", + "2043b5ea9cbf76f1cd0fbb5f589350d9b8273d241c8bb704189bc9fd4444493c384594536e0387ff121bcdbfa4fa401917e30609ac86ea82f13132d26280e74f9a", + "205f0e25631bdbcd37669b2f6c36594d0153e468be8b2b6a57f8eae49538132efd0dde1ad6a707788d6a2024efd03a55dd0bb478a40eedce48f6e5db19d365bce5" + ] + }); + + const tx = await chain.createTransaction(); + + const trace = await tx.generateAuthorityVerificationTrace(false, sourceTx); + + console.log(JSON.stringify(trace)); + + return trace.rootEntries; + }); + + expect(retVal).toStrictEqual([ + { + "processedEntry": "ecency", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM8AZuk2ja5vSFySFL2zpB9bNew8wJAg8r4QFtbnoamEX8Jvvq43", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "ecency.stats", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM8jviUDRAefxmTQ9m8wNdiQV5dmCPSMDjSnztPYZpHf1yfaD6Rd", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "esteem.app", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM64Bb5TXsiEbjjLsgVrvVttEDsLNSot9p8zJd41D5zEr5opxcHK", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "esteemapp", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM7S3wsVtQotgKLN8wFLPNBALe6YHt8MPLEHuTH5CxfxdhpGPBUP", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "good-karma", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM5dhkPS223F9d3TCXKttuWpdWgqS2Fx8KNRQve6BMGmAvJ5GnJR", + "processedRole": "posting", + "processingStatus": { + "entryAccepted": true, + "isOpenAuthority": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + } + ]); + }); + + test('Should be able to get authority trace root entires for multisig transaction with one broken signature ', async ({ waxTest }) => { + const retVal = await waxTest(async({ wax }) => { + const chain = await wax.createHiveChain(); + + const sourceTx = chain.createTransactionFromJson({ + "ref_block_num": 808, + "ref_block_prefix": 1359279161, + "extensions": [], + "expiration": "2024-08-02T12:09:03", + "operations": [ + { + "type": "vote_operation", + "value": { + "voter": "ecency", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "ecency.stats", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "esteem.app", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "good-karma", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + }, + { + "type": "vote_operation", + "value": { + "voter": "esteemapp", + "author": "el-panal", + "weight": 100, + "permlink": "el-panal-presentacion-de-autores-destacados-dia31072024" + } + } + ], + "signatures": [ + "1f4141e7645dd2bdcdb2001baea165e668a6f9c2a366f6fd2f3e9d878f071f5eb052509eb666b80c1e0daaa7fdec36e3de827087dcd3015c8672b536ddddbc5726", + "20223edff229382e67031d993c13d26062ab4d33c45ede7aced7f1e432d6b6d57a4fd68eae708f562a9644ee08ea447fa354febe34aa8ba14a434c66adc753774f", + "20286bd3b0ad2ecb01488ce866361b4fcd53b1f3dac41962496986fdf89c89c20a0e86f8dd2669ed14b6dafc3e0bb0d24ec54a794ee6c0b563275a22a122992ac1", + "2043b5ea9cbf76f1cd0fbb5f589350d9b8273d241c8bb704189bc9fd4444493c384594536e0387ff121bcdbfa4fa401917e30609ac86ea82f13132d26280e74f9a", + "205f0e25631bdbcd37669b2f6c36594d0153e468be8b2b6a57f8eae49538132efd0dde1ad6a707788d6a2024efd03a55dd0bb478a40eedce48f6e5db19d365" + ] + }); + + const tx = await chain.createTransaction(); + + const trace = await tx.generateAuthorityVerificationTrace(false, sourceTx); + + console.log(JSON.stringify(trace)); + + return trace.rootEntries; + }); + + expect(retVal).toStrictEqual([ + { + "processedEntry": "ecency", + "processedRole": "posting", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "ecency.app", + "processedRole": "posting", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 1, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "hivesigner", + "processedRole": "posting", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 2, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + } + ], + "weight": 0 + } + ], + "weight": 0 + }, + { + "processedEntry": "ecency", + "processedRole": "active", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + }, + { + "processedEntry": "ecency", + "processedRole": "owner", + "processingStatus": { + "accountAuthorityCountExceeded": false, + "accountAuthorityPointsMissingAccount": false, + "accountAuthorityProcessingDepthExceeded": false, + "entryAccepted": false, + "hasAccountAuthorityCycle": false, + "hasInsufficientWeight": true, + "hasMatchingPublicKey": false + }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 0 + }, + { + "processedEntry": "ecency.stats", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM8jviUDRAefxmTQ9m8wNdiQV5dmCPSMDjSnztPYZpHf1yfaD6Rd", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "esteem.app", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM64Bb5TXsiEbjjLsgVrvVttEDsLNSot9p8zJd41D5zEr5opxcHK", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "esteemapp", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM7S3wsVtQotgKLN8wFLPNBALe6YHt8MPLEHuTH5CxfxdhpGPBUP", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + }, + { + "processedEntry": "good-karma", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [ + { + "processedEntry": "STM5dhkPS223F9d3TCXKttuWpdWgqS2Fx8KNRQve6BMGmAvJ5GnJR", + "processedRole": "posting", + "processingStatus": { "entryAccepted": true, "isOpenAuthority": false }, + "recursionDepth": 0, + "threshold": 1, + "visitedEntries": [], + "weight": 1 + } + ], + "weight": 1 + } + ] + ); + }); + test('Should catch private key leak using online transaction interface during explicit online validation', async ({ waxTest, config }) => { const retVal = await waxTest(txSecurityLeakBody, mirrornetSkeletonKey, config!, false); expect(retVal.detectedLeakError).toStrictEqual({ -- GitLab From b4aa5789ec4f1c0af85ac323c58af392ed4b54a2 Mon Sep 17 00:00:00 2001 From: fwaszkiewicz <fabianwaszkiewicz09@gmail.com> Date: Fri, 21 Mar 2025 12:21:16 +0100 Subject: [PATCH 3/3] Remove parcel cache directory before running web server --- examples/ts/signature-extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ts/signature-extension/package.json b/examples/ts/signature-extension/package.json index 196a4df0f..ff3d044b8 100644 --- a/examples/ts/signature-extension/package.json +++ b/examples/ts/signature-extension/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "tsc", "test": "../../../ts/npm-common-config/scripts/bash/npm-helpers/npm_download_browser_extensions.sh \"${HOME}/preinstalled_browser_extensions\" && ln -sf \"${HOME}/preinstalled_browser_extensions\" ./__tests__/extensions && playwright install chromium && playwright test --max-failures 1", - "test:manual": "parcel test/index.html" + "test:manual": "rm -rf ./.parcel-cache && parcel test/index.html" }, "dependencies": { "@hiveio/wax": "file:../../../ts", -- GitLab