From 471e3a19a0854889078d5b36f700cc1adecc9055 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 6 Mar 2024 12:11:10 +0200 Subject: [PATCH 1/9] update to beta.1 --- package-lock.json | 411 +++++-------------------------- package.json | 2 +- src/circuits/atomicV3.ts | 1 - src/circuits/linkedMultiQuery.ts | 9 +- test/atomicV3.test.ts | 172 ++----------- test/linked-proofs.test.ts | 2 +- 6 files changed, 87 insertions(+), 510 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ee9452..af04649 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.1.1", "license": "AGPL-3.0", "dependencies": { - "@0xpolygonid/js-sdk": "1.7.4", + "@0xpolygonid/js-sdk": "../js-sdk", "@iden3/js-crypto": "1.0.3", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-jsonld-merklization": "1.1.2", @@ -46,10 +46,10 @@ "typescript": "^4.3.5" } }, - "node_modules/@0xpolygonid/js-sdk": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@0xpolygonid/js-sdk/-/js-sdk-1.7.4.tgz", - "integrity": "sha512-2JgnXblnFeLoIl2AqnHTFjRwmI+/ITbXP6i6+MBAu3FNbn9AUueqHlzj3Be6yPym3PrsX/5QSMAgi2jpUohHeg==", + "../js-sdk": { + "name": "@0xpolygonid/js-sdk", + "version": "1.9.0", + "license": "AGPL-3.0", "dependencies": { "ajv": "8.12.0", "ajv-formats": "2.1.1", @@ -58,10 +58,49 @@ "elliptic": "6.5.4", "ethers": "6.8.0", "idb-keyval": "6.2.0", - "js-sha3": "0.9.2", + "js-sha3": "0.9.3", "jsonld": "8.3.1", + "pubsub-js": "1.9.4", "uuid": "9.0.1" }, + "devDependencies": { + "@gr2m/fetch-mock": "9.11.0-pull-request-644.1", + "@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-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.4", + "@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", + "@types/node": "^20.8.9", + "@types/pubsub-js": "^1.8.6", + "@types/uuid": "^9.0.6", + "@typescript-eslint/eslint-plugin": "^5.41.0", + "chai": "^4.3.10", + "chai-as-promised": "^7.1.1", + "chai-spies": "^1.0.0", + "chokidar": "^3.5.3", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^4.2.1", + "mocha": "10.2.0", + "prettier": "^2.7.1", + "rimraf": "^5.0.5", + "rollup": "^4.2.0", + "ts-loader": "^9.4.1", + "ts-node": "^10.9.1", + "typescript": "^4.8.4" + }, "engines": { "node": ">=18.16.0" }, @@ -69,82 +108,19 @@ "@iden3/js-crypto": "1.0.3", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-jsonld-merklization": "1.1.2", - "@iden3/js-jwz": "1.2.1", + "@iden3/js-jwz": "1.3.0", "@iden3/js-merkletree": "1.1.2", - "ffjavascript": "0.2.62", + "ffjavascript": "0.2.63", "rfc4648": "1.5.3", - "snarkjs": "0.7.2" + "snarkjs": "0.7.3" } }, - "node_modules/@0xpolygonid/js-sdk/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/@0xpolygonid/js-sdk/node_modules/aes-js": { - "version": "4.0.0-beta.5", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", - "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" + "../js-sdk/dist": { + "extraneous": true }, - "node_modules/@0xpolygonid/js-sdk/node_modules/ethers": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.0.tgz", - "integrity": "sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/ethers-io/" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "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", - "tslib": "2.4.0", - "ws": "8.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@0xpolygonid/js-sdk/node_modules/idb-keyval": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.0.tgz", - "integrity": "sha512-uw+MIyQn2jl3+hroD7hF8J7PUviBU7BPKWw4f/ISf32D4LoGu98yHjrzWWJDASu9QNrX10tCJqk9YY0ClWm8Ng==", - "dependencies": { - "safari-14-idb-fix": "^3.0.0" - } - }, - "node_modules/@0xpolygonid/js-sdk/node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" - }, - "node_modules/@0xpolygonid/js-sdk/node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } + "node_modules/@0xpolygonid/js-sdk": { + "resolved": "../js-sdk", + "link": true }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", @@ -155,11 +131,6 @@ "node": ">=0.10.0" } }, - "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/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -2200,28 +2171,6 @@ "node": ">=12" } }, - "node_modules/@noble/curves": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", - "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", - "dependencies": { - "@noble/hashes": "1.3.2" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2298,154 +2247,6 @@ "@sinonjs/commons": "^3.0.0" } }, - "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/@tsconfig/node10": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", @@ -2883,37 +2684,6 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" }, - "node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -3368,11 +3138,6 @@ } ] }, - "node_modules/canonicalize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-2.0.0.tgz", - "integrity": "sha512-ulDEYPv7asdKvqahuAY35c1selLdzDwHqugK92hfkzvlDCwXRRelDkR+Er33md/PtnpqHemgkuDPanZ4fiYZ8w==" - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -3789,35 +3554,6 @@ "node": ">=8" } }, - "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", - "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" - } - }, - "node_modules/did-jwt/node_modules/bech32": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", - "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" - }, - "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", @@ -4407,7 +4143,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.3.0", @@ -5685,11 +5422,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sha3": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.9.2.tgz", - "integrity": "sha512-8kgvwd03wNGQG1GRvl3yy1Yt40sICAcIMsDU2ZLgoL0Z6z9rkRmf9Vd+bi/gYSzgAqMUGl/jiDKu0J8AWFd+BQ==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5737,11 +5469,6 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -6065,11 +5792,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/multiformats": { - "version": "9.9.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", - "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==" - }, "node_modules/mylas": { "version": "2.1.13", "resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz", @@ -6530,6 +6252,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "engines": { "node": ">=6" } @@ -6672,14 +6395,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-from-string": { - "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==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", @@ -6858,11 +6573,6 @@ "queue-microtask": "^1.2.2" } }, - "node_modules/safari-14-idb-fix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/safari-14-idb-fix/-/safari-14-idb-fix-3.0.0.tgz", - "integrity": "sha512-eBNFLob4PMq8JA1dGyFn6G97q3/WzNtFK4RnzT1fnLq+9RyrGknzYiM/9B12MnKAxuj1IXr7UKYtTNtjyKMBog==" - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -7589,14 +7299,6 @@ "node": ">=8" } }, - "node_modules/uint8arrays": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.1.1.tgz", - "integrity": "sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg==", - "dependencies": { - "multiformats": "^9.4.2" - } - }, "node_modules/underscore": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", @@ -7663,6 +7365,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } diff --git a/package.json b/package.json index 3e362fe..c576a59 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "@iden3/js-crypto": "1.0.3", - "@0xpolygonid/js-sdk": "1.7.4", + "@0xpolygonid/js-sdk": "../js-sdk", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-jsonld-merklization": "1.1.2", "@iden3/js-jwz": "1.2.1", diff --git a/src/circuits/atomicV3.ts b/src/circuits/atomicV3.ts index 2406fbe..c64e84d 100644 --- a/src/circuits/atomicV3.ts +++ b/src/circuits/atomicV3.ts @@ -52,7 +52,6 @@ export class AtomicQueryV3PubSignalsVerifier timestamp: this.pubSignals.timestamp, merklized: this.pubSignals.merklized, claimPathKey: this.pubSignals.claimPathKey, - claimPathNotExists: this.pubSignals.claimPathNotExists, valueArraySize: valuesSize, isRevocationChecked: this.pubSignals.isRevocationChecked, operatorOutput: this.pubSignals.operatorOutput diff --git a/src/circuits/linkedMultiQuery.ts b/src/circuits/linkedMultiQuery.ts index bf6d6e1..7cf9028 100644 --- a/src/circuits/linkedMultiQuery.ts +++ b/src/circuits/linkedMultiQuery.ts @@ -22,8 +22,7 @@ export class LinkedMultiQueryVerifier implements PubSignalsVerifier { constructor(pubSignals: string[]) { this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)), - 10 + byteEncoder.encode(JSON.stringify(pubSignals)) ); } @@ -67,9 +66,9 @@ export class LinkedMultiQueryVerifier implements PubSignalsVerifier { .filter((i) => i !== 0n) .sort(this.bigIntCompare); queryHashes.sort(this.bigIntCompare); - if (!queryHashes.every((queryHash, i) => queryHash === circuitQueryHashes[i])) { - throw new Error('query hashes do not match'); - } + // if (!queryHashes.every((queryHash, i) => queryHash === circuitQueryHashes[i])) { + // throw new Error('query hashes do not match'); + // } return this.pubSignals as unknown as BaseConfig; } diff --git a/test/atomicV3.test.ts b/test/atomicV3.test.ts index 1a5e2f5..68600c1 100644 --- a/test/atomicV3.test.ts +++ b/test/atomicV3.test.ts @@ -26,7 +26,7 @@ describe('atomicV3', () => { message: 'message to sign', scope: [ { - id: 84239, + id: 1, circuitId: CircuitId.AtomicQueryV3, optional: true, query: { @@ -53,47 +53,46 @@ describe('atomicV3', () => { message: 'message to sign', scope: [ { - id: 84239, + id: 1, circuitId: CircuitId.AtomicQueryV3, proof: { pi_a: [ - '15208931239306667614189217356426367087296508213411046833716711442163868780112', - '20490648944065703271613941501811057996992005137106581261392868037192830801319', + '4931850785213949686128999530866355140504398167046521116795481546947184272648', + '332774575245859134568137417770603285619416893331837204312155221564587668094', '1' ], pi_b: [ [ - '9658837325736932089175519161219586340790605854199431170964132439402760343882', - '2229712957417570067219766417050901639838551011053815708957384652110672096636' + '14792271695016162952390815554867533625013692933642600379618564819732493637941', + '18215310934256606244114322866050307053902107679161350635408930840065889072916' ], [ - '8001092431519117455354797520811940294780537362771012429305941024017334317686', - '14862879727984936294040948959940841120433831193863247939940900720892674782281' + '17048410972040698560239088146160392663861669520384562422376544822376801389912', + '21559641235416117505150830172567831599407748749353430076073365383629391654250' ], ['1', '0'] ], pi_c: [ - '10979201893913563932568403855542624651100292054247823659266571152101750130209', - '21286864035525845180147694216456377751365547090829007463506610939813242720910', + '1398727697779021690907399287414954376665288113096930249445808929806707726439', + '627223672270092807254159968400380256577737860448215394733886462613367964620', '1' ], protocol: 'groth16' }, pub_signals: [ '0', - '22466018227912887497595444357663749526852544754809814096731120723497783810', - '7232286365358812826682228661780467195854751779823604018938921042558237169817', + '21568225469889458305914841490175280093555015071329787375641431262509208065', + '4487386332479489158003597844990487984925471813907462483907054425759564175341', '0', '0', '0', '1', - '84239', - '26675680708205250151451142983868154544835349648265874601395279235340702210', '1', - '7232286365358812826682228661780467195854751779823604018938921042558237169817', - '1702457100', - '198285726510688200335207273836123338699', + '25191641634853875207018381290409317860151551336133597267061715643603096065', '1', + '4487386332479489158003597844990487984925471813907462483907054425759564175341', + '1708958378', + '198285726510688200335207273836123338699', '0', '3', '1', @@ -161,13 +160,14 @@ describe('atomicV3', () => { '0', '0', '0', - '22728440853100433399211827098349696449620101147489499428101651758549307906', + '1', + '0', '0' ] } ] }, - from: 'did:polygonid:polygon:mumbai:2qFXWZVHKTaYX1vmTGtStgRq1s8vUWhQ7HLjtqb2fV', + from: 'did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V', to: 'did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7' }; @@ -191,12 +191,12 @@ describe('atomicV3', () => { message: 'message to sign', scope: [ { - id: 84239, + id: 1, circuitId: CircuitId.AtomicQueryV3, optional: true, query: { allowedIssuers: [ - 'did:polygonid:polygon:mumbai:2qKKc4jxAhabrdFrAF3iC7boycfdQmWXq2qTBU4sPc' + '*' ], context: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', @@ -210,132 +210,8 @@ describe('atomicV3', () => { from: 'did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7' }; - const message: AuthorizationResponseMessage = { - id: 'a8ceddf8-24c8-4797-bb94-234a17c6b551', - typ: PROTOCOL_CONSTANTS.MediaType.PlainMessage, - type: 'https://iden3-communication.io/authorization/1.0/response', - thid: '7e5b5847-b479-4499-90ee-5fe4826a5bdd', - body: { - message: 'message to sign', - scope: [ - { - id: 84239, - circuitId: CircuitId.AtomicQueryV3, - proof: { - pi_a: [ - '2191675399003747228361650328748147195525067334657244384911902711268678817802', - '19948479904115663964234685946314006853666845209972027887002197866333362304394', - '1' - ], - pi_b: [ - [ - '422189606437031219571968003421368368386938453003241975855652752251201163758', - '9263822572774254449054388930060153687464515712228765747368750307969672340141' - ], - [ - '19293339395101879017873172109004141351276884864694548105955158013357482683356', - '2779213239514041287265984937924693652347623320831272361142245115033321578990' - ], - ['1', '0'] - ], - pi_c: [ - '3805936274754036854895936107504061566835912493410231954955974762213052034636', - '11817318886045212940702535466395270095280111730105021796772613798925818134104', - '1' - ], - protocol: 'groth16' - }, - pub_signals: [ - '1', - '22466018227912887497595444357663749526852544754809814096731120723497783810', - '16501727979801979045409842472064689783782600072880560178348889772807800718289', - '0', - '0', - '0', - '2', - '84239', - '26675680708205250151451142983868154544835349648265874601395279235340702210', - '1', - '16501727979801979045409842472064689783782600072880560178348889772807800718289', - '1702457550', - '219578617064540016234161640375755865412', - '0', - '1944808975288007371356450257872165609440470546066507760733183342797918372827', - '0', - '1', - '18586133768512220936620570745912940619677854269274689475585506675881198879027', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '0', - '22728440853100433399211827098349696449620101147489499428101651758549307906', - '0' - ] - } - ] - }, - from: 'did:polygonid:polygon:mumbai:2qFXWZVHKTaYX1vmTGtStgRq1s8vUWhQ7HLjtqb2fV', - to: 'did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7' - }; + + const message: AuthorizationResponseMessage = JSON.parse(`{"id":"3f660ddb-f658-4e49-8db1-a39c4fdc348f","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"7e5b5847-b479-4499-90ee-5fe4826a5bdd","body":{"message":"message to sign","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4120898270954196501698659371038588054918958563769831287147203948717242014624","8161421339704983205935832143741731851845367466023122838713066272249193414518","1"],"pi_b":[["2016142731671092085823980355087186874971933756399728048657567167042826575596","6793744608145762931207340557274708648520834540854771358056842986732615365330"],["8778588695583532060082422779657036840781757320865763695218580457590480892876","5111155321599578590956823356574570048809420578935237618371137640346580720238"],["1","0"]],"pi_c":["9353868372198554565265355896994535552872689398030095461666762398339915886396","20314706759118669909305881604960039713418625088875647733334383350621059880114","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","7777729897445253016468635824802413494952316305513954490382539913235271469351","0","0","0","2","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709716798","219578617064540016234161640375755865412","1944808975288007371356450257872165609440470546066507760733183342797918372827","0","1","18586133768512220936620570745912940619677854269274689475585506675881198879027","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","22728440853100433399211827098349696449620101147489499428101651758549307906","0"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7"}`); const authInstance = await Verifier.newVerifier({ stateResolver: resolvers, @@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NTg4NTU1Il0sWyIxIiwiMCJdXSwicGlfYyI6WyIxODA5MjQ2Mzg4NDM4OTY3MTM2MTA2ODg4MjMzOTMzNjQ4OTA0NDI3MTI4Mjg0NjYxNTEwODU4ODE4ODQ0Mzc5NzU2Nzk2ODQ4MDU5NyIsIjEyODI4MjkwMzk2Njk5NTM4OTc2NDM5MzMwODU2MDc4MDE1NjQxNjIyMDgxNDgwODU3NTUzMTEwMDY1MDkxNzIxMDA0NjMwMzAwMzc4IiwiMSJdLCJwcm90b2NvbCI6Imdyb3RoMTYiLCJjdXJ2ZSI6ImJuMTI4In0sInB1Yl9zaWduYWxzIjpbIjIxNTY4MjI1NDY5ODg5NDU4MzA1OTE0ODQxNDkwMTc1MjgwMDkzNTU1MDE1MDcxMzI5Nzg3Mzc1NjQxNDMxMjYyNTA5MjA4MDY1IiwiNDY3OTkxOTk5MTQ0MTMyNjM2OTQ5NzEyNzYzMTU2MzQ0NDk0MDM2NzExMjUxMjQ4MzgzNzA1MTgyNjYzODQ0MDk0Nzc0MDg4NTE4OSIsIjAiXX0'; await expect(verifier.fullVerify(token, request, testOpts)).resolves.not.toThrow(); }); diff --git a/test/linked-proofs.test.ts b/test/linked-proofs.test.ts index 0675bb0..6a63c20 100644 --- a/test/linked-proofs.test.ts +++ b/test/linked-proofs.test.ts @@ -80,7 +80,7 @@ describe('Linked proofs verification', () => { }; const tokenString = - 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjUxMmRhMWVlLWQwODctNGEwMC1hMGYzLTZjNmZmYjI0Zjc5NyIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zLXprcC1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsIn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ODE3Mjg2OTUzNjI5MzgxODgyNSIsIjEzMTc2NDA1MTUwNDIwMDIyNzg1MzMyMzI4Nzc1MjYzMTY0MzAxNjA4ODIyMjM2NDgzMDg1NDUzNTQ1Njg5NTQ5MjkwMjQ2MjI0NTA4IiwiMSJdLCJwcm90b2NvbCI6Imdyb3RoMTYiLCJjdXJ2ZSI6ImJuMTI4In0sInB1Yl9zaWduYWxzIjpbIjIxNTY4MjI1NDY5ODg5NDU4MzA1OTE0ODQxNDkwMTc1MjgwMDkzNTU1MDE1MDcxMzI5Nzg3Mzc1NjQxNDMxMjYyNTA5MjA4MDY1IiwiNTA0MDgzNzU5MDU3MzQwNjA1MjY2Njc2NTQzODAwODQxMjU0MzEyMzEyMzQ4MjY4Nzk0NDkwNDc0NjI5OTkwNTM4MTI5OTA0NTYxNCIsIjAiXX0'; const verifier = await Verifier.newVerifier({ stateResolver: resolvers, From 70c88c09fbda275ebc35e4da9877e510dbfd8e94 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 6 Mar 2024 12:40:49 +0200 Subject: [PATCH 2/9] update linked checks --- package-lock.json | 4 +- package.json | 2 +- src/circuits/linkedMultiQuery.ts | 84 +++++++++++++++++++++++--------- 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index af04649..abcf83b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@iden3/js-iden3-auth", - "version": "1.1.1", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@iden3/js-iden3-auth", - "version": "1.1.1", + "version": "1.2.0", "license": "AGPL-3.0", "dependencies": { "@0xpolygonid/js-sdk": "../js-sdk", diff --git a/package.json b/package.json index c576a59..7456687 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@iden3/js-iden3-auth", - "version": "1.1.1", + "version": "1.2.0", "description": "iden3-auth implementation in JavaScript", "main": "dist/cjs/index.js", "source": "./src/index.ts", diff --git a/src/circuits/linkedMultiQuery.ts b/src/circuits/linkedMultiQuery.ts index 7cf9028..604d73f 100644 --- a/src/circuits/linkedMultiQuery.ts +++ b/src/circuits/linkedMultiQuery.ts @@ -8,10 +8,14 @@ import { LinkedMultiQueryPubSignals, byteEncoder, cacheLoader, - createSchemaHash, - parseQueriesMetadata + parseQueriesMetadata, + calculateQueryHashV3, + LinkedMultiQueryInputs, + QueryMetadata, + caclulateCoreSchemaHash, + Operators, + fieldValueFromVerifiablePresentation } from '@0xpolygonid/js-sdk'; -import { poseidon } from '@iden3/js-crypto'; /** * Verifies the linked multi-query circuit. @@ -30,7 +34,7 @@ export class LinkedMultiQueryVerifier implements PubSignalsVerifier { return Promise.resolve(); } - async verifyQuery(query: Query, schemaLoader?: DocumentLoader): Promise { + async verifyQuery(query: Query, schemaLoader?: DocumentLoader, verifiablePresentation?: JSON): Promise { let schema: JSONObject; const ldOpts = { documentLoader: schemaLoader ?? cacheLoader() }; try { @@ -41,8 +45,9 @@ export class LinkedMultiQueryVerifier implements PubSignalsVerifier { const ldContextJSON = JSON.stringify(schema); const credentialSubject = query.credentialSubject as JSONObject; const schemaId: string = await Path.getTypeIDFromContext(ldContextJSON, query.type, ldOpts); - const schemaHash = createSchemaHash(byteEncoder.encode(schemaId)); + // const schemaHash = createSchemaHash(byteEncoder.encode(schemaId)); + const schemaHash = caclulateCoreSchemaHash(byteEncoder.encode(schemaId)); const queriesMetadata = await parseQueriesMetadata( query.type, ldContextJSON, @@ -50,25 +55,58 @@ export class LinkedMultiQueryVerifier implements PubSignalsVerifier { ldOpts ); - const queryHashes = queriesMetadata.map((queryMeta) => { - const valueHash = poseidon.spongeHashX(queryMeta.values, 6); - return poseidon.hash([ - schemaHash.bigInt(), - BigInt(queryMeta.slotIndex), - BigInt(queryMeta.operator), - BigInt(queryMeta.claimPathKey), - queryMeta.merklizedSchema ? 0n : 1n, - valueHash - ]); - }); + const request: { queryHash: bigint; queryMeta: QueryMetadata }[] = []; + const merklized = queriesMetadata[0]?.merklizedSchema ? 1 : 0; + for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) { + const queryMeta = queriesMetadata[i]; + const values = queryMeta?.values ?? []; + const valArrSize = values.length; - const circuitQueryHashes = this.pubSignals.circuitQueryHash - .filter((i) => i !== 0n) - .sort(this.bigIntCompare); - queryHashes.sort(this.bigIntCompare); - // if (!queryHashes.every((queryHash, i) => queryHash === circuitQueryHashes[i])) { - // throw new Error('query hashes do not match'); - // } + const queryHash = calculateQueryHashV3( + values, + schemaHash, + queryMeta?.slotIndex ?? 0, + queryMeta?.operator ?? 0, + queryMeta?.claimPathKey.toString() ?? 0, + valArrSize, + merklized, + 0, + 0, + 0 + ); + request.push({ queryHash, queryMeta }); + } + + const queryHashCompare = (a: { queryHash: bigint }, b: { queryHash: bigint }): number => { + if (a.queryHash < b.queryHash) return -1; + if (a.queryHash > b.queryHash) return 1; + return 0; + }; + + const pubSignalsMeta = this.pubSignals.circuitQueryHash.map((queryHash, index) => ({ + queryHash, + operatorOutput: this.pubSignals.operatorOutput[index] + })); + + pubSignalsMeta.sort(queryHashCompare); + request.sort(queryHashCompare); + + for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) { + if (request[i].queryHash != pubSignalsMeta[i].queryHash) { + throw new Error('query hashes do not match'); + } + + if (request[i].queryMeta?.operator === Operators.SD) { + const disclosedValue = await fieldValueFromVerifiablePresentation( + request[i].queryMeta.fieldName, + verifiablePresentation, + ldOpts.documentLoader + ); + if (disclosedValue != pubSignalsMeta[i].operatorOutput) { + throw new Error('disclosed value is not in the proof outputs'); + } + } + } return this.pubSignals as unknown as BaseConfig; } From 44e4ae22c25047c8578ce597ef4ae025fded818f Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 6 Mar 2024 17:20:58 +0200 Subject: [PATCH 3/9] rm circuits folder --- src/auth/auth.ts | 180 +++---- src/circuits/atomicMtpV2.ts | 92 ---- src/circuits/atomicSigV2.ts | 84 ---- src/circuits/atomicV3.ts | 148 ------ src/circuits/authV2.ts | 49 -- src/circuits/common.ts | 51 -- src/circuits/index.ts | 1 - src/circuits/linkedMultiQuery.ts | 123 ----- src/circuits/ownershipVerifier.ts | 19 - src/circuits/query.ts | 380 --------------- src/circuits/registry.ts | 55 --- test/atomicV3.test.ts | 14 +- test/auth.test.ts | 170 +++---- test/linked-proofs.test.ts | 6 +- test/mocks.ts | 55 ++- test/query.test.ts | 774 ------------------------------ 16 files changed, 244 insertions(+), 1957 deletions(-) delete mode 100644 src/circuits/atomicMtpV2.ts delete mode 100644 src/circuits/atomicSigV2.ts delete mode 100644 src/circuits/atomicV3.ts delete mode 100644 src/circuits/authV2.ts delete mode 100644 src/circuits/common.ts delete mode 100644 src/circuits/index.ts delete mode 100644 src/circuits/linkedMultiQuery.ts delete mode 100644 src/circuits/ownershipVerifier.ts delete mode 100644 src/circuits/query.ts delete mode 100644 src/circuits/registry.ts delete mode 100644 test/query.test.ts diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 066c89b..ac56c22 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -1,35 +1,38 @@ -import { AuthPubSignalsV2 } from '@lib/circuits/authV2'; -import { Query } from '@lib/circuits/query'; import { v4 as uuidv4 } from 'uuid'; import { Resolvers } from '@lib/state/resolver'; -import { Circuits, VerifyOpts } from '@lib/circuits/registry'; -import { proving, Token } from '@iden3/js-jwz'; import { AuthorizationRequestMessage, AuthorizationResponseMessage, - CircuitId, IPacker, JWSPacker, KMS, PackageManager, - ProvingParams, PROTOCOL_CONSTANTS, - VerificationHandlerFunc, - VerificationParams, - ZKPPacker, NativeProver, IZKProver, FSCircuitStorage, ICircuitStorage, cacheLoader, - byteEncoder + byteEncoder, + ZeroKnowledgeProofRequest, + VerifyContext, + PubSignalsVerifier, + IStateStorage, + ProofQuery, + VerifyOpts, + CircuitId, + ProvingParams, + VerificationHandlerFunc, + VerificationParams, + ZKPPacker, + ZeroKnowledgeProofResponse } from '@0xpolygonid/js-sdk'; import { Resolvable } from 'did-resolver'; import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization'; import path from 'path'; import { DID } from '@iden3/js-iden3-core'; -import { ZeroKnowledgeProofRequest } from '@0xpolygonid/js-sdk'; +import { proving } from '@iden3/js-jwz'; /** * createAuthorizationRequest is a function to create protocol authorization request @@ -82,6 +85,8 @@ export function createAuthorizationRequestWithMessage( export type VerifierParams = Options & { /* resolvers for state of the identities */ stateResolver: Resolvers; + /* state storage for state of the identities */ + stateStorage: IStateStorage; /* didDocumentResolver to init default jws packer */ didDocumentResolver?: Resolvable; /* circuitsDir - directory where circuits files are stored (default - 'circuits') */ @@ -113,6 +118,9 @@ export class Verifier { private packageManager: PackageManager; private prover: IZKProver; private circuitStorage: ICircuitStorage; + private readonly _pubSignalsVerifier: PubSignalsVerifier; + + // private readonly _authHandler: AuthHandler; /** * Creates an instance of the Verifier. @@ -120,12 +128,18 @@ export class Verifier { * @param {Resolvers} resolvers - state resolvers instances * @param {VerifierSuiteParams} params - suite for verification */ - private constructor(stateResolver: Resolvers, params: VerifierSuiteParams) { + private constructor( + stateResolver: Resolvers, + stateStorage: IStateStorage, + params: VerifierSuiteParams + ) { this.schemaLoader = params.documentLoader; this.stateResolver = stateResolver; this.packageManager = params.packageManager; this.circuitStorage = params.circuitStorage; this.prover = params.prover; + + this._pubSignalsVerifier = new PubSignalsVerifier(this.schemaLoader, stateStorage); } /** @@ -145,11 +159,11 @@ export class Verifier { prover: new NativeProver(circuitStorage), packageManager: new PackageManager() }; - const verifier = new Verifier(params.stateResolver, params.suite); + const verifier = new Verifier(params.stateResolver, params.stateStorage, params.suite); await verifier.initPackers(params.didDocumentResolver); return verifier; } - return new Verifier(params.stateResolver, params.suite); + return new Verifier(params.stateResolver, params.stateStorage, params.suite); } // setPackageManager sets the package manager for the Verifier. @@ -182,9 +196,10 @@ export class Verifier { if (circuitId !== CircuitId.AuthV2) { throw new Error(`CircuitId is not supported ${circuitId}`); } + // const verifier = new AuthPubSignalsV2(pubSignals); + // await verifier.verifyStates(this.stateResolver); - const verifier = new AuthPubSignalsV2(pubSignals); - await verifier.verifyStates(this.stateResolver); + // await this._pubSignalsVerifier.verify(circuitId, { pubSignals, query: {}, sender: '', challenge: 0n }); return true; }; @@ -267,12 +282,18 @@ export class Verifier { this.verifyAuthRequest(request); const requestScope = request.body.scope; + if (!response.from) { + throw new Error(`proof response doesn't contain from field`); + } + const groupIdToLinkIdMap = new Map(); // group requests by query group id for (const proofRequest of requestScope) { const groupId = proofRequest.query.groupId as number; - const proofResp = response.body.scope.find((resp) => resp.id === proofRequest.id); + const proofResp = response.body.scope.find( + (resp: ZeroKnowledgeProofResponse) => resp.id === proofRequest.id + ); if (!proofResp) { throw new Error(`proof is not given for requestId ${proofRequest.id}`); } @@ -283,56 +304,37 @@ export class Verifier { `proof is not given for requested circuit expected: ${proofRequest.circuitId}, given ${circuitId}` ); } - const isValid = await this.prover.verify(proofResp, circuitId); - if (!isValid) { - throw new Error( - `Proof with circuit id ${circuitId} and request id ${proofResp.id} is not valid` - ); - } - const CircuitVerifier = Circuits.getCircuitPubSignals(circuitId); - if (!CircuitVerifier) { - throw new Error(`circuit ${circuitId} is not supported by the library`); + const proofValid = await this.prover.verify(proofResp, proofResp.circuitId); + if (!proofValid) { + throw Error( + `Proof with circuit id ${proofResp.circuitId} and request id ${proofResp.id} is not valid` + ); } const params = proofRequest.params ?? {}; - params.verifierDid = DID.parse(request.from); + const verifyContext: VerifyContext = { + pubSignals: proofResp.pub_signals, + query: proofRequest.query as unknown as ProofQuery, + verifiablePresentation: proofResp.vp as JSON, + sender: response.from, + challenge: BigInt(proofResp.id), + opts: opts, + params: params + }; + const pubSignals = await this._pubSignalsVerifier.verify(proofResp.circuitId, verifyContext); + const linkID = (pubSignals as unknown as { linkID?: number }).linkID; - // verify query - const verifier = new CircuitVerifier(proofResp.pub_signals); - - const pubSignals = await verifier.verifyQuery( - proofRequest.query as unknown as Query, - this.schemaLoader, - proofResp.vp as JSON, - opts, - params - ); - - // write linkId to the proof response - const pubSig = pubSignals as unknown as { linkID?: number }; - - if (pubSig.linkID && groupId) { + if (linkID && groupId) { groupIdToLinkIdMap.set(groupId, [ ...(groupIdToLinkIdMap.get(groupId) ?? []), - { linkID: pubSig.linkID, requestId: proofResp.id } + { linkID: linkID as unknown as number, requestId: proofResp.id } ]); } - // verify states - - await verifier.verifyStates(this.stateResolver, opts); - - if (!response.from) { - throw new Error(`proof response doesn't contain from field`); - } - - // verify id ownership - await verifier.verifyIdOwnership(response.from, BigInt(proofResp.id)); } // verify grouping links - for (const [groupId, metas] of groupIdToLinkIdMap.entries()) { // check that all linkIds are the same if (metas.some((meta) => meta.linkID !== metas[0].linkID)) { @@ -345,41 +347,41 @@ export class Verifier { } } - /** - * verifies jwz token - * @public - * @param {string} tokenStr - token string - * @param {VerifyOpts} opts - verification options - * - * @returns `Promise` - */ - public async verifyJWZ(tokenStr: string, opts?: VerifyOpts): Promise { - const token = await Token.parse(tokenStr); - const key = (await this.circuitStorage.loadCircuitData(token.circuitId as CircuitId)) - .verificationKey; - if (!key) { - throw new Error(`verification key is not found for circuit ${token.circuitId}`); - } - - const isValid = await token.verify(key); - if (!isValid) { - throw new Error(`zero-knowledge proof of jwz token is not valid`); - } - - const CircuitVerifier = Circuits.getCircuitPubSignals(token.circuitId); - - if (!CircuitVerifier) { - throw new Error(`circuit ${token.circuitId} is not supported by the library`); - } - - // outputs unmarshaller - const verifier = new CircuitVerifier(token.zkProof.pub_signals); - - // state verification - await verifier.verifyStates(this.stateResolver, opts); - - return token; - } + // /** + // * verifies jwz token + // * @public + // * @param {string} tokenStr - token string + // * @param {VerifyOpts} opts - verification options + // * + // * @returns `Promise` + // */ + // public async verifyJWZ(tokenStr: string, opts?: VerifyOpts): Promise { + // const token = await Token.parse(tokenStr); + // const key = (await this.circuitStorage.loadCircuitData(token.circuitId as CircuitId)) + // .verificationKey; + // if (!key) { + // throw new Error(`verification key is not found for circuit ${token.circuitId}`); + // } + + // const isValid = await token.verify(key); + // if (!isValid) { + // throw new Error(`zero-knowledge proof of jwz token is not valid`); + // } + + // const CircuitVerifier = Circuits.getCircuitPubSignals(token.circuitId); + + // if (!CircuitVerifier) { + // throw new Error(`circuit ${token.circuitId} is not supported by the library`); + // } + + // // outputs unmarshaller + // const verifier = new CircuitVerifier(token.zkProof.pub_signals); + + // // state verification + // await verifier.verifyStates(this.stateResolver, opts); + + // return token; + // } /** * perform both verification of jwz / jws token and authorization request message diff --git a/src/circuits/atomicMtpV2.ts b/src/circuits/atomicMtpV2.ts deleted file mode 100644 index 8e5b209..0000000 --- a/src/circuits/atomicMtpV2.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; -import { Resolvers } from '@lib/state/resolver'; -import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query'; -import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry'; -import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier'; -import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { AtomicQueryMTPV2PubSignals, BaseConfig, byteEncoder } from '@0xpolygonid/js-sdk'; - -const valuesSize = 64; -const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour - -export class AtomicQueryMTPV2PubSignalsVerifier - extends IDOwnershipPubSignals - implements PubSignalsVerifier -{ - pubSignals = new AtomicQueryMTPV2PubSignals(); - constructor(pubSignals: string[]) { - super(); - this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)) - ); - - if (!this.pubSignals.userID) { - throw new Error('user id is not presented in proof public signals'); - } - - if (!this.pubSignals.requestID) { - throw new Error('requestId is not presented in proof public signals'); - } - - this.userId = this.pubSignals.userID; - this.challenge = this.pubSignals.requestID; - } - - async verifyQuery( - query: Query, - schemaLoader?: DocumentLoader, - verifiablePresentation?: JSON, - opts?: VerifyOpts - ): Promise { - const outs: ClaimOutputs = { - issuerId: this.pubSignals.issuerID, - schemaHash: this.pubSignals.claimSchema, - slotIndex: this.pubSignals.slotIndex, - operator: this.pubSignals.operator, - value: this.pubSignals.value, - timestamp: this.pubSignals.timestamp, - merklized: this.pubSignals.merklized, - claimPathKey: this.pubSignals.claimPathKey, - claimPathNotExists: this.pubSignals.claimPathNotExists, - valueArraySize: valuesSize, - isRevocationChecked: this.pubSignals.isRevocationChecked - }; - await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, false, opts); - - return this.pubSignals; - } - - async verifyStates(resolvers: Resolvers, opts?: VerifyOpts): Promise { - const resolver = getResolverByID(resolvers, this.pubSignals.issuerID); - if (!resolver) { - throw new Error(`resolver not found for issuerID ${this.pubSignals.issuerID.string()}`); - } - - await checkUserState(resolver, this.pubSignals.issuerID, this.pubSignals.issuerClaimIdenState); - - if (this.pubSignals.isRevocationChecked === 0) { - return; - } - - const issuerNonRevStateResolved = await checkIssuerNonRevState( - resolver, - this.pubSignals.issuerID, - this.pubSignals.issuerClaimNonRevState - ); - - let acceptedStateTransitionDelay = defaultProofVerifyOpts; - if (opts?.acceptedStateTransitionDelay) { - acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay; - } - - if (!issuerNonRevStateResolved.latest) { - const timeDiff = - Date.now() - - getDateFromUnixTimestamp(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime(); - if (timeDiff > acceptedStateTransitionDelay) { - throw new Error('issuer state is outdated'); - } - } - } -} diff --git a/src/circuits/atomicSigV2.ts b/src/circuits/atomicSigV2.ts deleted file mode 100644 index cb139a3..0000000 --- a/src/circuits/atomicSigV2.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry'; -import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query'; -import { Resolvers } from '@lib/state/resolver'; -import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier'; -import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common'; -import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { AtomicQuerySigV2PubSignals, BaseConfig, byteEncoder } from '@0xpolygonid/js-sdk'; - -const valuesSize = 64; -const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour - -export class AtomicQuerySigV2PubSignalsVerifier - extends IDOwnershipPubSignals - implements PubSignalsVerifier -{ - pubSignals = new AtomicQuerySigV2PubSignals(); - - constructor(pubSignals: string[]) { - super(); - this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)) - ); - - this.userId = this.pubSignals.userID; - this.challenge = this.pubSignals.requestID; - } - - async verifyQuery( - query: Query, - schemaLoader?: DocumentLoader, - verifiablePresentation?: JSON, - opts?: VerifyOpts - ): Promise { - const outs: ClaimOutputs = { - issuerId: this.pubSignals.issuerID, - schemaHash: this.pubSignals.claimSchema, - slotIndex: this.pubSignals.slotIndex, - operator: this.pubSignals.operator, - value: this.pubSignals.value, - timestamp: this.pubSignals.timestamp, - merklized: this.pubSignals.merklized, - claimPathKey: this.pubSignals.claimPathKey, - claimPathNotExists: this.pubSignals.claimPathNotExists, - valueArraySize: valuesSize, - isRevocationChecked: this.pubSignals.isRevocationChecked - }; - await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, false, opts); - - return this.pubSignals; - } - async verifyStates(resolvers: Resolvers, opts?: VerifyOpts): Promise { - const resolver = getResolverByID(resolvers, this.pubSignals.issuerID); - if (!resolver) { - throw new Error(`resolver not found for issuerID ${this.pubSignals.issuerID.string()}`); - } - - await checkUserState(resolver, this.pubSignals.issuerID, this.pubSignals.issuerAuthState); - - if (this.pubSignals.isRevocationChecked === 0) { - return; - } - - const issuerNonRevStateResolved = await checkIssuerNonRevState( - resolver, - this.pubSignals.issuerID, - this.pubSignals.issuerClaimNonRevState - ); - - let acceptedStateTransitionDelay = defaultProofVerifyOpts; - if (opts?.acceptedStateTransitionDelay) { - acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay; - } - - if (!issuerNonRevStateResolved.latest) { - const timeDiff = - Date.now() - - getDateFromUnixTimestamp(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime(); - if (timeDiff > acceptedStateTransitionDelay) { - throw new Error('issuer state is outdated'); - } - } - } -} diff --git a/src/circuits/atomicV3.ts b/src/circuits/atomicV3.ts deleted file mode 100644 index c64e84d..0000000 --- a/src/circuits/atomicV3.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry'; -import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query'; -import { Resolvers } from '@lib/state/resolver'; -import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier'; -import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common'; -import { DID, getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { - AtomicQueryV3PubSignals, - BaseConfig, - byteEncoder, - JSONObject, - ProofType -} from '@0xpolygonid/js-sdk'; - -const valuesSize = 64; -const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour - -/** - * Verifies the public signals for the AtomicQueryV3 circuit. - * @beta - */ -export class AtomicQueryV3PubSignalsVerifier - extends IDOwnershipPubSignals - implements PubSignalsVerifier -{ - pubSignals = new AtomicQueryV3PubSignals(); - - constructor(pubSignals: string[]) { - super(); - this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)) - ); - - this.userId = this.pubSignals.userID; - this.challenge = this.pubSignals.requestID; - } - - async verifyQuery( - query: Query, - schemaLoader?: DocumentLoader, - verifiablePresentation?: JSON, - opts?: VerifyOpts, - params?: JSONObject - ): Promise { - const outs: ClaimOutputs = { - issuerId: this.pubSignals.issuerID, - schemaHash: this.pubSignals.claimSchema, - slotIndex: this.pubSignals.slotIndex, - operator: this.pubSignals.operator, - value: this.pubSignals.value, - timestamp: this.pubSignals.timestamp, - merklized: this.pubSignals.merklized, - claimPathKey: this.pubSignals.claimPathKey, - valueArraySize: valuesSize, - isRevocationChecked: this.pubSignals.isRevocationChecked, - operatorOutput: this.pubSignals.operatorOutput - }; - await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, true, opts); - - const { proofType, verifierID, nullifier, nullifierSessionID, linkID } = this.pubSignals; - - switch (query.proofType) { - case ProofType.BJJSignature: - if (proofType !== 1) { - throw new Error('wrong proof type for BJJSignature'); - } - break; - case ProofType.Iden3SparseMerkleTreeProof: - if (proofType !== 2) { - throw new Error('wrong proof type for Iden3SparseMerkleTreeProof'); - } - break; - default: - throw new Error('invalid proof type'); - } - - const nSessionId = BigInt((params?.nullifierSessionId as string) ?? 0); - - if (nSessionId !== 0n) { - if (BigInt(nullifier ?? 0) === 0n) { - throw new Error('nullifier should be provided for nullification and should not be 0'); - } - // verify nullifier information - const verifierDIDParam = params?.verifierDid; - if (!verifierDIDParam) { - throw new Error('verifierDid is required'); - } - - const id = DID.idFromDID(verifierDIDParam as DID); - - if (verifierID.bigInt() != id.bigInt()) { - throw new Error('wrong verifier is used for nullification'); - } - - if (nullifierSessionID !== nSessionId) { - throw new Error( - `wrong verifier session id is used for nullification, expected ${nSessionId}, got ${nullifierSessionID}` - ); - } - } else if (nullifierSessionID !== 0n) { - throw new Error(`Nullifier id is generated but wasn't requested`); - } - - if (!query.groupId && linkID !== 0n) { - throw new Error(`proof contains link id, but group id is not provided`); - } - - if (query.groupId && linkID === 0n) { - throw new Error("proof doesn't contain link id, but group id is provided"); - } - - return this.pubSignals; - } - - async verifyStates(resolvers: Resolvers, opts?: VerifyOpts): Promise { - const resolver = getResolverByID(resolvers, this.pubSignals.issuerID); - if (!resolver) { - throw new Error(`resolver not found for issuerID ${this.pubSignals.issuerID.string()}`); - } - - await checkUserState(resolver, this.pubSignals.issuerID, this.pubSignals.issuerState); - - if (this.pubSignals.isRevocationChecked === 0) { - return; - } - - const issuerNonRevStateResolved = await checkIssuerNonRevState( - resolver, - this.pubSignals.issuerID, - this.pubSignals.issuerClaimNonRevState - ); - - const acceptedStateTransitionDelay = - opts?.acceptedStateTransitionDelay ?? defaultProofVerifyOpts; - - if (issuerNonRevStateResolved.latest) { - return; - } - - const timeDiff = - Date.now() - - getDateFromUnixTimestamp(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime(); - if (timeDiff > acceptedStateTransitionDelay) { - throw new Error('issuer state is outdated'); - } - } -} diff --git a/src/circuits/authV2.ts b/src/circuits/authV2.ts deleted file mode 100644 index ab3a6b4..0000000 --- a/src/circuits/authV2.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; -import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry'; -import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier'; -import { checkGlobalState, getResolverByID } from '@lib/circuits/common'; -import { Resolvers } from '@lib/state/resolver'; -import { AuthV2PubSignals, BaseConfig, byteEncoder } from '@0xpolygonid/js-sdk'; - -const defaultAuthVerifyOpts = 5 * 60 * 1000; // 5 minutes -export class AuthPubSignalsV2 extends IDOwnershipPubSignals implements PubSignalsVerifier { - pubSignals = new AuthV2PubSignals(); - constructor(pubSignals: string[]) { - super(); - this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)) - ); - - this.userId = this.pubSignals.userID; - this.challenge = this.pubSignals.challenge; - } - - verifyQuery(): Promise { - throw new Error(`authV2 circuit doesn't support queries`); - } - - async verifyStates(resolvers: Resolvers, opts?: VerifyOpts): Promise { - const resolver = getResolverByID(resolvers, this.userId); - if (!resolver) { - throw new Error(`resolver not found for id ${this.userId.string()}`); - } - const gist = await checkGlobalState(resolver, this.pubSignals.GISTRoot); - - let acceptedStateTransitionDelay = defaultAuthVerifyOpts; - if (opts?.acceptedStateTransitionDelay) { - acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay; - } - - if (!gist.latest) { - const timeDiff = - Date.now() - getDateFromUnixTimestamp(Number(gist.transitionTimestamp)).getTime(); - if (timeDiff > acceptedStateTransitionDelay) { - throw new Error('global state is outdated'); - } - } - } - - verifyIdOwnership(sender: string, challenge: bigint): Promise { - return super.verifyIdOwnership(sender, challenge); - } -} diff --git a/src/circuits/common.ts b/src/circuits/common.ts deleted file mode 100644 index daeceef..0000000 --- a/src/circuits/common.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Id, DID } from '@iden3/js-iden3-core'; -import { IStateResolver, ResolvedState, Resolvers } from '@lib/state/resolver'; -import { Hash } from '@iden3/js-merkletree'; - -export const userStateError = new Error(`user state is not valid`); -export const gistStateError = new Error(`gist state is not valid`); - -export async function checkUserState( - resolver: IStateResolver, - userId: Id, - userState: Hash -): Promise { - const userStateResolved: ResolvedState = await resolver.resolve( - userId.bigInt(), - userState.bigInt() - ); - if (!userStateResolved.latest) { - throw userStateError; - } - return userStateResolved; -} - -export async function checkGlobalState( - resolver: IStateResolver, - state: Hash -): Promise { - const gistStateResolved: ResolvedState = await resolver.rootResolve(state.bigInt()); - return gistStateResolved; -} - -export async function checkIssuerNonRevState( - resolver: IStateResolver, - issuerId: Id, - issuerClaimNonRevState: Hash -): Promise { - const issuerNonRevStateResolved: ResolvedState = await resolver.resolve( - issuerId.bigInt(), - issuerClaimNonRevState.bigInt() - ); - return issuerNonRevStateResolved; -} - -export function getResolverByID(resolvers: Resolvers, id: Id): IStateResolver { - const userDID = DID.parseFromId(id); - return getResolverByDID(resolvers, userDID); -} - -export function getResolverByDID(resolvers: Resolvers, did: DID): IStateResolver { - const { blockchain, networkId } = DID.decodePartsFromId(DID.idFromDID(did)); - return resolvers[`${blockchain}:${networkId}`]; -} diff --git a/src/circuits/index.ts b/src/circuits/index.ts deleted file mode 100644 index 570702d..0000000 --- a/src/circuits/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@lib/circuits/registry'; diff --git a/src/circuits/linkedMultiQuery.ts b/src/circuits/linkedMultiQuery.ts deleted file mode 100644 index 604d73f..0000000 --- a/src/circuits/linkedMultiQuery.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { PubSignalsVerifier } from '@lib/circuits/registry'; -import { Query } from '@lib/circuits/query'; -import { DocumentLoader, Path } from '@iden3/js-jsonld-merklization'; -import { - BaseConfig, - JSONObject, - LinkedMultiQueryPubSignals, - byteEncoder, - cacheLoader, - parseQueriesMetadata, - calculateQueryHashV3, - LinkedMultiQueryInputs, - QueryMetadata, - caclulateCoreSchemaHash, - Operators, - fieldValueFromVerifiablePresentation -} from '@0xpolygonid/js-sdk'; - -/** - * Verifies the linked multi-query circuit. - * @beta - */ -export class LinkedMultiQueryVerifier implements PubSignalsVerifier { - readonly pubSignals = new LinkedMultiQueryPubSignals(); - - constructor(pubSignals: string[]) { - this.pubSignals = this.pubSignals.pubSignalsUnmarshal( - byteEncoder.encode(JSON.stringify(pubSignals)) - ); - } - - verifyIdOwnership(): Promise { - return Promise.resolve(); - } - - async verifyQuery(query: Query, schemaLoader?: DocumentLoader, verifiablePresentation?: JSON): Promise { - let schema: JSONObject; - const ldOpts = { documentLoader: schemaLoader ?? cacheLoader() }; - try { - schema = (await ldOpts.documentLoader(query.context)).document as JSONObject; - } catch (e) { - throw new Error(`can't load schema for request query`); - } - const ldContextJSON = JSON.stringify(schema); - const credentialSubject = query.credentialSubject as JSONObject; - const schemaId: string = await Path.getTypeIDFromContext(ldContextJSON, query.type, ldOpts); - // const schemaHash = createSchemaHash(byteEncoder.encode(schemaId)); - - const schemaHash = caclulateCoreSchemaHash(byteEncoder.encode(schemaId)); - const queriesMetadata = await parseQueriesMetadata( - query.type, - ldContextJSON, - credentialSubject, - ldOpts - ); - - const request: { queryHash: bigint; queryMeta: QueryMetadata }[] = []; - const merklized = queriesMetadata[0]?.merklizedSchema ? 1 : 0; - for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) { - const queryMeta = queriesMetadata[i]; - const values = queryMeta?.values ?? []; - const valArrSize = values.length; - - const queryHash = calculateQueryHashV3( - values, - schemaHash, - queryMeta?.slotIndex ?? 0, - queryMeta?.operator ?? 0, - queryMeta?.claimPathKey.toString() ?? 0, - valArrSize, - merklized, - 0, - 0, - 0 - ); - request.push({ queryHash, queryMeta }); - } - - const queryHashCompare = (a: { queryHash: bigint }, b: { queryHash: bigint }): number => { - if (a.queryHash < b.queryHash) return -1; - if (a.queryHash > b.queryHash) return 1; - return 0; - }; - - const pubSignalsMeta = this.pubSignals.circuitQueryHash.map((queryHash, index) => ({ - queryHash, - operatorOutput: this.pubSignals.operatorOutput[index] - })); - - pubSignalsMeta.sort(queryHashCompare); - request.sort(queryHashCompare); - - for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) { - if (request[i].queryHash != pubSignalsMeta[i].queryHash) { - throw new Error('query hashes do not match'); - } - - if (request[i].queryMeta?.operator === Operators.SD) { - const disclosedValue = await fieldValueFromVerifiablePresentation( - request[i].queryMeta.fieldName, - verifiablePresentation, - ldOpts.documentLoader - ); - if (disclosedValue != pubSignalsMeta[i].operatorOutput) { - throw new Error('disclosed value is not in the proof outputs'); - } - } - } - - return this.pubSignals as unknown as BaseConfig; - } - - async verifyStates(): Promise { - return Promise.resolve(); - } - - private bigIntCompare = (a: bigint, b: bigint): number => { - if (a < b) return -1; - if (a > b) return 1; - return 0; - }; -} diff --git a/src/circuits/ownershipVerifier.ts b/src/circuits/ownershipVerifier.ts deleted file mode 100644 index 48df520..0000000 --- a/src/circuits/ownershipVerifier.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Id, DID } from '@iden3/js-iden3-core'; - -export abstract class IDOwnershipPubSignals { - userId!: Id; - challenge!: bigint; - async verifyIdOwnership(sender: string, challenge: bigint): Promise { - const senderId = DID.idFromDID(DID.parse(sender)); - if (senderId.string() !== this.userId.string()) { - throw new Error( - `sender id is not used for proof creation, expected ${sender}, user from public signals: ${this.userId.string()}` - ); - } - if (challenge !== this.challenge) { - throw new Error( - `challenge is not used for proof creation, expected ${challenge}, challenge from public signals: ${this.challenge} ` - ); - } - } -} diff --git a/src/circuits/query.ts b/src/circuits/query.ts deleted file mode 100644 index 25cd5a0..0000000 --- a/src/circuits/query.ts +++ /dev/null @@ -1,380 +0,0 @@ -import { Id, SchemaHash, DID, getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; -import { Merklizer, Path, MtValue, getDocumentLoader } from '@iden3/js-jsonld-merklization'; -import { Proof } from '@iden3/js-merkletree'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { - Operators, - byteEncoder, - createSchemaHash, - QueryOperators, - Parser, - byteDecoder, - isValidOperation -} from '@0xpolygonid/js-sdk'; -import { VerifyOpts } from './registry'; - -const defaultProofGenerationDelayOpts = 24 * 60 * 60 * 1000; // 24 hours - -// Query is a query to circuit -export interface Query { - allowedIssuers: string[]; - credentialSubject: { [key: string]: unknown }; - context: string; - type: string; - claimID?: string; - skipClaimRevocationCheck?: boolean; - proofType?: string; - groupId?: number; -} - -// ClaimOutputs fields that are used in proof generation -export interface ClaimOutputs { - issuerId: Id; - schemaHash: SchemaHash; - slotIndex?: number; - operator: number; - value: bigint[]; - timestamp: number; - merklized: number; - claimPathKey?: bigint; - claimPathNotExists?: number; - valueArraySize: number; - isRevocationChecked: number; - operatorOutput?: bigint; -} - -export async function checkQueryRequest( - query: Query, - outputs: ClaimOutputs, - schemaLoader?: DocumentLoader, - verifiablePresentation?: JSON, - supportsSDOperator?: boolean, - opts?: VerifyOpts -): Promise { - // validate issuer - const userDID = DID.parseFromId(outputs.issuerId); - const issuerAllowed = query.allowedIssuers.some( - (issuer) => issuer === '*' || issuer === userDID.string() - ); - if (!issuerAllowed) { - throw new Error('issuer is not in allowed list'); - } - - // validate schema - let schema: object; - try { - const loader = schemaLoader ?? getDocumentLoader(); - schema = (await loader(query.context)).document; - } catch (e) { - throw new Error(`can't load schema for request query`); - } - - const schemaId: string = await Path.getTypeIDFromContext(JSON.stringify(schema), query.type, { - documentLoader: schemaLoader - }); - const schemaHash = createSchemaHash(byteEncoder.encode(schemaId)); - - if (schemaHash.bigInt() !== outputs.schemaHash.bigInt()) { - throw new Error(`schema that was used is not equal to requested in query`); - } - - if (!query.skipClaimRevocationCheck && outputs.isRevocationChecked === 0) { - throw new Error(`check revocation is required`); - } - - const cq = await parseRequest( - query, - outputs, - byteEncoder.encode(JSON.stringify(schema)), - schemaLoader - ); - - // validate selective disclosure - if (cq.isSelectiveDisclosure) { - try { - if (!verifiablePresentation) { - throw new Error(`no vp present in selective disclosure request`); - } - await validateDisclosure( - verifiablePresentation, - cq, - outputs, - schemaLoader, - supportsSDOperator - ); - } catch (e) { - throw new Error(`failed to validate selective disclosure: ${(e as Error).message}`); - } - } else if (!cq.fieldName && cq.operator == Operators.NOOP) { - try { - await validateEmptyCredentialSubject(cq, outputs); - return; - } catch (e: unknown) { - throw new Error(`failed to validate operators: ${(e as Error).message}`); - } - } else { - try { - await validateOperators(cq, outputs); - } catch (e) { - throw new Error(`failed to validate operators: ${(e as Error).message}`); - } - } - - // verify claim - if (outputs.merklized === 1) { - if (outputs.claimPathNotExists === 1) { - throw new Error(`proof doesn't contains target query key`); - } - - const path = await Path.getContextPathKey(JSON.stringify(schema), query.type, cq.fieldName, { - documentLoader: schemaLoader - }); - path.prepend(['https://www.w3.org/2018/credentials#credentialSubject']); - const claimPathKey = await path.mtEntry(); - - if (outputs.claimPathKey !== claimPathKey) { - throw new Error(`proof was generated for another path`); - } - } else { - const slotIndex = await Parser.getFieldSlotIndex( - cq.fieldName, - query.type, - byteEncoder.encode(JSON.stringify(schema)) - ); - - if (outputs.slotIndex !== slotIndex) { - throw new Error(`wrong claim slot was used in claim`); - } - } - - // verify timestamp - let acceptedProofGenerationDelay = defaultProofGenerationDelayOpts; - if (opts?.acceptedProofGenerationDelay) { - acceptedProofGenerationDelay = opts.acceptedProofGenerationDelay; - } - - const timeDiff = Date.now() - getDateFromUnixTimestamp(Number(outputs.timestamp)).getTime(); - if (timeDiff > acceptedProofGenerationDelay) { - throw new Error('generated proof is outdated'); - } - return; -} - -async function validateEmptyCredentialSubject(cq: CircuitQuery, outputs: ClaimOutputs) { - if (outputs.operator !== Operators.EQ) { - throw new Error('empty credentialSubject request available only for equal operation'); - } - for (let index = 1; index < outputs.value.length; index++) { - if (outputs.value[index] !== BigInt(0)) { - throw new Error(`empty credentialSubject request not available for array of values`); - } - } - const path = await Path.newPath(['https://www.w3.org/2018/credentials#credentialSubject']); - const subjectEntry = await path.mtEntry(); - if (outputs.claimPathKey !== subjectEntry) { - throw new Error(`proof doesn't contain credentialSubject in claimPathKey`); - } - return; -} -async function validateOperators(cq: CircuitQuery, outputs: ClaimOutputs) { - if (outputs.operator !== cq.operator) { - throw new Error(`operator that was used is not equal to request`); - } - if (outputs.operator === Operators.NOOP) { - // for noop operator slot and value are not used in this case - return; - } - - for (let index = 0; index < outputs.value.length; index++) { - if (outputs.value[index] !== cq.values[index]) { - throw new Error(`comparison value that was used is not equal to requested in query`); - } - } -} - -async function validateDisclosure( - verifiablePresentation: JSON, - cq: CircuitQuery, - outputs: ClaimOutputs, - ldLoader?: DocumentLoader, - supportsSDOperator?: boolean -) { - if (!verifiablePresentation) { - throw new Error(`verifiablePresentation is required for selective disclosure request`); - } - - let mz: Merklizer; - const strVerifiablePresentation: string = JSON.stringify(verifiablePresentation); - try { - mz = await Merklizer.merklizeJSONLD(strVerifiablePresentation, { - documentLoader: ldLoader - }); - } catch (e) { - throw new Error(`can't merkelize verifiablePresentation`); - } - - let merklizedPath: Path; - try { - const p = `verifiableCredential.credentialSubject.${cq.fieldName}`; - merklizedPath = await Path.fromDocument(null, strVerifiablePresentation, p, { - documentLoader: ldLoader - }); - } catch (e) { - throw new Error(`can't build path to '${cq.fieldName}' key`); - } - - let proof: Proof; - let value: MtValue | undefined; - try { - ({ proof, value } = await mz.proof(merklizedPath)); - } catch (e) { - throw new Error(`can't get value by path '${cq.fieldName}'`); - } - if (!value) { - throw new Error(`can't get merkle value for field '${cq.fieldName}'`); - } - - if (!proof.existence) { - throw new Error( - `path [${merklizedPath.parts}] doesn't exist in verifiablePresentation document` - ); - } - const bi = await value.mtEntry(); - - if (supportsSDOperator) { - if (outputs.operator !== Operators.SD) { - throw new Error(`operator for selective disclosure must be $sd`); - } - - if (!outputs.operatorOutput || bi !== outputs.operatorOutput) { - throw new Error(`operator output must be equal to disclosed value`); - } - - for (let index = 0; index < outputs.value.length; index++) { - if (outputs.value[index] !== 0n) { - throw new Error(`in selective disclosure, comparing values must be zero for $sd operator`); - } - } - } else { - if (outputs.operator !== Operators.EQ) { - throw new Error(`operator for selective disclosure must be $eq`); - } - - for (let index = 1; index < outputs.value.length; index++) { - if (outputs.value[index] !== 0n) { - throw new Error(`selective disclosure not available for array of values`); - } - } - if (bi !== outputs.value[0]) { - throw new Error(`value that was used is not equal to requested in query`); - } - } - - return; -} - -async function parseRequest( - query: Query, - outputs: ClaimOutputs, - schema: Uint8Array, - ldLoader?: DocumentLoader -): Promise { - if (!query.credentialSubject) { - return { - operator: Operators.NOOP, - values: [], - slotIndex: 0, - isSelectiveDisclosure: false, - fieldName: '' - }; - } - if (Object.keys(query.credentialSubject).length > 1) { - throw new Error(`multiple requests not supported`); - } - - const txtSchema = byteDecoder.decode(schema); - - let fieldName = ''; - let predicate: Map = new Map(); - - for (const [key, value] of Object.entries(query.credentialSubject)) { - fieldName = key; - - predicate = value as Map; - - if (Object.keys(predicate).length > 1) { - throw new Error(`multiple predicates for one field not supported`); - } - break; - } - - let datatype = ''; - if (fieldName !== '') { - datatype = await Path.newTypeFromContext(txtSchema, `${query.type}.${fieldName}`, { - documentLoader: ldLoader - }); - } - - const [operator, values] = await parsePredicate(predicate, datatype); - const zeros: Array = Array.from({ - length: outputs.valueArraySize - values.length - }).fill(BigInt(0)) as Array; - const fullArray: Array = values.concat(zeros); - - const cq: CircuitQuery = { - operator, - values: fullArray, - isSelectiveDisclosure: false, - fieldName - }; - - if (Object.keys(predicate).length === 0) { - cq.isSelectiveDisclosure = true; - } - - return cq; -} - -type CircuitQuery = { - claimPathKey?: bigint; - slotIndex?: number; - values: bigint[]; - operator: number; - isSelectiveDisclosure: boolean; - fieldName: string; -}; - -async function getValuesAsArray(v: unknown, datatype: string): Promise { - const values: Array = []; - if (Array.isArray(v)) { - for (let index = 0; index < v.length; index++) { - values[index] = await Merklizer.hashValue(datatype, v[index]); - } - return values; - } - values[0] = await Merklizer.hashValue(datatype, v); - return values; -} - -async function parsePredicate( - predicate: Map, - datatype: string -): Promise<[number, bigint[]]> { - let operator = 0; - let values: bigint[] = []; - - for (const [key, value] of Object.entries(predicate)) { - if (!Object.keys(QueryOperators).includes(key)) { - throw new Error(`operator is not supported by lib`); - } - operator = QueryOperators[key as keyof typeof QueryOperators]; - - if (!isValidOperation(datatype, operator)) { - throw new Error(`operator '${key}' is not supported for '${datatype}' datatype`); - } - - values = await getValuesAsArray(value, datatype); - break; - } - return [operator, values]; -} diff --git a/src/circuits/registry.ts b/src/circuits/registry.ts deleted file mode 100644 index da73298..0000000 --- a/src/circuits/registry.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { AuthPubSignalsV2 } from '@lib/circuits/authV2'; -import { AtomicQueryMTPV2PubSignalsVerifier } from '@lib/circuits/atomicMtpV2'; -import { AtomicQuerySigV2PubSignalsVerifier } from '@lib/circuits/atomicSigV2'; -import { Query } from '@lib/circuits/query'; -import { Resolvers } from '@lib/state/resolver'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { AtomicQueryV3PubSignalsVerifier } from '@lib/circuits/atomicV3'; -import { BaseConfig } from '@0xpolygonid/js-sdk'; -import { LinkedMultiQueryVerifier } from '@lib/circuits/linkedMultiQuery'; - -export type VerifyOpts = { - // acceptedStateTransitionDelay is the period of time in milliseconds that a revoked state remains valid. - acceptedStateTransitionDelay?: number; - // acceptedProofGenerationDelay is the period of time in milliseconds that a generated proof remains valid. - acceptedProofGenerationDelay?: number; -}; - -export interface PubSignalsVerifier { - verifyQuery( - query: Query, - schemaLoader?: DocumentLoader, - verifiablePresentation?: JSON, - opts?: VerifyOpts, - circuitParams?: { [key: string]: unknown } - ): Promise; - verifyStates(resolver: Resolvers, opts?: VerifyOpts): Promise; - verifyIdOwnership(sender: string, challenge: bigint): Promise; -} - -export interface PubSignals { - new (pubSignals: string[]): PubSignalsVerifier; -} - -const authV2 = AuthPubSignalsV2; -const credentialAtomicQueryMTPV2 = AtomicQueryMTPV2PubSignalsVerifier; -const credentialAtomicQuerySigV2 = AtomicQuerySigV2PubSignalsVerifier; -const credentialAtomicQueryV3 = AtomicQueryV3PubSignalsVerifier; -const linkedMultiQuery10 = LinkedMultiQueryVerifier; - -export type VerifierType = PubSignalsVerifier & PubSignals; - -const supportedCircuits: { [key: string]: unknown } = { - authV2, - credentialAtomicQueryMTPV2, - credentialAtomicQuerySigV2, - credentialAtomicQueryV3, - linkedMultiQuery10 -}; - -export class Circuits { - static getCircuitPubSignals(id: string): VerifierType { - id = id.split('-')[0]; - return supportedCircuits[id] as VerifierType; - } -} diff --git a/test/atomicV3.test.ts b/test/atomicV3.test.ts index 68600c1..742a99e 100644 --- a/test/atomicV3.test.ts +++ b/test/atomicV3.test.ts @@ -1,5 +1,5 @@ import { Verifier } from '@lib/auth/auth'; -import { testOpts, resolvers } from './mocks'; +import { testOpts, resolvers, MOCK_STATE_STORAGE } from './mocks'; import path from 'path'; import { AuthorizationResponseMessage, @@ -173,6 +173,7 @@ describe('atomicV3', () => { const authInstance = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); @@ -195,9 +196,7 @@ describe('atomicV3', () => { circuitId: CircuitId.AtomicQueryV3, optional: true, query: { - allowedIssuers: [ - '*' - ], + allowedIssuers: ['*'], context: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', credentialSubject: { ZKPexperiance: { $eq: true } }, @@ -210,11 +209,13 @@ describe('atomicV3', () => { from: 'did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7' }; - - const message: AuthorizationResponseMessage = JSON.parse(`{"id":"3f660ddb-f658-4e49-8db1-a39c4fdc348f","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"7e5b5847-b479-4499-90ee-5fe4826a5bdd","body":{"message":"message to sign","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4120898270954196501698659371038588054918958563769831287147203948717242014624","8161421339704983205935832143741731851845367466023122838713066272249193414518","1"],"pi_b":[["2016142731671092085823980355087186874971933756399728048657567167042826575596","6793744608145762931207340557274708648520834540854771358056842986732615365330"],["8778588695583532060082422779657036840781757320865763695218580457590480892876","5111155321599578590956823356574570048809420578935237618371137640346580720238"],["1","0"]],"pi_c":["9353868372198554565265355896994535552872689398030095461666762398339915886396","20314706759118669909305881604960039713418625088875647733334383350621059880114","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","7777729897445253016468635824802413494952316305513954490382539913235271469351","0","0","0","2","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709716798","219578617064540016234161640375755865412","1944808975288007371356450257872165609440470546066507760733183342797918372827","0","1","18586133768512220936620570745912940619677854269274689475585506675881198879027","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","22728440853100433399211827098349696449620101147489499428101651758549307906","0"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7"}`); + const message: AuthorizationResponseMessage = JSON.parse( + `{"id":"3f660ddb-f658-4e49-8db1-a39c4fdc348f","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"7e5b5847-b479-4499-90ee-5fe4826a5bdd","body":{"message":"message to sign","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4120898270954196501698659371038588054918958563769831287147203948717242014624","8161421339704983205935832143741731851845367466023122838713066272249193414518","1"],"pi_b":[["2016142731671092085823980355087186874971933756399728048657567167042826575596","6793744608145762931207340557274708648520834540854771358056842986732615365330"],["8778588695583532060082422779657036840781757320865763695218580457590480892876","5111155321599578590956823356574570048809420578935237618371137640346580720238"],["1","0"]],"pi_c":["9353868372198554565265355896994535552872689398030095461666762398339915886396","20314706759118669909305881604960039713418625088875647733334383350621059880114","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","7777729897445253016468635824802413494952316305513954490382539913235271469351","0","0","0","2","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709716798","219578617064540016234161640375755865412","1944808975288007371356450257872165609440470546066507760733183342797918372827","0","1","18586133768512220936620570745912940619677854269274689475585506675881198879027","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","22728440853100433399211827098349696449620101147489499428101651758549307906","0"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7"}` + ); const authInstance = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); @@ -279,6 +280,7 @@ describe('atomicV3', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); diff --git a/test/auth.test.ts b/test/auth.test.ts index 3e4cae5..a1c7081 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -11,18 +11,15 @@ import { ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '@0xpolygonid/js-sdk'; -import { AuthPubSignalsV2 } from '@lib/circuits/authV2'; import { createAuthorizationRequest, createAuthorizationRequestWithMessage, Verifier } from '@lib/auth/auth'; -import { Circuits } from '@lib/circuits/registry'; import path from 'path'; -import { resolveDIDDocument, resolvers, schemaLoader, testOpts } from './mocks'; +import { MOCK_STATE_STORAGE, resolveDIDDocument, resolvers, schemaLoader, testOpts } from './mocks'; describe('auth tests', () => { - const connectionString = process.env.IPFS_URL ?? 'https://ipfs.io'; it('createAuthorizationRequest', () => { const sender = '1125GJqgw6YEsKFwj63GY87MMxPL9kwDKxPUiwMLNZ'; const callback = 'https://test.com/callback'; @@ -82,6 +79,7 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, suite: { prover: new NativeProver(new FSCircuitStorage({ dirname: '' })), circuitStorage: new FSCircuitStorage({ dirname: '../' }), @@ -254,6 +252,7 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); @@ -421,24 +420,26 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); await expect(verifier.verifyAuthResponse(response, request, testOpts)).resolves.not.toThrow(); }); - it('TestVerifyJWZ', async () => { - const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, - circuitsDir: path.join(__dirname, './testdata'), - ipfsNodeURL: connectionString - }); + // it('TestVerifyJWZ', async () => { + // const verifier = await Verifier.newVerifier({ + // stateResolver: resolvers, + // stateStorage: MOCK_STATE_STORAGE, + // circuitsDir: path.join(__dirname, './testdata'), + // ipfsNodeURL: connectionString + // }); - const token = - 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjljMGY5NjIzLWM1NmMtNDEwNC04ODk2LWVjMjgyYTNiMmExNyIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhNDgtOWZhYy0zNmFkZmRiOGI1NDIiLCJmcm9tIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycVBETFhEYVUxeGExRVJUYjFYS0JmUENCM28yd0E0NnE0OW5laVhXd1kiLCJ0byI6ImRpZDpwb2x5Z29uaWQ6cG9seWdvbjptdW1iYWk6MnFKNjg5a3BvSnhjU3pCNXNBRkp0UHNTQlNySEY1ZHE3MjJCSE1xVVJMIiwiYm9keSI6eyJkaWRfZG9jIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy9ucy9kaWQvdjEiXSwiaWQiOiJkaWQ6cG9seWdvbmlkOnBvbHlnb246bXVtYmFpOjJxUERMWERhVTF4YTFFUlRiMVhLQmZQQ0IzbzJ3QTQ2cTQ5bmVpWFd3WSIsInNlcnZpY2UiOlt7ImlkIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycVBETFhEYVUxeGExRVJUYjFYS0JmUENCM28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TE3NDEzODAxOTIzNTM3OTU3MzYzOTgwMjA0Il0sWyIxIiwiMCJdXSwicGlfYyI6WyIxNTUyMDYzNjk4OTY2MTg3NzExNDUwNjkwNDgxMDQxMzExNDI4NzQ5ODE1OTk2NDA5OTU2MTY5ODUyNjc4MzUwMDE1NjU1MjQzMDAwNCIsIjEyNjkyNzA3NDA3MTczMDg0OTM5NzQ1ODU5NzE0ODMxNDYyMDQ1ODg5NDA4NTk4NTI3MjU0ODA3NzkwNDk0NDY2Mjc5Njg3ODU5MjQ3IiwiMSJdLCJwcm90b2NvbCI6Imdyb3RoMTYiLCJjdXJ2ZSI6ImJuMTI4In0sInB1Yl9zaWduYWxzIjpbIjI3MTUyNjc2OTg3MTI4NTQyMDY2ODA4NTkxOTk4NTczMDAwMzcwNDM2NDY0NzIyNTE5NTEzMzQ4ODkxMDQ5NjQ0ODEzNzE4MDE4IiwiMTIxODQ5NzQwNzE0Mjc3NjgzNTIwMjcwMDM4NzgzMTkzMzgyNDkzODM4NDYxNjQ3MzAyMDQ1MDUzMjY5NTM1NTA2NDczOTExNzg4MDAiLCI4NzU2MDYwMjA1MDg2ODAzMzM1MjUyMzE5NzQ4NzQ4MzU0NzYxOTYxODE0MDEyNzI1NDk5ODczMzgyOTg4MDU2NDE4NjgwNjI4NjE5Il19'; - await expect(verifier.verifyJWZ(token)).resolves.not.toThrow(); - }); + // await expect(verifier.verifyJWZ(token)).resolves.not.toThrow(); + // }); it('TestFullVerify', async () => { const sender = 'did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL'; @@ -476,6 +477,7 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); request.id = '28494007-9c49-4f1a-9694-7700c08865bf'; @@ -527,13 +529,16 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, documentLoader: schemaLoader, circuitsDir: path.join(__dirname, './testdata'), didDocumentResolver: resolveDIDDocument }); verifier.setupJWSPacker(new KMS(), resolveDIDDocument); - await expect(verifier.fullVerify(token, request, testOpts)).resolves.not.toThrow(); + await verifier.fullVerify(token, request, testOpts); + + // await expect().resolves.not.toThrow(); }); test.skip('TestResponseWithEmptyQueryRequest_ErrorCase', async () => { @@ -690,6 +695,7 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); @@ -703,72 +709,73 @@ describe('auth tests', () => { } }); - it('registry: get existing circuit', () => { - const type = Circuits.getCircuitPubSignals('authV2'); - const instance = new type([ - '19229084873704550357232887142774605442297337229176579229011342091594174977', - '6110517768249559238193477435454792024732173865488900270849624328650765691494', - '1243904711429961858774220647610724273798918457991486031567244100767259239747' - ]) as AuthPubSignalsV2; - - expect(type).not.toBeNull(); - expect(instance).not.toBeNull(); - expect(instance.verifyQuery).not.toBeNull(); - expect(instance.userId.string()).toEqual('x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29'); - expect(instance.challenge.toString()).toEqual( - '6110517768249559238193477435454792024732173865488900270849624328650765691494' - ); - // TODO(illia-korotia): why Hash type doesn't implement `toString()` method? - expect(instance.pubSignals.GISTRoot.string()).toEqual( - '1243904711429961858774220647610724273798918457991486031567244100767259239747' - ); - }); - - it('verify jwz with selective disclosure', async () => { - const sender = 'did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL'; - const callback = 'https://test.com/callback'; - const reason = 'age verification'; - const request: AuthorizationRequestMessage = createAuthorizationRequestWithMessage( - reason, - '', - sender, - callback - ); - expect(request.body.scope.length).toEqual(0); - expect(request.body.callbackUrl).toEqual(callback); - expect(request.body.reason).toEqual(reason); - expect(request.from).toEqual(sender); - - const proofRequest: ZeroKnowledgeProofRequest = { - id: 1, - circuitId: 'credentialAtomicQuerySigV2', - query: { - allowedIssuers: ['*'], - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld', - type: 'KYCAgeCredential', - credentialSubject: { - birthday: {} - } - } - }; - request.body.scope.push(proofRequest); - - expect(request.body.scope.length).toEqual(1); - - const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); - request.id = '28494007-9c49-4f1a-9694-7700c08865bf'; - request.thid = '7f38a193-0918-4a48-9fac-36adfdb8b542'; // because it's used in the response - - const token = - 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6ImYzZjVmM2JkLTJkOGItNDk0OS1hMDY5LTk3NTliZTdjZjUwYSIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhNDgtOWZhYy0zNmFkZmRiOGI1NDIiLCJmcm9tIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycUpwUnFaTlJUeGtpQ1VONFZTZkxRN0tBNFB6SFN3d1Z3blNLU0ZLdHciLCJ0byI6ImRpZDpwb2x5Z29uaWQ6cG9seWdvbjptdW1iYWk6MnFKNjg5a3BvSnhjU3pCNXNBRkp0UHNTQlNySEY1ZHE3MjJCSE1xVVJMIiwiYm9keSI6eyJkaWRfZG9jIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy9ucy9kaWQvdjEiXSwiaWQiOiJkaWQ6cG9seWdvbmlkOnBvb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1NzM1NjMwNDc2OTY2MTcwOTIzODY3MDI3MDYxMzU2MDg4NzY5OTM1Mjk0NDk5NjU1MDI5NSJdfQ'; - - await expect(verifier.fullVerify(token, request, testOpts)).resolves.not.toThrow(); - }); + // it('registry: get existing circuit', () => { + // const type = Circuits.getCircuitPubSignals('authV2'); + // const instance = new type([ + // '19229084873704550357232887142774605442297337229176579229011342091594174977', + // '6110517768249559238193477435454792024732173865488900270849624328650765691494', + // '1243904711429961858774220647610724273798918457991486031567244100767259239747' + // ]) as AuthPubSignalsV2; + + // expect(type).not.toBeNull(); + // expect(instance).not.toBeNull(); + // expect(instance.verifyQuery).not.toBeNull(); + // expect(instance.userId.string()).toEqual('x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29'); + // expect(instance.challenge.toString()).toEqual( + // '6110517768249559238193477435454792024732173865488900270849624328650765691494' + // ); + // // TODO(illia-korotia): why Hash type doesn't implement `toString()` method? + // expect(instance.pubSignals.GISTRoot.string()).toEqual( + // '1243904711429961858774220647610724273798918457991486031567244100767259239747' + // ); + // }); + + // it('verify jwz with selective disclosure', async () => { + // const sender = 'did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL'; + // const callback = 'https://test.com/callback'; + // const reason = 'age verification'; + // const request: AuthorizationRequestMessage = createAuthorizationRequestWithMessage( + // reason, + // '', + // sender, + // callback + // ); + // expect(request.body.scope.length).toEqual(0); + // expect(request.body.callbackUrl).toEqual(callback); + // expect(request.body.reason).toEqual(reason); + // expect(request.from).toEqual(sender); + + // const proofRequest: ZeroKnowledgeProofRequest = { + // id: 1, + // circuitId: 'credentialAtomicQuerySigV2', + // query: { + // allowedIssuers: ['*'], + // context: + // 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld', + // type: 'KYCAgeCredential', + // credentialSubject: { + // birthday: {} + // } + // } + // }; + // request.body.scope.push(proofRequest); + + // expect(request.body.scope.length).toEqual(1); + + // const verifier = await Verifier.newVerifier({ + // stateResolver: resolvers, + // stateStorage: MOCK_STATE_STORAGE, + // circuitsDir: path.join(__dirname, './testdata'), + // documentLoader: schemaLoader + // }); + // request.id = '28494007-9c49-4f1a-9694-7700c08865bf'; + // request.thid = '7f38a193-0918-4a48-9fac-36adfdb8b542'; // because it's used in the response + + // const token = + // 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6ImYzZjVmM2JkLTJkOGItNDk0OS1hMDY5LTk3NTliZTdjZjUwYSIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhNDgtOWZhYy0zNmFkZmRiOGI1NDIiLCJmcm9tIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycUpwUnFaTlJUeGtpQ1VONFZTZkxRN0tBNFB6SFN3d1Z3blNLU0ZLdHciLCJ0byI6ImRpZDpwb2x5Z29uaWQ6cG9seWdvbjptdW1iYWk6MnFKNjg5a3BvSnhjU3pCNXNBRkp0UHNTQlNySEY1ZHE3MjJCSE1xVVJMIiwiYm9keSI6eyJkaWRfZG9jIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy9ucy9kaWQvdjEiXSwiaWQiOiJkaWQ6cG9seWdvbmlkOnBvbHlnb246bXVtYmFpOjJxSnBScVpOUlR4a2lDVU40VlNmTFE3S0E0UHpIU3d3VnduU0tTRkt0dyIsInNlcnZpY2UiOlt7ImlkIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycUpwUnFaTlJUeGtpQ1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DI1ODI1MTQ3NDM2OTc4NTk4NTE0MzcwODAyNjU1MjQ0MjgxNTM5OTE5NTk2MzU2OTI1MTAyMDM2MjkzNzA3MzE2MDY4NDgiXSxbIjE3MzgyMjA4OTc2NzM5NjY1NDYyNTI2OTEwMTQ5MTY2NzE5NzM5MTMwNzgyNzc5NTk2NjI2OTQ4NjI2NDc2ODI2ODU3OTQ2OTE1MjAyIiwiMTc1MzQ1OTM2Mjg1NDQ1NDQ5MzgxOTE0Njc4ODA1MjIyNTg5NjAzNzM4NTExNTk0MDI2NDg5NDE5ODI3Mzk1NjA3MTU1ODg1MTE5NzMiXSxbIjEiLCIwIl1dLCJwaV9jIjpbIjIxNTY4OTUwMTU3NDc2MjAwOTU0MDAxNTg3Mjg0NTg4NDQwMDk3ODg5NDQ5MjgyNjgyMzg1MDUyNTczODA3NTExOTU3NTgwNTUzNzcwIiwiMTg4MjcyMzI3NjEyMDEzNTIxNDQ4OTM0ODk3NTcwODEwMjIxMTMzMjExNjMyODg3NDg5NjgxOTc0NTg5NDM4MTYzNjg3MDUwNTM0MTUiLCIxIl0sInByb3RvY29sIjoiZ3JvdGgxNiIsImN1cnZlIjoiYm4xMjgifSwicHViX3NpZ25hbHMiOlsiMjE1MTMxNDA1MzAyMzM5MjE1MTU4MDkyMzUzODg3ODAxMzQ2ODEyNDU2MTI4NTg3NDQ5MDAyOTc3NDA0OTA0NDc3Mzg1NzMzMTQiLCI4MTcwNzQwNjM1NzM4Mjg0NTk1NzI0NjA2MTQxMzgzMzExNzQ4MzcwNzE1MzAyNjQ3NDQ4NDQ3NDk2MjA1MDcyMTg5NjUzNTQ2MTk3IiwiNTIyOTY2ODY4NjU1NzYzNzAxNzc4MTE1NzM1NjMwNDc2OTY2MTcwOTIzODY3MDI3MDYxMzU2MDg4NzY5OTM1Mjk0NDk5NjU1MDI5NSJdfQ'; + + // await expect(verifier.fullVerify(token, request, testOpts)).resolves.not.toThrow(); + // }); it('test verify empty credential subject', async () => { const sender = 'did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL'; @@ -801,6 +808,7 @@ describe('auth tests', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); diff --git a/test/linked-proofs.test.ts b/test/linked-proofs.test.ts index 6a63c20..e898f53 100644 --- a/test/linked-proofs.test.ts +++ b/test/linked-proofs.test.ts @@ -1,8 +1,7 @@ -import { AuthorizationRequestMessage, CircuitId } from '@0xpolygonid/js-sdk'; +import { AuthorizationRequestMessage, CircuitId, PROTOCOL_CONSTANTS } from '@0xpolygonid/js-sdk'; import { Verifier } from '@lib/auth/auth'; -import { resolvers, schemaLoader, testOpts } from './mocks'; +import { MOCK_STATE_STORAGE, resolvers, schemaLoader, testOpts } from './mocks'; import path from 'path'; -import { PROTOCOL_CONSTANTS } from '@0xpolygonid/js-sdk'; describe('Linked proofs verification', () => { it('should verification pass', async () => { @@ -84,6 +83,7 @@ describe('Linked proofs verification', () => { const verifier = await Verifier.newVerifier({ stateResolver: resolvers, + stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); diff --git a/test/mocks.ts b/test/mocks.ts index 488fd8a..bd91140 100644 --- a/test/mocks.ts +++ b/test/mocks.ts @@ -1,6 +1,12 @@ -import { cacheLoader } from '@0xpolygonid/js-sdk'; +import { + cacheLoader, + IStateStorage, + VerifiableConstants, + RootInfo, + StateProof, + VerifyOpts +} from '@0xpolygonid/js-sdk'; import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -import { VerifyOpts } from '@lib/circuits'; import { IStateResolver, ResolvedState, Resolvers } from '@lib/state/resolver'; import { DIDResolutionResult } from 'did-resolver'; @@ -63,3 +69,48 @@ export const resolveDIDDocument = { export const schemaLoader: DocumentLoader = cacheLoader({ ipfsNodeURL: process.env.IPFS_URL ?? 'https://ipfs.io' }); + +export const MOCK_STATE_STORAGE: IStateStorage = { + getLatestStateById: async () => { + throw new Error(VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST); + }, + getStateInfoByIdAndState: async (id: bigint, state: bigint) => { + const validTestIds = [ + '19898531390599208021876718705689344940605246460654065917270282371355906561', + '26675680708205250151451142983868154544835349648265874601395279235340702210', + '27752766823371471408248225708681313764866231655187366071881070918984471042', + '21803003425107230045260507608510138502859759480520560654156359021447614978', + '25191641634853875207018381290409317860151551336133597267061715643603096065', + '22942594156266665426613462771725327314382647426959044863446866613003751938' + ]; + if (validTestIds.includes(id.toString())) { + return { id, state }; + } + throw new Error(VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST); + }, + publishState: async () => { + return '0xc837f95c984892dbcc3ac41812ecb145fedc26d7003202c50e1b87e226a9b33c'; + }, + getGISTProof: (): Promise => { + return Promise.resolve({ + root: 0n, + existence: false, + siblings: [], + index: 0n, + value: 0n, + auxExistence: false, + auxIndex: 0n, + auxValue: 0n + }); + }, + getGISTRootInfo: (): Promise => { + return Promise.resolve({ + root: 0n, + replacedByRoot: 0n, + createdAtTimestamp: 0n, + replacedAtTimestamp: 0n, + createdAtBlock: 0n, + replacedAtBlock: 0n + }); + } +}; diff --git a/test/query.test.ts b/test/query.test.ts deleted file mode 100644 index b8b77b6..0000000 --- a/test/query.test.ts +++ /dev/null @@ -1,774 +0,0 @@ -import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query'; -import { getUnixTimestamp, Id, SchemaHash } from '@iden3/js-iden3-core'; -import { byteEncoder, cacheLoader, createSchemaHash } from '@0xpolygonid/js-sdk'; - -const defaultLoader = cacheLoader(); -const vpEmployee = JSON.parse(`{ - "@type": "VerifiablePresentation", - "@context": [ - "https://www.w3.org/2018/credentials/v1" - ], - "verifiableCredential": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld" - ], - "@type": [ - "VerifiableCredential", - "KYCEmployee" - ], - "credentialSubject": { - "@type": "KYCEmployee", - "position": "SSI Consultant" - } - } -}`); - -const vp = JSON.parse(`{ - "@context": [ - "https://www.w3.org/2018/credentials/v1" - ], - "@type": "VerifiablePresentation", - "verifiableCredential": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld" - ], - "@type": ["VerifiableCredential","KYCCountryOfResidenceCredential"], - "credentialSubject": { - "type": "KYCCountryOfResidenceCredential", - "countryCode": 800 - } - } -}`); - -const issuerDID = 'did:polygonid:polygon:mumbai:2qHSHBGWGJ68AosMKcLCTp8FYdVrtYE6MtNHhq8xpK'; -const issuerID = Id.fromBigInt( - BigInt('22638457188543025296541325416907897762715008870723718557276875842936181250') -); -const KYCCountrySchema = SchemaHash.newSchemaHashFromInt( - BigInt('336615423900919464193075592850483704600') -); -const KYCEmployeeSchema = SchemaHash.newSchemaHashFromInt( - BigInt('219578617064540016234161640375755865412') -); -const BigIntTrueHash = BigInt( - '18586133768512220936620570745912940619677854269274689475585506675881198879027' -); -const KYCAgeNonMerklizedSchema = createSchemaHash( - byteEncoder.encode( - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld#KYCAgeCredential' - ) -); -describe('Query', () => { - it('Check merklized query', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: { $nin: [800] } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 5, - value: new Array(BigInt(800)), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader)).resolves.not.toThrow(); - }); - - it('Check non-merklized query', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - birthday: { $eq: [19960424] } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld', - type: 'KYCAgeCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCAgeNonMerklizedSchema, - claimPathKey: BigInt(0), - operator: 1, - value: new Array(BigInt(19960424)), - merklized: 0, - slotIndex: 2, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader)).resolves.not.toThrow(); - }); - - it('Selective disclosure V2', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt(800)), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader, vp)).resolves.not.toThrow(); - }); - - it('Selective disclosure V3', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 16, - value: [], - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()), - operatorOutput: BigInt(800) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader, vp, true)).resolves.not.toThrow(); - }); - - it('Query with boolean type', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - ZKPexperiance: { - $eq: true - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '1944808975288007371356450257872165609440470546066507760733183342797918372827' - ), - operator: 1, - value: new Array(BigIntTrueHash), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader)).resolves.not.toThrow(); - }); - - it('Selective disclosure with xsd:string type', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - position: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '15406634529806189041952040954758558497189093183268091368437514469450172572054' - ), - operator: 1, - value: new Array( - BigInt('957410455271905675920624030785024750144198809104092676617070098470852489834') - ), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect( - checkQueryRequest(query, pubSig, defaultLoader, vpEmployee) - ).resolves.not.toThrow(); - }); - - it('EQ operator for xsd:string type', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - position: { - $eq: 'Software Engineer' - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '15406634529806189041952040954758558497189093183268091368437514469450172572054' - ), - operator: 1, - value: new Array( - BigInt('7481731651336040098616464366227645531920423822088928207225802836605991806542') - ), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - await expect(checkQueryRequest(query, pubSig, defaultLoader)).resolves.not.toThrow(); - }); - - it('Empty disclosure JSON for disclosure request', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - 'failed to validate selective disclosure: no vp present in selective disclosure request' - ); - } - }); - - it('Not EQ operation for disclosure request', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 5, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader, vp)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - 'failed to validate selective disclosure: operator for selective disclosure must be $eq' - ); - } - }); - - it('Not array of values for disclosure request', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: [BigInt('800'), BigInt('801')], - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader, vp)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - 'failed to validate selective disclosure: selective disclosure not available for array of values' - ); - } - }); - - it('Proof was generated for another disclosure value', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('1')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader, vp)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - 'failed to validate selective disclosure: value that was used is not equal to requested in query' - ); - } - }); - - it('Different key between proof and disclosure response', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - documentType: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader, vp)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - `failed to validate selective disclosure: can't get merkle value for field 'documentType'` - ); - } - }); - - it('Invalid issuer', async () => { - const query: Query = { - allowedIssuers: ['123'], - credentialSubject: { - documentType: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`issuer is not in allowed list`); - } - }); - - it('Invalid Schema ID', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - documentType: { - $eq: 3 - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCAgeCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('3')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`schema that was used is not equal to requested in query`); - } - }); - - it('Multiply query', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - documentType: {}, - countryCode: {} - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`multiple requests not supported`); - } - }); - - it('Multiple predicates in one request', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - countryCode: { - $eq: 20, - $ne: 10 - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`multiple predicates for one field not supported`); - } - }); - - it('Proof was generated for another query operator', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - countryCode: { - $eq: 20 - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 3, - value: new Array(BigInt('800')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - `failed to validate operators: operator that was used is not equal to request` - ); - } - }); - - it('failed to validate operators: comparison value that was used is not equal to requested in query', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - countryCode: { - $nin: [20] - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 5, - value: new Array(BigInt('40')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - `failed to validate operators: comparison value that was used is not equal to requested in query` - ); - } - }); - - it('Different slot index', async () => { - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - birthday: { $eq: [19960424] } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld', - type: 'KYCAgeCredential' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCAgeNonMerklizedSchema, - claimPathKey: BigInt(0), - operator: 1, - value: new Array(BigInt(19960424)), - merklized: 0, - slotIndex: 3, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`wrong claim slot was used in claim`); - } - }); - - it('Check revocation is required', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - countryCode: { - $nin: [20] - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', - type: 'KYCCountryOfResidenceCredential', - skipClaimRevocationCheck: false - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCCountrySchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 5, - value: new Array(BigInt('20')), - merklized: 1, - isRevocationChecked: 0, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`check revocation is required`); - } - }); - - it('Unsupported lt operator for xsd:boolean', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - ZKPexperiance: { - $lt: true - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 2, - value: new Array(BigInt('20')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - `operator '$lt' is not supported for 'http://www.w3.org/2001/XMLSchema#boolean' datatype` - ); - } - }); - - it('Negative value in request', async () => { - const query: Query = { - allowedIssuers: [issuerDID], - credentialSubject: { - documentType: { - $eq: -1 - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '17002437119434618783545694633038537380726339994244684348913844923422470806844' - ), - operator: 1, - value: new Array(BigInt('-1')), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: getUnixTimestamp(new Date()) - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe( - `failed to validate operators: comparison value that was used is not equal to requested in query` - ); - } - }); - - it('Generated proof is outdated', async () => { - const yesterday = new Date(); - yesterday.setDate(yesterday.getDate() - 1); - yesterday.setMinutes(yesterday.getMinutes() - 1); - const query: Query = { - allowedIssuers: ['*'], - credentialSubject: { - ZKPexperiance: { - $eq: true - } - }, - context: - 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld', - type: 'KYCEmployee' - }; - const pubSig: ClaimOutputs = { - issuerId: issuerID, - schemaHash: KYCEmployeeSchema, - claimPathKey: BigInt( - '1944808975288007371356450257872165609440470546066507760733183342797918372827' - ), - operator: 1, - value: new Array(BigIntTrueHash), - merklized: 1, - isRevocationChecked: 1, - valueArraySize: 64, - timestamp: yesterday.getTime() / 1000 - }; - try { - expect(await checkQueryRequest(query, pubSig, defaultLoader)).toThrowError(); - } catch (e) { - expect((e as Error).message).toBe(`generated proof is outdated`); - } - }); -}); From 0160eaa1ef0a9e50d2ef97957b7fa75781723c85 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 7 Mar 2024 14:35:12 +0200 Subject: [PATCH 4/9] add packageManager --- src/auth/auth.ts | 115 ++++--------------------------------- test/atomicV3.test.ts | 65 +++++++++++++++++---- test/auth.test.ts | 70 ++++++++++++++++++---- test/linked-proofs.test.ts | 60 ++++++++++++++++++- test/mocks.ts | 89 +++++++++++++++++++++++++++- 5 files changed, 269 insertions(+), 130 deletions(-) diff --git a/src/auth/auth.ts b/src/auth/auth.ts index ac56c22..289eea9 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -21,18 +21,13 @@ import { IStateStorage, ProofQuery, VerifyOpts, - CircuitId, - ProvingParams, - VerificationHandlerFunc, - VerificationParams, - ZKPPacker, - ZeroKnowledgeProofResponse + ZeroKnowledgeProofResponse, + IPackageManager } from '@0xpolygonid/js-sdk'; import { Resolvable } from 'did-resolver'; import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization'; import path from 'path'; import { DID } from '@iden3/js-iden3-core'; -import { proving } from '@iden3/js-jwz'; /** * createAuthorizationRequest is a function to create protocol authorization request @@ -83,10 +78,10 @@ export function createAuthorizationRequestWithMessage( * options to verify the query */ export type VerifierParams = Options & { - /* resolvers for state of the identities */ - stateResolver: Resolvers; /* state storage for state of the identities */ stateStorage: IStateStorage; + /* package manager */ + packageManager: IPackageManager; /* didDocumentResolver to init default jws packer */ didDocumentResolver?: Resolvable; /* circuitsDir - directory where circuits files are stored (default - 'circuits') */ @@ -100,7 +95,6 @@ export type VerifierParams = Options & { */ export interface VerifierSuiteParams { documentLoader: DocumentLoader; - packageManager: PackageManager; circuitStorage: ICircuitStorage; prover: IZKProver; } @@ -113,11 +107,9 @@ export interface VerifierSuiteParams { */ export class Verifier { private schemaLoader: DocumentLoader; - private stateResolver: Resolvers; - private packageManager: PackageManager; + private packageManager: IPackageManager; private prover: IZKProver; - private circuitStorage: ICircuitStorage; private readonly _pubSignalsVerifier: PubSignalsVerifier; // private readonly _authHandler: AuthHandler; @@ -129,14 +121,12 @@ export class Verifier { * @param {VerifierSuiteParams} params - suite for verification */ private constructor( - stateResolver: Resolvers, stateStorage: IStateStorage, + packageManager: IPackageManager, params: VerifierSuiteParams ) { this.schemaLoader = params.documentLoader; - this.stateResolver = stateResolver; - this.packageManager = params.packageManager; - this.circuitStorage = params.circuitStorage; + this.packageManager = packageManager; this.prover = params.prover; this._pubSignalsVerifier = new PubSignalsVerifier(this.schemaLoader, stateStorage); @@ -156,14 +146,12 @@ export class Verifier { params.suite = { documentLoader, circuitStorage, - prover: new NativeProver(circuitStorage), - packageManager: new PackageManager() + prover: new NativeProver(circuitStorage) }; - const verifier = new Verifier(params.stateResolver, params.stateStorage, params.suite); - await verifier.initPackers(params.didDocumentResolver); + const verifier = new Verifier(params.stateStorage, params.packageManager, params.suite); return verifier; } - return new Verifier(params.stateResolver, params.stateStorage, params.suite); + return new Verifier(params.stateStorage, params.packageManager, params.suite); } // setPackageManager sets the package manager for the Verifier. @@ -176,45 +164,6 @@ export class Verifier { return this.packageManager.registerPackers([packer]); } - // setupAuthV2ZKPPacker sets the custom packer manager for the Verifier. - public async setupAuthV2ZKPPacker(circuitStorage: ICircuitStorage) { - if (!circuitStorage) { - throw new Error('circuit storage is not defined'); - } - const authV2Set = await circuitStorage.loadCircuitData(CircuitId.AuthV2); - - if (!authV2Set.verificationKey) { - throw new Error('verification key is not for authv2 circuit'); - } - const mapKey = proving.provingMethodGroth16AuthV2Instance.methodAlg.toString(); - const provingParamMap: Map = new Map(); - - const stateVerificationFn = async ( - circuitId: string, - pubSignals: Array - ): Promise => { - if (circuitId !== CircuitId.AuthV2) { - throw new Error(`CircuitId is not supported ${circuitId}`); - } - // const verifier = new AuthPubSignalsV2(pubSignals); - // await verifier.verifyStates(this.stateResolver); - - // await this._pubSignalsVerifier.verify(circuitId, { pubSignals, query: {}, sender: '', challenge: 0n }); - return true; - }; - - const verificationFn = new VerificationHandlerFunc(stateVerificationFn); - - const verificationParamMap: Map = new Map(); - verificationParamMap.set(mapKey, { - key: authV2Set.verificationKey, - verificationFn - }); - - const zkpPacker = new ZKPPacker(provingParamMap, verificationParamMap); - return this.setPacker(zkpPacker); - } - // setupJWSPacker sets the JWS packer for the Verifier. public setupJWSPacker(kms: KMS, documentResolver: Resolvable) { const jwsPacker = new JWSPacker(kms, documentResolver); @@ -347,42 +296,6 @@ export class Verifier { } } - // /** - // * verifies jwz token - // * @public - // * @param {string} tokenStr - token string - // * @param {VerifyOpts} opts - verification options - // * - // * @returns `Promise` - // */ - // public async verifyJWZ(tokenStr: string, opts?: VerifyOpts): Promise { - // const token = await Token.parse(tokenStr); - // const key = (await this.circuitStorage.loadCircuitData(token.circuitId as CircuitId)) - // .verificationKey; - // if (!key) { - // throw new Error(`verification key is not found for circuit ${token.circuitId}`); - // } - - // const isValid = await token.verify(key); - // if (!isValid) { - // throw new Error(`zero-knowledge proof of jwz token is not valid`); - // } - - // const CircuitVerifier = Circuits.getCircuitPubSignals(token.circuitId); - - // if (!CircuitVerifier) { - // throw new Error(`circuit ${token.circuitId} is not supported by the library`); - // } - - // // outputs unmarshaller - // const verifier = new CircuitVerifier(token.zkProof.pub_signals); - - // // state verification - // await verifier.verifyStates(this.stateResolver, opts); - - // return token; - // } - /** * perform both verification of jwz / jws token and authorization request message * @public @@ -402,12 +315,4 @@ export class Verifier { await this.verifyAuthResponse(response, request, opts); return response; } - - private async initPackers(didResolver?: Resolvable) { - await this.setupAuthV2ZKPPacker(this.circuitStorage); - // set default jws packer if packageManager is not present in options but did document resolver is. - if (didResolver) { - this.setupJWSPacker(new KMS(), didResolver); - } - } } diff --git a/test/atomicV3.test.ts b/test/atomicV3.test.ts index 742a99e..9fe0f6a 100644 --- a/test/atomicV3.test.ts +++ b/test/atomicV3.test.ts @@ -1,19 +1,64 @@ import { Verifier } from '@lib/auth/auth'; -import { testOpts, resolvers, MOCK_STATE_STORAGE } from './mocks'; +import { + testOpts, + resolvers, + MOCK_STATE_STORAGE, + getPackageMgr, + registerBJJIntoInMemoryKMS, + getInMemoryDataStorage, + schemaLoader +} from './mocks'; import path from 'path'; import { AuthorizationResponseMessage, PROTOCOL_CONSTANTS, AuthorizationRequestMessage, - cacheLoader, - CircuitId + IPackageManager, + CircuitId, + IDataStorage, + IdentityWallet, + CredentialWallet, + ProofService, + CredentialStatusResolverRegistry, + CredentialStatusType, + RHSResolver, + FSCircuitStorage } from '@0xpolygonid/js-sdk'; -import { DocumentLoader } from '@iden3/js-jsonld-merklization'; -const schemaLoader: DocumentLoader = cacheLoader({ - ipfsNodeURL: process.env.IPFS_URL ?? 'https://ipfs.io' -}); describe('atomicV3', () => { + let packageMgr: IPackageManager; + let dataStorage: IDataStorage; + let idWallet: IdentityWallet; + let credWallet: CredentialWallet; + let proofService: ProofService; + + beforeEach(async () => { + const kms = registerBJJIntoInMemoryKMS(); + dataStorage = getInMemoryDataStorage(MOCK_STATE_STORAGE); + const circuitStorage = new FSCircuitStorage({ + dirname: path.join(__dirname, './testdata') + }); + + const resolvers = new CredentialStatusResolverRegistry(); + resolvers.register( + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + new RHSResolver(dataStorage.states) + ); + + credWallet = new CredentialWallet(dataStorage, resolvers); + idWallet = new IdentityWallet(kms, dataStorage, credWallet); + + proofService = new ProofService(idWallet, credWallet, circuitStorage, MOCK_STATE_STORAGE, { + documentLoader: schemaLoader + }); + + packageMgr = await getPackageMgr( + await circuitStorage.loadCircuitData(CircuitId.AuthV2), + proofService.generateAuthV2Inputs.bind(proofService), + () => Promise.resolve(true) + ); + }); + it('TestVerifyV3MessageWithSigProof_NonMerklized', async () => { const request: AuthorizationRequestMessage = { id: '28b15cd4-3aa1-4ddc-88a3-c05a0f788065', @@ -172,7 +217,7 @@ describe('atomicV3', () => { }; const authInstance = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); @@ -214,7 +259,7 @@ describe('atomicV3', () => { ); const authInstance = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); @@ -279,7 +324,7 @@ describe('atomicV3', () => { }; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader diff --git a/test/auth.test.ts b/test/auth.test.ts index a1c7081..22b2016 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -7,9 +7,17 @@ import { KMS, NativeProver, PROTOCOL_CONSTANTS, - PackageManager, ZeroKnowledgeProofRequest, - ZeroKnowledgeProofResponse + ZeroKnowledgeProofResponse, + IPackageManager, + CircuitId, + IDataStorage, + IdentityWallet, + CredentialWallet, + ProofService, + CredentialStatusResolverRegistry, + CredentialStatusType, + RHSResolver } from '@0xpolygonid/js-sdk'; import { createAuthorizationRequest, @@ -17,9 +25,50 @@ import { Verifier } from '@lib/auth/auth'; import path from 'path'; -import { MOCK_STATE_STORAGE, resolveDIDDocument, resolvers, schemaLoader, testOpts } from './mocks'; +import { + getInMemoryDataStorage, + getPackageMgr, + MOCK_STATE_STORAGE, + registerBJJIntoInMemoryKMS, + resolveDIDDocument, + resolvers, + schemaLoader, + testOpts +} from './mocks'; describe('auth tests', () => { + let packageMgr: IPackageManager; + let dataStorage: IDataStorage; + let idWallet: IdentityWallet; + let credWallet: CredentialWallet; + let proofService: ProofService; + + beforeEach(async () => { + const kms = registerBJJIntoInMemoryKMS(); + dataStorage = getInMemoryDataStorage(MOCK_STATE_STORAGE); + const circuitStorage = new FSCircuitStorage({ + dirname: path.join(__dirname, './testdata') + }); + + const resolvers = new CredentialStatusResolverRegistry(); + resolvers.register( + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + new RHSResolver(dataStorage.states) + ); + + credWallet = new CredentialWallet(dataStorage, resolvers); + idWallet = new IdentityWallet(kms, dataStorage, credWallet); + + proofService = new ProofService(idWallet, credWallet, circuitStorage, MOCK_STATE_STORAGE, { + documentLoader: schemaLoader + }); + + packageMgr = await getPackageMgr( + await circuitStorage.loadCircuitData(CircuitId.AuthV2), + proofService.generateAuthV2Inputs.bind(proofService), + () => Promise.resolve(true) + ); + }); it('createAuthorizationRequest', () => { const sender = '1125GJqgw6YEsKFwj63GY87MMxPL9kwDKxPUiwMLNZ'; const callback = 'https://test.com/callback'; @@ -78,12 +127,11 @@ describe('auth tests', () => { }; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, stateStorage: MOCK_STATE_STORAGE, + packageManager: packageMgr, suite: { prover: new NativeProver(new FSCircuitStorage({ dirname: '' })), circuitStorage: new FSCircuitStorage({ dirname: '../' }), - packageManager: new PackageManager(), documentLoader: schemaLoader } }); @@ -251,8 +299,8 @@ describe('auth tests', () => { }; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, stateStorage: MOCK_STATE_STORAGE, + packageManager: packageMgr, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader }); @@ -419,7 +467,7 @@ describe('auth tests', () => { }; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader @@ -476,7 +524,7 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata') }); @@ -528,7 +576,7 @@ describe('auth tests', () => { request.body.scope.push(proofRequest); const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, documentLoader: schemaLoader, circuitsDir: path.join(__dirname, './testdata'), @@ -694,7 +742,7 @@ describe('auth tests', () => { }; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader @@ -807,7 +855,7 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader diff --git a/test/linked-proofs.test.ts b/test/linked-proofs.test.ts index e898f53..1539b56 100644 --- a/test/linked-proofs.test.ts +++ b/test/linked-proofs.test.ts @@ -1,9 +1,63 @@ -import { AuthorizationRequestMessage, CircuitId, PROTOCOL_CONSTANTS } from '@0xpolygonid/js-sdk'; +import { + AuthorizationRequestMessage, + PROTOCOL_CONSTANTS, + CircuitId, + IDataStorage, + IdentityWallet, + CredentialWallet, + ProofService, + CredentialStatusResolverRegistry, + IPackageManager, + CredentialStatusType, + RHSResolver, + FSCircuitStorage +} from '@0xpolygonid/js-sdk'; import { Verifier } from '@lib/auth/auth'; -import { MOCK_STATE_STORAGE, resolvers, schemaLoader, testOpts } from './mocks'; +import { + getInMemoryDataStorage, + getPackageMgr, + MOCK_STATE_STORAGE, + registerBJJIntoInMemoryKMS, + resolvers, + schemaLoader, + testOpts +} from './mocks'; import path from 'path'; describe('Linked proofs verification', () => { + let packageMgr: IPackageManager; + let dataStorage: IDataStorage; + let idWallet: IdentityWallet; + let credWallet: CredentialWallet; + let proofService: ProofService; + + beforeEach(async () => { + const kms = registerBJJIntoInMemoryKMS(); + dataStorage = getInMemoryDataStorage(MOCK_STATE_STORAGE); + const circuitStorage = new FSCircuitStorage({ + dirname: path.join(__dirname, './testdata') + }); + + const resolvers = new CredentialStatusResolverRegistry(); + resolvers.register( + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + new RHSResolver(dataStorage.states) + ); + + credWallet = new CredentialWallet(dataStorage, resolvers); + idWallet = new IdentityWallet(kms, dataStorage, credWallet); + + proofService = new ProofService(idWallet, credWallet, circuitStorage, MOCK_STATE_STORAGE, { + documentLoader: schemaLoader + }); + + packageMgr = await getPackageMgr( + await circuitStorage.loadCircuitData(CircuitId.AuthV2), + proofService.generateAuthV2Inputs.bind(proofService), + () => Promise.resolve(true) + ); + }); + it('should verification pass', async () => { const authRequest: AuthorizationRequestMessage = { id: 'f5bcdfc9-3819-4052-ad97-c059119e563c', @@ -82,7 +136,7 @@ describe('Linked proofs verification', () => { 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjNhNTQ1YjY5LTYyZ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I5Nzg3Mzc1NjQxNDMxMjYyNTA5MjA4MDY1IiwiNTA0MDgzNzU5MDU3MzQwNjA1MjY2Njc2NTQzODAwODQxMjU0MzEyMzEyMzQ4MjY4Nzk0NDkwNDc0NjI5OTkwNTM4MTI5OTA0NTYxNCIsIjAiXX0'; const verifier = await Verifier.newVerifier({ - stateResolver: resolvers, + packageManager: packageMgr, stateStorage: MOCK_STATE_STORAGE, circuitsDir: path.join(__dirname, './testdata'), documentLoader: schemaLoader diff --git a/test/mocks.ts b/test/mocks.ts index bd91140..173a19e 100644 --- a/test/mocks.ts +++ b/test/mocks.ts @@ -4,9 +4,32 @@ import { VerifiableConstants, RootInfo, StateProof, - VerifyOpts + VerifyOpts, + CircuitData, + AuthDataPrepareFunc, + StateVerificationFunc, + IPackageManager, + DataPrepareHandlerFunc, + VerificationHandlerFunc, + VerificationParams, + ProvingParams, + ZKPPacker, + PackageManager, + PlainPacker, + InMemoryPrivateKeyStore, + BjjProvider, + KmsKeyType, + KMS, + CredentialStorage, + InMemoryDataSource, + W3CCredential, + IdentityStorage, + Identity, + Profile, + InMemoryMerkleTreeStorage } from '@0xpolygonid/js-sdk'; import { DocumentLoader } from '@iden3/js-jsonld-merklization'; +import { proving } from '@iden3/js-jwz'; import { IStateResolver, ResolvedState, Resolvers } from '@lib/state/resolver'; import { DIDResolutionResult } from 'did-resolver'; @@ -114,3 +137,67 @@ export const MOCK_STATE_STORAGE: IStateStorage = { }); } }; + +export const getPackageMgr = async ( + circuitData: CircuitData, + prepareFn: AuthDataPrepareFunc, + stateVerificationFn: StateVerificationFunc +): Promise => { + const authInputsHandler = new DataPrepareHandlerFunc(prepareFn); + + const verificationFn = new VerificationHandlerFunc(stateVerificationFn); + const mapKey = proving.provingMethodGroth16AuthV2Instance.methodAlg.toString(); + + if (!circuitData.verificationKey) { + throw new Error(`verification key doesn't exist for ${circuitData.circuitId}`); + } + const verificationParamMap: Map = new Map([ + [ + mapKey, + { + key: circuitData.verificationKey, + verificationFn + } + ] + ]); + + if (!circuitData.provingKey) { + throw new Error(`proving doesn't exist for ${circuitData.circuitId}`); + } + if (!circuitData.wasm) { + throw new Error(`wasm file doesn't exist for ${circuitData.circuitId}`); + } + const provingParamMap: Map = new Map(); + provingParamMap.set(mapKey, { + dataPreparer: authInputsHandler, + provingKey: circuitData.provingKey, + wasm: circuitData.wasm + }); + + const mgr: IPackageManager = new PackageManager(); + const packer = new ZKPPacker(provingParamMap, verificationParamMap); + const plainPacker = new PlainPacker(); + mgr.registerPackers([packer, plainPacker]); + + return mgr; +}; + +export const registerBJJIntoInMemoryKMS = (): KMS => { + const memoryKeyStore = new InMemoryPrivateKeyStore(); + const bjjProvider = new BjjProvider(KmsKeyType.BabyJubJub, memoryKeyStore); + const kms = new KMS(); + kms.registerKeyProvider(KmsKeyType.BabyJubJub, bjjProvider); + return kms; +}; + +export const getInMemoryDataStorage = (states: IStateStorage) => { + return { + credential: new CredentialStorage(new InMemoryDataSource()), + identity: new IdentityStorage( + new InMemoryDataSource(), + new InMemoryDataSource() + ), + mt: new InMemoryMerkleTreeStorage(40), + states + }; +}; From 07f9229cccf987f1f8f637227a819f61aeea446c Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 7 Mar 2024 15:06:32 +0200 Subject: [PATCH 5/9] reuse AuthHandler --- Readme.md | 20 +---- src/auth/auth.ts | 176 ++++--------------------------------- test/atomicV3.test.ts | 21 +---- test/auth.test.ts | 53 ++--------- test/linked-proofs.test.ts | 8 +- 5 files changed, 27 insertions(+), 251 deletions(-) diff --git a/Readme.md b/Readme.md index cd7d401..33d7411 100644 --- a/Readme.md +++ b/Readme.md @@ -118,25 +118,7 @@ The blockchain verification algorithm is used Init Verifier: ``` javascript - const ethStateResolver = new resolver.EthStateResolver( - ethUrl, - contractAddress, - ); - - const resolvers: resolver.Resolvers = { - ['polygon:mumbai']: ethStateResolver, - }; - - const schemaLoader = getDocumentLoader({ - ipfsNodeURL: 'ipfs.io' - }); - const ethStateResolver = new resolver.EthStateResolver('rpc url', 'contractAddress'); - const verifier = await auth.Verifier.newVerifier({ - stateResolver: resolvers, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - } - ); + const authInstance = new Verifier(packageManager, proofService); ``` FullVerify diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 289eea9..8c7eb10 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -1,6 +1,5 @@ import { v4 as uuidv4 } from 'uuid'; -import { Resolvers } from '@lib/state/resolver'; import { AuthorizationRequestMessage, AuthorizationResponseMessage, @@ -15,19 +14,16 @@ import { ICircuitStorage, cacheLoader, byteEncoder, - ZeroKnowledgeProofRequest, - VerifyContext, PubSignalsVerifier, IStateStorage, - ProofQuery, VerifyOpts, - ZeroKnowledgeProofResponse, - IPackageManager + IPackageManager, + IProofService, + AuthHandler } from '@0xpolygonid/js-sdk'; import { Resolvable } from 'did-resolver'; import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization'; import path from 'path'; -import { DID } from '@iden3/js-iden3-core'; /** * createAuthorizationRequest is a function to create protocol authorization request @@ -82,8 +78,8 @@ export type VerifierParams = Options & { stateStorage: IStateStorage; /* package manager */ packageManager: IPackageManager; - /* didDocumentResolver to init default jws packer */ - didDocumentResolver?: Resolvable; + /* proof service */ + proofService: IProofService; /* circuitsDir - directory where circuits files are stored (default - 'circuits') */ circuitsDir?: string; /* suite - optional suite with prover, circuit storage, package manager and document loader */ @@ -106,62 +102,29 @@ export interface VerifierSuiteParams { * @class Verifier */ export class Verifier { - private schemaLoader: DocumentLoader; - - private packageManager: IPackageManager; - private prover: IZKProver; - private readonly _pubSignalsVerifier: PubSignalsVerifier; - - // private readonly _authHandler: AuthHandler; + private _authHandler: AuthHandler; /** * Creates an instance of the Verifier. - * @private * @param {Resolvers} resolvers - state resolvers instances * @param {VerifierSuiteParams} params - suite for verification */ - private constructor( - stateStorage: IStateStorage, - packageManager: IPackageManager, - params: VerifierSuiteParams + constructor( + private _packageManager: IPackageManager, + private readonly _proofService: IProofService, ) { - this.schemaLoader = params.documentLoader; - this.packageManager = packageManager; - this.prover = params.prover; - - this._pubSignalsVerifier = new PubSignalsVerifier(this.schemaLoader, stateStorage); - } - - /** - * Creates an instance of the Verifier. - * @public - * @param {VerifierParams} params - params to init verifier - * @returns `Promise` - */ - static async newVerifier(params: VerifierParams): Promise { - if (!params.suite) { - const documentLoader = (params as Options).documentLoader ?? cacheLoader(params as Options); - const dirname = params?.circuitsDir ?? path.join(process.cwd(), 'circuits'); - const circuitStorage = new FSCircuitStorage({ dirname }); - params.suite = { - documentLoader, - circuitStorage, - prover: new NativeProver(circuitStorage) - }; - const verifier = new Verifier(params.stateStorage, params.packageManager, params.suite); - return verifier; - } - return new Verifier(params.stateStorage, params.packageManager, params.suite); + this._authHandler = new AuthHandler(_packageManager, _proofService); } // setPackageManager sets the package manager for the Verifier. public setPackageManager(manager: PackageManager) { - this.packageManager = manager; + this._packageManager = manager; + this._authHandler = new AuthHandler(manager, this._proofService); } // setPacker sets the custom packer manager for the Verifier. public setPacker(packer: IPacker) { - return this.packageManager.registerPackers([packer]); + return this._packageManager.registerPackers([packer]); } // setupJWSPacker sets the JWS packer for the Verifier. @@ -170,40 +133,6 @@ export class Verifier { return this.setPacker(jwsPacker); } - public verifyAuthRequest(request: AuthorizationRequestMessage) { - const groupIdValidationMap: { [k: string]: ZeroKnowledgeProofRequest[] } = {}; - const requestScope = request.body.scope; - for (const proofRequest of requestScope) { - const groupId = proofRequest.query.groupId as number; - if (groupId) { - const existingRequests = groupIdValidationMap[groupId] ?? []; - - //validate that all requests in the group have the same schema, issuer and circuit - for (const existingRequest of existingRequests) { - if (existingRequest.query.type !== proofRequest.query.type) { - throw new Error(`all requests in the group should have the same type`); - } - - if (existingRequest.query.context !== proofRequest.query.context) { - throw new Error(`all requests in the group should have the same context`); - } - - const allowedIssuers = proofRequest.query.allowedIssuers as string[]; - const existingRequestAllowedIssuers = existingRequest.query.allowedIssuers as string[]; - if ( - !( - allowedIssuers.includes('*') || - allowedIssuers.every((issuer) => existingRequestAllowedIssuers.includes(issuer)) - ) - ) { - throw new Error(`all requests in the group should have the same issuer`); - } - } - groupIdValidationMap[groupId] = [...(groupIdValidationMap[groupId] ?? []), proofRequest]; - } - } - } - /** * verifies zero knowledge proof response according to the proof request * @public @@ -218,82 +147,7 @@ export class Verifier { request: AuthorizationRequestMessage, opts?: VerifyOpts ) { - if ((request.body.message ?? '') !== (response.body.message ?? '')) { - throw new Error('message for signing from request is not presented in response'); - } - - if (request.from !== response.to) { - throw new Error( - `sender of the request is not a target of response - expected ${request.from}, given ${response.to}` - ); - } - - this.verifyAuthRequest(request); - const requestScope = request.body.scope; - - if (!response.from) { - throw new Error(`proof response doesn't contain from field`); - } - - const groupIdToLinkIdMap = new Map(); - // group requests by query group id - for (const proofRequest of requestScope) { - const groupId = proofRequest.query.groupId as number; - - const proofResp = response.body.scope.find( - (resp: ZeroKnowledgeProofResponse) => resp.id === proofRequest.id - ); - if (!proofResp) { - throw new Error(`proof is not given for requestId ${proofRequest.id}`); - } - - const circuitId = proofResp.circuitId; - if (circuitId !== proofRequest.circuitId) { - throw new Error( - `proof is not given for requested circuit expected: ${proofRequest.circuitId}, given ${circuitId}` - ); - } - - const proofValid = await this.prover.verify(proofResp, proofResp.circuitId); - if (!proofValid) { - throw Error( - `Proof with circuit id ${proofResp.circuitId} and request id ${proofResp.id} is not valid` - ); - } - - const params = proofRequest.params ?? {}; - params.verifierDid = DID.parse(request.from); - const verifyContext: VerifyContext = { - pubSignals: proofResp.pub_signals, - query: proofRequest.query as unknown as ProofQuery, - verifiablePresentation: proofResp.vp as JSON, - sender: response.from, - challenge: BigInt(proofResp.id), - opts: opts, - params: params - }; - const pubSignals = await this._pubSignalsVerifier.verify(proofResp.circuitId, verifyContext); - const linkID = (pubSignals as unknown as { linkID?: number }).linkID; - - if (linkID && groupId) { - groupIdToLinkIdMap.set(groupId, [ - ...(groupIdToLinkIdMap.get(groupId) ?? []), - { linkID: linkID as unknown as number, requestId: proofResp.id } - ]); - } - } - - // verify grouping links - for (const [groupId, metas] of groupIdToLinkIdMap.entries()) { - // check that all linkIds are the same - if (metas.some((meta) => meta.linkID !== metas[0].linkID)) { - throw new Error( - `Link id validation failed for group ${groupId}, request linkID to requestIds info: ${JSON.stringify( - metas - )}` - ); - } - } + return this._authHandler.handleAuthorizationResponse(response, request, opts); } /** @@ -310,7 +164,7 @@ export class Verifier { request: AuthorizationRequestMessage, opts?: VerifyOpts ): Promise { - const msg = await this.packageManager.unpack(byteEncoder.encode(tokenStr)); + const msg = await this._packageManager.unpack(byteEncoder.encode(tokenStr)); const response = msg.unpackedMessage as AuthorizationResponseMessage; await this.verifyAuthResponse(response, request, opts); return response; diff --git a/test/atomicV3.test.ts b/test/atomicV3.test.ts index 9fe0f6a..1044d34 100644 --- a/test/atomicV3.test.ts +++ b/test/atomicV3.test.ts @@ -216,12 +216,7 @@ describe('atomicV3', () => { to: 'did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7' }; - const authInstance = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata') - }); - + const authInstance = new Verifier(packageMgr, proofService); await authInstance.verifyAuthResponse(message, request, testOpts); }); @@ -258,11 +253,7 @@ describe('atomicV3', () => { `{"id":"3f660ddb-f658-4e49-8db1-a39c4fdc348f","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"7e5b5847-b479-4499-90ee-5fe4826a5bdd","body":{"message":"message to sign","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4120898270954196501698659371038588054918958563769831287147203948717242014624","8161421339704983205935832143741731851845367466023122838713066272249193414518","1"],"pi_b":[["2016142731671092085823980355087186874971933756399728048657567167042826575596","6793744608145762931207340557274708648520834540854771358056842986732615365330"],["8778588695583532060082422779657036840781757320865763695218580457590480892876","5111155321599578590956823356574570048809420578935237618371137640346580720238"],["1","0"]],"pi_c":["9353868372198554565265355896994535552872689398030095461666762398339915886396","20314706759118669909305881604960039713418625088875647733334383350621059880114","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","7777729897445253016468635824802413494952316305513954490382539913235271469351","0","0","0","2","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709716798","219578617064540016234161640375755865412","1944808975288007371356450257872165609440470546066507760733183342797918372827","0","1","18586133768512220936620570745912940619677854269274689475585506675881198879027","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","22728440853100433399211827098349696449620101147489499428101651758549307906","0"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7"}` ); - const authInstance = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata') - }); + const authInstance = new Verifier(packageMgr, proofService); await authInstance.verifyAuthResponse(message, request, testOpts); }); @@ -323,13 +314,7 @@ describe('atomicV3', () => { from: 'did:iden3:polygon:mumbai:wzokvZ6kMoocKJuSbftdZxTD6qvayGpJb3m4FVXth' }; - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); - + const verifier = new Verifier(packageMgr, proofService); const token = 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYX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wMDkzNTU1MDE1MDcxMzI5Nzg3Mzc1NjQxNDMxMjYyNTA5MjA4MDY1IiwiNDY3OTkxOTk5MTQ0MTMyNjM2OTQ5NzEyNzYzMTU2MzQ0NDk0MDM2NzExMjUxMjQ4MzgzNzA1MTgyNjYzODQ0MDk0Nzc0MDg4NTE4OSIsIjAiXX0'; diff --git a/test/auth.test.ts b/test/auth.test.ts index 22b2016..b26072f 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -126,16 +126,7 @@ describe('auth tests', () => { } }; - const verifier = await Verifier.newVerifier({ - stateStorage: MOCK_STATE_STORAGE, - packageManager: packageMgr, - suite: { - prover: new NativeProver(new FSCircuitStorage({ dirname: '' })), - circuitStorage: new FSCircuitStorage({ dirname: '../' }), - documentLoader: schemaLoader - } - }); - + const verifier = new Verifier(packageMgr, proofService); await expect(verifier.verifyAuthResponse(response, request)).resolves.not.toThrow(); }); @@ -298,12 +289,7 @@ describe('auth tests', () => { } }; - const verifier = await Verifier.newVerifier({ - stateStorage: MOCK_STATE_STORAGE, - packageManager: packageMgr, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); + const verifier = new Verifier(packageMgr, proofService); await expect(verifier.verifyAuthResponse(response, request, testOpts)).resolves.not.toThrow(); }); @@ -466,12 +452,7 @@ describe('auth tests', () => { } }; - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); + const verifier = new Verifier(packageMgr, proofService); await expect(verifier.verifyAuthResponse(response, request, testOpts)).resolves.not.toThrow(); }); @@ -523,11 +504,7 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata') - }); + const verifier = new Verifier(packageMgr, proofService); request.id = '28494007-9c49-4f1a-9694-7700c08865bf'; request.thid = '7f38a193-0918-4a48-9fac-36adfdb8b542'; // because it's used in the response @@ -575,13 +552,7 @@ describe('auth tests', () => { }; request.body.scope.push(proofRequest); - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - documentLoader: schemaLoader, - circuitsDir: path.join(__dirname, './testdata'), - didDocumentResolver: resolveDIDDocument - }); + const verifier = new Verifier(packageMgr, proofService); verifier.setupJWSPacker(new KMS(), resolveDIDDocument); await verifier.fullVerify(token, request, testOpts); @@ -741,12 +712,7 @@ describe('auth tests', () => { } }; - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); + const verifier = new Verifier(packageMgr, proofService); try { expect(await verifier.verifyAuthResponse(response, request)).toThrowError(); @@ -854,12 +820,7 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); + const verifier = new Verifier(packageMgr, proofService); request.id = '28494007-9c49-4f1a-9694-7700c08865bf'; request.thid = 'ee92ab12-2671-457e-aa5e-8158c205a985'; // because it's used in the response diff --git a/test/linked-proofs.test.ts b/test/linked-proofs.test.ts index 1539b56..bc382be 100644 --- a/test/linked-proofs.test.ts +++ b/test/linked-proofs.test.ts @@ -135,13 +135,7 @@ describe('Linked proofs verification', () => { const tokenString = 'eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjNhNTQ1YjY5LTYyZDctNGU2Yy05MWI0LTYyNzk4ZmI1NWYzZCIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zLXprcC1qc29uIiwidHlwZSI6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zEyMzEyMzQ4MjY4Nzk0NDkwNDc0NjI5OTkwNTM4MTI5OTA0NTYxNCIsIjAiXX0'; - const verifier = await Verifier.newVerifier({ - packageManager: packageMgr, - stateStorage: MOCK_STATE_STORAGE, - circuitsDir: path.join(__dirname, './testdata'), - documentLoader: schemaLoader - }); - + const verifier = new Verifier(packageMgr, proofService); await verifier.fullVerify(tokenString, authRequest, testOpts); }); }); From 8c12faf57347057d473be99474ff5ed676d9e4b7 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 7 Mar 2024 15:17:49 +0200 Subject: [PATCH 6/9] rm resolvers --- src/auth/auth.ts | 28 +------- src/state/resolver.ts | 128 ------------------------------------- test/atomicV3.test.ts | 1 - test/auth.test.ts | 2 - test/genesis.test.ts | 21 ------ test/linked-proofs.test.ts | 1 - test/mocks.ts | 26 -------- 7 files changed, 3 insertions(+), 204 deletions(-) delete mode 100644 src/state/resolver.ts delete mode 100644 test/genesis.test.ts diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 8c7eb10..7b6f859 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -8,22 +8,16 @@ import { KMS, PackageManager, PROTOCOL_CONSTANTS, - NativeProver, IZKProver, - FSCircuitStorage, ICircuitStorage, - cacheLoader, byteEncoder, - PubSignalsVerifier, - IStateStorage, VerifyOpts, IPackageManager, IProofService, AuthHandler } from '@0xpolygonid/js-sdk'; import { Resolvable } from 'did-resolver'; -import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization'; -import path from 'path'; +import { DocumentLoader } from '@iden3/js-jsonld-merklization'; /** * createAuthorizationRequest is a function to create protocol authorization request @@ -69,22 +63,6 @@ export function createAuthorizationRequestWithMessage( }; return request; } -/** - * VerifierParams are params to pass init verifier that contain jsonld document loader options and - * options to verify the query - */ -export type VerifierParams = Options & { - /* state storage for state of the identities */ - stateStorage: IStateStorage; - /* package manager */ - packageManager: IPackageManager; - /* proof service */ - proofService: IProofService; - /* circuitsDir - directory where circuits files are stored (default - 'circuits') */ - circuitsDir?: string; - /* suite - optional suite with prover, circuit storage, package manager and document loader */ - suite?: VerifierSuiteParams; -}; /** * VerifierSuiteParams are custom defined prover, circuit storage, package manager and document loader @@ -109,9 +87,9 @@ export class Verifier { * @param {Resolvers} resolvers - state resolvers instances * @param {VerifierSuiteParams} params - suite for verification */ - constructor( + constructor( private _packageManager: IPackageManager, - private readonly _proofService: IProofService, + private readonly _proofService: IProofService ) { this._authHandler = new AuthHandler(_packageManager, _proofService); } diff --git a/src/state/resolver.ts b/src/state/resolver.ts deleted file mode 100644 index ca20c75..0000000 --- a/src/state/resolver.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { Id } from '@iden3/js-iden3-core'; -import { ethers } from 'ethers'; -import { Abi__factory } from './types/ethers-contracts'; -import { IState } from './types/ethers-contracts/Abi'; - -const zeroInt = BigInt(0); - -export type Resolvers = { - [key: string]: IStateResolver; -}; - -export interface IStateResolver { - resolve(id: bigint, state: bigint): Promise; - rootResolve(state: bigint): Promise; -} -export type ResolvedState = { - latest: boolean; - genesis: boolean; - state: unknown; - transitionTimestamp: number | string; -}; -export class EthStateResolver implements IStateResolver { - private rpcUrl: string; - private contractAddress: string; - - constructor(rpcUrl: string, contractAddress: string) { - this.rpcUrl = rpcUrl; - this.contractAddress = contractAddress; - } - - public async resolve(id: bigint, state: bigint): Promise { - const url = new URL(this.rpcUrl); - const ethersProvider = new ethers.providers.JsonRpcProvider({ - url: url.href, - user: url.username, - password: url.password - }); - const contract = Abi__factory.connect(this.contractAddress, ethersProvider); - - // check if id is genesis - const isGenesis = isGenesisStateId(id, state); - - let contractState: IState.StateInfoStructOutput; - try { - contractState = await contract.getStateInfoByIdAndState(id, state); - } catch (e) { - if ((e as { errorArgs: string[] }).errorArgs[0] === 'State does not exist') { - if (isGenesis) { - return { - latest: true, - genesis: isGenesis, - state: state, - transitionTimestamp: 0 - }; - } - throw new Error('State is not genesis and not registered in the smart contract'); - } - throw e; - } - - if (!contractState.id.eq(id)) { - throw new Error(`state was recorded for another identity`); - } - - if (!contractState.state.eq(state)) { - if (contractState.replacedAtTimestamp.eq(zeroInt)) { - throw new Error(`no information about state transition`); - } - return { - latest: false, - genesis: false, - state: state, - transitionTimestamp: contractState.replacedAtTimestamp.toNumber() - }; - } - - return { latest: true, genesis: isGenesis, state, transitionTimestamp: 0 }; - } - - public async rootResolve(state: bigint): Promise { - const url = new URL(this.rpcUrl); - const ethersProvider = new ethers.providers.JsonRpcProvider({ - url: url.href, - user: url.username, - password: url.password - }); - const contract = Abi__factory.connect(this.contractAddress, ethersProvider); - - let globalStateInfo: IState.GistRootInfoStructOutput; - try { - globalStateInfo = await contract.getGISTRootInfo(state); - } catch (e: unknown) { - if ((e as { errorArgs: string[] }).errorArgs[0] === 'Root does not exist') { - throw new Error('GIST root does not exist in the smart contract'); - } - throw e; - } - - if (!globalStateInfo.root.eq(state)) { - throw new Error(`gist info contains invalid state`); - } - - if (!globalStateInfo.replacedByRoot.eq(zeroInt)) { - if (globalStateInfo.replacedAtTimestamp.eq(zeroInt)) { - throw new Error(`state was replaced, but replaced time unknown`); - } - return { - latest: false, - state: state, - transitionTimestamp: globalStateInfo.replacedAtTimestamp.toString(), - genesis: false - }; - } - - return { - latest: true, - state: state, - transitionTimestamp: 0, - genesis: false - }; - } -} - -export function isGenesisStateId(id: bigint, state: bigint): boolean { - const userID = Id.fromBigInt(id); - const identifier = Id.idGenesisFromIdenState(userID.type(), state); - return userID.equal(identifier); -} diff --git a/test/atomicV3.test.ts b/test/atomicV3.test.ts index 1044d34..8977800 100644 --- a/test/atomicV3.test.ts +++ b/test/atomicV3.test.ts @@ -1,7 +1,6 @@ import { Verifier } from '@lib/auth/auth'; import { testOpts, - resolvers, MOCK_STATE_STORAGE, getPackageMgr, registerBJJIntoInMemoryKMS, diff --git a/test/auth.test.ts b/test/auth.test.ts index b26072f..3818afb 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -5,7 +5,6 @@ import { AuthorizationResponseMessage, FSCircuitStorage, KMS, - NativeProver, PROTOCOL_CONSTANTS, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse, @@ -31,7 +30,6 @@ import { MOCK_STATE_STORAGE, registerBJJIntoInMemoryKMS, resolveDIDDocument, - resolvers, schemaLoader, testOpts } from './mocks'; diff --git a/test/genesis.test.ts b/test/genesis.test.ts deleted file mode 100644 index 3f2947e..0000000 --- a/test/genesis.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { DID } from '@iden3/js-iden3-core'; -import { isGenesisStateId } from '@lib/state/resolver'; - -describe('Genesis', () => { - it('isGenesisState', async () => { - const userDIDString = 'did:iden3:polygon:mumbai:x6suHR8HkEYczV9yVeAKKiXCZAd25P8WS6QvNhszk'; - const userDID = DID.parse(userDIDString); - const userID = DID.idFromDID(userDID); - - const genesisState = - '7521024223205616003431860562270429547098131848980857190502964780628723574810'; - const nonGenesisState = - '6017654403209798611575982337826892532952335378376369712724079246845524041042'; - - let isGenesis = isGenesisStateId(userID.bigInt(), BigInt(genesisState)); - expect(isGenesis).toEqual(true); - - isGenesis = isGenesisStateId(userID.bigInt(), BigInt(nonGenesisState)); - expect(isGenesis).toEqual(false); - }); -}); diff --git a/test/linked-proofs.test.ts b/test/linked-proofs.test.ts index bc382be..cd2cd21 100644 --- a/test/linked-proofs.test.ts +++ b/test/linked-proofs.test.ts @@ -18,7 +18,6 @@ import { getPackageMgr, MOCK_STATE_STORAGE, registerBJJIntoInMemoryKMS, - resolvers, schemaLoader, testOpts } from './mocks'; diff --git a/test/mocks.ts b/test/mocks.ts index 173a19e..c30e3d0 100644 --- a/test/mocks.ts +++ b/test/mocks.ts @@ -30,30 +30,8 @@ import { } from '@0xpolygonid/js-sdk'; import { DocumentLoader } from '@iden3/js-jsonld-merklization'; import { proving } from '@iden3/js-jwz'; -import { IStateResolver, ResolvedState, Resolvers } from '@lib/state/resolver'; import { DIDResolutionResult } from 'did-resolver'; -class MockResolver implements IStateResolver { - resolve(): Promise { - const t: ResolvedState = { - latest: true, - state: null, - genesis: false, - transitionTimestamp: 0 - }; - return Promise.resolve(t); - } - rootResolve(): Promise { - const t: ResolvedState = { - latest: true, - state: null, - genesis: false, - transitionTimestamp: 0 - }; - return Promise.resolve(t); - } -} - export const exampleDidDoc = { '@context': [ 'https://www.w3.org/ns/did/v1', @@ -81,10 +59,6 @@ export const testOpts: VerifyOpts = { acceptedProofGenerationDelay: 10 * 365 * 24 * 60 * 60 * 1000 // 10 years }; -const mockStateResolver: MockResolver = new MockResolver(); -export const resolvers: Resolvers = { - 'polygon:mumbai': mockStateResolver -}; export const resolveDIDDocument = { resolve: () => Promise.resolve({ didDocument: exampleDidDoc } as DIDResolutionResult) }; From ddfb244a484b58f9fe118abb7eae0c3d40a6c9a3 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 20 Mar 2024 18:28:32 +0200 Subject: [PATCH 7/9] use js-sdk version --- package-lock.json | 64 +++++++++++++++++++---------------------------- package.json | 4 +-- 2 files changed, 28 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index abcf83b..8da674a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,11 @@ "version": "1.2.0", "license": "AGPL-3.0", "dependencies": { - "@0xpolygonid/js-sdk": "../js-sdk", + "@0xpolygonid/js-sdk": "1.9.0", "@iden3/js-crypto": "1.0.3", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-jsonld-merklization": "1.1.2", - "@iden3/js-jwz": "1.2.1", + "@iden3/js-jwz": "1.3.0", "@iden3/js-merkletree": "1.1.2", "did-resolver": "^4.1.0", "ethers": "^5.4.0", @@ -1224,11 +1224,6 @@ "js-sha3": "0.8.0" } }, - "node_modules/@ethersproject/keccak256/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/@ethersproject/logger": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", @@ -1681,16 +1676,16 @@ } }, "node_modules/@iden3/js-jwz": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@iden3/js-jwz/-/js-jwz-1.2.1.tgz", - "integrity": "sha512-LzXa81cuH7FkjLbQP5cKdk1XmHGnJDe139aj4ydbtTXEFokaORmMxurMT9WQQBWQlSMsCSfplCpCVz1grd0bFg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@iden3/js-jwz/-/js-jwz-1.3.0.tgz", + "integrity": "sha512-rb6qtxDITy6gagxcoJJcTTccM0dDviyOVwDZVSPmmP/YHZ6JAPeZrIeC9hXDiKxmq83Gg9jD2qp9i89tjYBUTQ==", "peerDependencies": { "@iden3/js-crypto": "1.0.3", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-merkletree": "1.1.2", - "ffjavascript": "0.2.62", + "ffjavascript": "0.2.63", "rfc4648": "1.5.3", - "snarkjs": "0.7.2" + "snarkjs": "0.7.3" } }, "node_modules/@iden3/js-merkletree": { @@ -2796,9 +2791,9 @@ } }, "node_modules/b4a": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz", - "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", + "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", "peer": true }, "node_modules/babel-jest": { @@ -4238,14 +4233,14 @@ } }, "node_modules/ffjavascript": { - "version": "0.2.62", - "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.62.tgz", - "integrity": "sha512-uJ7MTrdzhX/3f+hxn0XhdXbJCqYZJSBB6y2/ui4t21vKYVjyTMlU80pPXu40ir6qpqbrdzUeKdlOdJ0aFG9UNA==", + "version": "0.2.63", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.63.tgz", + "integrity": "sha512-dBgdsfGks58b66JnUZeZpGxdMIDQ4QsD3VYlRJyFVrKQHb2kJy4R2gufx5oetrTxXPT+aEjg0dOvOLg1N0on4A==", "peer": true, "dependencies": { "wasmbuilder": "0.0.16", "wasmcurves": "0.2.2", - "web-worker": "^1.2.0" + "web-worker": "1.2.0" } }, "node_modules/file-entry-cache": { @@ -5422,6 +5417,11 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "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/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6687,9 +6687,9 @@ } }, "node_modules/snarkjs": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.7.2.tgz", - "integrity": "sha512-A8yPFm9pRnZ7XYXfPSjSFnugEV1rsHGjb8W7c0Qk7nzXl5h3WANTkpVC5FYxakmw/GKWekz7wjjHaOFtPp823Q==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.7.3.tgz", + "integrity": "sha512-cDLpWqdqEJSCQNc+cXYX1XTKdUZBtYEisuOsgmXf/HUsN5WmGN+FO7HfCS+cMQT1Nzbm1a9gAEpKH6KRtDtS1Q==", "peer": true, "dependencies": { "@iden3/binfileutils": "0.0.11", @@ -6698,7 +6698,7 @@ "circom_runtime": "0.1.24", "ejs": "^3.1.6", "fastfile": "0.0.20", - "ffjavascript": "0.2.62", + "ffjavascript": "0.2.63", "js-sha3": "^0.8.0", "logplease": "^1.2.15", "r1csfile": "0.0.47" @@ -6707,12 +6707,6 @@ "snarkjs": "build/cli.cjs" } }, - "node_modules/snarkjs/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==", - "peer": true - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -7271,12 +7265,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/typechain/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==", - "dev": true - }, "node_modules/typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -7435,9 +7423,9 @@ } }, "node_modules/web-worker": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.3.0.tgz", - "integrity": "sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", + "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==", "peer": true }, "node_modules/which": { diff --git a/package.json b/package.json index 7456687..e0e8335 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,10 @@ }, "dependencies": { "@iden3/js-crypto": "1.0.3", - "@0xpolygonid/js-sdk": "../js-sdk", + "@0xpolygonid/js-sdk": "1.9.0", "@iden3/js-iden3-core": "1.2.1", "@iden3/js-jsonld-merklization": "1.1.2", - "@iden3/js-jwz": "1.2.1", + "@iden3/js-jwz": "1.3.0", "@iden3/js-merkletree": "1.1.2", "did-resolver": "^4.1.0", "ethers": "^5.4.0", From 3bcb2e6d1c140dafaaf893b1dfaa6062684f888f Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 20 Mar 2024 18:30:41 +0200 Subject: [PATCH 8/9] fix build --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index f738d8b..24ee69e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,3 @@ export * as auth from '@lib/auth/auth'; -export * as resolver from '@lib/state/resolver'; export * as protocol from '@lib/types-sdk'; export { core } from '@0xpolygonid/js-sdk'; From bffd5b15312359e85bbc2917e1123cf29c8f53ac Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 21 Mar 2024 09:55:40 +0200 Subject: [PATCH 9/9] fix gateway URL --- test/schema.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/schema.test.ts b/test/schema.test.ts index 2f066ba..d398b6d 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -17,7 +17,7 @@ describe('schema loader', () => { connectionString = 'https://ipfs.io'; } const loader = getDocumentLoader({ - ipfsNodeURL: connectionString + ipfsGatewayURL: connectionString }); const schemaResult = (await loader('ipfs://Qmb1Q5jLETkUkhswCVX52ntTCNQnRm3NyyGf1NZG98u5cv')) .document;