diff --git a/package-lock.json b/package-lock.json index 8dac2adf..45b0dc93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.21.0", + "version": "1.22.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.21.0", + "version": "1.22.0", "license": "MIT or Apache-2.0", "dependencies": { "@noble/curves": "^1.4.0", diff --git a/package.json b/package.json index 54816ae6..2681f338 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.21.0", + "version": "1.22.0", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", diff --git a/src/circuits/auth-v2.ts b/src/circuits/auth-v2.ts index 8396a05d..b2219d79 100644 --- a/src/circuits/auth-v2.ts +++ b/src/circuits/auth-v2.ts @@ -1,7 +1,13 @@ import { Hash, Proof } from '@iden3/js-merkletree'; import { Claim, Id } from '@iden3/js-iden3-core'; import { CircuitError, GISTProof, TreeState } from './models'; -import { BaseConfig, getNodeAuxValue, prepareSiblingsStr } from './common'; +import { + BaseConfig, + getNodeAuxValue, + IStateInfoPubSignals, + prepareSiblingsStr, + StatesInfo +} from './common'; import { Signature } from '@iden3/js-crypto'; import { byteDecoder, byteEncoder } from '../utils'; @@ -117,7 +123,7 @@ interface AuthV2CircuitInputs { * @public * @class AuthV2PubSignals */ -export class AuthV2PubSignals { +export class AuthV2PubSignals implements IStateInfoPubSignals { userID!: Id; challenge!: bigint; GISTRoot!: Hash; @@ -143,4 +149,11 @@ export class AuthV2PubSignals { this.GISTRoot = Hash.fromString(sVals[2]); return this; } + + getStatesInfo(): StatesInfo { + return { + states: [], + gists: [{ id: this.userID, root: this.GISTRoot }] + }; + } } diff --git a/src/iden3comm/handlers/contract-request.ts b/src/iden3comm/handlers/contract-request.ts index 2a1a4a20..7869fb89 100644 --- a/src/iden3comm/handlers/contract-request.ts +++ b/src/iden3comm/handlers/contract-request.ts @@ -8,7 +8,7 @@ import { FunctionSignatures, IOnChainZKPVerifier } from '../../storage'; import { Signer } from 'ethers'; import { processZeroKnowledgeProofRequests } from './common'; import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler'; - +import { prepareAuthV2ZeroKnowledgeResponse } from '../utils'; /** * Interface that allows the processing of the contract request * @@ -65,6 +65,7 @@ export class ContractRequestHandler implements IContractRequestHandler, IProtocolMessageHandler { private readonly _supportedCircuits = [ + CircuitId.AuthV2, CircuitId.AtomicQueryMTPV2OnChain, CircuitId.AtomicQuerySigV2OnChain, CircuitId.AtomicQueryV3OnChain @@ -121,13 +122,30 @@ export class ContractRequestHandler throw new Error(`Invalid chain id ${chain_id}`); } const verifierDid = message.from ? DID.parse(message.from) : undefined; - const zkpResponses = await processZeroKnowledgeProofRequests( - did, - message?.body?.scope, - verifierDid, - this._proofService, - { ethSigner, challenge, supportedCircuits: this._supportedCircuits } - ); + + const { scope = [] } = message.body; + + let zkpResponses: ZeroKnowledgeProofResponse[] = []; + + if (scope.length) { + zkpResponses = await processZeroKnowledgeProofRequests( + did, + scope, + verifierDid, + this._proofService, + { + ethSigner, + challenge, + supportedCircuits: this._supportedCircuits + } + ); + } else { + zkpResponses = await prepareAuthV2ZeroKnowledgeResponse( + await ctx.ethSigner.getAddress(), + did, + this._proofService + ); + } const methodId = message.body.transaction_data.method_id.replace('0x', ''); switch (methodId) { diff --git a/src/iden3comm/utils/contract-request.utils.ts b/src/iden3comm/utils/contract-request.utils.ts new file mode 100644 index 00000000..51bd5b6c --- /dev/null +++ b/src/iden3comm/utils/contract-request.utils.ts @@ -0,0 +1,67 @@ +import { keccak256 } from 'ethers'; +import { byteEncoder, hexToBytes, isEthereumIdentity } from '../../utils'; +import { CircuitId } from '../../circuits'; +import { Hex } from '@iden3/js-crypto'; +import { DID } from '@iden3/js-iden3-core'; +import { IProofService } from '../../proof'; +import { ZeroKnowledgeProofResponse } from '../types'; + +/** + * Retrieves the AuthV2 request ID. + * + * @returns The AuthV2 request ID. + */ +export function getAuthV2RequestId(): number { + const circuitHash = keccak256(byteEncoder.encode(CircuitId.AuthV2)); + const dataView = new DataView(Hex.decodeString(circuitHash.replace('0x', '')).buffer); + const id = dataView.getUint32(0); + return id; +} + + +/** + * Prepares the zero-knowledge proof response for the AuthV2 circuit. + * @param address - The address associated with the request. + * @param senderDid - The sender's decentralized identifier (DID). + * @param proofService - The proof service used to generate the proof. + * @returns A promise that resolves to an array of ZeroKnowledgeProofResponse objects. + */ +export async function prepareAuthV2ZeroKnowledgeResponse( + address: string, + senderDid: DID, + proofService: IProofService +): Promise { + const circuitId = CircuitId.AuthV2; + const id = getAuthV2RequestId(); + + if (isEthereumIdentity(senderDid)) { + return [ + { + circuitId, + id, + pub_signals: [], + proof: { + pi_a: [], + pi_b: [], + pi_c: [], + protocol: 'groth16' + } + } + ]; + } + const hash = Uint8Array.from([...hexToBytes(address), ...new Uint8Array(12)]).reverse(); + const authInputs = await proofService.generateAuthV2Inputs(hash, senderDid, CircuitId.AuthV2); + + const prover = proofService.getProver(); + + const { proof, pub_signals } = await prover.generate(authInputs, CircuitId.AuthV2); + + return [ + { + circuitId, + id, + pub_signals, + proof + } + ]; +} diff --git a/src/iden3comm/utils/index.ts b/src/iden3comm/utils/index.ts index 351289d8..77cb2574 100644 --- a/src/iden3comm/utils/index.ts +++ b/src/iden3comm/utils/index.ts @@ -1,3 +1,4 @@ export * from './envelope'; export * from './message'; export * from './did'; +export * from './contract-request.utils'; diff --git a/src/proof/proof-service.ts b/src/proof/proof-service.ts index 02719bd1..01dac93d 100644 --- a/src/proof/proof-service.ts +++ b/src/proof/proof-service.ts @@ -163,6 +163,12 @@ export interface IProofService { query: ProofQuery, opts?: { skipClaimRevocationCheck: boolean } ): Promise<{ cred: W3CCredential; revStatus: RevocationStatus | undefined }>; + + /** + * Returns prover instance + * @returns {IZKProver} + */ + getProver(): IZKProver; } /** * Proof service is an implementation of IProofService @@ -200,6 +206,11 @@ export class ProofService implements IProofService { ); } + /** {@inheritdoc IProofService.getProver} */ + getProver(): IZKProver { + return this._prover; + } + /** {@inheritdoc IProofService.verifyProof} */ async verifyProof(zkp: ZKProof, circuitId: CircuitId): Promise { return this._prover.verify(zkp, circuitId); diff --git a/src/storage/blockchain/onchain-zkp-verifier.ts b/src/storage/blockchain/onchain-zkp-verifier.ts index fc3ac635..6dce8975 100644 --- a/src/storage/blockchain/onchain-zkp-verifier.ts +++ b/src/storage/blockchain/onchain-zkp-verifier.ts @@ -8,15 +8,16 @@ import { } from '../../iden3comm'; import abi from './abi/ZkpVerifier.json'; import { TransactionService } from '../../blockchain'; -import { DID } from '@iden3/js-iden3-core'; +import { DID, Id } from '@iden3/js-iden3-core'; import { AtomicQueryMTPV2OnChainPubSignals, AtomicQuerySigV2OnChainPubSignals, AtomicQueryV3OnChainPubSignals, + AuthV2PubSignals, CircuitId, StatesInfo } from '../../circuits'; -import { byteEncoder, DIDDocumentSignature, resolveDidDocument } from '../../utils'; +import { byteEncoder, DIDDocumentSignature, getChainIdFromId, resolveDidDocument } from '../../utils'; import { GlobalStateUpdate, IdentityStateUpdate } from '../entities/state'; import { poseidon } from '@iden3/js-crypto'; import { Hash } from '@iden3/js-merkletree'; @@ -43,6 +44,12 @@ export type OnChainZKPVerifierOptions = { didResolverUrl?: string; }; +type OnChainZKPVerifierCircuitId = + | CircuitId.AuthV2 + | CircuitId.AtomicQueryMTPV2OnChain + | CircuitId.AtomicQuerySigV2OnChain + | CircuitId.AtomicQueryV3OnChain; + /** * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract * and submitZKPResponse. @@ -54,12 +61,20 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { /** * supported circuits */ - private readonly _supportedCircuits = [ + private readonly _supportedCircuits: OnChainZKPVerifierCircuitId[] = [ + CircuitId.AuthV2, CircuitId.AtomicQueryMTPV2OnChain, CircuitId.AtomicQuerySigV2OnChain, CircuitId.AtomicQueryV3OnChain ]; + private readonly _supportedCircuitsPubSignalsMap = { + [CircuitId.AtomicQueryMTPV2OnChain]: AtomicQueryMTPV2OnChainPubSignals, + [CircuitId.AtomicQuerySigV2OnChain]: AtomicQuerySigV2OnChainPubSignals, + [CircuitId.AtomicQueryV3OnChain]: AtomicQueryV3OnChainPubSignals, + [CircuitId.AuthV2]: AuthV2PubSignals + }; + /** * abi coder to encode/decode structures to solidity bytes */ @@ -219,6 +234,44 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { return new Map().set(txnHash, zkProofResponses); } + private getCrossChainResolvers( + source: { + id: Id; + root?: Hash; + state?: Hash; + }[], + txDataChainId: number, + type: 'gist' | 'state', + didResolverUrl: string + ) { + return [ + ...new Set( + source.map((info) => + JSON.stringify({ + id: info.id.string(), + [type]: type === 'gist' ? info.root?.string() : info.state?.string() + }) + ) + ) + ].reduce((acc: Promise[], s: string) => { + const info = JSON.parse(s); + const id = Id.fromString(info.id); + const chainId = getChainIdFromId(id); + + if (txDataChainId === chainId) { + return acc; + } + const promise = this.resolveDidDocumentEip712MessageAndSignature( + DID.parseFromId(Id.fromString(info.id)), + didResolverUrl, + { + [type]: Hash.fromString(info[type]) + } + ); + return [...acc, promise]; + }, []); + } + public async prepareTxArgsSubmitV2( txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[] @@ -228,24 +281,32 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { `submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.` ); } - if (!this._opts?.didResolverUrl) { - throw new Error(`did resolver url required for crosschain verification`); + const didResolverUrl = this._opts?.didResolverUrl; + if (!didResolverUrl) { + throw new Error(`did resolver url required for cross chain verification`); } - const gistUpdateArr = []; - const stateUpdateArr = []; + const gistUpdates = []; + const stateUpdates = []; const payload = []; - // Resolved gists and states to avoid duplicate requests - const gistUpdateResolutionsPending: string[] = []; - const stateUpdateResolutionsPending: string[] = []; + const emptyBytes = '0x'; for (const zkProof of zkProofResponses) { - const requestID = zkProof.id; - const inputs = zkProof.pub_signals; + const { id: requestId, pub_signals: inputs } = zkProof; + const proofCircuitId = zkProof.circuitId as OnChainZKPVerifierCircuitId; - if (!this._supportedCircuits.includes(zkProof.circuitId as CircuitId)) { + if (!this._supportedCircuits.includes(proofCircuitId)) { throw new Error(`Circuit ${zkProof.circuitId} not supported by OnChainZKPVerifier`); } + if (inputs.length === 0) { + payload.push({ + requestId: requestId, + zkProof: emptyBytes, + data: emptyBytes + }); + continue; + } + const zkProofEncoded = this.packZkpProof( inputs, zkProof.proof.pi_a.slice(0, 2), @@ -256,61 +317,28 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { zkProof.proof.pi_c.slice(0, 2) ); - const stateInfo = this.getOnChainGistRootStatePubSignals( - zkProof.circuitId as - | CircuitId.AtomicQueryMTPV2OnChain - | CircuitId.AtomicQuerySigV2OnChain - | CircuitId.AtomicQueryV3OnChain, - zkProof.pub_signals - ); - - const gistUpdateResolutions = []; - for (const gist of stateInfo.gists) { - const gistResolutionPending = gistUpdateResolutionsPending.find( - (g) => g == JSON.stringify(gist) - ); - - if (gistResolutionPending) { - continue; - } - gistUpdateResolutionsPending.push(JSON.stringify(gist)); - - gistUpdateResolutions.push( - this.resolveDidDocumentEip712MessageAndSignature( - DID.parseFromId(gist.id), - this._opts.didResolverUrl, - { gist: gist.root } - ) - ); - } + const stateInfo = this.getOnChainGistRootStatePubSignals(proofCircuitId, inputs); - const stateUpdateResolutions = []; - for (const state of stateInfo.states) { - const stateResolutionPending = stateUpdateResolutionsPending.find( - (s) => s == JSON.stringify(state) - ); + const chainId = txData.chain_id; + const gistUpdateResolutions = this.getCrossChainResolvers( + stateInfo.gists, + chainId, + 'gist', + didResolverUrl + ); - if (stateResolutionPending) { - continue; - } - stateUpdateResolutionsPending.push(JSON.stringify(state)); - - stateUpdateResolutions.push( - this.resolveDidDocumentEip712MessageAndSignature( - DID.parseFromId(state.id), - this._opts.didResolverUrl, - { - state: state.state - } - ) - ); - } + const stateUpdateResolutions = this.getCrossChainResolvers( + stateInfo.states, + chainId, + 'state', + didResolverUrl + ); if (gistUpdateResolutions.length > 0) { - gistUpdateArr.push(...((await Promise.all(gistUpdateResolutions)) as GlobalStateUpdate[])); + gistUpdates.push(...((await Promise.all(gistUpdateResolutions)) as GlobalStateUpdate[])); } if (stateUpdateResolutions.length > 0) { - stateUpdateArr.push( + stateUpdates.push( ...((await Promise.all(stateUpdateResolutions)) as IdentityStateUpdate[]) ); } @@ -334,15 +362,18 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { } } - const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : '0x'; + const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : emptyBytes; payload.push({ - requestId: requestID, + requestId: requestId, zkProof: zkProofEncoded, data: metadata }); } - const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr); + const crossChainProofs = + gistUpdates.length || stateUpdates.length + ? this.packCrossChainProofs(gistUpdates, stateUpdates) + : emptyBytes; return [payload, crossChainProofs]; } @@ -421,24 +452,14 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier { } private getOnChainGistRootStatePubSignals( - onChainCircuitId: - | CircuitId.AtomicQueryMTPV2OnChain - | CircuitId.AtomicQuerySigV2OnChain - | CircuitId.AtomicQueryV3OnChain, + onChainCircuitId: OnChainZKPVerifierCircuitId, inputs: string[] ): StatesInfo { - let atomicQueryPubSignals; - switch (onChainCircuitId) { - case CircuitId.AtomicQueryMTPV2OnChain: - atomicQueryPubSignals = new AtomicQueryMTPV2OnChainPubSignals(); - break; - case CircuitId.AtomicQuerySigV2OnChain: - atomicQueryPubSignals = new AtomicQuerySigV2OnChainPubSignals(); - break; - case CircuitId.AtomicQueryV3OnChain: - atomicQueryPubSignals = new AtomicQueryV3OnChainPubSignals(); - break; + const PubSignals = this._supportedCircuitsPubSignalsMap[onChainCircuitId]; + if (!PubSignals) { + throw new Error(`Circuit ${onChainCircuitId} not supported by OnChainZKPVerifier`); } + const atomicQueryPubSignals = new PubSignals(); const encodedInputs = byteEncoder.encode(JSON.stringify(inputs)); atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs); return atomicQueryPubSignals.getStatesInfo(); diff --git a/src/utils/did-helper.ts b/src/utils/did-helper.ts index 058094ee..6fd857cb 100644 --- a/src/utils/did-helper.ts +++ b/src/utils/did-helper.ts @@ -1,5 +1,5 @@ import { Hex } from '@iden3/js-crypto'; -import { Id, buildDIDType, genesisFromEthAddress, DID } from '@iden3/js-iden3-core'; +import { Id, buildDIDType, genesisFromEthAddress, DID, ChainIds } from '@iden3/js-iden3-core'; import { Hash } from '@iden3/js-merkletree'; import { DIDResolutionResult, VerificationMethod, DIDResolutionMetadata } from 'did-resolver'; import { keccak256 } from 'js-sha3'; @@ -134,10 +134,13 @@ export const resolveDidDocument = async ( if (opts?.gist) { url += `${url.includes('?') ? '&' : '?'}gist=${opts.gist.hex()}`; } - const resp = await fetch(url); - const data = await resp.json(); - - return data; + try { + const resp = await fetch(url); + const data = await resp.json(); + return data; + } catch (e) { + throw new Error(`Failed to resolve DID document for ${did} ${e}`); + } }; export const buildDIDFromEthPubKey = (didType: Uint8Array, pubKeyEth: string): DID => { @@ -152,3 +155,10 @@ export const buildDIDFromEthPubKey = (didType: Uint8Array, pubKeyEth: string): D const identifier = new Id(didType, genesis); return DID.parseFromId(identifier); }; + + +export function getChainIdFromId(id: Id): number { + const { blockchain, networkId } = DID.decodePartsFromId(id); + const chainKey = `${blockchain}:${networkId}`; + return ChainIds[chainKey]; +} diff --git a/tests/handlers/contract-request.test.ts b/tests/handlers/contract-request.test.ts index 109da2e0..26875f0c 100644 --- a/tests/handlers/contract-request.test.ts +++ b/tests/handlers/contract-request.test.ts @@ -10,7 +10,8 @@ import { EthStateStorage, OnChainZKPVerifier, defaultEthConnectionConfig, - hexToBytes + hexToBytes, + FunctionSignatures } from '../../src'; import { IDataStorage, IStateStorage, IOnChainZKPVerifier } from '../../src/storage/interfaces'; import { InMemoryDataSource, InMemoryMerkleTreeStorage } from '../../src/storage/memory'; @@ -55,8 +56,16 @@ import { expect } from 'chai'; import { CredentialStatusResolverRegistry } from '../../src/credentials'; import { RHSResolver } from '../../src/credentials'; import { ethers, JsonRpcProvider, Signer } from 'ethers'; -import { registerKeyProvidersInMemoryKMS, RPC_URL } from '../helpers'; +import { + createEthereumBasedIdentity, + createIdentity, + getInMemoryDataStorage, + registerKeyProvidersInMemoryKMS, + RPC_URL, + SEED_USER +} from '../helpers'; import { AbstractMessageHandler } from '../../src/iden3comm/handlers/message-handler'; +import { Hex } from '@iden3/js-crypto'; describe('contract-request', () => { let idWallet: IdentityWallet; @@ -650,49 +659,58 @@ describe('contract-request', () => { // cross chain integration test it.skip('cross chain contract request flow - integration test', async () => { - 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 CONTRACTS = { + AMOY_STATE_CONTRACT: '0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124', + AMOY_UNIVERSAL_VERIFIER: '0x1Df0B05F15b5ea9648B8a081aca8ad0dE065bD1F', + PRIVADO_STATE_CONTRACT: '0x975556428F077dB5877Ea2474D783D6C69233742', + AUTH_V2_AMOY_VALIDATOR: '0x1a593E1aD3843b4363Dfa42585c4bBCA885553c0' }; - const issuerStateEthConfig = { - ...defaultEthConnectionConfig, - url: privadoTestRpcUrl, - contractAddress: privadoStateContract, - chainId: 21001 + const networkConfigs = { + amoy: (contractAddress) => ({ + ...defaultEthConnectionConfig, + url: '<>', + contractAddress, + chainId: 80002 + }), + privadoMain: (contractAddress) => ({ + ...defaultEthConnectionConfig, + url: '<>', + contractAddress, + chainId: 21000 + }), + privadoTest: (contractAddress) => ({ + ...defaultEthConnectionConfig, + url: 'https://rpc-testnet.privado.id', + contractAddress, + chainId: 21001 + }), + lineaSepolia: (contractAddress) => ({ + ...defaultEthConnectionConfig, + url: '<>', + contractAddress, + chainId: 80001 + }) }; - const userStateEthConfig = { - ...defaultEthConnectionConfig, - url: privadoMainRpcUrl, - contractAddress: privadoStateContract, - chainId: 21000 - }; + const issuerAmoyStateEthConfig = networkConfigs.amoy(CONTRACTS.AMOY_STATE_CONTRACT); + + const issuerPrivadoTestStateEthConfig = networkConfigs.privadoTest( + CONTRACTS.PRIVADO_STATE_CONTRACT + ); + + // const userStateEthConfig = networkConfigs.amoy(CONTRACTS.AMOY_STATE_CONTRACT); + const userStateEthConfig = networkConfigs.privadoMain(CONTRACTS.PRIVADO_STATE_CONTRACT); const kms = registerKeyProvidersInMemoryKMS(); - dataStorage = { - credential: new CredentialStorage(new InMemoryDataSource()), - identity: new IdentityStorage( - new InMemoryDataSource(), - new InMemoryDataSource() - ), - mt: new InMemoryMerkleTreeStorage(40), - states: new EthStateStorage([ + dataStorage = getInMemoryDataStorage( + new EthStateStorage([ issuerAmoyStateEthConfig, userStateEthConfig, - issuerStateEthConfig + issuerPrivadoTestStateEthConfig ]) - }; + ); + const circuitStorage = new FSCircuitStorage({ dirname: path.join(__dirname, '../proofs/testdata') }); @@ -714,29 +732,14 @@ describe('contract-request', () => { proofService.verifyState.bind(proofService) ); - const { did: userDID, credential: cred } = await idWallet.createIdentity({ - method: DidMethod.Iden3, + const { did: userDID } = await createIdentity(idWallet, { + seed: SEED_USER, blockchain: Blockchain.Privado, networkId: NetworkId.Main, - seed: seedPhrase, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } }); - expect(cred).not.to.be.undefined; - const { did: issuerDID, credential: issuerAuthCredential } = await idWallet.createIdentity({ - method: DidMethod.Iden3, - blockchain: Blockchain.Polygon, - networkId: NetworkId.Amoy, - seed: seedPhraseIssuer, - revocationOpts: { - type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, - id: rhsUrl - } - }); + const { did: issuerDID, credential: issuerAuthCredential } = await createIdentity(idWallet); expect(issuerAuthCredential).not.to.be.undefined; const claimReq: CredentialRequest = { @@ -758,6 +761,8 @@ describe('contract-request', () => { await credWallet.save(issuerCred); + // ADD proofReq to scope + // eslint-disable-next-line @typescript-eslint/no-unused-vars const proofReqs: ZeroKnowledgeProofRequest[] = [ { id: 138, @@ -778,28 +783,24 @@ describe('contract-request', () => { } ]; - const conf = { - ...defaultEthConnectionConfig, - contractAddress: erc20Verifier, - url: lineaSepoliaRpc, - chainId: 59141 - }; + const zkpVerifierNetworkConfig = networkConfigs.amoy(CONTRACTS.AMOY_UNIVERSAL_VERIFIER); - const zkpVerifier = new OnChainZKPVerifier([conf], { + const zkpVerifier = new OnChainZKPVerifier([zkpVerifierNetworkConfig], { didResolverUrl: 'https://resolver-dev.privado.id' }); + contractRequestHandler = new ContractRequestHandler(packageMgr, proofService, zkpVerifier); const transactionData: ContractInvokeTransactionData = { - contract_address: erc20Verifier, - method_id: 'ade09fcd', - chain_id: conf.chainId + contract_address: zkpVerifierNetworkConfig.contractAddress, + method_id: FunctionSignatures.SubmitZKPResponseV2, + chain_id: zkpVerifierNetworkConfig.chainId }; const ciRequestBody: ContractInvokeRequestBody = { reason: 'reason', transaction_data: transactionData, - scope: [...proofReqs] + scope: [] }; const id = uuid.v4();