From 7588468f03cfc6396816003ccaa72a30b073d9eb Mon Sep 17 00:00:00 2001 From: Dimasik Kolezhniuk Date: Mon, 22 Apr 2024 19:16:43 +0200 Subject: [PATCH] KMS provider improvements (#222) Migrate secp256k1 provider --- package-lock.json | 609 ++++++------------ package.json | 20 +- src/iden3comm/packers/jws.ts | 10 +- src/iden3comm/types/packer.ts | 4 +- src/iden3comm/utils/did.ts | 22 +- src/kms/key-providers/bjj-provider.ts | 15 +- src/kms/key-providers/ed25519-provider.ts | 15 +- src/kms/key-providers/index.ts | 2 +- ...56k1-provider.ts => secp256k1-provider.ts} | 60 +- src/kms/kms.ts | 26 + tests/handlers/auth.test.ts | 8 - tests/iden3comm/jws.test.ts | 33 +- tests/kms/kms.test.ts | 79 ++- 13 files changed, 406 insertions(+), 497 deletions(-) rename src/kms/key-providers/{sec256k1-provider.ts => secp256k1-provider.ts} (51%) diff --git a/package-lock.json b/package-lock.json index a5ee1560..023ed5de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,19 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.10.4", + "version": "1.11.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.10.4", + "version": "1.11.0", "license": "AGPL-3.0", "dependencies": { "@noble/curves": "^1.4.0", "ajv": "8.12.0", "ajv-formats": "2.1.1", - "did-jwt": "6.11.6", + "did-jwt": "8.0.4", "did-resolver": "4.1.0", - "elliptic": "6.5.4", "ethers": "6.8.0", "idb-keyval": "6.2.0", "js-sha3": "0.9.3", @@ -27,18 +26,17 @@ "@iden3/eslint-config": "https://github.com/iden3/eslint-config", "@microsoft/api-documenter": "^7.8.20", "@microsoft/api-extractor": "^7.9.0", - "@rollup/plugin-commonjs": "^25.0.4", - "@rollup/plugin-json": "^6.0.1", - "@rollup/plugin-node-resolve": "^15.2.1", - "@rollup/plugin-replace": "^5.0.3", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", "@rollup/plugin-terser": "^0.4.4", - "@rollup/plugin-typescript": "^11.1.4", + "@rollup/plugin-typescript": "^11.1.6", "@rollup/plugin-virtual": "^3.0.2", "@typechain/ethers-v6": "^0.5.1", "@types/chai": "^4.3.9", "@types/chai-as-promised": "^7.1.7", "@types/chai-spies": "^1.0.5", - "@types/elliptic": "^6.4.16", "@types/fs-extra": "^11.0.1", "@types/jsonld": "^1.5.11", "@types/mocha": "^10.0.3", @@ -55,7 +53,7 @@ "mocha": "10.2.0", "prettier": "^2.7.1", "rimraf": "^5.0.5", - "rollup": "^4.2.0", + "rollup": "^4.14.3", "ts-loader": "^9.4.1", "ts-node": "^10.9.1", "typescript": "^4.8.4" @@ -116,27 +114,27 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.1.tgz", - "integrity": "sha512-Pc65opHDliVpRHuKfzI+gSA4zcgr65O4cl64fFJIWEEh8JoHIHh0Oez1Eo8Arz8zq/JhgKodQaxEwUPRtZylVA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.4.tgz", + "integrity": "sha512-vg8Gih2MLK+kOkHJp4gBEIkyaIi00jgWot2D9QOmmfLC8jINSOzmCLta6Bvz/JSBCqnegV0L80jhxkol5GWNfQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.3.tgz", - "integrity": "sha512-5FcvN1JHw2sHJChotgx8Ek0lyuh4kCKelgMTTqhYJJtloNvUfpAFMeNQUtdlIaktwrSV9LtCdqwk48wL2wBacQ==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.4.tgz", + "integrity": "sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.2", - "@babel/generator": "^7.24.1", + "@babel/generator": "^7.24.4", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-module-transforms": "^7.23.3", - "@babel/helpers": "^7.24.1", - "@babel/parser": "^7.24.1", + "@babel/helpers": "^7.24.4", + "@babel/parser": "^7.24.4", "@babel/template": "^7.24.0", "@babel/traverse": "^7.24.1", "@babel/types": "^7.24.0", @@ -155,9 +153,9 @@ } }, "node_modules/@babel/generator": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.1.tgz", - "integrity": "sha512-DfCRfZsBcrPEHUfuBMgbJ1Ut01Y/itOs+hY2nFLgqsqXd52/iSiVq5TITtUasIUgm+IIKdY2/1I7auiQOEeC9A==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.4.tgz", + "integrity": "sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==", "dev": true, "dependencies": { "@babel/types": "^7.24.0", @@ -302,9 +300,9 @@ } }, "node_modules/@babel/helpers": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.1.tgz", - "integrity": "sha512-BpU09QqEe6ZCHuIHFphEFgvNSrubve1FtyMton26ekZ85gRGi6LrTF7zArARp2YvyFxloeiRmtSCq5sjh1WqIg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.4.tgz", + "integrity": "sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==", "dev": true, "dependencies": { "@babel/template": "^7.24.0", @@ -331,9 +329,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz", - "integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.4.tgz", + "integrity": "sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -343,9 +341,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.1.tgz", - "integrity": "sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" @@ -640,9 +638,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true, "peer": true }, @@ -666,7 +664,6 @@ "version": "1.0.0", "resolved": "git+ssh://git@github.com/iden3/eslint-config.git#2848a55e4d4fabe196315b4828158856a84292aa", "dev": true, - "license": "AGPL-3.0", "peerDependencies": { "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", @@ -898,16 +895,16 @@ } }, "node_modules/@microsoft/api-documenter": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.24.1.tgz", - "integrity": "sha512-DX332aznb5SWpOLGuymvzg2OZsQ5+dCbSm8yvVYqTylDgSAiPouvKrdlWPoEeicuLU8wzxSl3xv7DMb6xgYwPw==", + "version": "7.24.2", + "resolved": "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.24.2.tgz", + "integrity": "sha512-q03DXLBj7nzAzLyLRAVklBynqKgSFI/JBmrhF/mEEIpg8orNo4qKXWO1RSkD2IYrqvZV63b13mcUPYgcFdifQA==", "dev": true, "dependencies": { - "@microsoft/api-extractor-model": "7.28.13", + "@microsoft/api-extractor-model": "7.28.14", "@microsoft/tsdoc": "0.14.2", - "@rushstack/node-core-library": "4.0.2", - "@rushstack/terminal": "0.10.0", - "@rushstack/ts-command-line": "4.19.1", + "@rushstack/node-core-library": "4.1.0", + "@rushstack/terminal": "0.10.1", + "@rushstack/ts-command-line": "4.19.2", "js-yaml": "~3.13.1", "resolve": "~1.22.1" }, @@ -916,18 +913,18 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.43.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.43.0.tgz", - "integrity": "sha512-GFhTcJpB+MI6FhvXEI9b2K0snulNLWHqC/BbcJtyNYcKUiw7l3Lgis5ApsYncJ0leALX7/of4XfmXk+maT111w==", + "version": "7.43.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.43.1.tgz", + "integrity": "sha512-ohg40SsvFFgzHFAtYq5wKJc8ZDyY46bphjtnSvhSSlXpPTG7GHwyyXkn48UZiUCBwr2WC7TRC1Jfwz7nreuiyQ==", "dev": true, "dependencies": { - "@microsoft/api-extractor-model": "7.28.13", + "@microsoft/api-extractor-model": "7.28.14", "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "4.0.2", + "@rushstack/node-core-library": "4.1.0", "@rushstack/rig-package": "0.5.2", - "@rushstack/terminal": "0.10.0", - "@rushstack/ts-command-line": "4.19.1", + "@rushstack/terminal": "0.10.1", + "@rushstack/ts-command-line": "4.19.2", "lodash": "~4.17.15", "minimatch": "~3.0.3", "resolve": "~1.22.1", @@ -940,14 +937,14 @@ } }, "node_modules/@microsoft/api-extractor-model": { - "version": "7.28.13", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.28.13.tgz", - "integrity": "sha512-39v/JyldX4MS9uzHcdfmjjfS6cYGAoXV+io8B5a338pkHiSt+gy2eXQ0Q7cGFJ7quSa1VqqlMdlPrB6sLR/cAw==", + "version": "7.28.14", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.28.14.tgz", + "integrity": "sha512-Bery/c8A8SsKPSvA82cTTuy/+OcxZbLRmKhPkk91/AJOQzxZsShcrmHFAGeiEqSIrv1nPZ3tKq9kfMLdCHmsqg==", "dev": true, "dependencies": { "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "4.0.2" + "@rushstack/node-core-library": "4.1.0" } }, "node_modules/@microsoft/api-extractor/node_modules/lru-cache": { @@ -1049,6 +1046,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/@multiformats/base-x": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@multiformats/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==" + }, + "node_modules/@noble/ciphers": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.5.2.tgz", + "integrity": "sha512-GADtQmZCdgbnNp+daPLc3OY3ibEtGGDV/+CzeM3MFnhiQ7ELQKlsHWYq0YbYUXx4jU3/Y1erAxU6r+hwpewqmQ==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/curves": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", @@ -1295,9 +1305,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.13.2.tgz", - "integrity": "sha512-3XFIDKWMFZrMnao1mJhnOT1h2g0169Os848NhhmGweEcfJ4rCi+3yMCOLG4zA61rbJdkcrM/DjVZm9Hg5p5w7g==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.3.tgz", + "integrity": "sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g==", "cpu": [ "arm" ], @@ -1308,9 +1318,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.13.2.tgz", - "integrity": "sha512-GdxxXbAuM7Y/YQM9/TwwP+L0omeE/lJAR1J+olu36c3LqqZEBdsIWeQ91KBe6nxwOnb06Xh7JS2U5ooWU5/LgQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.3.tgz", + "integrity": "sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ==", "cpu": [ "arm64" ], @@ -1321,9 +1331,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.13.2.tgz", - "integrity": "sha512-mCMlpzlBgOTdaFs83I4XRr8wNPveJiJX1RLfv4hggyIVhfB5mJfN4P8Z6yKh+oE4Luz+qq1P3kVdWrCKcMYrrA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.3.tgz", + "integrity": "sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA==", "cpu": [ "arm64" ], @@ -1334,9 +1344,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.13.2.tgz", - "integrity": "sha512-yUoEvnH0FBef/NbB1u6d3HNGyruAKnN74LrPAfDQL3O32e3k3OSfLrPgSJmgb3PJrBZWfPyt6m4ZhAFa2nZp2A==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.3.tgz", + "integrity": "sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw==", "cpu": [ "x64" ], @@ -1347,9 +1357,22 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.13.2.tgz", - "integrity": "sha512-GYbLs5ErswU/Xs7aGXqzc3RrdEjKdmoCrgzhJWyFL0r5fL3qd1NPcDKDowDnmcoSiGJeU68/Vy+OMUluRxPiLQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.3.tgz", + "integrity": "sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.14.3.tgz", + "integrity": "sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw==", "cpu": [ "arm" ], @@ -1360,9 +1383,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.13.2.tgz", - "integrity": "sha512-L1+D8/wqGnKQIlh4Zre9i4R4b4noxzH5DDciyahX4oOz62CphY7WDWqJoQ66zNR4oScLNOqQJfNSIAe/6TPUmQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.3.tgz", + "integrity": "sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA==", "cpu": [ "arm64" ], @@ -1373,9 +1396,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.13.2.tgz", - "integrity": "sha512-tK5eoKFkXdz6vjfkSTCupUzCo40xueTOiOO6PeEIadlNBkadH1wNOH8ILCPIl8by/Gmb5AGAeQOFeLev7iZDOA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.3.tgz", + "integrity": "sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw==", "cpu": [ "arm64" ], @@ -1386,11 +1409,11 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.13.2.tgz", - "integrity": "sha512-zvXvAUGGEYi6tYhcDmb9wlOckVbuD+7z3mzInCSTACJ4DQrdSLPNUeDIcAQW39M3q6PDquqLWu7pnO39uSMRzQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.3.tgz", + "integrity": "sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw==", "cpu": [ - "ppc64le" + "ppc64" ], "dev": true, "optional": true, @@ -1399,9 +1422,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.13.2.tgz", - "integrity": "sha512-C3GSKvMtdudHCN5HdmAMSRYR2kkhgdOfye4w0xzyii7lebVr4riCgmM6lRiSCnJn2w1Xz7ZZzHKuLrjx5620kw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.3.tgz", + "integrity": "sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ==", "cpu": [ "riscv64" ], @@ -1412,9 +1435,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.13.2.tgz", - "integrity": "sha512-l4U0KDFwzD36j7HdfJ5/TveEQ1fUTjFFQP5qIt9gBqBgu1G8/kCaq5Ok05kd5TG9F8Lltf3MoYsUMw3rNlJ0Yg==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.3.tgz", + "integrity": "sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg==", "cpu": [ "s390x" ], @@ -1425,9 +1448,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.13.2.tgz", - "integrity": "sha512-xXMLUAMzrtsvh3cZ448vbXqlUa7ZL8z0MwHp63K2IIID2+DeP5iWIT6g1SN7hg1VxPzqx0xZdiDM9l4n9LRU1A==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.3.tgz", + "integrity": "sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA==", "cpu": [ "x64" ], @@ -1438,9 +1461,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.13.2.tgz", - "integrity": "sha512-M/JYAWickafUijWPai4ehrjzVPKRCyDb1SLuO+ZyPfoXgeCEAlgPkNXewFZx0zcnoIe3ay4UjXIMdXQXOZXWqA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.3.tgz", + "integrity": "sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg==", "cpu": [ "x64" ], @@ -1451,9 +1474,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.13.2.tgz", - "integrity": "sha512-2YWwoVg9KRkIKaXSh0mz3NmfurpmYoBBTAXA9qt7VXk0Xy12PoOP40EFuau+ajgALbbhi4uTj3tSG3tVseCjuA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.3.tgz", + "integrity": "sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg==", "cpu": [ "arm64" ], @@ -1464,9 +1487,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.13.2.tgz", - "integrity": "sha512-2FSsE9aQ6OWD20E498NYKEQLneShWes0NGMPQwxWOdws35qQXH+FplabOSP5zEe1pVjurSDOGEVCE2agFwSEsw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.3.tgz", + "integrity": "sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw==", "cpu": [ "ia32" ], @@ -1477,9 +1500,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.13.2.tgz", - "integrity": "sha512-7h7J2nokcdPePdKykd8wtc8QqqkqxIrUz7MHj6aNr8waBRU//NLDVnNjQnqQO6fqtjrtCdftpbTuOKAyrAQETQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.3.tgz", + "integrity": "sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA==", "cpu": [ "x64" ], @@ -1490,9 +1513,9 @@ ] }, "node_modules/@rushstack/node-core-library": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-4.0.2.tgz", - "integrity": "sha512-hyES82QVpkfQMeBMteQUnrhASL/KHPhd7iJ8euduwNJG4mu2GSOKybf0rOEjOm1Wz7CwJEUm9y0yD7jg2C1bfg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-4.1.0.tgz", + "integrity": "sha512-qz4JFBZJCf1YN5cAXa1dP6Mki/HrsQxc/oYGAGx29dF2cwF2YMxHoly0FBhMw3IEnxo5fMj0boVfoHVBkpkx/w==", "dev": true, "dependencies": { "fs-extra": "~7.0.1", @@ -1555,12 +1578,12 @@ } }, "node_modules/@rushstack/terminal": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.10.0.tgz", - "integrity": "sha512-UbELbXnUdc7EKwfH2sb8ChqNgapUOdqcCIdQP4NGxBpTZV2sQyeekuK3zmfQSa/MN+/7b4kBogl2wq0vpkpYGw==", + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.10.1.tgz", + "integrity": "sha512-C6Vi/m/84IYJTkfzmXr1+W8Wi3MmBjVF/q3za91Gb3VYjKbpALHVxY6FgH625AnDe5Z0Kh4MHKWA3Z7bqgAezA==", "dev": true, "dependencies": { - "@rushstack/node-core-library": "4.0.2", + "@rushstack/node-core-library": "4.1.0", "supports-color": "~8.1.1" }, "peerDependencies": { @@ -1573,163 +1596,23 @@ } }, "node_modules/@rushstack/ts-command-line": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.19.1.tgz", - "integrity": "sha512-J7H768dgcpG60d7skZ5uSSwyCZs/S2HrWP1Ds8d1qYAyaaeJmpmmLr9BVw97RjFzmQPOYnoXcKA4GkqDCkduQg==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.19.2.tgz", + "integrity": "sha512-cqmXXmBEBlzo9WtyUrHtF9e6kl0LvBY7aTSVX4jfnBfXWZQWnPq9JTFPlQZ+L/ZwjZ4HrNwQsOVvhe9oOucZkw==", "dev": true, "dependencies": { - "@rushstack/terminal": "0.10.0", + "@rushstack/terminal": "0.10.1", "@types/argparse": "1.0.38", "argparse": "~1.0.9", "string-argv": "~0.3.1" } }, - "node_modules/@stablelib/aead": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-1.0.1.tgz", - "integrity": "sha512-q39ik6sxGHewqtO0nP4BuSe3db5G1fEJE8ukvngS2gLkBXyy6E7pLubhbYgnkDFv6V8cWaxcE4Xn0t6LWcJkyg==" - }, - "node_modules/@stablelib/binary": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", - "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", - "dependencies": { - "@stablelib/int": "^1.0.1" - } - }, - "node_modules/@stablelib/bytes": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/bytes/-/bytes-1.0.1.tgz", - "integrity": "sha512-Kre4Y4kdwuqL8BR2E9hV/R5sOrUj6NanZaZis0V6lX5yzqC3hBuVSDXUIBqQv/sCpmuWRiHLwqiT1pqqjuBXoQ==" - }, - "node_modules/@stablelib/chacha": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-1.0.1.tgz", - "integrity": "sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/chacha20poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/chacha20poly1305/-/chacha20poly1305-1.0.1.tgz", - "integrity": "sha512-MmViqnqHd1ymwjOQfghRKw2R/jMIGT3wySN7cthjXCBdO+qErNPUBnRzqNpnvIwg7JBCg3LdeCZZO4de/yEhVA==", - "dependencies": { - "@stablelib/aead": "^1.0.1", - "@stablelib/binary": "^1.0.1", - "@stablelib/chacha": "^1.0.1", - "@stablelib/constant-time": "^1.0.1", - "@stablelib/poly1305": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/constant-time/-/constant-time-1.0.1.tgz", - "integrity": "sha512-tNOs3uD0vSJcK6z1fvef4Y+buN7DXhzHDPqRLSXUel1UfqMB1PWNsnnAezrKfEwTLpN0cGH2p9NNjs6IqeD0eg==" - }, - "node_modules/@stablelib/ed25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/ed25519/-/ed25519-1.0.3.tgz", - "integrity": "sha512-puIMWaX9QlRsbhxfDc5i+mNPMY+0TmQEskunY1rZEBPi1acBCVQAhnsk/1Hk50DGPtVsZtAWQg4NHGlVaO9Hqg==", - "dependencies": { - "@stablelib/random": "^1.0.2", - "@stablelib/sha512": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/hash": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/hash/-/hash-1.0.1.tgz", - "integrity": "sha512-eTPJc/stDkdtOcrNMZ6mcMK1e6yBbqRBaNW55XA1jU8w/7QdnCF0CmMmOD1m7VSkBR44PWrMHU2l6r8YEQHMgg==" - }, - "node_modules/@stablelib/int": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", - "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==" - }, - "node_modules/@stablelib/keyagreement": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/keyagreement/-/keyagreement-1.0.1.tgz", - "integrity": "sha512-VKL6xBwgJnI6l1jKrBAfn265cspaWBPAPEc62VBQrWHLqVgNRE09gQ/AnOEyKUWrrqfD+xSQ3u42gJjLDdMDQg==", - "dependencies": { - "@stablelib/bytes": "^1.0.1" - } - }, - "node_modules/@stablelib/poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-1.0.1.tgz", - "integrity": "sha512-1HlG3oTSuQDOhSnLwJRKeTRSAdFNVB/1djy2ZbS35rBSJ/PFqx9cf9qatinWghC2UbfOYD8AcrtbUQl8WoxabA==", - "dependencies": { - "@stablelib/constant-time": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/random": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", - "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha256": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz", - "integrity": "sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha512": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", - "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/wipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", - "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==" - }, - "node_modules/@stablelib/x25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/x25519/-/x25519-1.0.3.tgz", - "integrity": "sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==", - "dependencies": { - "@stablelib/keyagreement": "^1.0.1", - "@stablelib/random": "^1.0.2", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/xchacha20": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/xchacha20/-/xchacha20-1.0.1.tgz", - "integrity": "sha512-1YkiZnFF4veUwBVhDnDYwo6EHeKzQK4FnLiO7ezCl/zu64uG0bCCAUROJaBkaLH+5BEsO3W7BTXTguMbSLlWSw==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/chacha": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/xchacha20poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/xchacha20poly1305/-/xchacha20poly1305-1.0.1.tgz", - "integrity": "sha512-B1Abj0sMJ8h3HNmGnJ7vHBrAvxuNka6cJJoZ1ILN7iuacXp7sUYcgOVEOTLWj+rtQMpspY9tXSCRLPmN1mQNWg==", - "dependencies": { - "@stablelib/aead": "^1.0.1", - "@stablelib/chacha20poly1305": "^1.0.1", - "@stablelib/constant-time": "^1.0.1", - "@stablelib/wipe": "^1.0.1", - "@stablelib/xchacha20": "^1.0.1" + "node_modules/@scure/base": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.6.tgz", + "integrity": "sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g==", + "funding": { + "url": "https://paulmillr.com/funding/" } }, "node_modules/@tsconfig/node10": { @@ -1777,15 +1660,6 @@ "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", "dev": true }, - "node_modules/@types/bn.js": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.5.tgz", - "integrity": "sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/chai": { "version": "4.3.14", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.14.tgz", @@ -1810,19 +1684,10 @@ "@types/chai": "*" } }, - "node_modules/@types/elliptic": { - "version": "6.4.18", - "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.18.tgz", - "integrity": "sha512-UseG6H5vjRiNpQvrhy4VF/JXdA3V/Fp5amvveaL+fs28BZ6xIKJBPnUPRlEaZpysD9MbpfaLi8lbl7PGUAkpWw==", - "dev": true, - "dependencies": { - "@types/bn.js": "*" - } - }, "node_modules/@types/eslint": { - "version": "8.56.6", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.6.tgz", - "integrity": "sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==", + "version": "8.56.9", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.9.tgz", + "integrity": "sha512-W4W3KcqzjJ0sHg2vAq9vfml6OhsJ53TcUjUqfzzZf/EChUtwspszj/S0pzMxnfRcO55/iGq47dscXw71Fxc4Zg==", "dev": true, "peer": true, "dependencies": { @@ -1885,9 +1750,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.12.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.2.tgz", - "integrity": "sha512-zQ0NYO87hyN6Xrclcqp7f8ZbXNbRfoGWNcMvHTPQp9UUrwI0mI7XBz+cu7/W6/VClYo2g63B0cjull/srU7LgQ==", + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -2605,11 +2470,6 @@ ], "peer": true }, - "node_modules/bech32": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", - "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" - }, "node_modules/bfj": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.1.0.tgz", @@ -2654,11 +2514,6 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "peer": true }, - "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==" - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2680,11 +2535,6 @@ "node": ">=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==" - }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -2788,9 +2638,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001603", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001603.tgz", - "integrity": "sha512-iL2iSS0eDILMb9n5yKQoTBim9jMZ0Yrk8g0N9K7UzYyWnfIKzXBZD5ngpM37ZcL/cv0Mli8XtVMRYMQAfFpi5Q==", + "version": "1.0.30001611", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001611.tgz", + "integrity": "sha512-19NuN1/3PjA3QI8Eki55N8my4LzfkMCRLgCVfrl/slbSAchQfV0+GwjPrK3rq37As4UCLlM/DHajbKkAqbv92Q==", "dev": true, "funding": [ { @@ -3066,9 +2916,9 @@ "dev": true }, "node_modules/core-js": { - "version": "3.36.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.36.1.tgz", - "integrity": "sha512-BTvUrwxVBezj5SZ3f10ImnX2oRByMxql3EimVqMysepbC9EeMUOpLwdy6Eoili2x6E4kf+ZUB5k/+Jv55alPfA==", + "version": "3.37.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.0.tgz", + "integrity": "sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==", "dev": true, "hasInstallScript": true, "funding": { @@ -3171,29 +3021,21 @@ } }, "node_modules/did-jwt": { - "version": "6.11.6", - "resolved": "https://registry.npmjs.org/did-jwt/-/did-jwt-6.11.6.tgz", - "integrity": "sha512-OfbWknRxJuUqH6Lk0x+H1FsuelGugLbBDEwsoJnicFOntIG/A4y19fn0a8RLxaQbWQ5gXg0yDq5E2huSBiiXzw==", - "dependencies": { - "@stablelib/ed25519": "^1.0.2", - "@stablelib/random": "^1.0.1", - "@stablelib/sha256": "^1.0.1", - "@stablelib/x25519": "^1.0.2", - "@stablelib/xchacha20poly1305": "^1.0.1", - "bech32": "^2.0.0", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/did-jwt/-/did-jwt-8.0.4.tgz", + "integrity": "sha512-KPtG7H+8GgKGMiDqFvOdNy5BBN3hpA+8xV7VygEnpst5oPIqjvcH3rTtnPF55a8bOxIzE2PudKGIXIQhekv7WA==", + "dependencies": { + "@noble/ciphers": "^0.5.0", + "@noble/curves": "^1.0.0", + "@noble/hashes": "^1.3.0", + "@scure/base": "^1.1.3", "canonicalize": "^2.0.0", - "did-resolver": "^4.0.0", - "elliptic": "^6.5.4", - "js-sha3": "^0.8.0", - "multiformats": "^9.6.5", - "uint8arrays": "^3.0.0" + "did-resolver": "^4.1.0", + "multibase": "^4.0.6", + "multiformats": "^9.6.2", + "uint8arrays": "3.1.1" } }, - "node_modules/did-jwt/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==" - }, "node_modules/did-resolver": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-4.1.0.tgz", @@ -3240,9 +3082,9 @@ "dev": true }, "node_modules/ejs": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", - "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", "peer": true, "dependencies": { "jake": "^10.8.5" @@ -3255,25 +3097,11 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.722", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.722.tgz", - "integrity": "sha512-5nLE0TWFFpZ80Crhtp4pIp8LXCztjYX41yUcV6b+bKR2PqzjskTMOOlBi1VjBHlvHwS+4gar7kNKOrsbsewEZQ==", + "version": "1.4.741", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.741.tgz", + "integrity": "sha512-AyTBZqDoS7/mvQK22gOQpjxbeV8iPeUBTvYlEh/1S9dKAHgQdxuF49g9rLbj0cRKtqH8PzLJzqT3nAdl+qoZTA==", "dev": true }, - "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -4326,15 +4154,6 @@ "node": ">=8" } }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -4356,16 +4175,6 @@ "he": "bin/he" } }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -4461,7 +4270,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/is-binary-path": { "version": "2.1.0", @@ -5101,15 +4911,12 @@ } }, "node_modules/magic-string": { - "version": "0.30.8", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.8.tgz", - "integrity": "sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==", + "version": "0.30.10", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz", + "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "engines": { - "node": ">=12" } }, "node_modules/make-error": { @@ -5170,16 +4977,6 @@ "node": ">= 0.6" } }, - "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==" - }, - "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==" - }, "node_modules/minimatch": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", @@ -5385,6 +5182,19 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/multibase": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.6.tgz", + "integrity": "sha512-x23pDe5+svdLz/k5JPGCVdfn7Q5mZVMBETiC+ORfO+sor9Sgs0smJzAjfTbM5tckeCqnaUuMYoz+k3RXMmJClQ==", + "deprecated": "This module has been superseded by the multiformats module", + "dependencies": { + "@multiformats/base-x": "^4.0.1" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, "node_modules/multiformats": { "version": "9.9.0", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", @@ -5961,9 +5771,9 @@ } }, "node_modules/rollup": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.13.2.tgz", - "integrity": "sha512-MIlLgsdMprDBXC+4hsPgzWUasLO9CE4zOkj/u6j+Z6j5A4zRY+CtiXAdJyPtgCsc42g658Aeh1DlrdVEJhsL2g==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.3.tgz", + "integrity": "sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -5976,21 +5786,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.13.2", - "@rollup/rollup-android-arm64": "4.13.2", - "@rollup/rollup-darwin-arm64": "4.13.2", - "@rollup/rollup-darwin-x64": "4.13.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.13.2", - "@rollup/rollup-linux-arm64-gnu": "4.13.2", - "@rollup/rollup-linux-arm64-musl": "4.13.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.13.2", - "@rollup/rollup-linux-riscv64-gnu": "4.13.2", - "@rollup/rollup-linux-s390x-gnu": "4.13.2", - "@rollup/rollup-linux-x64-gnu": "4.13.2", - "@rollup/rollup-linux-x64-musl": "4.13.2", - "@rollup/rollup-win32-arm64-msvc": "4.13.2", - "@rollup/rollup-win32-ia32-msvc": "4.13.2", - "@rollup/rollup-win32-x64-msvc": "4.13.2", + "@rollup/rollup-android-arm-eabi": "4.14.3", + "@rollup/rollup-android-arm64": "4.14.3", + "@rollup/rollup-darwin-arm64": "4.14.3", + "@rollup/rollup-darwin-x64": "4.14.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.14.3", + "@rollup/rollup-linux-arm-musleabihf": "4.14.3", + "@rollup/rollup-linux-arm64-gnu": "4.14.3", + "@rollup/rollup-linux-arm64-musl": "4.14.3", + "@rollup/rollup-linux-powerpc64le-gnu": "4.14.3", + "@rollup/rollup-linux-riscv64-gnu": "4.14.3", + "@rollup/rollup-linux-s390x-gnu": "4.14.3", + "@rollup/rollup-linux-x64-gnu": "4.14.3", + "@rollup/rollup-linux-x64-musl": "4.14.3", + "@rollup/rollup-win32-arm64-msvc": "4.14.3", + "@rollup/rollup-win32-ia32-msvc": "4.14.3", + "@rollup/rollup-win32-x64-msvc": "4.14.3", "fsevents": "~2.3.2" } }, @@ -6390,9 +6201,9 @@ } }, "node_modules/terser": { - "version": "5.30.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.0.tgz", - "integrity": "sha512-Y/SblUl5kEyEFzhMAQdsxVHh+utAxd4IuRNJzKywY/4uzSogh3G219jqbDDxYu4MXO9CzY3tSEqmZvW6AoEDJw==", + "version": "5.30.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.3.tgz", + "integrity": "sha512-STdUgOUx8rLbMGO9IOwHLpCqolkDITFFQSMYYwKE1N2lY6MVSaeoi10z/EhWxRc6ybqoVmKSkhKYH/XUpl7vSA==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", diff --git a/package.json b/package.json index e7b0dbcc..77ec481d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.10.4", + "version": "1.11.0", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", @@ -25,7 +25,7 @@ "build": "npm run clean && npm run build:node && npm run build:browser", "build:node": "npm run build:tsc && npm run build:esm", "build:esm": "tsc --outDir dist/node/esm --declaration --declarationDir dist/types", - "build:browser": "rollup -c rollup.config.mjs --failAfterWarnings", + "build:browser": "rollup -c rollup.config.mjs --failAfterWarnings --filterLogs \"/* @__PURE__ */\"", "build:tsc": "tsc --module commonjs --outDir dist/node/cjs", "doc:extract": "ts-node ./scripts/doc-extract.ts", "doc:documenter": "ts-node ./scripts/doc-documenter.ts", @@ -53,18 +53,17 @@ "@iden3/eslint-config": "https://github.com/iden3/eslint-config", "@microsoft/api-documenter": "^7.8.20", "@microsoft/api-extractor": "^7.9.0", - "@rollup/plugin-commonjs": "^25.0.4", - "@rollup/plugin-json": "^6.0.1", - "@rollup/plugin-node-resolve": "^15.2.1", - "@rollup/plugin-replace": "^5.0.3", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", "@rollup/plugin-terser": "^0.4.4", - "@rollup/plugin-typescript": "^11.1.4", + "@rollup/plugin-typescript": "^11.1.6", "@rollup/plugin-virtual": "^3.0.2", "@typechain/ethers-v6": "^0.5.1", "@types/chai": "^4.3.9", "@types/chai-as-promised": "^7.1.7", "@types/chai-spies": "^1.0.5", - "@types/elliptic": "^6.4.16", "@types/fs-extra": "^11.0.1", "@types/jsonld": "^1.5.11", "@types/mocha": "^10.0.3", @@ -81,7 +80,7 @@ "mocha": "10.2.0", "prettier": "^2.7.1", "rimraf": "^5.0.5", - "rollup": "^4.2.0", + "rollup": "^4.14.3", "ts-loader": "^9.4.1", "ts-node": "^10.9.1", "typescript": "^4.8.4" @@ -100,9 +99,8 @@ "@noble/curves": "^1.4.0", "ajv": "8.12.0", "ajv-formats": "2.1.1", - "did-jwt": "6.11.6", + "did-jwt": "8.0.4", "did-resolver": "4.1.0", - "elliptic": "6.5.4", "ethers": "6.8.0", "idb-keyval": "6.2.0", "js-sha3": "0.9.3", diff --git a/src/iden3comm/packers/jws.ts b/src/iden3comm/packers/jws.ts index 98aabb7d..17218961 100644 --- a/src/iden3comm/packers/jws.ts +++ b/src/iden3comm/packers/jws.ts @@ -5,6 +5,7 @@ import { keyPath, KMS } from '../../kms/'; import { verifyJWS } from 'did-jwt'; import { DIDDocument, Resolvable, parse } from 'did-resolver'; +import { bytesToBase64url } from '../../utils/encoding'; import { byteDecoder, byteEncoder, @@ -163,8 +164,8 @@ export class JWSPacker implements IPacker { const signingInputBytes = byteEncoder.encode(signingInput); let signatureBase64: string; if (params.signer) { - const signerFn = params.signer(vm, signingInputBytes); - signatureBase64 = (await signerFn(signingInput)).toString(); + const signature = await params.signer(vm, signingInputBytes); + signatureBase64 = bytesToBase64url(signature); } else { if (!publicKeyBytes) { throw new Error('No public key found'); @@ -176,10 +177,11 @@ export class JWSPacker implements IPacker { const signatureBytes = await this._kms.sign( { type: kmsKeyType, id: keyPath(kmsKeyType, bytesToHex(publicKeyBytes)) }, - signingInputBytes + signingInputBytes, + { alg: params.alg } ); - signatureBase64 = byteDecoder.decode(signatureBytes); + signatureBase64 = bytesToBase64url(signatureBytes); } return byteEncoder.encode(`${signingInput}.${signatureBase64}`); diff --git a/src/iden3comm/types/packer.ts b/src/iden3comm/types/packer.ts index 3693a94b..05790936 100644 --- a/src/iden3comm/types/packer.ts +++ b/src/iden3comm/types/packer.ts @@ -4,7 +4,6 @@ import { ProvingMethodAlg } from '@iden3/js-jwz'; import { CircuitId } from '../../circuits'; import { MediaType } from '../constants'; import { DIDDocument, VerificationMethod } from 'did-resolver'; -import { Signer } from 'did-jwt'; /** * Protocol message type */ @@ -50,8 +49,9 @@ export type ZKPPackerParams = PackerParams & { /** * SignerFn Is function to sign data with a verification method + * @returns Promise of signature bytes; */ -export type SignerFn = (vm: VerificationMethod, data: Uint8Array) => Signer; +export type SignerFn = (vm: VerificationMethod, dataToSign: Uint8Array) => Promise; /** * JWSPackerParams are parameters for JWS packer diff --git a/src/iden3comm/utils/did.ts b/src/iden3comm/utils/did.ts index 237290bd..84135516 100644 --- a/src/iden3comm/utils/did.ts +++ b/src/iden3comm/utils/did.ts @@ -1,6 +1,6 @@ import { SUPPORTED_PUBLIC_KEY_TYPES } from '../constants'; -import elliptic from 'elliptic'; import { DIDDocument, VerificationMethod } from 'did-resolver'; +import { secp256k1 as sec } from '@noble/curves/secp256k1'; import { KmsKeyType } from '../../kms'; import { base58ToBytes, base64UrlToBytes, bytesToHex, hexToBytes } from '../../utils'; @@ -29,8 +29,6 @@ export const resolveVerificationMethods = (didDocument: DIDDocument): Verificati return sortedVerificationMethods; }; -const secp256k1 = new elliptic.ec('secp256k1'); - export const extractPublicKeyBytes = ( vm: VerificationMethod ): { publicKeyBytes: Uint8Array | null; kmsKeyType?: KmsKeyType } => { @@ -55,15 +53,17 @@ export const extractPublicKeyBytes = ( vm.publicKeyJwk.x && vm.publicKeyJwk.y ) { + const [xHex, yHex] = [ + base64UrlToBytes(vm.publicKeyJwk.x), + base64UrlToBytes(vm.publicKeyJwk.y) + ].map(bytesToHex); + const x = xHex.includes('0x') ? BigInt(xHex) : BigInt(`0x${xHex}`); + const y = yHex.includes('0x') ? BigInt(yHex) : BigInt(`0x${yHex}`); return { - publicKeyBytes: hexToBytes( - secp256k1 - .keyFromPublic({ - x: bytesToHex(base64UrlToBytes(vm.publicKeyJwk.x)), - y: bytesToHex(base64UrlToBytes(vm.publicKeyJwk.y)) - }) - .getPublic('hex') - ), + publicKeyBytes: sec.ProjectivePoint.fromAffine({ + x, + y + }).toRawBytes(false), kmsKeyType: KmsKeyType.Secp256k1 }; } diff --git a/src/kms/key-providers/bjj-provider.ts b/src/kms/key-providers/bjj-provider.ts index f1c0479e..171df184 100644 --- a/src/kms/key-providers/bjj-provider.ts +++ b/src/kms/key-providers/bjj-provider.ts @@ -1,9 +1,10 @@ -import { Hex, PrivateKey } from '@iden3/js-crypto'; +import { Hex, PrivateKey, PublicKey, Signature } from '@iden3/js-crypto'; import { BytesHelper, checkBigIntInField } from '@iden3/js-iden3-core'; import { IKeyProvider } from '../kms'; import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store'; import * as providerHelpers from '../provider-helpers'; +import { hexToBytes } from '../../utils'; /** * Provider for Baby Jub Jub keys @@ -24,6 +25,9 @@ export class BjjProvider implements IKeyProvider { * @param {AbstractPrivateKeyStore} keyStore - key store for kms */ constructor(keyType: KmsKeyType, keyStore: AbstractPrivateKeyStore) { + if (keyType !== KmsKeyType.BabyJubJub) { + throw new Error('Key type must be BabyJubJub'); + } this.keyType = keyType; this.keyStore = keyStore; } @@ -88,4 +92,13 @@ export class BjjProvider implements IKeyProvider { return new PrivateKey(Hex.decodeString(privateKeyHex)); } + + async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { + const publicKey = await this.publicKey(keyId); + + return PublicKey.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon( + BytesHelper.bytesToInt(message), + Signature.newFromCompressed(hexToBytes(signatureHex)) + ); + } } diff --git a/src/kms/key-providers/ed25519-provider.ts b/src/kms/key-providers/ed25519-provider.ts index 1a9dbd62..4d6ade44 100644 --- a/src/kms/key-providers/ed25519-provider.ts +++ b/src/kms/key-providers/ed25519-provider.ts @@ -3,6 +3,7 @@ import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store'; import * as providerHelpers from '../provider-helpers'; import { ed25519 } from '@noble/curves/ed25519'; import { bytesToHex } from '../../utils'; +import { sha256 } from '@iden3/js-crypto'; /** * Provider for Ed25519 keys @@ -65,7 +66,19 @@ export class Ed25519Provider implements IKeyProvider { */ async sign(keyId: KmsKeyId, data: Uint8Array): Promise { const privateKeyHex = await this.privateKey(keyId); - return ed25519.sign(data, privateKeyHex); + return ed25519.sign(sha256(data), privateKeyHex); + } + + /** + * Verifies a signature for the given message and key identifier. + * @param message - The message to verify the signature against. + * @param signatureHex - The signature to verify, as a hexadecimal string. + * @param keyId - The key identifier to use for verification. + * @returns A Promise that resolves to a boolean indicating whether the signature is valid. + */ + async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { + const publicKeyHex = await this.publicKey(keyId); + return ed25519.verify(signatureHex, sha256(message), publicKeyHex); } /** diff --git a/src/kms/key-providers/index.ts b/src/kms/key-providers/index.ts index 51cf1e46..1ca4cd7c 100644 --- a/src/kms/key-providers/index.ts +++ b/src/kms/key-providers/index.ts @@ -1,3 +1,3 @@ export * from './bjj-provider'; export * from './ed25519-provider'; -export * from './sec256k1-provider'; +export * from './secp256k1-provider'; diff --git a/src/kms/key-providers/sec256k1-provider.ts b/src/kms/key-providers/secp256k1-provider.ts similarity index 51% rename from src/kms/key-providers/sec256k1-provider.ts rename to src/kms/key-providers/secp256k1-provider.ts index a7693a8d..4d6f1c1a 100644 --- a/src/kms/key-providers/sec256k1-provider.ts +++ b/src/kms/key-providers/secp256k1-provider.ts @@ -1,14 +1,15 @@ import { IKeyProvider } from '../kms'; import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store'; -import Elliptic from 'elliptic'; import * as providerHelpers from '../provider-helpers'; -import { ES256KSigner } from 'did-jwt'; -import { base64UrlToBytes, byteEncoder, bytesToHex, hexToBytes } from '../../utils'; +import { base64UrlToBytes, bytesToHex } from '../../utils'; +import { secp256k1 } from '@noble/curves/secp256k1'; +import { sha256 } from '@iden3/js-crypto'; +import { ES256KSigner, hexToBytes } from 'did-jwt'; /** - * Provider for Sec256p1 keys256p1 + * Provider for Secp256k1 * @public - * @class Sec256p1Provider + * @class Secp256k1Provider * @implements implements IKeyProvider interface */ export class Sec256k1Provider implements IKeyProvider { @@ -19,16 +20,17 @@ export class Sec256k1Provider implements IKeyProvider { keyType: KmsKeyType; private _keyStore: AbstractPrivateKeyStore; - private readonly _ec; /** * Creates an instance of BjjProvider. * @param {KmsKeyType} keyType - kms key type * @param {AbstractPrivateKeyStore} keyStore - key store for kms */ constructor(keyType: KmsKeyType, keyStore: AbstractPrivateKeyStore) { + if (keyType !== KmsKeyType.Secp256k1) { + throw new Error('Key type must be Secp256k1'); + } this.keyType = keyType; this._keyStore = keyStore; - this._ec = new Elliptic.ec('secp256k1'); } /** * generates a baby jub jub key from a seed phrase @@ -39,14 +41,15 @@ export class Sec256k1Provider implements IKeyProvider { if (seed.length !== 32) { throw new Error('Seed should be 32 bytes'); } - const keyPair = this._ec.keyFromPrivate(seed); + const publicKey = secp256k1.getPublicKey(seed); const kmsId = { type: this.keyType, - id: providerHelpers.keyPath(this.keyType, keyPair.getPublic().encode('hex', false)) + id: providerHelpers.keyPath(this.keyType, bytesToHex(publicKey)) }; + await this._keyStore.importKey({ alias: kmsId.id, - key: keyPair.getPrivate().toString('hex').padStart(64, '0') + key: bytesToHex(seed).padStart(64, '0') }); return kmsId; @@ -59,16 +62,16 @@ export class Sec256k1Provider implements IKeyProvider { */ async publicKey(keyId: KmsKeyId): Promise { const privateKeyHex = await this.privateKey(keyId); - return this._ec.keyFromPrivate(privateKeyHex, 'hex').getPublic().encode('hex', false); // 04 + x + y (uncompressed key) + const publicKey = secp256k1.getPublicKey(privateKeyHex, false); // 04 + x + y (uncompressed key) + return bytesToHex(publicKey); } /** - * signs prepared payload of size, - * with a key id - * - * @param {KmsKeyId} keyId - key identifier - * @param {Uint8Array} data - data to sign (32 bytes) - * @returns Uint8Array signature + * Signs the given data using the private key associated with the specified key identifier. + * @param keyId - The key identifier to use for signing. + * @param data - The data to sign. + * @param opts - Signing options, such as the algorithm to use. + * @returns A Promise that resolves to the signature as a Uint8Array. */ async sign( keyId: KmsKeyId, @@ -76,20 +79,29 @@ export class Sec256k1Provider implements IKeyProvider { opts: { [key: string]: unknown } = { alg: 'ES256K' } ): Promise { const privateKeyHex = await this.privateKey(keyId); - if (!privateKeyHex) { - throw new Error('Private key not found for keyId: ' + keyId.id); - } + const signatureBase64 = await ES256KSigner( hexToBytes(privateKeyHex), opts.alg === 'ES256K-R' )(data); - const signatureHex = bytesToHex(base64UrlToBytes(signatureBase64.toString())); - if (typeof signatureHex !== 'string') { - throw new Error('Signature is not a string'); + if (typeof signatureBase64 !== 'string') { + throw new Error('signatureBase64 must be a string'); } - return byteEncoder.encode(signatureBase64.toString()); + return base64UrlToBytes(signatureBase64); + } + + /** + * Verifies a signature for the given message and key identifier. + * @param message - The message to verify the signature against. + * @param signatureHex - The signature to verify, as a hexadecimal string. + * @param keyId - The key identifier to use for verification. + * @returns A Promise that resolves to a boolean indicating whether the signature is valid. + */ + async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { + const publicKeyHex = await this.publicKey(keyId); + return secp256k1.verify(signatureHex, sha256(message), publicKeyHex); } private async privateKey(keyId: KmsKeyId): Promise { diff --git a/src/kms/kms.ts b/src/kms/kms.ts index 94e4f170..081c1d9a 100644 --- a/src/kms/kms.ts +++ b/src/kms/kms.ts @@ -37,6 +37,16 @@ export interface IKeyProvider { * @returns `Promise` */ newPrivateKeyFromSeed(seed: Uint8Array): Promise; + + /** + * Verifies a message signature using the provided key ID. + * + * @param message - The message bytes to verify. + * @param signatureHex - The signature in hexadecimal format. + * @param keyId - The KMS key ID used to verify the signature. + * @returns A promise that resolves to a boolean indicating whether the signature is valid. + */ + verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise; } /** * Key management system class contains different key providers. @@ -112,4 +122,20 @@ export class KMS { return keyProvider.sign(keyId, data, opts); } + + /** + * Verifies a signature against the provided data and key ID. + * + * @param data - The data to verify the signature against. + * @param signatureHex - The signature to verify, in hexadecimal format. + * @param keyId - The key ID to use for verification. + * @returns A promise that resolves to a boolean indicating whether the signature is valid. + */ + verify(data: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { + const keyProvider = this._registry.get(keyId.type); + if (!keyProvider) { + throw new Error(`keyProvider not found for: ${keyId.type}`); + } + return keyProvider.verify(data, signatureHex, keyId); + } } diff --git a/tests/handlers/auth.test.ts b/tests/handlers/auth.test.ts index 30a205ec..6fb7c0d1 100644 --- a/tests/handlers/auth.test.ts +++ b/tests/handlers/auth.test.ts @@ -401,9 +401,7 @@ describe('auth', () => { const msgBytes = byteEncoder.encode(JSON.stringify(authReq)); const authRes = await authHandler.handleAuthorizationRequest(userDID, msgBytes); - // console.log(JSON.stringify(authRes.authResponse)); const tokenStr = authRes.token; - // console.log(tokenStr); expect(tokenStr).to.be.a('string'); const token = await Token.parse(tokenStr); expect(token).to.be.a('object'); @@ -585,9 +583,7 @@ describe('auth', () => { // Restore the mock state storage MOCK_STATE_STORAGE.getLatestStateById = previousGetLatestStateById; - // console.log(JSON.stringify(authRes.authResponse)); const tokenStr = authRes.token; - // console.log(tokenStr); expect(tokenStr).to.be.a('string'); const token = await Token.parse(tokenStr); expect(token).to.be.a('object'); @@ -811,9 +807,7 @@ describe('auth', () => { const msgBytes = byteEncoder.encode(JSON.stringify(authReq)); const authRes = await authHandler.handleAuthorizationRequest(didUser, msgBytes); - // console.log('authRes', JSON.stringify(authRes.authResponse)); const tokenStr = authRes.token; - // console.log(tokenStr); expect(tokenStr).to.be.a('string'); const token = await Token.parse(tokenStr); expect(token).to.be.a('object'); @@ -2056,9 +2050,7 @@ describe('auth', () => { const msgBytes = byteEncoder.encode(JSON.stringify(authReq)); const authRes = await authHandler.handleAuthorizationRequest(userDID, msgBytes); - // console.log(JSON.stringify(authRes.authResponse)); const tokenStr = authRes.token; - // console.log(tokenStr); expect(tokenStr).to.be.a('string'); const token = await Token.parse(tokenStr); expect(token).to.be.a('object'); diff --git a/tests/iden3comm/jws.test.ts b/tests/iden3comm/jws.test.ts index a3b94b76..8d1415c2 100644 --- a/tests/iden3comm/jws.test.ts +++ b/tests/iden3comm/jws.test.ts @@ -4,6 +4,8 @@ import { JWSPacker, KmsKeyType, Sec256k1Provider, + SignerFn, + base64UrlToBytes, byteEncoder, bytesToBase64url, hexToBytes, @@ -11,6 +13,7 @@ import { } from '../../src'; import { expect } from 'chai'; import { DIDResolutionResult } from 'did-resolver'; +import { ES256KSigner } from 'did-jwt'; const didExample = { '@context': [ @@ -56,8 +59,8 @@ describe('jws packer tests', () => { let packer: JWSPacker; const bodyMsgStr = `{"type":"https://iden3-communication.io/authorization/1.0/response","from": "${did}", "body":{"scope":[{"type":"zeroknowledge","circuit_id":"auth","pub_signals":["1","18311560525383319719311394957064820091354976310599818797157189568621466950811","323416925264666217617288569742564703632850816035761084002720090377353297920"],"proof_data":{"pi_a":["11130843150540789299458990586020000719280246153797882843214290541980522375072","1300841912943781723022032355836893831132920783788455531838254465784605762713","1"],"pi_b":[["20615768536988438336537777909042352056392862251785722796637590212160561351656","10371144806107778890538857700855108667622042215096971747203105997454625814080"],["19598541350804478549141207835028671111063915635580679694907635914279928677812","15264553045517065669171584943964322117397645147006909167427809837929458012913"],["1","0"]],"pi_c":["16443309279825508893086251290003936935077348754097470818523558082502364822049","2984180227766048100510120407150752052334571876681304999595544138155611963273","1"],"protocol":""}}]}}`; + const sk = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'; beforeEach(async () => { - const sk = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'; const pub = '04fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea535847946393f8145252eea68afe67e287b3ed9b31685ba6c3b00060a73b9b1242d68f7'; @@ -103,6 +106,34 @@ describe('jws packer tests', () => { expect(data).to.not.be.undefined; }); + it('pack / unpack: external signer', async () => { + const msgBytes = byteEncoder.encode(bodyMsgStr); + + const signer: SignerFn = async (_, data) => { + const signatureBase64 = await ES256KSigner(hexToBytes(sk), false)(data); + return base64UrlToBytes(signatureBase64.toString()); + }; + + const tokenBytesSigner = await packer.pack(msgBytes, { + alg: 'ES256K', + did, + issuer: did, + signer + }); + + const tokenBytesKMS = await packer.pack(msgBytes, { + alg: 'ES256K', + did, + issuer: did + }); + + const signerData = await packer.unpack(tokenBytesSigner); + expect(signerData).to.not.be.undefined; + const data = await packer.unpack(tokenBytesKMS); + expect(data).to.not.be.undefined; + expect(signerData).to.deep.equal(data); + }); + it('unpack: no kid', async () => { const token = 'eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJhcHBsaWNhdGlvbi9pZGVuM2NvbW0tc2lnbmVkLWpzb24ifQ.eyJ0eXBlIjoiaHR0cHM6Ly9pZGVuMy1jb21tdW5pY2F0aW9uLmlvL2F1dGhvcml6YXRpb24vMS4wL3Jlc3BvbnNlIiwiZnJvbSI6ImRpZDpleGFtcGxlOjEyMyIsImJvZHkiOnsic2NvcGUiOlt7InR5cGUiOiJ6ZXJva25vd2xlZGdlIiwiY2lyY3VpdF9pZCI6ImF1dGgiLCJwdWJfc2lnbmFscyI6WyIxIiwiMTgzMTE1NjA1MjUzODMzMTk3MTkzMTEzOTQ5NTcwNjQ4MjAwOTEzNTQ5NzYzMTA1OTk4MTg3OTcxNTcxODk1Njg2MjE0NjY5NTA4MTEiLCIzMjM0MTY5MjUyNjQ2NjYyMTc2MTcyODg1Njk3NDI1NjQ3MDM2MzI4NTA4MTYwMzU3NjEwODQwMDI3MjAwOTAzNzczNTMyOTc5MjAiXSwicHJvb2ZfZGF0YSI6eyJwaV9hIjpbIjExMTMwODQzMTUwNTQwNzg5Mjk5NDU4OTkwNTg2MDIwMDAwNzE5MjgwMjQ2MTUzNzk3ODgyODQzMjE0MjkwNTQxOTgwNTIyMzc1MDcyIiwiMTMwMDg0MTkxMjk0Mzc4MTcyMzAyMjAzMjM1NTgzNjg5MzgzMTEzMjkyMDc4Mzc4ODQ1NTUzMTgzODI1NDQ2NTc4NDYwNTc2MjcxMyIsIjEiXSwicGlfYiI6W1siMjA2MTU3Njg1MzY5ODg0MzgzMzY1Mzc3Nzc5MDkwNDIzNTIwNTYzOTI4NjIyNTE3ODU3MjI3OTY2Mzc1OTAyMTIxNjA1NjEzNTE2NTYiLCIxMDM3MTE0NDgwNjEwNzc3ODg5MDUzODg1NzcwMDg1NTEwODY2NzYyMjA0MjIxNTA5Njk3MTc0NzIwMzEwNTk5NzQ1NDYyNTgxNDA4MCJdLFsiMTk1OTg1NDEzNTA4MDQ0Nzg1NDkxNDEyMDc4MzUwMjg2NzExMTEwNjM5MTU2MzU1ODA2Nzk2OTQ5MDc2MzU5MTQyNzk5Mjg2Nzc4MTIiLCIxNTI2NDU1MzA0NTUxNzA2NTY2OTE3MTU4NDk0Mzk2NDMyMjExNzM5NzY0NTE0NzAwNjkwOTE2NzQyNzgwOTgzNzkyOTQ1ODAxMjkxMyJdLFsiMSIsIjAiXV0sInBpX2MiOlsiMTY0NDMzMDkyNzk4MjU1MDg4OTMwODYyNTEyOTAwMDM5MzY5MzUwNzczNDg3NTQwOTc0NzA4MTg1MjM1NTgwODI1MDIzNjQ4MjIwNDkiLCIyOTg0MTgwMjI3NzY2MDQ4MTAwNTEwMTIwNDA3MTUwNzUyMDUyMzM0NTcxODc2NjgxMzA0OTk5NTk1NTQ0MTM4MTU1NjExOTYzMjczIiwiMSJdLCJwcm90b2NvbCI6IiJ9fV19fQ.W6gORh7uC47pv3Sg83meipfBbPoDplhc7aog2CCCausjhvjMJJN1u_N59gdwj5enWD0fworFbqGIv1y4sBvF3A'; diff --git a/tests/kms/kms.test.ts b/tests/kms/kms.test.ts index 86f5d6fc..28d7b050 100644 --- a/tests/kms/kms.test.ts +++ b/tests/kms/kms.test.ts @@ -4,46 +4,57 @@ import { InMemoryPrivateKeyStore, KmsKeyType, Sec256k1Provider, - Ed25519Provider + Ed25519Provider, + IKeyProvider, + bytesToHex, + BjjProvider } from '../../src'; import { getRandomBytes } from '@iden3/js-crypto'; -import { ed25519 } from '@noble/curves/ed25519'; +import { BytesHelper, Constants } from '@iden3/js-iden3-core'; -describe('secp256k1 KMS', () => { - it('should sec256k1 signatures be equal for the same data and private key', async () => { - const keyStore: AbstractPrivateKeyStore = new InMemoryPrivateKeyStore(); - const secp256k1 = new Sec256k1Provider(KmsKeyType.Secp256k1, keyStore); - const seed = getRandomBytes(32); - const dataToSign = getRandomBytes(32); - const [keyId1, keyId2] = await Promise.all([ - secp256k1.newPrivateKeyFromSeed(seed), - secp256k1.newPrivateKeyFromSeed(seed) - ]); - const [signature1, signature2] = await Promise.all([ - secp256k1.sign(keyId1, dataToSign), - secp256k1.sign(keyId2, dataToSign) - ]); - expect(signature1).to.deep.equal(signature2); - }); -}); +const testFlow = async (provider: IKeyProvider) => { + const seed1 = getRandomBytes(32); + const seed2 = getRandomBytes(32); + expect(seed1).to.not.deep.equal(seed2); + let dataToSign1 = getRandomBytes(32); + let dataToSign2 = getRandomBytes(32); + if (provider instanceof BjjProvider) { + // because challenge should be in the finite field of Constant.Q + dataToSign1 = BytesHelper.intToBytes(Constants.Q - 1n); + dataToSign2 = BytesHelper.intToBytes(Constants.Q - 100n); + } + const [keyId1, keyId2, keyId3] = await Promise.all([ + provider.newPrivateKeyFromSeed(seed1), + provider.newPrivateKeyFromSeed(seed2), + provider.newPrivateKeyFromSeed(seed1) + ]); + const [signature1, signature2, signature3] = await Promise.all([ + provider.sign(keyId1, dataToSign1), + provider.sign(keyId2, dataToSign2), + provider.sign(keyId3, dataToSign1) + ]); + const [isPublicKey1Valid, isPublicKey2Valid, isPublicKey3Valid] = await Promise.all([ + provider.verify(dataToSign1, bytesToHex(signature1), keyId1), + provider.verify(dataToSign2, bytesToHex(signature2), keyId2), + provider.verify(dataToSign1, bytesToHex(signature3), keyId3) + ]); + expect(signature1).to.not.deep.equal(signature2); + expect(signature1).to.deep.equal(signature3); + expect(isPublicKey1Valid).to.be.true; + expect(isPublicKey2Valid).to.be.true; + expect(isPublicKey3Valid).to.be.true; +}; -describe('ed25519 KMS', () => { - it('should ed25519 signatures be valid and equal for the same data and private key', async () => { +describe('Key store providers', () => { + it('should signatures be valid and equal for the same data and private key', async () => { const keyStore: AbstractPrivateKeyStore = new InMemoryPrivateKeyStore(); const ed25519Provider = new Ed25519Provider(KmsKeyType.Ed25519, keyStore); - const seed = getRandomBytes(32); - const dataToSign = getRandomBytes(32); - const [keyId1, keyId2] = await Promise.all([ - ed25519Provider.newPrivateKeyFromSeed(seed), - ed25519Provider.newPrivateKeyFromSeed(seed) - ]); - const [signature1, signature2] = await Promise.all([ - ed25519Provider.sign(keyId1, dataToSign), - ed25519Provider.sign(keyId2, dataToSign) + const secp256k1Provider = new Sec256k1Provider(KmsKeyType.Secp256k1, keyStore); + const bjjProvider = new BjjProvider(KmsKeyType.BabyJubJub, keyStore); + await Promise.all([ + testFlow(bjjProvider), + testFlow(ed25519Provider), + testFlow(secp256k1Provider) ]); - const publicKey1 = await ed25519Provider.publicKey(keyId1); - const isPublicKey1Valid = await ed25519.verify(signature1, dataToSign, publicKey1); - expect(signature1).to.deep.equal(signature2); - expect(isPublicKey1Valid).to.be.true; }); });