From 0198a4a67ee55c580a6b052a96349e08c9107b6d Mon Sep 17 00:00:00 2001 From: Dimasik Kolezhniuk Date: Wed, 12 Jul 2023 19:56:00 +0200 Subject: [PATCH] Advanced boolean search credential support. Refactor sig test --- package-lock.json | 114 ++++++------ package.json | 2 +- src/storage/filters/jsonQuery.ts | 18 +- tests/credentials/credential-wallet.test.ts | 81 +++++++++ tests/credentials/mock.ts | 4 +- tests/proofs/sig.test.ts | 188 ++++---------------- 6 files changed, 196 insertions(+), 211 deletions(-) diff --git a/package-lock.json b/package-lock.json index c78439e6..b9f4a9d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.0.0-beta.17", + "version": "1.0.0-beta.18", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.0.0-beta.17", + "version": "1.0.0-beta.18", "license": "AGPL-3.0", "dependencies": { "@iden3/js-crypto": "1.0.0-beta.1", @@ -1231,9 +1231,9 @@ "integrity": "sha512-eHKfv4NzuqTYBk2Hn1IVb/vVUd5+g8xqcXZumwqp2FH5hwv02f9cyhpV8ZQRU9IOhBidddFktbB6r/ifKhWnlw==" }, "node_modules/@microsoft/api-documenter": { - "version": "7.22.24", - "resolved": "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.22.24.tgz", - "integrity": "sha512-KdO7p/weirR/po0SqwWsbqoPUTqLv0QVvxqopysxF2PVdBpeKx4eOrII1VGw0rL0QY6WVvttIOJwD/JpYv9oWw==", + "version": "7.22.26", + "resolved": "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.22.26.tgz", + "integrity": "sha512-Df//s/W9eXpUfOAP5f/KiBXWJM5vvjvXl1DnnEP73NQx5AACLSZWZzExwxJlpyaefcD7iYziFkK4I2oQhnVcFA==", "dev": true, "dependencies": { "@microsoft/api-extractor-model": "7.27.4", @@ -1249,9 +1249,9 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.36.1", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.36.1.tgz", - "integrity": "sha512-2SPp1jq6wDY5IOsRLUv/4FxngslctBZJlztAJ3uWpCAwqKQG7ESdL3DhEza+StbYLtBQmu1Pk6q1Vkhl7qD/bg==", + "version": "7.36.2", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.36.2.tgz", + "integrity": "sha512-ONe/jOmTZtR3OjTkWKHmeSV1P5ozbHDxHr6FV3KoWyIl1AcPk2B3dmvVBM5eOlZB5bgM66nxcWQTZ6msQo2hHg==", "dev": true, "dependencies": { "@microsoft/api-extractor-model": "7.27.4", @@ -1750,15 +1750,15 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.61.0.tgz", - "integrity": "sha512-A5l/eUAug103qtkwccSCxn8ZRwT+7RXWkFECdA4Cvl1dOlDUgTpAOfSEElZn2uSUxhdDpnCdetrf0jvU4qrL+g==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", + "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.61.0", - "@typescript-eslint/type-utils": "5.61.0", - "@typescript-eslint/utils": "5.61.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/type-utils": "5.62.0", + "@typescript-eslint/utils": "5.62.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.0", @@ -1784,15 +1784,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.61.0.tgz", - "integrity": "sha512-yGr4Sgyh8uO6fSi9hw3jAFXNBHbCtKKFMdX2IkT3ZqpKmtAq3lHS4ixB/COFuAIJpwl9/AqF7j72ZDWYKmIfvg==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", + "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "dev": true, "peer": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.61.0", - "@typescript-eslint/types": "5.61.0", - "@typescript-eslint/typescript-estree": "5.61.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", "debug": "^4.3.4" }, "engines": { @@ -1812,13 +1812,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.61.0.tgz", - "integrity": "sha512-W8VoMjoSg7f7nqAROEmTt6LoBpn81AegP7uKhhW5KzYlehs8VV0ZW0fIDVbcZRcaP3aPSW+JZFua+ysQN+m/Nw==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", + "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.61.0", - "@typescript-eslint/visitor-keys": "5.61.0" + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1829,13 +1829,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.61.0.tgz", - "integrity": "sha512-kk8u//r+oVK2Aj3ph/26XdH0pbAkC2RiSjUYhKD+PExemG4XSjpGFeyZ/QM8lBOa7O8aGOU+/yEbMJgQv/DnCg==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", + "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.61.0", - "@typescript-eslint/utils": "5.61.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/utils": "5.62.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -1856,9 +1856,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.61.0.tgz", - "integrity": "sha512-ldyueo58KjngXpzloHUog/h9REmHl59G1b3a5Sng1GfBo14BkS3ZbMEb3693gnP1k//97lh7bKsp6/V/0v1veQ==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", + "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1869,13 +1869,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.61.0.tgz", - "integrity": "sha512-Fud90PxONnnLZ36oR5ClJBLTLfU4pIWBmnvGwTbEa2cXIqj70AEDEmOmpkFComjBZ/037ueKrOdHuYmSFVD7Rw==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", + "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.61.0", - "@typescript-eslint/visitor-keys": "5.61.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1896,17 +1896,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.61.0.tgz", - "integrity": "sha512-mV6O+6VgQmVE6+xzlA91xifndPW9ElFW8vbSF0xCT/czPXVhwDewKila1jOyRwa9AE19zKnrr7Cg5S3pJVrTWQ==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", + "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.61.0", - "@typescript-eslint/types": "5.61.0", - "@typescript-eslint/typescript-estree": "5.61.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -1922,12 +1922,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.61.0.tgz", - "integrity": "sha512-50XQ5VdbWrX06mQXhy93WywSFZZGsv3EOjq+lqp6WC2t+j3mb6A9xYVdrRxafvK88vg9k9u+CT4l6D8PEatjKg==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", + "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.61.0", + "@typescript-eslint/types": "5.62.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -2642,9 +2642,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001514", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001514.tgz", - "integrity": "sha512-ENcIpYBmwAAOm/V2cXgM7rZUrKKaqisZl4ZAI520FIkqGXUxJjmaIssbRW5HVVR5tyV6ygTLIm15aU8LUmQSaQ==", + "version": "1.0.30001515", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz", + "integrity": "sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==", "dev": true, "funding": [ { @@ -3428,9 +3428,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.454", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.454.tgz", - "integrity": "sha512-pmf1rbAStw8UEQ0sr2cdJtWl48ZMuPD9Sto8HVQOq9vx9j2WgDEN6lYoaqFvqEHYOmGA9oRGn7LqWI9ta0YugQ==", + "version": "1.4.457", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.457.tgz", + "integrity": "sha512-/g3UyNDmDd6ebeWapmAoiyy+Sy2HyJ+/X8KyvNeHfKRFfHaA2W8oF5fxD5F3tjBDcjpwo0iek6YNgxNXDBoEtA==", "dev": true, "peer": true }, @@ -7696,9 +7696,9 @@ } }, "node_modules/terser": { - "version": "5.18.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.2.tgz", - "integrity": "sha512-Ah19JS86ypbJzTzvUCX7KOsEIhDaRONungA4aYBjEP3JZRf4ocuDzTg4QWZnPn9DEMiMYGJPiSOy7aykoCc70w==", + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.0.tgz", + "integrity": "sha512-JpcpGOQLOXm2jsomozdMDpd5f8ZHh1rR48OFgWUH3QsyZcfPgv2qDCYbcDEAYNd4OZRj2bWYKpwdll/udZCk/Q==", "dev": true, "peer": true, "dependencies": { diff --git a/package.json b/package.json index b930330e..fb0e16f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.0.0-beta.17", + "version": "1.0.0-beta.18", "description": "SDK to work with Polygon ID", "main": "dist/cjs/index.js", "module": "dist/esm_esbuild/index.js", diff --git a/src/storage/filters/jsonQuery.ts b/src/storage/filters/jsonQuery.ts index 8bec58ad..1b8e4fd2 100644 --- a/src/storage/filters/jsonQuery.ts +++ b/src/storage/filters/jsonQuery.ts @@ -34,15 +34,29 @@ export interface IFilterQuery { execute(credential: W3CCredential): boolean; } +const truthyValues = [true, 1, 'true']; +const falsyValues = [false, 0, 'false']; + +const equalsComparator = (a, b) => { + if (truthyValues.includes(a) && truthyValues.includes(b)) { + return true; + } + if (falsyValues.includes(a) && falsyValues.includes(b)) { + return true; + } + + return a === b; +}; + export /** @type {*} - filter operators and their functions */ const comparatorOptions: { [v in FilterOperatorMethod]: FilterOperatorFunction } = { $noop: () => true, - $eq: (a, b) => a === b, + $eq: (a, b) => equalsComparator(a, b), $in: (a: string, b: string[]) => b.includes(a), $nin: (a: string, b: string[]) => !b.includes(a), $gt: (a: number, b: number) => a > b, $lt: (a: number, b: number) => a < b, - $ne: (a, b) => a !== b + $ne: (a, b) => !equalsComparator(a, b) }; /** diff --git a/tests/credentials/credential-wallet.test.ts b/tests/credentials/credential-wallet.test.ts index 71934071..8badc43f 100644 --- a/tests/credentials/credential-wallet.test.ts +++ b/tests/credentials/credential-wallet.test.ts @@ -213,6 +213,87 @@ const credentialFlow = async (storage: IDataStorage) => { } }, expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $eq: 'true' } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $eq: 1 } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $eq: true } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $ne: 'false' } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $ne: 0 } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.insured': { $ne: false } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.hasOwnPackage': { $eq: 'false' } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.hasOwnPackage': { $eq: 0 } + } + }, + expected: [cred4] + }, + { + query: { + allowedIssuers: ['*'], + credentialSubject: { + 'country.hasOwnPackage': { $eq: false } + } + }, + expected: [cred4] } ]; diff --git a/tests/credentials/mock.ts b/tests/credentials/mock.ts index e74f6a81..e411d69f 100644 --- a/tests/credentials/mock.ts +++ b/tests/credentials/mock.ts @@ -75,7 +75,9 @@ export const cred4 = createTestCredential({ countOfFines: 0, country: { name: 'Spain', - code: 'ES' + code: 'ES', + insured: true, + hasOwnPackage: 'false' } }, expirationDate: '2023-11-11', diff --git a/tests/proofs/sig.test.ts b/tests/proofs/sig.test.ts index 5622e50f..c0c6d4c7 100644 --- a/tests/proofs/sig.test.ts +++ b/tests/proofs/sig.test.ts @@ -20,9 +20,8 @@ import path from 'path'; import { byteEncoder } from '../../src'; import { ZeroKnowledgeProofRequest } from '../../src/iden3comm'; import { CircuitData } from '../../src/storage/entities/circuitData'; -import { Blockchain, DidMethod, NetworkId } from '@iden3/js-iden3-core'; +import { Blockchain, DID, DidMethod, NetworkId } from '@iden3/js-iden3-core'; import { expect } from 'chai'; -import { checkVerifiablePresentation } from './common'; import { CredentialStatusResolverRegistry } from '../../src/credentials'; import { RHSResolver } from '../../src/credentials'; @@ -33,8 +32,9 @@ describe('sig proofs', () => { let dataStorage: IDataStorage; let proofService: ProofService; const rhsUrl = process.env.RHS_URL as string; - const seedPhraseIssuer: Uint8Array = byteEncoder.encode('seedseedseedseedseedseedseedseed'); - const seedPhrase: Uint8Array = byteEncoder.encode('seedseedseedseedseedseedseeduser'); + let userDID: DID; + let issuerDID: DID; + let circuitStorage: CircuitStorage; const mockStateStorage: IStateStorage = { getLatestStateById: async () => { @@ -67,23 +67,8 @@ describe('sig proofs', () => { } }; - beforeEach(async () => { - const memoryKeyStore = new InMemoryPrivateKeyStore(); - const bjjProvider = new BjjProvider(KmsKeyType.BabyJubJub, memoryKeyStore); - const kms = new KMS(); - kms.registerKeyProvider(KmsKeyType.BabyJubJub, bjjProvider); - - dataStorage = { - credential: new CredentialStorage(new InMemoryDataSource()), - identity: new IdentityStorage( - new InMemoryDataSource(), - new InMemoryDataSource() - ), - mt: new InMemoryMerkleTreeStorage(40), - states: mockStateStorage - }; - - const circuitStorage = new CircuitStorage(new InMemoryDataSource()); + before(async () => { + circuitStorage = new CircuitStorage(new InMemoryDataSource()); const loader = new FSKeyLoader(path.join(__dirname, './testdata')); @@ -111,6 +96,22 @@ describe('sig proofs', () => { `${CircuitId.AtomicQueryMTPV2.toString()}/verification_key.json` ) }); + }); + + beforeEach(async () => { + const memoryKeyStore = new InMemoryPrivateKeyStore(); + const bjjProvider = new BjjProvider(KmsKeyType.BabyJubJub, memoryKeyStore); + const kms = new KMS(); + kms.registerKeyProvider(KmsKeyType.BabyJubJub, bjjProvider); + dataStorage = { + credential: new CredentialStorage(new InMemoryDataSource()), + identity: new IdentityStorage( + new InMemoryDataSource(), + new InMemoryDataSource() + ), + mt: new InMemoryMerkleTreeStorage(40), + states: mockStateStorage + }; const resolvers = new CredentialStatusResolverRegistry(); resolvers.register( @@ -123,30 +124,28 @@ describe('sig proofs', () => { proofService = new ProofService(idWallet, credWallet, circuitStorage, mockStateStorage, { ipfsGatewayURL: 'https://ipfs.io' }); - }); - it('sigv2-non-merklized', async () => { - const { did: userDID, credential: cred } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - const { did: issuerDID, credential: issuerAuthCredential } = await idWallet.createIdentity({ + const seedPhraseIssuer: Uint8Array = byteEncoder.encode('seedseedseedseedseedseedseedseed'); + const seedPhrase: Uint8Array = byteEncoder.encode('seedseedseedseedseedseedseeduser'); + + const opts = (seed: Uint8Array) => ({ method: DidMethod.Iden3, blockchain: Blockchain.Polygon, networkId: NetworkId.Mumbai, - seed: seedPhraseIssuer, + seed, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl } }); + const { did: user } = await idWallet.createIdentity(opts(seedPhrase)); + const { did: issuer } = await idWallet.createIdentity(opts(seedPhraseIssuer)); + userDID = user; + issuerDID = issuer; + }); + + it('sigv2-non-merklized', async () => { const claimReq: CredentialRequest = { credentialSchema: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v2.json', @@ -190,41 +189,12 @@ describe('sig proofs', () => { expect(credsForMyUserDID.length).to.equal(1); const { proof, vp } = await proofService.generateProof(proofReq, userDID, credsForMyUserDID[0]); - console.log(proof); + expect(proof).not.to.be.undefined; expect(vp).to.be.undefined; - - await checkVerifiablePresentation( - claimReq.type, - userDID, - credsForMyUserDID[0], - proofService, - CircuitId.AtomicQuerySigV2 - ); }); it('sigv2-merklized', async () => { - const { did: userDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - - const { did: issuerDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhraseIssuer, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); const claimReq: CredentialRequest = { credentialSchema: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json', @@ -268,41 +238,12 @@ describe('sig proofs', () => { expect(credsForMyUserDID.length).to.equal(1); const { proof, vp } = await proofService.generateProof(proofReq, userDID, credsForMyUserDID[0]); - console.log(proof); expect(vp).to.be.undefined; - - await checkVerifiablePresentation( - claimReq.type, - userDID, - credsForMyUserDID[0], - proofService, - CircuitId.AtomicQuerySigV2 - ); + expect(proof).not.to.be.undefined; }); it('sigv2-merklized-query-array', async () => { - const { did: userDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - - const { did: issuerDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhraseIssuer, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); const claimReq: CredentialRequest = { credentialSchema: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json', @@ -346,17 +287,8 @@ describe('sig proofs', () => { expect(credsForMyUserDID.length).to.equal(1); const { proof, vp } = await proofService.generateProof(proofReq, userDID, credsForMyUserDID[0]); - console.log(proof); - + expect(proof).not.to.be.undefined; expect(vp).to.be.undefined; - - await checkVerifiablePresentation( - claimReq.type, - userDID, - credsForMyUserDID[0], - proofService, - CircuitId.AtomicQuerySigV2 - ); }); it('sigv2-ipfs-string-eq', async () => { @@ -388,27 +320,6 @@ describe('sig proofs', () => { from: 'did:polygonid:polygon:mumbai:2qLPqvayNQz9TA2r5VPxUugoF18teGU583zJ859wfy' }; - const { did: userDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - - const { did: issuerDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhraseIssuer, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); const claimReq: CredentialRequest = { credentialSchema: 'ipfs://Qmb1Q5jLETkUkhswCVX52ntTCNQnRm3NyyGf1NZG98u5cv', type: 'TestString', @@ -439,8 +350,7 @@ describe('sig proofs', () => { userDID, credsForMyUserDID[0] ); - console.log(proof); - + expect(proof).not.to.be.undefined; expect(vp).to.be.undefined; }); @@ -454,28 +364,6 @@ describe('sig proofs', () => { type: 'DeliveryAddress' }; - const { did: issuerDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhraseIssuer, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - - const { did: userDID } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Mumbai, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); - const claimReq: CredentialRequest = { credentialSchema: 'ipfs://QmbLQKw9Mzc9fVHowatJbvZjWNSUZchxYQX5Wtt8Ff9rGx', type: 'DeliveryAddress',