From 0131a3ef6de73874f93e78238e00abfb3b6e478b Mon Sep 17 00:00:00 2001 From: Alejo Acosta Date: Mon, 13 May 2024 17:22:19 -0300 Subject: [PATCH 1/2] add script to test 'UTXOHNodeWallet' init() and update 'signTransaction' --- .gitignore | 2 +- package-lock.json | 415 +++--------------- scripts/deploy.js | 4 +- scripts/quais6deploy.js | 2 +- ...tion_musig.js => signTransaction_musig.js} | 95 ++-- ..._schnoor.js => signTransaction_schnoor.js} | 45 +- scripts/tools.js | 6 +- scripts/{getUTXO.js => wallet_init.js} | 20 +- 8 files changed, 151 insertions(+), 438 deletions(-) rename scripts/{signUTXOTransaction_musig.js => signTransaction_musig.js} (61%) rename scripts/{signUTXOTransaction_schnoor.js => signTransaction_schnoor.js} (72%) rename scripts/{getUTXO.js => wallet_init.js} (74%) diff --git a/.gitignore b/.gitignore index f78a0fd..016aac5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ cache artifacts #Env files -.env \ No newline at end of file +.env* \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ce5df9b..e9d5a78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "ethers": "^6.9.2", - "quais": "file:quais-1.0.0.tgz", - "quais6": "file:quais6-0.0.1.tgz" + "@brandonblack/musig": "^0.0.1-alpha.1", + "ethers": "^6.9.2" }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^3.0.0", @@ -410,17 +409,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@babel/standalone": { "version": "7.24.0", "resolved": "https://registry.npmjs.org/@babel/standalone/-/standalone-7.24.0.tgz", @@ -526,15 +514,10 @@ "node": ">=4" } }, - "node_modules/@babel/types": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", - "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", - "dependencies": { - "esutils": "^2.0.2", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } + "node_modules/@brandonblack/musig": { + "version": "0.0.1-alpha.1", + "resolved": "https://registry.npmjs.org/@brandonblack/musig/-/musig-0.0.1-alpha.1.tgz", + "integrity": "sha512-00RbByQG85lSzrkDjCblzrUc2n1LJAPPrEMHS4oMg+QckE0kzjd26JytT6yx6tNU2+aOXfK7O4kGW/sKVL67cw==" }, "node_modules/@chainsafe/as-sha256": { "version": "0.3.1", @@ -1889,99 +1872,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@ledgerhq/cryptoassets": { - "version": "5.53.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/cryptoassets/-/cryptoassets-5.53.0.tgz", - "integrity": "sha512-M3ibc3LRuHid5UtL7FI3IC6nMEppvly98QHFoSa7lJU0HDzQxY6zHec/SPM4uuJUC8sXoGVAiRJDkgny54damw==", - "dependencies": { - "invariant": "2" - } - }, - "node_modules/@ledgerhq/devices": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-5.51.1.tgz", - "integrity": "sha512-4w+P0VkbjzEXC7kv8T1GJ/9AVaP9I6uasMZ/JcdwZBS3qwvKo5A5z9uGhP5c7TvItzcmPb44b5Mw2kT+WjUuAA==", - "dependencies": { - "@ledgerhq/errors": "^5.50.0", - "@ledgerhq/logs": "^5.50.0", - "rxjs": "6", - "semver": "^7.3.5" - } - }, - "node_modules/@ledgerhq/devices/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@ledgerhq/devices/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@ledgerhq/devices/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/@ledgerhq/errors": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-5.50.0.tgz", - "integrity": "sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow==" - }, - "node_modules/@ledgerhq/hw-app-eth": { - "version": "5.27.2", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-app-eth/-/hw-app-eth-5.27.2.tgz", - "integrity": "sha512-llNdrE894cCN8j6yxJEUniciyLVcLmu5N0UmIJLOObztG+5rOF4bX54h4SreTWK+E10Z0CzHSeyE5Lz/tVcqqQ==", - "dependencies": { - "@ledgerhq/cryptoassets": "^5.27.2", - "@ledgerhq/errors": "^5.26.0", - "@ledgerhq/hw-transport": "^5.26.0", - "bignumber.js": "^9.0.1", - "rlp": "^2.2.6" - } - }, - "node_modules/@ledgerhq/hw-transport": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-5.26.0.tgz", - "integrity": "sha512-NFeJOJmyEfAX8uuIBTpocWHcz630sqPcXbu864Q+OCBm4EK5UOKV1h/pX7e0xgNIKY8zhJ/O4p4cIZp9tnXLHQ==", - "dependencies": { - "@ledgerhq/devices": "^5.26.0", - "@ledgerhq/errors": "^5.26.0", - "events": "^3.2.0" - } - }, - "node_modules/@ledgerhq/hw-transport-u2f": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-u2f/-/hw-transport-u2f-5.26.0.tgz", - "integrity": "sha512-QTxP1Rsh+WZ184LUOelYVLeaQl3++V3I2jFik+l9JZtakwEHjD0XqOT750xpYNL/vfHsy31Wlz+oicdxGzFk+w==", - "deprecated": "@ledgerhq/hw-transport-u2f is deprecated. Please use @ledgerhq/hw-transport-webusb or @ledgerhq/hw-transport-webhid. https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md", - "dependencies": { - "@ledgerhq/errors": "^5.26.0", - "@ledgerhq/hw-transport": "^5.26.0", - "@ledgerhq/logs": "^5.26.0", - "u2f-api": "0.2.7" - } - }, - "node_modules/@ledgerhq/logs": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-5.50.0.tgz", - "integrity": "sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==" - }, "node_modules/@metamask/eth-sig-util": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz", @@ -3997,7 +3887,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/base-x": { "version": "3.0.9", @@ -4031,7 +3922,8 @@ "node_modules/bech32": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", - "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" + "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==", + "dev": true }, "node_modules/bigint-crypto-utils": { "version": "3.3.0", @@ -4042,14 +3934,6 @@ "node": ">=14.0.0" } }, - "node_modules/bignumber.js": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", - "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", - "engines": { - "node": "*" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -4108,7 +3992,8 @@ "node_modules/bn.js": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true }, "node_modules/boolbase": { "version": "1.0.0", @@ -4120,6 +4005,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4140,7 +4026,8 @@ "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true }, "node_modules/browser-level": { "version": "1.0.1", @@ -4725,7 +4612,8 @@ "node_modules/command-exists": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", - "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==" + "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", + "dev": true }, "node_modules/command-line-args": { "version": "5.2.1", @@ -4794,7 +4682,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/concat-stream": { "version": "1.6.2", @@ -5549,6 +5438,7 @@ "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, "engines": { "node": ">=12" }, @@ -5594,6 +5484,7 @@ "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -5607,7 +5498,8 @@ "node_modules/elliptic/node_modules/bn.js": { "version": "4.12.0", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -6165,6 +6057,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -6467,14 +6361,6 @@ "npm": ">=3" } }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -6682,6 +6568,7 @@ "version": "1.15.5", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "dev": true, "funding": [ { "type": "individual", @@ -6803,7 +6690,8 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true }, "node_modules/fsevents": { "version": "2.3.3", @@ -6922,6 +6810,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -7039,11 +6928,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/google-protobuf": { - "version": "3.21.2", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz", - "integrity": "sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==" - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -7106,7 +6990,8 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true }, "node_modules/graphemer": { "version": "1.4.0", @@ -7429,6 +7314,7 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -7466,6 +7352,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", @@ -7633,6 +7520,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -7641,7 +7529,8 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/ini": { "version": "1.3.8", @@ -7673,14 +7562,6 @@ "node": ">=4" } }, - "node_modules/invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", - "dependencies": { - "loose-envify": "^1.0.0" - } - }, "node_modules/io-ts": { "version": "1.10.4", "resolved": "https://registry.npmjs.org/io-ts/-/io-ts-1.10.4.tgz", @@ -7929,12 +7810,14 @@ "node_modules/js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", - "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", + "dev": true }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true }, "node_modules/js-yaml": { "version": "4.1.0", @@ -8060,6 +7943,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", "integrity": "sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==", + "dev": true, "optionalDependencies": { "graceful-fs": "^4.1.9" } @@ -8146,7 +8030,8 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "node_modules/lodash.camelcase": { "version": "4.3.0", @@ -8281,22 +8166,6 @@ "node": ">=8" } }, - "node_modules/long": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", - "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, "node_modules/loupe": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", @@ -8423,6 +8292,7 @@ "version": "0.3.1", "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", + "dev": true, "engines": { "node": ">= 0.10.0" } @@ -8490,17 +8360,20 @@ "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true }, "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "dev": true }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -9068,6 +8941,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -9101,6 +8975,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -9237,6 +9112,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -9956,32 +9832,6 @@ "hardhat": "^2.0.5" } }, - "node_modules/quais": { - "version": "1.0.0", - "resolved": "file:quais-1.0.0.tgz", - "integrity": "sha512-R5MEB8OyZxcSEfY3qGrOOaokS8eRzBIW1o6xGh+COinz931RkFXgCecfO6O14khP8UoPN0vqy4H4F9eiSMYh4A==", - "hasInstallScript": true, - "dependencies": { - "@babel/parser": "7.8.4", - "@babel/types": "7.8.3", - "@ledgerhq/hw-app-eth": "5.27.2", - "@ledgerhq/hw-transport": "5.26.0", - "@ledgerhq/hw-transport-u2f": "5.26.0", - "@types/mocha": "^5.2.0", - "aes-js": "3.0.0", - "bech32": "1.1.4", - "bn.js": "^5.2.1", - "elliptic": "6.5.4", - "google-protobuf": "^3.21.2", - "hash.js": "1.1.7", - "js-sha3": "0.8.0", - "long": "^5.2.3", - "scrypt-js": "3.0.1", - "solc": "0.7.1", - "tiny-inflate": "1.0.3", - "ws": "7.4.6" - } - }, "node_modules/quais-polling": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/quais-polling/-/quais-polling-1.0.4.tgz", @@ -9991,131 +9841,6 @@ "unbuild": "^2.0.0" } }, - "node_modules/quais/node_modules/@types/mocha": { - "version": "5.2.7", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", - "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==" - }, - "node_modules/quais/node_modules/aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" - }, - "node_modules/quais/node_modules/commander": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", - "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==" - }, - "node_modules/quais/node_modules/fs-extra": { - "version": "0.30.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", - "integrity": "sha512-UvSPKyhMn6LEd/WpUaV9C9t3zATuqoqfWc3QdPhPLb58prN9tqYPlPWi8Krxi44loBoUzlobqZ3+8tGpxxSzwA==", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" - } - }, - "node_modules/quais/node_modules/jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/quais/node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/quais/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/quais/node_modules/solc": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/solc/-/solc-0.7.1.tgz", - "integrity": "sha512-LepFVKDOcZ1O3OskOy45XTQ6G4rMRTmsGjn4gssaOrI9uyJI9LL6/X2MlYqeJx22UrpPUtCjQAb5IFWRoOSe+w==", - "dependencies": { - "command-exists": "^1.2.8", - "commander": "3.0.2", - "follow-redirects": "^1.12.1", - "fs-extra": "^0.30.0", - "js-sha3": "0.8.0", - "memorystream": "^0.3.1", - "require-from-string": "^2.0.0", - "semver": "^5.5.0", - "tmp": "0.0.33" - }, - "bin": { - "solcjs": "solcjs" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/quais/node_modules/ws": { - "version": "7.4.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", - "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/quais6": { - "version": "0.0.1", - "resolved": "file:quais6-0.0.1.tgz", - "integrity": "sha512-4CwsehviQA3EVzvUK4LGIuORdIhULnwcta3052Eh5OgvZPa32IDPadMVme+Pr90+pyfLf2Iuz5k7JbfA5MvCsg==", - "license": "MIT", - "dependencies": { - "@adraffy/ens-normalize": "1.10.0", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@types/node": "18.15.13", - "aes-js": "4.0.0-beta.5", - "dotenv": "^16.4.1", - "tslib": "2.4.0", - "ws": "8.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/quais6/node_modules/@adraffy/ens-normalize": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", - "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" - }, - "node_modules/quais6/node_modules/@types/node": { - "version": "18.15.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", - "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" - }, "node_modules/query-string": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", @@ -10285,6 +10010,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -10360,6 +10086,7 @@ "version": "2.2.7", "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz", "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==", + "dev": true, "dependencies": { "bn.js": "^5.2.0" }, @@ -10457,22 +10184,6 @@ "integrity": "sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==", "dev": true }, - "node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", - "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" - } - }, - "node_modules/rxjs/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -10626,7 +10337,8 @@ "node_modules/scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==", + "dev": true }, "node_modules/scule": { "version": "1.3.0", @@ -11625,15 +11337,11 @@ "node": ">=0.10.0" } }, - "node_modules/tiny-inflate": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz", - "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==" - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, "dependencies": { "os-tmpdir": "~1.0.2" }, @@ -11651,6 +11359,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, "engines": { "node": ">=4" } @@ -12039,11 +11748,6 @@ "node": ">=8" } }, - "node_modules/u2f-api": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/u2f-api/-/u2f-api-0.2.7.tgz", - "integrity": "sha512-fqLNg8vpvLOD5J/z4B6wpPg4Lvowz1nJ9xdHcCzdUPKcFE/qNCceV2gNZxSJd5vhAZemHr/K/hbzVA0zxB5mkg==" - }, "node_modules/ufo": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.4.0.tgz", @@ -12540,7 +12244,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/ws": { "version": "8.5.0", diff --git a/scripts/deploy.js b/scripts/deploy.js index f1779a6..59fe3e6 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,5 +1,5 @@ const hre = require('hardhat') -const quais = require('quais') +const quais = require('quais6') const { pollFor } = require('quais-polling') const GreeterJson = require('../artifacts/contracts/Greeter.sol/Greeter.json') @@ -10,7 +10,7 @@ constructorArgs = { async function main() { // Configure quai network provider based on hardhat network config - const quaisProvider = new quais.providers.JsonRpcProvider(hre.network.config.url) + const quaisProvider = new quais.JsonRpcProvider(hre.network.config.url) // Configure quai wallet based on hardhat network config const walletWithProvider = new quais.Wallet(hre.network.config.accounts[0], quaisProvider) diff --git a/scripts/quais6deploy.js b/scripts/quais6deploy.js index 766e58c..2dd52e0 100644 --- a/scripts/quais6deploy.js +++ b/scripts/quais6deploy.js @@ -12,7 +12,7 @@ const constructorArgs = { async function main() { // Configure quai network provider based on hardhat network config - const quaisProvider = new quais.JsonRpcProvider('http://127.0.0.1:9003') + const quaisProvider = new quais.JsonRpcProvider('http://127.0.0.1:9100') // Configure quai wallet based on hardhat network config diff --git a/scripts/signUTXOTransaction_musig.js b/scripts/signTransaction_musig.js similarity index 61% rename from scripts/signUTXOTransaction_musig.js rename to scripts/signTransaction_musig.js index 983a38d..d678268 100644 --- a/scripts/signUTXOTransaction_musig.js +++ b/scripts/signTransaction_musig.js @@ -1,6 +1,3 @@ -//! NOTE: This script is for developement and only works with a modified version of the 'signTransaction' method in the UTXOHDWallet class -//! In order for this script to work, 'signTransaction' must be modified to return the tx object (instead of the serialized string) - const quais = require('quais6') const { keccak_256 } = require('@noble/hashes/sha3'); const { mnemonicPhrase, derivationPath, privKey1, privKey2, mockTxHash1, mockTxHash2} = require('./constants.js'); @@ -34,86 +31,94 @@ async function main() { // Define the UTXO addresses for the wallet const utxoAddresses = [ { - address: addr1, - privKey: privKey1, + address: addr1, + privKey: privKey1, }, { - address: addr2, - privKey: privKey2, + address: addr2, + privKey: privKey2, }, ]; // Define the outpoints for the UTXO addresses const addressOutPoints = { addr1: [ - { - Txhash: mockTxHash1, - Index: 0, - Denomination: 7, - }, - { - Txhash: mockTxHash2, - Index: 0, - Denomination: 7, - } + { + Txhash: mockTxHash1, + Index: 0, + Denomination: 7, + }, + { + Txhash: mockTxHash2, + Index: 0, + Denomination: 7, + } ], }; + console.log('Wallet key/addres pairs: ', utxoAddresses); // Manually populate the UTXO addresses and outpoints into the UTXOHDWallet - utxoWallet.addressOutpoints = addressOutPoints; - utxoWallet.utxoAddresses = utxoAddresses; - console.log('Wallet key/addres pairs: ', utxoWallet.utxoAddresses); + utxoWallet.shardWalletsMap.set('cyprus1', {addressesInfo: utxoAddresses, outpoints: addressOutPoints}) // Define tx inputs, outputs and chainId for the UTXO let txInputs = [ { - txhash: mockTxHash1, - index: 0, // ! NOTE: The pubkey is in uncompressed format. Only this format will result in a valid address - pubKey: hexToUint8Array(pubkey1uncompressed), + pub_key: hexToUint8Array(pubkey1uncompressed), + previous_out_point: + { + hash: { + value: hexToUint8Array(mockTxHash1), + }, + index: 0, + }, }, { - txhash: mockTxHash2, - index: 0, // ! NOTE: The pubkey is in uncompressed format. Only this format will result in a valid address - pubKey: hexToUint8Array(pubkey2uncompressed), - }, + pub_key: hexToUint8Array(pubkey2uncompressed), + previous_out_point: + { + hash: { + value: hexToUint8Array(mockTxHash2), + }, + index: 0, + }, + } ]; - console.log('txInputs:', txInputs) - + console.log('\ntxInputs[0].pubKey: ', hexlify(txInputs[0].pub_key)); + console.log('txInputs[1].pubKey: ', hexlify(txInputs[1].pub_key)); let txOutputs = [ { - Address: addr2, - Denomination: 7, + address: hexToUint8Array(addr2), + denomination: 7, }, ]; - console.log('txOutputs:', txOutputs) + console.log('\ntxOutput.address:', hexlify(txOutputs[0].address)); - const chainId = BigInt(969); - // Create the UTXO to be signed + const chainId = BigInt(969); const utxo = createTransaction(chainId, txInputs, txOutputs, addr1); - console.log('utxo tx Serialized:', utxo.unsignedSerialized); - // calculate the hash of the UTXO (message to be signed) + // calculate the hash of the tx (message to be signed) const txHash = keccak_256(utxo.unsignedSerialized); - console.log('tx hash to sign:', hexlify(txHash)); + console.log('\ntx hash to sign:', hexlify(txHash)); // Sign the tx - console.log('Signing UTXO...'); - const signedUTXO = await utxoWallet.signTransaction(utxo); + console.log('Signing tx...'); + const signedTx = await utxoWallet.signTransaction(utxo); - // Get the signature from the signed UTXO - console.log("Getting the signature...") - console.log('Signature: ', signedUTXO.signature); - const signatureSerialzed = getSignatureSerialized(signedUTXO.signature); + console.log('Unmarshalling signed tx...') + const signedTxUnmarshalled = quais.QiTransaction.from(signedTx); + console.log('Signed tx:', signedTxUnmarshalled); + + // Get the signature from the signed tx + const signatureSerialzed = signedTxUnmarshalled.signature; - // Verify the transaction passing the signature, txHash and public key (in compressed format) console.log('Verifying transaction musig signature...'); - + // Verify the transaction passing the signature, txHash and public key (in compressed format) const verified = verifyMusigSignature(signatureSerialzed, txHash, [hexToUint8Array(pubkey1), hexToUint8Array(pubkey2)]); console.log('Verified:', verified); diff --git a/scripts/signUTXOTransaction_schnoor.js b/scripts/signTransaction_schnoor.js similarity index 72% rename from scripts/signUTXOTransaction_schnoor.js rename to scripts/signTransaction_schnoor.js index a98259b..be436e8 100644 --- a/scripts/signUTXOTransaction_schnoor.js +++ b/scripts/signTransaction_schnoor.js @@ -1,6 +1,3 @@ -//! NOTE: This script is for developement and only works with a modified version of the 'signTransaction' method in the UTXOHDWallet class -//! In order for this script to work, 'signTransaction' must be modified to return the tx object (instead of the serialized string) - const quais = require('quais6') const { keccak_256 } = require('@noble/hashes/sha3'); @@ -53,35 +50,37 @@ async function main() { ], }; + console.log('Wallet key/addres pairs: ', utxoAddresses); // Manually populate the UTXO addresses and outpoints into the UTXOHDWallet - utxoWallet.addressOutpoints = addressOutPoints; - utxoWallet.utxoAddresses = utxoAddresses; - console.log('Wallet key/addres pairs: ', utxoWallet.utxoAddresses); + utxoWallet.shardWalletsMap.set('cyprus1', {addressesInfo: utxoAddresses, outpoints: addressOutPoints}) // Define tx inputs, outputs and chainId for the UTXO let txInputs = [ { - txhash: mockTxHash1, - index: 0, // ! NOTE: The pubkey is in uncompressed format. Only this format will result in a valid address - pubKey: hexToUint8Array(pubkey1uncompressed), + pub_key: hexToUint8Array(pubkey1uncompressed), + previous_out_point: + { + hash: { + value: hexToUint8Array(mockTxHash1), + }, + index: 0, + }, }, ]; - console.log('txInputs:', txInputs) - + console.log('\ntxInputs[0].pubKey: ', hexlify(txInputs[0].pub_key)); let txOutputs = [ { - Address: addr2, - Denomination: 7, + address: hexToUint8Array(addr2), + denomination: 7, }, ]; - console.log('txOutputs:', txOutputs) + console.log('\ntxOutput.address:', hexlify(txOutputs[0].address)); - const chainId = BigInt(969); - // Create the UTXO to be signed + const chainId = BigInt(969); const utxo = createTransaction(chainId, txInputs, txOutputs, addr1); console.log('utxo tx Serialized:', utxo.unsignedSerialized); @@ -90,13 +89,15 @@ async function main() { console.log('tx hash to sign:', hexlify(txHash)); // Sign the tx - console.log('Signing UTXO...'); - const signedUTXO = await utxoWallet.signTransaction(utxo); + console.log('Signing tx...'); + const signedTx = await utxoWallet.signTransaction(utxo); + + console.log('Unmarshalling signed tx...') + const signedTxUnmarshalled = quais.QiTransaction.from(signedTx); + console.log('Signed tx:', signedTxUnmarshalled); - // Get the signature from the signed UTXO - console.log("Getting the signature...") - console.log('Signature: ', signedUTXO.signature); - const signatureSerialzed = getSignatureSerialized(signedUTXO.signature); + // Get the signature from the signed tx + const signatureSerialzed = signedTxUnmarshalled.signature; // Verify the transaction passing the signature, txHash and public key (in compressed format) console.log('Verifying transaction Schnorr signature...'); diff --git a/scripts/tools.js b/scripts/tools.js index 1e20bec..5424187 100644 --- a/scripts/tools.js +++ b/scripts/tools.js @@ -7,10 +7,10 @@ const { nobleCrypto } = require("quais6"); // Function to create a UTXO function createTransaction(chainId, inputs, outputs, address) { - const tx = new quais.Transaction(address); + const tx = new quais.QiTransaction(address); tx.chainId = chainId; - tx.inputsUTXO = inputs; - tx.outputsUTXO = outputs; + tx.txInputs = inputs; + tx.txOutputs = outputs; return tx; } diff --git a/scripts/getUTXO.js b/scripts/wallet_init.js similarity index 74% rename from scripts/getUTXO.js rename to scripts/wallet_init.js index 8e6bed8..47a0978 100644 --- a/scripts/getUTXO.js +++ b/scripts/wallet_init.js @@ -13,19 +13,22 @@ async function main() { // connect wallet to provider const utxoConnectedWallet = utxoWallet.connect(quaisProvider); - // Ensure provider is ready - await quaisProvider.ready; + console.log('\nInitializing wallet...'); + await utxoConnectedWallet.init('cyprus1'); + + const shardWallets = utxoConnectedWallet.shardWalletsMap; - await utxoConnectedWallet.syncUTXOs('cyprus1', 5); + let addrData = shardWallets.get('cyprus1').addressesInfo; - let addresses = utxoConnectedWallet.utxoAddresses; + console.log('\nQi addresses: '); + for (let i = 0; i < addrData.length; i++) { + console.log(`Address[${i}]: ${addrData[i].address}`); + } - console.log('utxo addresses: ', addresses); - - let outpoints = utxoConnectedWallet.addressOutpoints; + let outpoints = shardWallets.get('cyprus1').outpoints; // get the outpoint for the first address - let [[firstAddress, firstAddressOutpoints]] = Object.entries(outpoints); + let [[firstAddress, firstAddressOutpoints]] = Array.from(outpoints); console.log('First Address:', firstAddress); console.log('Total Outpoints for First Address:', firstAddressOutpoints.length); @@ -33,7 +36,6 @@ async function main() { const denominations = [0.001, 0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1, 5, 10, 20, 50, 100, 1000, 10000, 100000, 1000000]; const totalValue = firstAddressOutpoints.reduce((acc, {TxHash, Index, Denomination}) => { const value = BigInt(denominations[Denomination]); - // console.log('TxHash:', TxHash, 'Index:', Index, 'Denomination:', denominations[Denomination], " value:", value); return acc + value; }, BigInt(0)); From 409d4e94ae25df264b2f1a5a95491dc3f535bc75 Mon Sep 17 00:00:00 2001 From: Alejo Acosta Date: Thu, 23 May 2024 13:43:19 -0300 Subject: [PATCH 2/2] update scripts to test QiHDWallet and QuaiHDWallet --- scripts/QIHDWallet_getAddress.js | 36 +++++++++++++++++++ ...js => QIHDWallet_signTransaction_musig.js} | 9 +++-- ... => QIHDWallet_signTransaction_schnoor.js} | 0 .../{wallet_init.js => QiHDWallet_init.js} | 8 ++--- scripts/QuaiHDWallet_getAddress.js | 21 +++++++++++ scripts/constants.js | 26 +++++++------- 6 files changed, 81 insertions(+), 19 deletions(-) create mode 100644 scripts/QIHDWallet_getAddress.js rename scripts/{signTransaction_musig.js => QIHDWallet_signTransaction_musig.js} (91%) rename scripts/{signTransaction_schnoor.js => QIHDWallet_signTransaction_schnoor.js} (100%) rename scripts/{wallet_init.js => QiHDWallet_init.js} (86%) create mode 100644 scripts/QuaiHDWallet_getAddress.js diff --git a/scripts/QIHDWallet_getAddress.js b/scripts/QIHDWallet_getAddress.js new file mode 100644 index 0000000..005673d --- /dev/null +++ b/scripts/QIHDWallet_getAddress.js @@ -0,0 +1,36 @@ +const hre = require('hardhat') +const quais = require('quais6') +const { MNEMONICPHRASE, QI_DERIVATIONPATH} = require('./constants.js'); + +async function main() { + // Configure quai network provider based on hardhat network config + const quaisProvider = new quais.JsonRpcProvider(hre.network.config.url) + + const mnemonic = quais.Mnemonic.fromPhrase(MNEMONICPHRASE); + const qiWallet = quais.QiHDWallet.fromMnemonic(mnemonic, QI_DERIVATIONPATH); + + // connect wallet to provider + const qiConnectedWallet = qiWallet.connect(quaisProvider); + + console.log('\nInitializing wallet...'); + await qiConnectedWallet.init('cyprus1'); + + const shardWallets = qiConnectedWallet.shardWalletsMap; + + let addrData = shardWallets.get('cyprus1').addressesInfo; + + console.log('\nQi addresses: '); + for (let i = 0; i < addrData.length; i++) { + console.log(`Address[${i}]: ${addrData[i].address}`); + } + + const nakedAddress = await qiConnectedWallet.getAddress('cyprus1'); + console.log('first naked Address:', nakedAddress); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) diff --git a/scripts/signTransaction_musig.js b/scripts/QIHDWallet_signTransaction_musig.js similarity index 91% rename from scripts/signTransaction_musig.js rename to scripts/QIHDWallet_signTransaction_musig.js index d678268..fe90027 100644 --- a/scripts/signTransaction_musig.js +++ b/scripts/QIHDWallet_signTransaction_musig.js @@ -17,7 +17,10 @@ async function main() { // Create the UTXO wallet const mnemonic = quais.Mnemonic.fromPhrase(mnemonicPhrase); - const utxoWallet = quais.UTXOHDWallet.fromMnemonic(mnemonic, derivationPath); + const qiWallet = quais.QiHDWallet.fromMnemonic(mnemonic, derivationPath); + + // print the name of the class of qiWallet + console.log('Class of qiWallet:', qiWallet.constructor.name); // Get the compressed public key, uncompressed public key and address for the two private keys const pubkey1 = getCompressedPublicKey(privKey1); @@ -58,7 +61,7 @@ async function main() { console.log('Wallet key/addres pairs: ', utxoAddresses); // Manually populate the UTXO addresses and outpoints into the UTXOHDWallet - utxoWallet.shardWalletsMap.set('cyprus1', {addressesInfo: utxoAddresses, outpoints: addressOutPoints}) + qiWallet.shardWalletsMap.set('cyprus1', {addressesInfo: utxoAddresses, outpoints: addressOutPoints}) // Define tx inputs, outputs and chainId for the UTXO let txInputs = [ @@ -108,7 +111,7 @@ async function main() { // Sign the tx console.log('Signing tx...'); - const signedTx = await utxoWallet.signTransaction(utxo); + const signedTx = await qiWallet.signTransaction(utxo); console.log('Unmarshalling signed tx...') const signedTxUnmarshalled = quais.QiTransaction.from(signedTx); diff --git a/scripts/signTransaction_schnoor.js b/scripts/QIHDWallet_signTransaction_schnoor.js similarity index 100% rename from scripts/signTransaction_schnoor.js rename to scripts/QIHDWallet_signTransaction_schnoor.js diff --git a/scripts/wallet_init.js b/scripts/QiHDWallet_init.js similarity index 86% rename from scripts/wallet_init.js rename to scripts/QiHDWallet_init.js index 47a0978..e5fedf5 100644 --- a/scripts/wallet_init.js +++ b/scripts/QiHDWallet_init.js @@ -8,15 +8,15 @@ async function main() { const mnemonicPhrase = "empower cook violin million wool twelve involve nice donate author mammal salt royal shiver birth olympic embody hello beef suit isolate mixed text spot"; const mnemonic = quais.Mnemonic.fromPhrase(mnemonicPhrase); const derivationPath = "m/44'/969'/0'/0"; - const utxoWallet = quais.UTXOHDWallet.fromMnemonic(mnemonic, derivationPath); + const qiWallet = quais.QiHDWallet.fromMnemonic(mnemonic, derivationPath); // connect wallet to provider - const utxoConnectedWallet = utxoWallet.connect(quaisProvider); + const connectedQiWallet = qiWallet.connect(quaisProvider); console.log('\nInitializing wallet...'); - await utxoConnectedWallet.init('cyprus1'); + await connectedQiWallet.init('cyprus1'); - const shardWallets = utxoConnectedWallet.shardWalletsMap; + const shardWallets = connectedQiWallet.shardWalletsMap; let addrData = shardWallets.get('cyprus1').addressesInfo; diff --git a/scripts/QuaiHDWallet_getAddress.js b/scripts/QuaiHDWallet_getAddress.js new file mode 100644 index 0000000..5e841e2 --- /dev/null +++ b/scripts/QuaiHDWallet_getAddress.js @@ -0,0 +1,21 @@ +const hre = require('hardhat') +const quais = require('quais6') +const { MNEMONICPHRASE, QI_DERIVATIONPATH} = require('./constants.js'); + +async function main() { + const mnemonic = quais.Mnemonic.fromPhrase(MNEMONICPHRASE); + const quaiWallet = quais.QuaiHDWallet.fromMnemonic(mnemonic, QI_DERIVATIONPATH); + + console.log("\nCalling quaiWallet.getAddress('cyprus1')..."); + let address = await quaiWallet.getAddress('cyprus1'); + console.log('getAddress(cyprus1) #1:', address); + address = await quaiWallet.getAddress('cyprus1'); + console.log('getAddress(cyprus1) #2:', address); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) diff --git a/scripts/constants.js b/scripts/constants.js index 2c4090f..cdb7d26 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -1,16 +1,18 @@ -const mnemonicPhrase = "empower cook violin million wool twelve involve nice donate author mammal salt royal shiver birth olympic embody hello beef suit isolate mixed text spot"; -const derivationPath = "m/44'/969'/0'/0"; -const privKey1 = "0x2d3236b8ae2cb7ab607886b50f2ebb2732491c26ae4f3ca005d3d7c4607f7d05"; -const privKey2 = "0xea5e2852d1dd5db30fadaad7dd203a56addb6201961c3fca35b203a2726e34c2"; -const mockTxHash1 = "0x1234567890123456789012345678901234567890123456789012345678901234"; -const mockTxHash2 = "0xef125e7cf37f3b8de7725d111b62168147b390fc22448c4f46b649768860c213"; +const MNEMONICPHRASE = "empower cook violin million wool twelve involve nice donate author mammal salt royal shiver birth olympic embody hello beef suit isolate mixed text spot"; +const QI_DERIVATIONPATH = "m/44'/969'/0'/0"; +const QUAI_DERIVATIONPATH = "m/44'/994'/0'/0"; +const PRIVKEY1 = "0x2d3236b8ae2cb7ab607886b50f2ebb2732491c26ae4f3ca005d3d7c4607f7d05"; +const PRIVKEY2 = "0xea5e2852d1dd5db30fadaad7dd203a56addb6201961c3fca35b203a2726e34c2"; +const MOCKTXHASH1 = "0x1234567890123456789012345678901234567890123456789012345678901234"; +const MOCKTXHASH2 = "0xef125e7cf37f3b8de7725d111b62168147b390fc22448c4f46b649768860c213"; module.exports = { - mnemonicPhrase, - derivationPath, - privKey1, - privKey2, - mockTxHash1, - mockTxHash2 + MNEMONICPHRASE, + QI_DERIVATIONPATH, + QUAI_DERIVATIONPATH, + PRIVKEY1, + PRIVKEY2, + MOCKTXHASH1, + MOCKTXHASH2 } \ No newline at end of file