diff --git a/web/cashtab/package-lock.json b/web/cashtab/package-lock.json --- a/web/cashtab/package-lock.json +++ b/web/cashtab/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "cashtab", "version": "1.0.0", "dependencies": { "@ant-design/icons": "^4.3.0", @@ -90,13 +91,40 @@ "webpack-dev-server": "^4.6.0", "webpack-manifest-plugin": "^4.0.2", "wif": "^2.0.6", - "workbox-webpack-plugin": "^6.4.1" + "workbox-webpack-plugin": "^6.4.1", + "xecjs-message": "^1.0.3" }, "devDependencies": { "husky": "^8.0.1", "jest-when": "^3.5.1" } }, + "../../../../bitcoinjs-message": { + "name": "xecjs-message", + "version": "1.0.2", + "extraneous": true, + "license": "MIT", + "dependencies": { + "bech32": "^1.1.3", + "bs58check": "^2.1.2", + "buffer-equals": "^1.0.3", + "create-hash": "^1.1.2", + "ecashaddrjs": "^1.0.7", + "secp256k1": "^3.0.1", + "varuint-bitcoin": "^1.0.1" + }, + "devDependencies": { + "bigi": "^1.4.1", + "bitcoinjs-lib": "^3.2.0", + "nyc": "^14.1.1", + "standard": "^12.0.1", + "tape": "^4.5.1", + "tinyify": "^4.0.0" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/@adobe/css-tools": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.0.1.tgz", @@ -5263,8 +5291,6 @@ "version": "8.11.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "optional": true, - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -5279,9 +5305,7 @@ "node_modules/ajv-formats/node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "optional": true, - "peer": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/ajv-keywords": { "version": "3.5.2", @@ -20589,6 +20613,23 @@ } } }, + "node_modules/xecjs-message": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/xecjs-message/-/xecjs-message-1.0.3.tgz", + "integrity": "sha512-fsfn4d3M3k5YAxC82fFJLnQPd3DvNp/pdcE69KjkaflDqmQKe73W0stfdDliUhgp7ci2FGnBUZ8tuGmh1rkwXA==", + "dependencies": { + "bech32": "^1.1.3", + "bs58check": "^2.1.2", + "buffer-equals": "^1.0.3", + "create-hash": "^1.1.2", + "ecashaddrjs": "^1.0.7", + "secp256k1": "^3.0.1", + "varuint-bitcoin": "^1.0.1" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/xml": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", @@ -24337,13 +24378,14 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "requires": {}, + "requires": { + "ajv": "^8.0.0" + }, "dependencies": { "ajv": { - "version": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "optional": true, - "peer": true, "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -24354,9 +24396,7 @@ "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "optional": true, - "peer": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" } } }, @@ -34367,6 +34407,7 @@ "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", + "postcss": "^8.4.14", "postcss-import": "^14.1.0", "postcss-js": "^4.0.0", "postcss-load-config": "^3.1.4", @@ -35613,6 +35654,20 @@ "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==", "requires": {} }, + "xecjs-message": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/xecjs-message/-/xecjs-message-1.0.3.tgz", + "integrity": "sha512-fsfn4d3M3k5YAxC82fFJLnQPd3DvNp/pdcE69KjkaflDqmQKe73W0stfdDliUhgp7ci2FGnBUZ8tuGmh1rkwXA==", + "requires": { + "bech32": "^1.1.3", + "bs58check": "^2.1.2", + "buffer-equals": "^1.0.3", + "create-hash": "^1.1.2", + "ecashaddrjs": "^1.0.7", + "secp256k1": "^3.0.1", + "varuint-bitcoin": "^1.0.1" + } + }, "xml": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", diff --git a/web/cashtab/package.json b/web/cashtab/package.json --- a/web/cashtab/package.json +++ b/web/cashtab/package.json @@ -86,7 +86,8 @@ "webpack-dev-server": "^4.6.0", "webpack-manifest-plugin": "^4.0.2", "wif": "^2.0.6", - "workbox-webpack-plugin": "^6.4.1" + "workbox-webpack-plugin": "^6.4.1", + "xecjs-message": "^1.0.3" }, "scripts": { "start": "node scripts/start.js", diff --git a/web/cashtab/src/components/Send/Send.js b/web/cashtab/src/components/Send/Send.js --- a/web/cashtab/src/components/Send/Send.js +++ b/web/cashtab/src/components/Send/Send.js @@ -63,6 +63,7 @@ import styled from 'styled-components'; import WalletLabel from 'components/Common/WalletLabel.js'; import { ThemedCopySolid } from 'components/Common/CustomIcons'; +import xecMessage from 'xecjs-message'; const { TextArea } = Input; @@ -682,19 +683,35 @@ const verifyMessageBySig = async () => { let verification; + let newVerification; try { verification = await bchObj.BitcoinCash.verifyMessage( toLegacyCash(messageVerificationAddr), messageVerificationSig, messageVerificationMsg, ); + newVerification = xecMessage.verify( + messageVerificationMsg, + messageVerificationAddr, + messageVerificationSig, + ); } catch (err) { + console.log(`Error in verifyMessageBySig`, err); errorNotification( 'Error', 'Unable to execute signature verification', ); } + if (verification === newVerification) { + console.log( + `Both signature verification methods return the same result`, + ); + } else { + console.log(`legacy verification method returned`, verification); + console.log(`new verification method returned`, newVerification); + } + if (verification) { generalNotification('Signature successfully verified', 'Verified'); } else {