From 6e691177b94df2c0ac728eb5b0b122b3c6a6e35d Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Fri, 27 Sep 2024 12:58:07 +0300 Subject: [PATCH 1/6] add type ZeroKnowledgeProofQuery to scope.query --- package-lock.json | 4 ++-- package.json | 2 +- src/iden3comm/handlers/common.ts | 7 ++++--- src/iden3comm/types/protocol/auth.ts | 17 +++++++++++++++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7671e5a..719365d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.20.1", + "version": "1.20.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.20.1", + "version": "1.20.2", "license": "MIT or Apache-2.0", "dependencies": { "@noble/curves": "^1.4.0", diff --git a/package.json b/package.json index db2d9543..bec45ff3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.20.1", + "version": "1.20.2", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", diff --git a/src/iden3comm/handlers/common.ts b/src/iden3comm/handlers/common.ts index d35cbd5e..3a3a49aa 100644 --- a/src/iden3comm/handlers/common.ts +++ b/src/iden3comm/handlers/common.ts @@ -2,6 +2,7 @@ import { getRandomBytes } from '@iden3/js-crypto'; import { JsonDocumentObject, JWSPackerParams, + ZeroKnowledgeProofQuery, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../types'; @@ -18,11 +19,11 @@ import { Signer } from 'ethers'; * Returns a Map where the key is the groupId and the value is an object containing the query and linkNonce. * * @param requestScope - An array of ZeroKnowledgeProofRequest objects. - * @returns A Map representing the grouped queries. + * @returns A Map representing the grouped queries. */ const getGroupedQueries = ( requestScope: ZeroKnowledgeProofRequest[] -): Map => +): Map => requestScope.reduce((acc, proofReq) => { const groupId = proofReq.query.groupId as number | undefined; if (!groupId) { @@ -54,7 +55,7 @@ const getGroupedQueries = ( }); return acc; - }, new Map()); + }, new Map()); /** * Processes zero knowledge proof requests. diff --git a/src/iden3comm/types/protocol/auth.ts b/src/iden3comm/types/protocol/auth.ts index 6f787cdb..b32ecbf4 100644 --- a/src/iden3comm/types/protocol/auth.ts +++ b/src/iden3comm/types/protocol/auth.ts @@ -1,6 +1,8 @@ import { ZKProof } from '@iden3/js-jwz'; import { BasicMessage, JsonDocumentObject } from '../packer'; import { PROTOCOL_MESSAGE_TYPE } from '../../constants'; +import { ProofType } from '../../../verifiable'; +import { CircuitId } from '../../../circuits'; /** AuthorizationResponseMessage is struct the represents iden3message authorization response */ export type AuthorizationResponseMessage = BasicMessage & { @@ -36,14 +38,25 @@ export type AuthorizationRequestMessageBody = { /** ZeroKnowledgeProofRequest represents structure of zkp request object */ export type ZeroKnowledgeProofRequest = { id: number; - circuitId: string; + circuitId: CircuitId; optional?: boolean; - query: JsonDocumentObject; + query: ZeroKnowledgeProofQuery; params?: { nullifierSessionId?: string | number; }; }; +/** ZeroKnowledgeProofQuery represents structure of zkp request query object */ +export type ZeroKnowledgeProofQuery = { + allowedIssuers: string[]; + context: string; + credentialSubject?: JsonDocumentObject; + proofType?: ProofType; + skipClaimRevocationCheck?: boolean; + groupId?: number; + type: string; +}; + /** ZeroKnowledgeProofResponse represents structure of zkp response */ export type ZeroKnowledgeProofResponse = { id: number; From 17a71927b2fc92e28ad07be6170314761b4995b0 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Fri, 27 Sep 2024 13:09:46 +0300 Subject: [PATCH 2/6] fix unit --- tests/handlers/auth.test.ts | 8 ++++---- tests/proofs/sig.test.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/handlers/auth.test.ts b/tests/handlers/auth.test.ts index 64418d46..2888d5b3 100644 --- a/tests/handlers/auth.test.ts +++ b/tests/handlers/auth.test.ts @@ -835,7 +835,7 @@ describe('auth', () => { const proofRequest: ZeroKnowledgeProofRequest = { id: 23, - circuitId: 'credentialAtomicQueryMTPV2', + circuitId: CircuitId.AtomicQueryMTPV2, query: { allowedIssuers: ['*'], context: @@ -997,7 +997,7 @@ describe('auth', () => { const proofRequest: ZeroKnowledgeProofRequest = { id: 84239, - circuitId: 'credentialAtomicQuerySigV2', + circuitId: CircuitId.AtomicQuerySigV2, query: { allowedIssuers: ['*'], context: @@ -1318,7 +1318,7 @@ describe('auth', () => { context: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', credentialSubject: { documentType: { $eq: 99 } }, - proofType: 'Iden3SparseMerkleTreeProof', + proofType: ProofType.Iden3SparseMerkleTreeProof, type: 'KYCAgeCredential' } } @@ -1779,7 +1779,7 @@ describe('auth', () => { const proofRequest: ZeroKnowledgeProofRequest = { id: 1, - circuitId: 'credentialAtomicQuerySigV2', + circuitId: CircuitId.AtomicQuerySigV2, query: { allowedIssuers: ['*'], context: diff --git a/tests/proofs/sig.test.ts b/tests/proofs/sig.test.ts index 44bf92fc..5c25f5d8 100644 --- a/tests/proofs/sig.test.ts +++ b/tests/proofs/sig.test.ts @@ -309,7 +309,7 @@ describe('sig proofs', () => { scope: [ { id: 1, - circuitId: 'credentialAtomicQuerySigV2', + circuitId: CircuitId.AtomicQuerySigV2, query: { allowedIssuers: ['*'], context: 'ipfs://QmZ1zsLspwnjifxsncqDkB7EHb2pnaRnBPc5kqQcVxW5rV', @@ -477,7 +477,7 @@ describe('sig proofs', () => { expect(credsForMyUserDID.length).to.equal(1); const vpReq = { id: 1, - circuitId: 'credentialAtomicQuerySigV2', + circuitId: CircuitId.AtomicQuerySigV2, query }; const { proof, vp } = await proofService.generateProof(vpReq, userDID); @@ -500,7 +500,7 @@ describe('sig proofs', () => { }); const deliveryVPReq = { id: 1, - circuitId: 'credentialAtomicQuerySigV2', + circuitId: CircuitId.AtomicQuerySigV2, query: { ...deliveryCredQuery, credentialSubject: { 'postalProviderInformation.insured': {} } @@ -540,7 +540,7 @@ describe('sig proofs', () => { reason: 'test flow', scope: [ { - circuitId: 'credentialAtomicQueryV3-beta.1', + circuitId: CircuitId.AtomicQueryV3, id: 1711115116, query: { allowedIssuers: ['*'], @@ -612,7 +612,7 @@ describe('sig proofs', () => { reason: 'test flow', scope: [ { - circuitId: 'credentialAtomicQueryV3-beta.1', + circuitId: CircuitId.AtomicQueryV3, id: 1711115116, query: { allowedIssuers: ['*'], From 5b84ea7da550c746e875e3ae20565f4940107f15 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Fri, 27 Sep 2024 16:04:38 +0300 Subject: [PATCH 3/6] use did_doc?: DIDDocument; (type from did-resolver) --- src/iden3comm/handlers/credential-proposal.ts | 3 ++- src/iden3comm/types/protocol/auth.ts | 5 +++-- src/iden3comm/types/protocol/proposal-request.ts | 3 ++- tests/handlers/auth.test.ts | 8 -------- tests/iden3comm/message-handler.test.ts | 1 - 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/iden3comm/handlers/credential-proposal.ts b/src/iden3comm/handlers/credential-proposal.ts index ae2496ec..d487bcc1 100644 --- a/src/iden3comm/handlers/credential-proposal.ts +++ b/src/iden3comm/handlers/credential-proposal.ts @@ -21,12 +21,13 @@ import { IIdentityWallet } from '../../identity'; import { byteEncoder } from '../../utils'; import { W3CCredential } from '../../verifiable'; import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler'; +import { DIDDocument } from 'did-resolver'; /** @beta ProposalRequestCreationOptions represents proposal-request creation options */ export type ProposalRequestCreationOptions = { credentials: ProposalRequestCredential[]; metadata?: { type: string; data?: JsonDocumentObject }; - did_doc?: JsonDocumentObject; + did_doc?: DIDDocument; }; /** diff --git a/src/iden3comm/types/protocol/auth.ts b/src/iden3comm/types/protocol/auth.ts index b32ecbf4..e1aa06e3 100644 --- a/src/iden3comm/types/protocol/auth.ts +++ b/src/iden3comm/types/protocol/auth.ts @@ -3,6 +3,7 @@ import { BasicMessage, JsonDocumentObject } from '../packer'; import { PROTOCOL_MESSAGE_TYPE } from '../../constants'; import { ProofType } from '../../../verifiable'; import { CircuitId } from '../../../circuits'; +import { DIDDocument } from 'did-resolver'; /** AuthorizationResponseMessage is struct the represents iden3message authorization response */ export type AuthorizationResponseMessage = BasicMessage & { @@ -14,7 +15,7 @@ export type AuthorizationResponseMessage = BasicMessage & { /** AuthorizationMessageResponseBody is struct the represents authorization response data */ export type AuthorizationMessageResponseBody = { - did_doc?: JsonDocumentObject; + did_doc?: DIDDocument; message?: string; scope: Array; }; @@ -31,7 +32,7 @@ export type AuthorizationRequestMessageBody = { callbackUrl: string; reason?: string; message?: string; - did_doc?: JsonDocumentObject; + did_doc?: DIDDocument; scope: Array; }; diff --git a/src/iden3comm/types/protocol/proposal-request.ts b/src/iden3comm/types/protocol/proposal-request.ts index 300d2046..18ec8487 100644 --- a/src/iden3comm/types/protocol/proposal-request.ts +++ b/src/iden3comm/types/protocol/proposal-request.ts @@ -1,3 +1,4 @@ +import { DIDDocument } from 'did-resolver'; import { BasicMessage, JsonDocumentObject } from '../'; import { PROTOCOL_MESSAGE_TYPE } from '../../constants'; @@ -11,7 +12,7 @@ export type ProposalRequestMessage = BasicMessage & { export type ProposalRequestMessageBody = { credentials: ProposalRequestCredential[]; metadata?: { type: string; data?: JsonDocumentObject }; - did_doc?: JsonDocumentObject; + did_doc?: DIDDocument; }; /** @beta ProposalMessage is struct the represents proposal message */ diff --git a/tests/handlers/auth.test.ts b/tests/handlers/auth.test.ts index 2888d5b3..d68f1cc8 100644 --- a/tests/handlers/auth.test.ts +++ b/tests/handlers/auth.test.ts @@ -157,7 +157,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: [proofReq as ZeroKnowledgeProofRequest] }; @@ -227,7 +226,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: [proofReq as ZeroKnowledgeProofRequest] }; @@ -386,7 +384,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: proofReqs }; @@ -550,7 +547,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: proofReqs }; @@ -792,7 +788,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: proofReqs }; @@ -1467,7 +1462,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: [ { id: 1, @@ -2092,7 +2086,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: proofReqs }; @@ -2157,7 +2150,6 @@ describe('auth', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: [proofReq as ZeroKnowledgeProofRequest] }; diff --git a/tests/iden3comm/message-handler.test.ts b/tests/iden3comm/message-handler.test.ts index 7de37b91..eb94d104 100644 --- a/tests/iden3comm/message-handler.test.ts +++ b/tests/iden3comm/message-handler.test.ts @@ -148,7 +148,6 @@ describe('MessageHandler', () => { callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123', reason: 'reason', message: 'message', - did_doc: {}, scope: [ { id: 1, From 22499365b752a279626263d8f86ccca4926c14af Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Fri, 27 Sep 2024 16:29:36 +0300 Subject: [PATCH 4/6] extend VM with state info --- src/iden3comm/handlers/credential-proposal.ts | 2 +- src/iden3comm/types/protocol/auth.ts | 18 +++++++++++++++++- .../types/protocol/proposal-request.ts | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/iden3comm/handlers/credential-proposal.ts b/src/iden3comm/handlers/credential-proposal.ts index d487bcc1..2471481d 100644 --- a/src/iden3comm/handlers/credential-proposal.ts +++ b/src/iden3comm/handlers/credential-proposal.ts @@ -3,6 +3,7 @@ import { BasicMessage, CredentialOffer, CredentialsOfferMessage, + DIDDocument, IPackageManager, JsonDocumentObject, PackerParams @@ -21,7 +22,6 @@ import { IIdentityWallet } from '../../identity'; import { byteEncoder } from '../../utils'; import { W3CCredential } from '../../verifiable'; import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler'; -import { DIDDocument } from 'did-resolver'; /** @beta ProposalRequestCreationOptions represents proposal-request creation options */ export type ProposalRequestCreationOptions = { diff --git a/src/iden3comm/types/protocol/auth.ts b/src/iden3comm/types/protocol/auth.ts index e1aa06e3..48080219 100644 --- a/src/iden3comm/types/protocol/auth.ts +++ b/src/iden3comm/types/protocol/auth.ts @@ -3,7 +3,11 @@ import { BasicMessage, JsonDocumentObject } from '../packer'; import { PROTOCOL_MESSAGE_TYPE } from '../../constants'; import { ProofType } from '../../../verifiable'; import { CircuitId } from '../../../circuits'; -import { DIDDocument } from 'did-resolver'; +import { + DIDDocument as DidResolverDidDocument, + VerificationMethod as DidResolverVerificationMethod +} from 'did-resolver'; +import { RootInfo, StateInfo } from '../../../storage'; /** AuthorizationResponseMessage is struct the represents iden3message authorization response */ export type AuthorizationResponseMessage = BasicMessage & { @@ -75,3 +79,15 @@ export type VerifiablePresentation = { credentialSubject: JsonDocumentObject; }; }; + +/** DIDDocument represents structure of DID Document */ +export type DIDDocument = DidResolverDidDocument & { + verificationMethod?: VerificationMethod[]; +}; + +/** VerificationMethod represents structure of Verification Method */ +export type VerificationMethod = DidResolverVerificationMethod & { + published?: boolean; + info?: StateInfo; + global?: RootInfo; +}; diff --git a/src/iden3comm/types/protocol/proposal-request.ts b/src/iden3comm/types/protocol/proposal-request.ts index 18ec8487..fef46747 100644 --- a/src/iden3comm/types/protocol/proposal-request.ts +++ b/src/iden3comm/types/protocol/proposal-request.ts @@ -1,5 +1,4 @@ -import { DIDDocument } from 'did-resolver'; -import { BasicMessage, JsonDocumentObject } from '../'; +import { BasicMessage, DIDDocument, JsonDocumentObject } from '../'; import { PROTOCOL_MESSAGE_TYPE } from '../../constants'; /** @beta ProposalRequestMessage is struct the represents proposal-request message */ From c9453565456fdd13063dcf36a4d69ca596808064 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Mon, 30 Sep 2024 12:20:31 +0300 Subject: [PATCH 5/6] bamp to 1.20.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 719365d9..dd6652fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.20.2", + "version": "1.20.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.20.2", + "version": "1.20.3", "license": "MIT or Apache-2.0", "dependencies": { "@noble/curves": "^1.4.0", diff --git a/package.json b/package.json index bec45ff3..12efea30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.20.2", + "version": "1.20.3", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", From f7f18ddaa54968bcbb2f8b0d656a39d15a7a6b32 Mon Sep 17 00:00:00 2001 From: GopherDID <74898029+vmidyllic@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:45:47 +0300 Subject: [PATCH 6/6] Fix/skip claim revocation check onchain (#272) * update cross-chain integration test * fix wrong tree state fullfilment * 1.20.2 * you are the most pretty one --------- Co-authored-by: vbasiuk --- src/circuits/atomic-query-sig-v2-on-chain.ts | 18 ++-- tests/handlers/contract-request.test.ts | 86 +++++++++++++------- 2 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/circuits/atomic-query-sig-v2-on-chain.ts b/src/circuits/atomic-query-sig-v2-on-chain.ts index c91c17a3..636f4cc8 100644 --- a/src/circuits/atomic-query-sig-v2-on-chain.ts +++ b/src/circuits/atomic-query-sig-v2-on-chain.ts @@ -113,6 +113,10 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig { const valueProof = this.query?.valueProof ?? new ValueProof(); + const treeState = this.skipClaimRevocationCheck + ? this.claim.signatureProof?.issuerAuthNonRevProof.treeState + : this.claim.nonRevProof?.treeState; + const s: Partial = { requestID: this.requestID.toString(), userGenesisID: this.id.bigInt().toString(), @@ -120,16 +124,10 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig { claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(), issuerID: this.claim.issuerID?.bigInt().toString(), issuerClaim: this.claim.claim?.marshalJson(), - issuerClaimNonRevClaimsTreeRoot: this.claim.nonRevProof?.treeState?.claimsRoot - ?.bigInt() - .toString(), - issuerClaimNonRevRevTreeRoot: this.claim.nonRevProof?.treeState?.revocationRoot - ?.bigInt() - .toString(), - issuerClaimNonRevRootsTreeRoot: this.claim.nonRevProof?.treeState?.rootOfRoots - ?.bigInt() - .toString(), - issuerClaimNonRevState: this.claim.nonRevProof?.treeState?.state?.bigInt().toString(), + issuerClaimNonRevClaimsTreeRoot: treeState?.claimsRoot?.bigInt().toString(), + issuerClaimNonRevRevTreeRoot: treeState?.revocationRoot?.bigInt().toString(), + issuerClaimNonRevRootsTreeRoot: treeState?.rootOfRoots?.bigInt().toString(), + issuerClaimNonRevState: treeState?.state?.bigInt().toString(), issuerClaimNonRevMtp: this.claim.nonRevProof?.proof && prepareSiblingsStr(this.claim.nonRevProof.proof, this.getMTLevel()), diff --git a/tests/handlers/contract-request.test.ts b/tests/handlers/contract-request.test.ts index ef9142e2..109da2e0 100644 --- a/tests/handlers/contract-request.test.ts +++ b/tests/handlers/contract-request.test.ts @@ -31,7 +31,9 @@ import { ContractInvokeHandlerOptions, ContractInvokeRequest, ContractInvokeRequestBody, + ContractInvokeResponse, ContractInvokeTransactionData, + ContractMessageHandlerOptions, ContractRequestHandler, DataPrepareHandlerFunc, IContractRequestHandler, @@ -54,6 +56,7 @@ import { CredentialStatusResolverRegistry } from '../../src/credentials'; import { RHSResolver } from '../../src/credentials'; import { ethers, JsonRpcProvider, Signer } from 'ethers'; import { registerKeyProvidersInMemoryKMS, RPC_URL } from '../helpers'; +import { AbstractMessageHandler } from '../../src/iden3comm/handlers/message-handler'; describe('contract-request', () => { let idWallet: IdentityWallet; @@ -647,14 +650,34 @@ describe('contract-request', () => { // cross chain integration test it.skip('cross chain contract request flow - integration test', async () => { - const privadoTestRpcUrl = '<>'; // issuer RPC URL - privado test - const privadoTestStateContract = '0x975556428F077dB5877Ea2474D783D6C69233742'; - const amoyVerifierRpcUrl = '<>'; // verifier RPC URL - amoy - const erc20Verifier = '0x74030e4c5d53ef381A889C01f0bBd3B8336F4a4a'; + const privadoTestRpcUrl = '< >'; + const privadoMainRpcUrl = '< >'; + const amoyRpcUrl = '< >'; + const amoyStateContract = '< >'; + const privadoStateContract = '< >'; + const lineaSepoliaRpc = '< >'; + const erc20Verifier = '0xcfe3f46048cb9dAa40c90fd574F6E1deB534b9e7'; + + const issuerAmoyStateEthConfig = { + ...defaultEthConnectionConfig, + url: amoyRpcUrl, + contractAddress: amoyStateContract, + chainId: 80002 + }; - const issuerStateEthConfig = defaultEthConnectionConfig; - issuerStateEthConfig.url = privadoTestRpcUrl; - issuerStateEthConfig.contractAddress = privadoTestStateContract; // privado test state contract + const issuerStateEthConfig = { + ...defaultEthConnectionConfig, + url: privadoTestRpcUrl, + contractAddress: privadoStateContract, + chainId: 21001 + }; + + const userStateEthConfig = { + ...defaultEthConnectionConfig, + url: privadoMainRpcUrl, + contractAddress: privadoStateContract, + chainId: 21000 + }; const kms = registerKeyProvidersInMemoryKMS(); dataStorage = { @@ -664,7 +687,11 @@ describe('contract-request', () => { new InMemoryDataSource() ), mt: new InMemoryMerkleTreeStorage(40), - states: new EthStateStorage(issuerStateEthConfig) + states: new EthStateStorage([ + issuerAmoyStateEthConfig, + userStateEthConfig, + issuerStateEthConfig + ]) }; const circuitStorage = new FSCircuitStorage({ dirname: path.join(__dirname, '../proofs/testdata') @@ -702,8 +729,8 @@ describe('contract-request', () => { const { did: issuerDID, credential: issuerAuthCredential } = await idWallet.createIdentity({ method: DidMethod.Iden3, - blockchain: Blockchain.Privado, - networkId: NetworkId.Test, + blockchain: Blockchain.Polygon, + networkId: NetworkId.Amoy, seed: seedPhraseIssuer, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, @@ -733,27 +760,30 @@ describe('contract-request', () => { const proofReqs: ZeroKnowledgeProofRequest[] = [ { - id: 4, // 2 - mtp, 4 - sig + id: 138, circuitId: CircuitId.AtomicQuerySigV2OnChain, optional: false, query: { + skipClaimRevocationCheck: true, allowedIssuers: ['*'], type: claimReq.type, context: 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld', credentialSubject: { birthday: { - $lt: 20020101 + $ne: 20500101 } } } } ]; - const conf = defaultEthConnectionConfig; - conf.contractAddress = erc20Verifier; - conf.url = amoyVerifierRpcUrl; - conf.chainId = 80002; // amoy chain id + const conf = { + ...defaultEthConnectionConfig, + contractAddress: erc20Verifier, + url: lineaSepoliaRpc, + chainId: 59141 + }; const zkpVerifier = new OnChainZKPVerifier([conf], { didResolverUrl: 'https://resolver-dev.privado.id' @@ -762,7 +792,7 @@ describe('contract-request', () => { const transactionData: ContractInvokeTransactionData = { contract_address: erc20Verifier, - method_id: 'fd41d8d4', + method_id: 'ade09fcd', chain_id: conf.chainId }; @@ -778,31 +808,27 @@ describe('contract-request', () => { typ: MediaType.PlainMessage, type: PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE, thid: id, - body: ciRequestBody + body: ciRequestBody, + from: 'did:iden3:polygon:amoy:x6x5sor7zpySUbxeFoAZUYbUh68LQ4ipcvJLRYM6c' }; const ethSigner = new ethers.Wallet(walletKey); const challenge = BytesHelper.bytesToInt(hexToBytes(ethSigner.address)); - const options: ContractInvokeHandlerOptions = { + const options: ContractMessageHandlerOptions = { ethSigner, - challenge + challenge, + senderDid: userDID }; - const msgBytes = byteEncoder.encode(JSON.stringify(ciRequest)); - const ciResponse = await contractRequestHandler.handleContractInvokeRequest( - userDID, - msgBytes, + const ciResponse = await (contractRequestHandler as unknown as AbstractMessageHandler).handle( + ciRequest, options ); expect(ciResponse).not.be.undefined; - expect( - ( - (ciResponse as Map).values().next() - .value as ZeroKnowledgeProofResponse - ).id - ).to.be.equal(proofReqs[0].id); + console.log(ciResponse); + expect((ciResponse as unknown as ContractInvokeResponse).body.scope[0].txHash).not.be.undefined; }); it.skip('contract request flow V3 sig `email-verified` Transak req - integration test', async () => {