@0xpolygonid/js-sdk 1.28.1 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/browser/esm/index.js +1633 -799
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +24289 -23453
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/iden3comm/handlers/auth.js +1 -1
  6. package/dist/node/cjs/iden3comm/handlers/common.js +63 -1
  7. package/dist/node/cjs/iden3comm/handlers/contract-request.js +64 -7
  8. package/dist/node/cjs/iden3comm/types/protocol/contract-request.js +6 -0
  9. package/dist/node/cjs/iden3comm/utils/contract-request.utils.js +16 -1
  10. package/dist/node/cjs/proof/proof-service.js +26 -0
  11. package/dist/node/cjs/proof/provers/inputs-generator.js +2 -4
  12. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +107 -16
  13. package/dist/node/cjs/storage/blockchain/state.js +5 -6
  14. package/dist/node/esm/iden3comm/handlers/auth.js +1 -1
  15. package/dist/node/esm/iden3comm/handlers/common.js +62 -2
  16. package/dist/node/esm/iden3comm/handlers/contract-request.js +66 -9
  17. package/dist/node/esm/iden3comm/types/protocol/contract-request.js +5 -1
  18. package/dist/node/esm/iden3comm/utils/contract-request.utils.js +14 -1
  19. package/dist/node/esm/proof/proof-service.js +26 -0
  20. package/dist/node/esm/proof/provers/inputs-generator.js +2 -4
  21. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +107 -16
  22. package/dist/node/esm/storage/blockchain/state.js +5 -6
  23. package/dist/types/iden3comm/handlers/common.d.ts +16 -1
  24. package/dist/types/iden3comm/handlers/contract-request.d.ts +3 -1
  25. package/dist/types/iden3comm/types/protocol/auth.d.ts +10 -2
  26. package/dist/types/iden3comm/types/protocol/contract-request.d.ts +12 -0
  27. package/dist/types/iden3comm/utils/contract-request.utils.d.ts +7 -0
  28. package/dist/types/proof/proof-service.d.ts +14 -2
  29. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +10 -3
  30. package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts +18 -1
  31. package/package.json +2 -1
@@ -52547,6 +52547,395 @@ class TransactionService {
52547
52547
  }
52548
52548
  }
52549
52549
 
52550
+ /**
52551
+ * creates empty basic message
52552
+ *
52553
+ * @returns BasicMessage
52554
+ */
52555
+ const basicMessageFactory = () => {
52556
+ return {
52557
+ id: '',
52558
+ typ: '',
52559
+ thid: '',
52560
+ type: '',
52561
+ body: {},
52562
+ from: '',
52563
+ to: ''
52564
+ };
52565
+ };
52566
+ /**
52567
+ * create empty header stub
52568
+ *
52569
+ * @returns {HeaderStub}
52570
+ */
52571
+ const headerStubFactory = () => {
52572
+ return {
52573
+ typ: ''
52574
+ };
52575
+ };
52576
+
52577
+ // Envelope Errors
52578
+ // Token Errors
52579
+ const ErrUnknownCircuitID = "unknown circuit ID. can't verify msg sender";
52580
+ const ErrSenderNotUsedTokenCreation = 'sender of message is not used for jwz token creation';
52581
+ // ZKP-Packer Errors
52582
+ const ErrPackedWithUnsupportedCircuit = 'message was packed with unsupported circuit';
52583
+ const ErrProofIsInvalid = 'message proof is invalid';
52584
+ const ErrStateVerificationFailed = 'message state verification failed';
52585
+ const ErrNoProvingMethodAlg = 'unknown proving method algorithm';
52586
+
52587
+ const objectIs = (obj, //eslint-disable-line @typescript-eslint/no-explicit-any
52588
+ targetObj //eslint-disable-line @typescript-eslint/no-explicit-any
52589
+ ) => {
52590
+ Object.keys(targetObj).forEach((prop) => {
52591
+ if (!obj[prop]) {
52592
+ return false;
52593
+ }
52594
+ if (typeof targetObj[prop] !== typeof obj[prop]) {
52595
+ return false;
52596
+ }
52597
+ });
52598
+ return true;
52599
+ };
52600
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
52601
+ const isProtocolMessage = (message) => {
52602
+ const basicMessage = basicMessageFactory();
52603
+ Object.keys(basicMessage).forEach((prop) => {
52604
+ if (!message[prop]) {
52605
+ return false;
52606
+ }
52607
+ if (prop !== 'body') {
52608
+ const res = typeof basicMessage[prop] ===
52609
+ typeof message[prop]; //eslint-disable-line @typescript-eslint/no-explicit-any
52610
+ if (!res) {
52611
+ return false;
52612
+ }
52613
+ }
52614
+ });
52615
+ return true;
52616
+ };
52617
+ /**
52618
+ * helper function to convert serialized JSON bytes to protocol message
52619
+ *
52620
+ * @param {Uint8Array} bytes
52621
+ * @returns {BasicMessage}
52622
+ */
52623
+ const bytesToProtocolMessage = (bytes) => {
52624
+ const str = byteDecoder.decode(bytes);
52625
+ const message = JSON.parse(str);
52626
+ if (!isProtocolMessage(message)) ;
52627
+ return message;
52628
+ };
52629
+ /**
52630
+ * helper function to convert serialized JSON bytes to header stub
52631
+ * so we can work with know the media type of the message
52632
+ *
52633
+ * @param {Uint8Array} envelope
52634
+ * @returns {HeaderStub}
52635
+ */
52636
+ const bytesToHeaderStub = (envelope) => {
52637
+ const tmpObj = headerStubFactory();
52638
+ const str = byteDecoder.decode(envelope);
52639
+ const message = JSON.parse(str);
52640
+ if (!objectIs(message, tmpObj)) ;
52641
+ return message;
52642
+ };
52643
+
52644
+ const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
52645
+ const DIDCOMM_PROTOCOL = 'https://didcomm.org/';
52646
+ /**
52647
+ * Constants for Iden3 protocol
52648
+ */
52649
+ const PROTOCOL_MESSAGE_TYPE = Object.freeze({
52650
+ // AuthorizationV2RequestMessageType defines auth request type of the communication protocol
52651
+ AUTHORIZATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/request`,
52652
+ // AuthorizationResponseMessageType defines auth response type of the communication protocol
52653
+ AUTHORIZATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/response`,
52654
+ // CredentialIssuanceRequestMessageType accepts request for credential creation
52655
+ CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-request`,
52656
+ // CredentialFetchRequestMessageType is type for request of credential generation
52657
+ CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/fetch-request`,
52658
+ // CredentialOfferMessageType is type of message with credential offering
52659
+ CREDENTIAL_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/offer`,
52660
+ // CredentialIssuanceResponseMessageType is type for message with a credential issuance
52661
+ CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-response`,
52662
+ // CredentialRefreshMessageType is type for message with a credential issuance
52663
+ CREDENTIAL_REFRESH_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/refresh`,
52664
+ // DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
52665
+ DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}devices/1.0/registration`,
52666
+ // MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
52667
+ MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}messages/1.0/fetch`,
52668
+ // ProofGenerationRequestMessageType is type for request of proof generation
52669
+ PROOF_GENERATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/request`,
52670
+ // ProofGenerationResponseMessageType is type for response of proof generation
52671
+ PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/response`,
52672
+ // RevocationStatusRequestMessageType is type for request of revocation status
52673
+ REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/request-status`,
52674
+ // RevocationStatusResponseMessageType is type for response with a revocation status
52675
+ REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status`,
52676
+ // ContractInvokeRequestMessageType is type for request of contract invoke request
52677
+ CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request`,
52678
+ // ContractInvokeResponseMessageType is type for response of contract invoke request
52679
+ CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-response`,
52680
+ // CredentialOnchainOfferMessageType is type of message with credential onchain offering
52681
+ CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer`,
52682
+ // ProposalRequestMessageType is type for proposal-request message
52683
+ PROPOSAL_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal-request`,
52684
+ // ProposalMessageType is type for proposal message
52685
+ PROPOSAL_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal`,
52686
+ // PaymentRequestMessageType is type for payment-request message
52687
+ PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
52688
+ // PaymentMessageType is type for payment message
52689
+ PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`,
52690
+ // DiscoveryProtocolQueriesMessageType is type for didcomm discovery protocol queries
52691
+ DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/queries`,
52692
+ // DiscoveryProtocolDiscloseMessageType is type for didcomm discovery protocol disclose
52693
+ DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/disclose`,
52694
+ // ProblemReportMessageType is type for didcomm problem report
52695
+ PROBLEM_REPORT_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}report-problem/2.0/problem-report`
52696
+ });
52697
+ /**
52698
+ * Media types for iden3 comm communication protocol
52699
+ *
52700
+ * @enum {number}
52701
+ */
52702
+ var MediaType;
52703
+ (function (MediaType) {
52704
+ MediaType["ZKPMessage"] = "application/iden3-zkp-json";
52705
+ MediaType["PlainMessage"] = "application/iden3comm-plain-json";
52706
+ MediaType["SignedMessage"] = "application/iden3comm-signed-json";
52707
+ })(MediaType || (MediaType = {}));
52708
+ const SUPPORTED_PUBLIC_KEY_TYPES = {
52709
+ ES256K: [
52710
+ 'EcdsaSecp256k1VerificationKey2019',
52711
+ /**
52712
+ * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
52713
+ */
52714
+ 'EcdsaSecp256k1RecoveryMethod2020',
52715
+ 'JsonWebKey2020'
52716
+ ],
52717
+ 'ES256K-R': [
52718
+ 'EcdsaSecp256k1VerificationKey2019',
52719
+ /**
52720
+ * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
52721
+ */
52722
+ 'EcdsaSecp256k1RecoveryMethod2020',
52723
+ 'JsonWebKey2020'
52724
+ ]
52725
+ };
52726
+ var ProtocolVersion;
52727
+ (function (ProtocolVersion) {
52728
+ ProtocolVersion["V1"] = "iden3comm/v1";
52729
+ })(ProtocolVersion || (ProtocolVersion = {}));
52730
+ var AcceptAuthCircuits;
52731
+ (function (AcceptAuthCircuits) {
52732
+ AcceptAuthCircuits["AuthV2"] = "authV2";
52733
+ AcceptAuthCircuits["AuthV3"] = "authV3";
52734
+ })(AcceptAuthCircuits || (AcceptAuthCircuits = {}));
52735
+ var AcceptJwzAlgorithms;
52736
+ (function (AcceptJwzAlgorithms) {
52737
+ AcceptJwzAlgorithms["Groth16"] = "groth16";
52738
+ })(AcceptJwzAlgorithms || (AcceptJwzAlgorithms = {}));
52739
+ var AcceptJwsAlgorithms;
52740
+ (function (AcceptJwsAlgorithms) {
52741
+ AcceptJwsAlgorithms["ES256K"] = "ES256K";
52742
+ AcceptJwsAlgorithms["ES256KR"] = "ES256K-R";
52743
+ })(AcceptJwsAlgorithms || (AcceptJwsAlgorithms = {}));
52744
+ const defaultAcceptProfile = {
52745
+ protocolVersion: ProtocolVersion.V1,
52746
+ env: MediaType.ZKPMessage,
52747
+ circuits: [AcceptAuthCircuits.AuthV2],
52748
+ alg: [AcceptJwzAlgorithms.Groth16]
52749
+ };
52750
+ const DEFAULT_PROOF_VERIFY_DELAY = 1 * 60 * 60 * 1000; // 1 hour
52751
+ const DEFAULT_AUTH_VERIFY_DELAY = 5 * 60 * 1000; // 5 minutes
52752
+
52753
+ var constants = /*#__PURE__*/Object.freeze({
52754
+ __proto__: null,
52755
+ get AcceptAuthCircuits () { return AcceptAuthCircuits; },
52756
+ get AcceptJwsAlgorithms () { return AcceptJwsAlgorithms; },
52757
+ get AcceptJwzAlgorithms () { return AcceptJwzAlgorithms; },
52758
+ DEFAULT_AUTH_VERIFY_DELAY: DEFAULT_AUTH_VERIFY_DELAY,
52759
+ DEFAULT_PROOF_VERIFY_DELAY: DEFAULT_PROOF_VERIFY_DELAY,
52760
+ get MediaType () { return MediaType; },
52761
+ PROTOCOL_MESSAGE_TYPE: PROTOCOL_MESSAGE_TYPE,
52762
+ get ProtocolVersion () { return ProtocolVersion; },
52763
+ SUPPORTED_PUBLIC_KEY_TYPES: SUPPORTED_PUBLIC_KEY_TYPES,
52764
+ defaultAcceptProfile: defaultAcceptProfile
52765
+ });
52766
+
52767
+ const DIDAuthenticationSection = 'authentication';
52768
+ const resolveVerificationMethods = (didDocument) => {
52769
+ const vms = didDocument.verificationMethod || [];
52770
+ // prioritize: first verification methods to be chosen are from `authentication` section.
52771
+ const sortedVerificationMethods = (didDocument[DIDAuthenticationSection] || [])
52772
+ .map((verificationMethod) => {
52773
+ if (typeof verificationMethod === 'string') {
52774
+ return vms.find((i) => i.id === verificationMethod);
52775
+ }
52776
+ return verificationMethod;
52777
+ })
52778
+ .filter((key) => key);
52779
+ // add all other verification methods
52780
+ for (let index = 0; index < vms.length; index++) {
52781
+ const id = vms[index].id;
52782
+ if (sortedVerificationMethods.findIndex((vm) => vm.id === id) === -1) {
52783
+ sortedVerificationMethods.push(vms[index]);
52784
+ }
52785
+ }
52786
+ return sortedVerificationMethods;
52787
+ };
52788
+ const extractPublicKeyBytes = (vm) => {
52789
+ const isSupportedVmType = Object.keys(SUPPORTED_PUBLIC_KEY_TYPES).some((key) => SUPPORTED_PUBLIC_KEY_TYPES[key].includes(vm.type));
52790
+ if (vm.publicKeyBase58 && isSupportedVmType) {
52791
+ return { publicKeyBytes: base58ToBytes$1(vm.publicKeyBase58), kmsKeyType: KmsKeyType.Secp256k1 };
52792
+ }
52793
+ if (vm.publicKeyBase64 && isSupportedVmType) {
52794
+ return {
52795
+ publicKeyBytes: base64UrlToBytes(vm.publicKeyBase64),
52796
+ kmsKeyType: KmsKeyType.Secp256k1
52797
+ };
52798
+ }
52799
+ if (vm.publicKeyHex && isSupportedVmType) {
52800
+ return { publicKeyBytes: hexToBytes$3(vm.publicKeyHex), kmsKeyType: KmsKeyType.Secp256k1 };
52801
+ }
52802
+ if (vm.publicKeyJwk &&
52803
+ vm.publicKeyJwk.crv === 'secp256k1' &&
52804
+ vm.publicKeyJwk.x &&
52805
+ vm.publicKeyJwk.y) {
52806
+ const [xHex, yHex] = [
52807
+ base64UrlToBytes(vm.publicKeyJwk.x),
52808
+ base64UrlToBytes(vm.publicKeyJwk.y)
52809
+ ].map(bytesToHex$3);
52810
+ const x = xHex.includes('0x') ? BigInt(xHex) : BigInt(`0x${xHex}`);
52811
+ const y = yHex.includes('0x') ? BigInt(yHex) : BigInt(`0x${yHex}`);
52812
+ return {
52813
+ publicKeyBytes: secp256k1$1.ProjectivePoint.fromAffine({
52814
+ x,
52815
+ y
52816
+ }).toRawBytes(false),
52817
+ kmsKeyType: KmsKeyType.Secp256k1
52818
+ };
52819
+ }
52820
+ return { publicKeyBytes: null };
52821
+ };
52822
+
52823
+ const packZkpProof = (inputs, a, b, c) => {
52824
+ return new AbiCoder().encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
52825
+ };
52826
+ const prepareZkpProof = (proof) => {
52827
+ return {
52828
+ a: proof.pi_a.slice(0, 2),
52829
+ b: [
52830
+ [proof.pi_b[0][1], proof.pi_b[0][0]],
52831
+ [proof.pi_b[1][1], proof.pi_b[1][0]]
52832
+ ],
52833
+ c: proof.pi_c.slice(0, 2)
52834
+ };
52835
+ };
52836
+
52837
+ function isProtocolVersion(value) {
52838
+ return Object.values(ProtocolVersion).includes(value);
52839
+ }
52840
+ function isMediaType(value) {
52841
+ return Object.values(MediaType).includes(value);
52842
+ }
52843
+ function isAcceptAuthCircuits(value) {
52844
+ return Object.values(AcceptAuthCircuits).includes(value);
52845
+ }
52846
+ function isAcceptJwsAlgorithms(value) {
52847
+ return Object.values(AcceptJwsAlgorithms).includes(value);
52848
+ }
52849
+ function isAcceptJwzAlgorithms(value) {
52850
+ return Object.values(AcceptJwzAlgorithms).includes(value);
52851
+ }
52852
+ const buildAccept = (profiles) => {
52853
+ const result = [];
52854
+ for (const profile of profiles) {
52855
+ let accept = `${profile.protocolVersion};env=${profile.env}`;
52856
+ if (profile.circuits?.length) {
52857
+ accept += `;circuitId=${profile.circuits.join(',')}`;
52858
+ }
52859
+ if (profile.alg?.length) {
52860
+ accept += `;alg=${profile.alg.join(',')}`;
52861
+ }
52862
+ result.push(accept);
52863
+ }
52864
+ return result;
52865
+ };
52866
+ const parseAcceptProfile = (profile) => {
52867
+ const params = profile.split(';');
52868
+ if (params.length < 2) {
52869
+ throw new Error('Invalid accept profile');
52870
+ }
52871
+ const protocolVersion = params[0].trim();
52872
+ if (!isProtocolVersion(protocolVersion)) {
52873
+ throw new Error(`Protocol version '${protocolVersion}' not supported`);
52874
+ }
52875
+ const envParam = params[1].split('=');
52876
+ if (envParam.length !== 2) {
52877
+ throw new Error(`Invalid accept profile 'env' parameter`);
52878
+ }
52879
+ const env = params[1].split('=')[1].trim();
52880
+ if (!isMediaType(env)) {
52881
+ throw new Error(`Envelop '${env}' not supported`);
52882
+ }
52883
+ const circuitsIndex = params.findIndex((i) => i.includes('circuitId='));
52884
+ if (env !== MediaType.ZKPMessage && circuitsIndex > 0) {
52885
+ throw new Error(`Circuits not supported for env '${env}'`);
52886
+ }
52887
+ let circuits = undefined;
52888
+ if (circuitsIndex > 0) {
52889
+ circuits = params[circuitsIndex]
52890
+ .split('=')[1]
52891
+ .split(',')
52892
+ .map((i) => i.trim())
52893
+ .map((i) => {
52894
+ if (!isAcceptAuthCircuits(i)) {
52895
+ throw new Error(`Circuit '${i}' not supported`);
52896
+ }
52897
+ return i;
52898
+ });
52899
+ }
52900
+ const algIndex = params.findIndex((i) => i.includes('alg='));
52901
+ let alg = undefined;
52902
+ if (algIndex > 0) {
52903
+ if (env === MediaType.ZKPMessage) {
52904
+ alg = params[algIndex]
52905
+ .split('=')[1]
52906
+ .split(',')
52907
+ .map((i) => {
52908
+ i = i.trim();
52909
+ if (!isAcceptJwzAlgorithms(i)) {
52910
+ throw new Error(`Algorithm '${i}' not supported for '${env}'`);
52911
+ }
52912
+ return i;
52913
+ });
52914
+ }
52915
+ else if (env === MediaType.SignedMessage) {
52916
+ alg = params[algIndex]
52917
+ .split('=')[1]
52918
+ .split(',')
52919
+ .map((i) => {
52920
+ i = i.trim();
52921
+ if (!isAcceptJwsAlgorithms(i)) {
52922
+ throw new Error(`Algorithm '${i}' not supported for '${env}'`);
52923
+ }
52924
+ return i;
52925
+ });
52926
+ }
52927
+ else {
52928
+ throw new Error(`Algorithm not supported for '${env}'`);
52929
+ }
52930
+ }
52931
+ return {
52932
+ protocolVersion,
52933
+ env,
52934
+ circuits,
52935
+ alg
52936
+ };
52937
+ };
52938
+
52550
52939
  const defaultEthConnectionConfig = {
52551
52940
  url: 'http://localhost:8545',
52552
52941
  defaultGasLimit: 600000,
@@ -52616,17 +53005,15 @@ class EthStateStorage {
52616
53005
  const { userId, oldUserState, newUserState, isOldStateGenesis } = stateTransitionPubSig;
52617
53006
  const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
52618
53007
  const contract = stateContract.connect(signer);
53008
+ const preparedZkpProof = prepareZkpProof(proof.proof);
52619
53009
  const payload = [
52620
53010
  userId.bigInt().toString(),
52621
53011
  oldUserState.bigInt().toString(),
52622
53012
  newUserState.bigInt().toString(),
52623
53013
  isOldStateGenesis,
52624
- proof.proof.pi_a.slice(0, 2),
52625
- [
52626
- [proof.proof.pi_b[0][1], proof.proof.pi_b[0][0]],
52627
- [proof.proof.pi_b[1][1], proof.proof.pi_b[1][0]]
52628
- ],
52629
- proof.proof.pi_c.slice(0, 2)
53014
+ preparedZkpProof.a,
53015
+ preparedZkpProof.b,
53016
+ preparedZkpProof.c
52630
53017
  ];
52631
53018
  const feeData = await provider.getFeeData();
52632
53019
  const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
@@ -52733,184 +53120,524 @@ var abi$2 = [
52733
53120
  {
52734
53121
  inputs: [
52735
53122
  ],
52736
- name: "InvalidInitialization",
52737
- type: "error"
53123
+ name: "InvalidInitialization",
53124
+ type: "error"
53125
+ },
53126
+ {
53127
+ inputs: [
53128
+ {
53129
+ internalType: "string",
53130
+ name: "message",
53131
+ type: "string"
53132
+ },
53133
+ {
53134
+ internalType: "uint64",
53135
+ name: "requestId",
53136
+ type: "uint64"
53137
+ },
53138
+ {
53139
+ internalType: "uint256",
53140
+ name: "linkID",
53141
+ type: "uint256"
53142
+ },
53143
+ {
53144
+ internalType: "uint64",
53145
+ name: "requestIdToCompare",
53146
+ type: "uint64"
53147
+ },
53148
+ {
53149
+ internalType: "uint256",
53150
+ name: "linkIdToCompare",
53151
+ type: "uint256"
53152
+ }
53153
+ ],
53154
+ name: "LinkedProofError",
53155
+ type: "error"
53156
+ },
53157
+ {
53158
+ inputs: [
53159
+ ],
53160
+ name: "NotInitializing",
53161
+ type: "error"
53162
+ },
53163
+ {
53164
+ inputs: [
53165
+ {
53166
+ internalType: "address",
53167
+ name: "owner",
53168
+ type: "address"
53169
+ }
53170
+ ],
53171
+ name: "OwnableInvalidOwner",
53172
+ type: "error"
53173
+ },
53174
+ {
53175
+ inputs: [
53176
+ {
53177
+ internalType: "address",
53178
+ name: "account",
53179
+ type: "address"
53180
+ }
53181
+ ],
53182
+ name: "OwnableUnauthorizedAccount",
53183
+ type: "error"
53184
+ },
53185
+ {
53186
+ anonymous: false,
53187
+ inputs: [
53188
+ {
53189
+ indexed: false,
53190
+ internalType: "uint64",
53191
+ name: "version",
53192
+ type: "uint64"
53193
+ }
53194
+ ],
53195
+ name: "Initialized",
53196
+ type: "event"
53197
+ },
53198
+ {
53199
+ anonymous: false,
53200
+ inputs: [
53201
+ {
53202
+ indexed: true,
53203
+ internalType: "address",
53204
+ name: "previousOwner",
53205
+ type: "address"
53206
+ },
53207
+ {
53208
+ indexed: true,
53209
+ internalType: "address",
53210
+ name: "newOwner",
53211
+ type: "address"
53212
+ }
53213
+ ],
53214
+ name: "OwnershipTransferStarted",
53215
+ type: "event"
53216
+ },
53217
+ {
53218
+ anonymous: false,
53219
+ inputs: [
53220
+ {
53221
+ indexed: true,
53222
+ internalType: "address",
53223
+ name: "previousOwner",
53224
+ type: "address"
53225
+ },
53226
+ {
53227
+ indexed: true,
53228
+ internalType: "address",
53229
+ name: "newOwner",
53230
+ type: "address"
53231
+ }
53232
+ ],
53233
+ name: "OwnershipTransferred",
53234
+ type: "event"
53235
+ },
53236
+ {
53237
+ anonymous: false,
53238
+ inputs: [
53239
+ {
53240
+ indexed: true,
53241
+ internalType: "uint64",
53242
+ name: "requestId",
53243
+ type: "uint64"
53244
+ },
53245
+ {
53246
+ indexed: true,
53247
+ internalType: "address",
53248
+ name: "requestOwner",
53249
+ type: "address"
53250
+ },
53251
+ {
53252
+ indexed: false,
53253
+ internalType: "string",
53254
+ name: "metadata",
53255
+ type: "string"
53256
+ },
53257
+ {
53258
+ indexed: false,
53259
+ internalType: "address",
53260
+ name: "validator",
53261
+ type: "address"
53262
+ },
53263
+ {
53264
+ indexed: false,
53265
+ internalType: "bytes",
53266
+ name: "data",
53267
+ type: "bytes"
53268
+ }
53269
+ ],
53270
+ name: "ZKPRequestSet",
53271
+ type: "event"
53272
+ },
53273
+ {
53274
+ anonymous: false,
53275
+ inputs: [
53276
+ {
53277
+ indexed: true,
53278
+ internalType: "uint64",
53279
+ name: "requestId",
53280
+ type: "uint64"
53281
+ },
53282
+ {
53283
+ indexed: true,
53284
+ internalType: "address",
53285
+ name: "caller",
53286
+ type: "address"
53287
+ }
53288
+ ],
53289
+ name: "ZKPResponseSubmitted",
53290
+ type: "event"
53291
+ },
53292
+ {
53293
+ inputs: [
53294
+ ],
53295
+ name: "REQUESTS_RETURN_LIMIT",
53296
+ outputs: [
53297
+ {
53298
+ internalType: "uint256",
53299
+ name: "",
53300
+ type: "uint256"
53301
+ }
53302
+ ],
53303
+ stateMutability: "view",
53304
+ type: "function"
53305
+ },
53306
+ {
53307
+ inputs: [
53308
+ ],
53309
+ name: "VERSION",
53310
+ outputs: [
53311
+ {
53312
+ internalType: "string",
53313
+ name: "",
53314
+ type: "string"
53315
+ }
53316
+ ],
53317
+ stateMutability: "view",
53318
+ type: "function"
53319
+ },
53320
+ {
53321
+ inputs: [
53322
+ ],
53323
+ name: "acceptOwnership",
53324
+ outputs: [
53325
+ ],
53326
+ stateMutability: "nonpayable",
53327
+ type: "function"
53328
+ },
53329
+ {
53330
+ inputs: [
53331
+ {
53332
+ internalType: "contract ICircuitValidator",
53333
+ name: "validator",
53334
+ type: "address"
53335
+ }
53336
+ ],
53337
+ name: "addValidatorToWhitelist",
53338
+ outputs: [
53339
+ ],
53340
+ stateMutability: "nonpayable",
53341
+ type: "function"
53342
+ },
53343
+ {
53344
+ inputs: [
53345
+ {
53346
+ internalType: "uint64",
53347
+ name: "requestId",
53348
+ type: "uint64"
53349
+ }
53350
+ ],
53351
+ name: "disableZKPRequest",
53352
+ outputs: [
53353
+ ],
53354
+ stateMutability: "nonpayable",
53355
+ type: "function"
53356
+ },
53357
+ {
53358
+ inputs: [
53359
+ {
53360
+ internalType: "uint64",
53361
+ name: "requestId",
53362
+ type: "uint64"
53363
+ }
53364
+ ],
53365
+ name: "enableZKPRequest",
53366
+ outputs: [
53367
+ ],
53368
+ stateMutability: "nonpayable",
53369
+ type: "function"
52738
53370
  },
52739
53371
  {
52740
53372
  inputs: [
52741
53373
  {
52742
- internalType: "string",
52743
- name: "message",
52744
- type: "string"
53374
+ internalType: "address",
53375
+ name: "sender",
53376
+ type: "address"
52745
53377
  },
52746
53378
  {
52747
53379
  internalType: "uint64",
52748
53380
  name: "requestId",
52749
53381
  type: "uint64"
52750
- },
53382
+ }
53383
+ ],
53384
+ name: "getProofStatus",
53385
+ outputs: [
52751
53386
  {
52752
- internalType: "uint256",
52753
- name: "linkID",
52754
- type: "uint256"
53387
+ components: [
53388
+ {
53389
+ internalType: "bool",
53390
+ name: "isVerified",
53391
+ type: "bool"
53392
+ },
53393
+ {
53394
+ internalType: "string",
53395
+ name: "validatorVersion",
53396
+ type: "string"
53397
+ },
53398
+ {
53399
+ internalType: "uint256",
53400
+ name: "blockNumber",
53401
+ type: "uint256"
53402
+ },
53403
+ {
53404
+ internalType: "uint256",
53405
+ name: "blockTimestamp",
53406
+ type: "uint256"
53407
+ }
53408
+ ],
53409
+ internalType: "struct IZKPVerifier.ProofStatus",
53410
+ name: "",
53411
+ type: "tuple"
53412
+ }
53413
+ ],
53414
+ stateMutability: "view",
53415
+ type: "function"
53416
+ },
53417
+ {
53418
+ inputs: [
53419
+ {
53420
+ internalType: "address",
53421
+ name: "user",
53422
+ type: "address"
52755
53423
  },
52756
53424
  {
52757
53425
  internalType: "uint64",
52758
- name: "requestIdToCompare",
53426
+ name: "requestId",
52759
53427
  type: "uint64"
52760
53428
  },
53429
+ {
53430
+ internalType: "string",
53431
+ name: "key",
53432
+ type: "string"
53433
+ }
53434
+ ],
53435
+ name: "getProofStorageField",
53436
+ outputs: [
52761
53437
  {
52762
53438
  internalType: "uint256",
52763
- name: "linkIdToCompare",
53439
+ name: "",
52764
53440
  type: "uint256"
52765
53441
  }
52766
53442
  ],
52767
- name: "LinkedProofError",
52768
- type: "error"
52769
- },
52770
- {
52771
- inputs: [
52772
- ],
52773
- name: "NotInitializing",
52774
- type: "error"
53443
+ stateMutability: "view",
53444
+ type: "function"
52775
53445
  },
52776
53446
  {
52777
53447
  inputs: [
52778
53448
  {
52779
- internalType: "address",
52780
- name: "owner",
52781
- type: "address"
53449
+ internalType: "uint64",
53450
+ name: "requestId",
53451
+ type: "uint64"
52782
53452
  }
52783
53453
  ],
52784
- name: "OwnableInvalidOwner",
52785
- type: "error"
52786
- },
52787
- {
52788
- inputs: [
53454
+ name: "getRequestOwner",
53455
+ outputs: [
52789
53456
  {
52790
53457
  internalType: "address",
52791
- name: "account",
53458
+ name: "",
52792
53459
  type: "address"
52793
53460
  }
52794
53461
  ],
52795
- name: "OwnableUnauthorizedAccount",
52796
- type: "error"
53462
+ stateMutability: "view",
53463
+ type: "function"
52797
53464
  },
52798
53465
  {
52799
- anonymous: false,
52800
53466
  inputs: [
52801
53467
  {
52802
- indexed: false,
52803
53468
  internalType: "uint64",
52804
- name: "version",
53469
+ name: "requestId",
52805
53470
  type: "uint64"
52806
53471
  }
52807
53472
  ],
52808
- name: "Initialized",
52809
- type: "event"
53473
+ name: "getZKPRequest",
53474
+ outputs: [
53475
+ {
53476
+ components: [
53477
+ {
53478
+ internalType: "string",
53479
+ name: "metadata",
53480
+ type: "string"
53481
+ },
53482
+ {
53483
+ internalType: "contract ICircuitValidator",
53484
+ name: "validator",
53485
+ type: "address"
53486
+ },
53487
+ {
53488
+ internalType: "bytes",
53489
+ name: "data",
53490
+ type: "bytes"
53491
+ }
53492
+ ],
53493
+ internalType: "struct IZKPVerifier.ZKPRequest",
53494
+ name: "zkpRequest",
53495
+ type: "tuple"
53496
+ }
53497
+ ],
53498
+ stateMutability: "view",
53499
+ type: "function"
52810
53500
  },
52811
53501
  {
52812
- anonymous: false,
52813
53502
  inputs: [
52814
53503
  {
52815
- indexed: true,
52816
- internalType: "address",
52817
- name: "previousOwner",
52818
- type: "address"
53504
+ internalType: "uint256",
53505
+ name: "startIndex",
53506
+ type: "uint256"
52819
53507
  },
52820
53508
  {
52821
- indexed: true,
52822
- internalType: "address",
52823
- name: "newOwner",
52824
- type: "address"
53509
+ internalType: "uint256",
53510
+ name: "length",
53511
+ type: "uint256"
52825
53512
  }
52826
53513
  ],
52827
- name: "OwnershipTransferStarted",
52828
- type: "event"
53514
+ name: "getZKPRequests",
53515
+ outputs: [
53516
+ {
53517
+ components: [
53518
+ {
53519
+ internalType: "string",
53520
+ name: "metadata",
53521
+ type: "string"
53522
+ },
53523
+ {
53524
+ internalType: "contract ICircuitValidator",
53525
+ name: "validator",
53526
+ type: "address"
53527
+ },
53528
+ {
53529
+ internalType: "bytes",
53530
+ name: "data",
53531
+ type: "bytes"
53532
+ }
53533
+ ],
53534
+ internalType: "struct IZKPVerifier.ZKPRequest[]",
53535
+ name: "",
53536
+ type: "tuple[]"
53537
+ }
53538
+ ],
53539
+ stateMutability: "view",
53540
+ type: "function"
52829
53541
  },
52830
53542
  {
52831
- anonymous: false,
52832
53543
  inputs: [
53544
+ ],
53545
+ name: "getZKPRequestsCount",
53546
+ outputs: [
52833
53547
  {
52834
- indexed: true,
52835
- internalType: "address",
52836
- name: "previousOwner",
52837
- type: "address"
52838
- },
53548
+ internalType: "uint256",
53549
+ name: "",
53550
+ type: "uint256"
53551
+ }
53552
+ ],
53553
+ stateMutability: "view",
53554
+ type: "function"
53555
+ },
53556
+ {
53557
+ inputs: [
52839
53558
  {
52840
- indexed: true,
52841
- internalType: "address",
52842
- name: "newOwner",
53559
+ internalType: "contract IStateCrossChain",
53560
+ name: "stateCrossChain",
52843
53561
  type: "address"
52844
53562
  }
52845
53563
  ],
52846
- name: "OwnershipTransferred",
52847
- type: "event"
53564
+ name: "initialize",
53565
+ outputs: [
53566
+ ],
53567
+ stateMutability: "nonpayable",
53568
+ type: "function"
52848
53569
  },
52849
53570
  {
52850
- anonymous: false,
52851
53571
  inputs: [
52852
53572
  {
52853
- indexed: true,
52854
- internalType: "uint64",
52855
- name: "requestId",
52856
- type: "uint64"
52857
- },
52858
- {
52859
- indexed: true,
52860
53573
  internalType: "address",
52861
- name: "requestOwner",
53574
+ name: "sender",
52862
53575
  type: "address"
52863
53576
  },
52864
53577
  {
52865
- indexed: false,
52866
- internalType: "string",
52867
- name: "metadata",
52868
- type: "string"
52869
- },
53578
+ internalType: "uint64",
53579
+ name: "requestId",
53580
+ type: "uint64"
53581
+ }
53582
+ ],
53583
+ name: "isProofVerified",
53584
+ outputs: [
52870
53585
  {
52871
- indexed: false,
52872
- internalType: "address",
53586
+ internalType: "bool",
53587
+ name: "",
53588
+ type: "bool"
53589
+ }
53590
+ ],
53591
+ stateMutability: "view",
53592
+ type: "function"
53593
+ },
53594
+ {
53595
+ inputs: [
53596
+ {
53597
+ internalType: "contract ICircuitValidator",
52873
53598
  name: "validator",
52874
53599
  type: "address"
52875
- },
53600
+ }
53601
+ ],
53602
+ name: "isWhitelistedValidator",
53603
+ outputs: [
52876
53604
  {
52877
- indexed: false,
52878
- internalType: "bytes",
52879
- name: "data",
52880
- type: "bytes"
53605
+ internalType: "bool",
53606
+ name: "",
53607
+ type: "bool"
52881
53608
  }
52882
53609
  ],
52883
- name: "ZKPRequestSet",
52884
- type: "event"
53610
+ stateMutability: "view",
53611
+ type: "function"
52885
53612
  },
52886
53613
  {
52887
- anonymous: false,
52888
53614
  inputs: [
52889
53615
  {
52890
- indexed: true,
52891
53616
  internalType: "uint64",
52892
53617
  name: "requestId",
52893
53618
  type: "uint64"
52894
- },
53619
+ }
53620
+ ],
53621
+ name: "isZKPRequestEnabled",
53622
+ outputs: [
52895
53623
  {
52896
- indexed: true,
52897
- internalType: "address",
52898
- name: "caller",
52899
- type: "address"
53624
+ internalType: "bool",
53625
+ name: "",
53626
+ type: "bool"
52900
53627
  }
52901
53628
  ],
52902
- name: "ZKPResponseSubmitted",
52903
- type: "event"
53629
+ stateMutability: "view",
53630
+ type: "function"
52904
53631
  },
52905
53632
  {
52906
53633
  inputs: [
52907
53634
  ],
52908
- name: "REQUESTS_RETURN_LIMIT",
53635
+ name: "owner",
52909
53636
  outputs: [
52910
53637
  {
52911
- internalType: "uint256",
53638
+ internalType: "address",
52912
53639
  name: "",
52913
- type: "uint256"
53640
+ type: "address"
52914
53641
  }
52915
53642
  ],
52916
53643
  stateMutability: "view",
@@ -52919,12 +53646,12 @@ var abi$2 = [
52919
53646
  {
52920
53647
  inputs: [
52921
53648
  ],
52922
- name: "VERSION",
53649
+ name: "pendingOwner",
52923
53650
  outputs: [
52924
53651
  {
52925
- internalType: "string",
53652
+ internalType: "address",
52926
53653
  name: "",
52927
- type: "string"
53654
+ type: "address"
52928
53655
  }
52929
53656
  ],
52930
53657
  stateMutability: "view",
@@ -52932,8 +53659,13 @@ var abi$2 = [
52932
53659
  },
52933
53660
  {
52934
53661
  inputs: [
53662
+ {
53663
+ internalType: "contract ICircuitValidator",
53664
+ name: "validator",
53665
+ type: "address"
53666
+ }
52935
53667
  ],
52936
- name: "acceptOwnership",
53668
+ name: "removeValidatorFromWhitelist",
52937
53669
  outputs: [
52938
53670
  ],
52939
53671
  stateMutability: "nonpayable",
@@ -52941,13 +53673,8 @@ var abi$2 = [
52941
53673
  },
52942
53674
  {
52943
53675
  inputs: [
52944
- {
52945
- internalType: "contract ICircuitValidator",
52946
- name: "validator",
52947
- type: "address"
52948
- }
52949
53676
  ],
52950
- name: "addValidatorToWhitelist",
53677
+ name: "renounceOwnership",
52951
53678
  outputs: [
52952
53679
  ],
52953
53680
  stateMutability: "nonpayable",
@@ -52961,10 +53688,15 @@ var abi$2 = [
52961
53688
  type: "uint64"
52962
53689
  }
52963
53690
  ],
52964
- name: "disableZKPRequest",
53691
+ name: "requestIdExists",
52965
53692
  outputs: [
53693
+ {
53694
+ internalType: "bool",
53695
+ name: "",
53696
+ type: "bool"
53697
+ }
52966
53698
  ],
52967
- stateMutability: "nonpayable",
53699
+ stateMutability: "view",
52968
53700
  type: "function"
52969
53701
  },
52970
53702
  {
@@ -52973,9 +53705,14 @@ var abi$2 = [
52973
53705
  internalType: "uint64",
52974
53706
  name: "requestId",
52975
53707
  type: "uint64"
53708
+ },
53709
+ {
53710
+ internalType: "address",
53711
+ name: "requestOwner",
53712
+ type: "address"
52976
53713
  }
52977
53714
  ],
52978
- name: "enableZKPRequest",
53715
+ name: "setRequestOwner",
52979
53716
  outputs: [
52980
53717
  ],
52981
53718
  stateMutability: "nonpayable",
@@ -52984,92 +53721,234 @@ var abi$2 = [
52984
53721
  {
52985
53722
  inputs: [
52986
53723
  {
52987
- internalType: "address",
52988
- name: "sender",
52989
- type: "address"
53724
+ internalType: "uint64",
53725
+ name: "requestId",
53726
+ type: "uint64"
52990
53727
  },
53728
+ {
53729
+ components: [
53730
+ {
53731
+ internalType: "string",
53732
+ name: "metadata",
53733
+ type: "string"
53734
+ },
53735
+ {
53736
+ internalType: "contract ICircuitValidator",
53737
+ name: "validator",
53738
+ type: "address"
53739
+ },
53740
+ {
53741
+ internalType: "bytes",
53742
+ name: "data",
53743
+ type: "bytes"
53744
+ }
53745
+ ],
53746
+ internalType: "struct IZKPVerifier.ZKPRequest",
53747
+ name: "request",
53748
+ type: "tuple"
53749
+ }
53750
+ ],
53751
+ name: "setZKPRequest",
53752
+ outputs: [
53753
+ ],
53754
+ stateMutability: "nonpayable",
53755
+ type: "function"
53756
+ },
53757
+ {
53758
+ inputs: [
52991
53759
  {
52992
53760
  internalType: "uint64",
52993
53761
  name: "requestId",
52994
53762
  type: "uint64"
53763
+ },
53764
+ {
53765
+ internalType: "uint256[]",
53766
+ name: "inputs",
53767
+ type: "uint256[]"
53768
+ },
53769
+ {
53770
+ internalType: "uint256[2]",
53771
+ name: "a",
53772
+ type: "uint256[2]"
53773
+ },
53774
+ {
53775
+ internalType: "uint256[2][2]",
53776
+ name: "b",
53777
+ type: "uint256[2][2]"
53778
+ },
53779
+ {
53780
+ internalType: "uint256[2]",
53781
+ name: "c",
53782
+ type: "uint256[2]"
52995
53783
  }
52996
53784
  ],
52997
- name: "getProofStatus",
53785
+ name: "submitZKPResponse",
52998
53786
  outputs: [
53787
+ ],
53788
+ stateMutability: "nonpayable",
53789
+ type: "function"
53790
+ },
53791
+ {
53792
+ inputs: [
52999
53793
  {
53000
53794
  components: [
53001
53795
  {
53002
- internalType: "bool",
53003
- name: "isVerified",
53004
- type: "bool"
53005
- },
53006
- {
53007
- internalType: "string",
53008
- name: "validatorVersion",
53009
- type: "string"
53796
+ internalType: "uint64",
53797
+ name: "requestId",
53798
+ type: "uint64"
53010
53799
  },
53011
53800
  {
53012
- internalType: "uint256",
53013
- name: "blockNumber",
53014
- type: "uint256"
53801
+ internalType: "bytes",
53802
+ name: "zkProof",
53803
+ type: "bytes"
53015
53804
  },
53016
53805
  {
53017
- internalType: "uint256",
53018
- name: "blockTimestamp",
53019
- type: "uint256"
53806
+ internalType: "bytes",
53807
+ name: "data",
53808
+ type: "bytes"
53020
53809
  }
53021
53810
  ],
53022
- internalType: "struct IZKPVerifier.ProofStatus",
53023
- name: "",
53024
- type: "tuple"
53811
+ internalType: "struct ZKPResponse[]",
53812
+ name: "responses",
53813
+ type: "tuple[]"
53814
+ },
53815
+ {
53816
+ internalType: "bytes",
53817
+ name: "crossChainProof",
53818
+ type: "bytes"
53025
53819
  }
53026
53820
  ],
53027
- stateMutability: "view",
53821
+ name: "submitZKPResponseV2",
53822
+ outputs: [
53823
+ ],
53824
+ stateMutability: "nonpayable",
53028
53825
  type: "function"
53029
53826
  },
53030
53827
  {
53031
53828
  inputs: [
53032
53829
  {
53033
53830
  internalType: "address",
53034
- name: "user",
53831
+ name: "newOwner",
53832
+ type: "address"
53833
+ }
53834
+ ],
53835
+ name: "transferOwnership",
53836
+ outputs: [
53837
+ ],
53838
+ stateMutability: "nonpayable",
53839
+ type: "function"
53840
+ },
53841
+ {
53842
+ inputs: [
53843
+ {
53844
+ internalType: "address",
53845
+ name: "sender",
53035
53846
  type: "address"
53036
53847
  },
53848
+ {
53849
+ internalType: "uint64[]",
53850
+ name: "requestIds",
53851
+ type: "uint64[]"
53852
+ }
53853
+ ],
53854
+ name: "verifyLinkedProofs",
53855
+ outputs: [
53856
+ ],
53857
+ stateMutability: "view",
53858
+ type: "function"
53859
+ },
53860
+ {
53861
+ inputs: [
53037
53862
  {
53038
53863
  internalType: "uint64",
53039
53864
  name: "requestId",
53040
53865
  type: "uint64"
53041
53866
  },
53042
53867
  {
53043
- internalType: "string",
53044
- name: "key",
53045
- type: "string"
53868
+ internalType: "uint256[]",
53869
+ name: "inputs",
53870
+ type: "uint256[]"
53871
+ },
53872
+ {
53873
+ internalType: "uint256[2]",
53874
+ name: "a",
53875
+ type: "uint256[2]"
53876
+ },
53877
+ {
53878
+ internalType: "uint256[2][2]",
53879
+ name: "b",
53880
+ type: "uint256[2][2]"
53881
+ },
53882
+ {
53883
+ internalType: "uint256[2]",
53884
+ name: "c",
53885
+ type: "uint256[2]"
53886
+ },
53887
+ {
53888
+ internalType: "address",
53889
+ name: "sender",
53890
+ type: "address"
53891
+ }
53892
+ ],
53893
+ name: "verifyZKPResponse",
53894
+ outputs: [
53895
+ {
53896
+ components: [
53897
+ {
53898
+ internalType: "string",
53899
+ name: "key",
53900
+ type: "string"
53901
+ },
53902
+ {
53903
+ internalType: "uint256",
53904
+ name: "inputValue",
53905
+ type: "uint256"
53906
+ }
53907
+ ],
53908
+ internalType: "struct ICircuitValidator.KeyToInputValue[]",
53909
+ name: "",
53910
+ type: "tuple[]"
53046
53911
  }
53047
53912
  ],
53048
- name: "getProofStorageField",
53913
+ stateMutability: "nonpayable",
53914
+ type: "function"
53915
+ },
53916
+ {
53917
+ inputs: [
53918
+ ],
53919
+ name: "version",
53049
53920
  outputs: [
53050
53921
  {
53051
- internalType: "uint256",
53922
+ internalType: "string",
53052
53923
  name: "",
53053
- type: "uint256"
53924
+ type: "string"
53054
53925
  }
53055
53926
  ],
53056
- stateMutability: "view",
53927
+ stateMutability: "pure",
53057
53928
  type: "function"
53058
- },
53929
+ }
53930
+ ];
53931
+
53932
+ var IVerifierABI = [
53059
53933
  {
53060
53934
  inputs: [
53061
53935
  {
53062
- internalType: "uint64",
53063
- name: "requestId",
53064
- type: "uint64"
53936
+ internalType: "uint256",
53937
+ name: "multiRequestId",
53938
+ type: "uint256"
53939
+ },
53940
+ {
53941
+ internalType: "address",
53942
+ name: "userAddress",
53943
+ type: "address"
53065
53944
  }
53066
53945
  ],
53067
- name: "getRequestOwner",
53946
+ name: "areMultiRequestProofsVerified",
53068
53947
  outputs: [
53069
53948
  {
53070
- internalType: "address",
53949
+ internalType: "bool",
53071
53950
  name: "",
53072
- type: "address"
53951
+ type: "bool"
53073
53952
  }
53074
53953
  ],
53075
53954
  stateMutability: "view",
@@ -53078,34 +53957,44 @@ var abi$2 = [
53078
53957
  {
53079
53958
  inputs: [
53080
53959
  {
53081
- internalType: "uint64",
53082
- name: "requestId",
53083
- type: "uint64"
53960
+ internalType: "uint256",
53961
+ name: "groupID",
53962
+ type: "uint256"
53084
53963
  }
53085
53964
  ],
53086
- name: "getZKPRequest",
53965
+ name: "getGroupedRequests",
53087
53966
  outputs: [
53088
53967
  {
53089
53968
  components: [
53969
+ {
53970
+ internalType: "uint256",
53971
+ name: "requestId",
53972
+ type: "uint256"
53973
+ },
53090
53974
  {
53091
53975
  internalType: "string",
53092
53976
  name: "metadata",
53093
53977
  type: "string"
53094
53978
  },
53095
53979
  {
53096
- internalType: "contract ICircuitValidator",
53980
+ internalType: "contract IRequestValidator",
53097
53981
  name: "validator",
53098
53982
  type: "address"
53099
53983
  },
53100
53984
  {
53101
53985
  internalType: "bytes",
53102
- name: "data",
53986
+ name: "params",
53103
53987
  type: "bytes"
53988
+ },
53989
+ {
53990
+ internalType: "address",
53991
+ name: "creator",
53992
+ type: "address"
53104
53993
  }
53105
53994
  ],
53106
- internalType: "struct IZKPVerifier.ZKPRequest",
53107
- name: "zkpRequest",
53108
- type: "tuple"
53995
+ internalType: "struct IVerifier.RequestInfo[]",
53996
+ name: "",
53997
+ type: "tuple[]"
53109
53998
  }
53110
53999
  ],
53111
54000
  stateMutability: "view",
@@ -53113,40 +54002,54 @@ var abi$2 = [
53113
54002
  },
53114
54003
  {
53115
54004
  inputs: [
54005
+ ],
54006
+ name: "getGroupsCount",
54007
+ outputs: [
53116
54008
  {
53117
54009
  internalType: "uint256",
53118
- name: "startIndex",
54010
+ name: "",
53119
54011
  type: "uint256"
53120
- },
54012
+ }
54013
+ ],
54014
+ stateMutability: "view",
54015
+ type: "function"
54016
+ },
54017
+ {
54018
+ inputs: [
53121
54019
  {
53122
54020
  internalType: "uint256",
53123
- name: "length",
54021
+ name: "multiRequestId",
53124
54022
  type: "uint256"
53125
54023
  }
53126
54024
  ],
53127
- name: "getZKPRequests",
54025
+ name: "getMultiRequest",
53128
54026
  outputs: [
53129
54027
  {
53130
54028
  components: [
53131
54029
  {
53132
- internalType: "string",
53133
- name: "metadata",
53134
- type: "string"
54030
+ internalType: "uint256",
54031
+ name: "multiRequestId",
54032
+ type: "uint256"
53135
54033
  },
53136
54034
  {
53137
- internalType: "contract ICircuitValidator",
53138
- name: "validator",
53139
- type: "address"
54035
+ internalType: "uint256[]",
54036
+ name: "requestIds",
54037
+ type: "uint256[]"
54038
+ },
54039
+ {
54040
+ internalType: "uint256[]",
54041
+ name: "groupIds",
54042
+ type: "uint256[]"
53140
54043
  },
53141
54044
  {
53142
54045
  internalType: "bytes",
53143
- name: "data",
54046
+ name: "metadata",
53144
54047
  type: "bytes"
53145
54048
  }
53146
54049
  ],
53147
- internalType: "struct IZKPVerifier.ZKPRequest[]",
53148
- name: "",
53149
- type: "tuple[]"
54050
+ internalType: "struct IVerifier.MultiRequest",
54051
+ name: "multiRequest",
54052
+ type: "tuple"
53150
54053
  }
53151
54054
  ],
53152
54055
  stateMutability: "view",
@@ -53154,13 +54057,45 @@ var abi$2 = [
53154
54057
  },
53155
54058
  {
53156
54059
  inputs: [
54060
+ {
54061
+ internalType: "uint256",
54062
+ name: "multiRequestId",
54063
+ type: "uint256"
54064
+ },
54065
+ {
54066
+ internalType: "address",
54067
+ name: "userAddress",
54068
+ type: "address"
54069
+ }
53157
54070
  ],
53158
- name: "getZKPRequestsCount",
54071
+ name: "getMultiRequestProofsStatus",
53159
54072
  outputs: [
53160
54073
  {
53161
- internalType: "uint256",
54074
+ components: [
54075
+ {
54076
+ internalType: "uint256",
54077
+ name: "requestId",
54078
+ type: "uint256"
54079
+ },
54080
+ {
54081
+ internalType: "bool",
54082
+ name: "isVerified",
54083
+ type: "bool"
54084
+ },
54085
+ {
54086
+ internalType: "string",
54087
+ name: "validatorVersion",
54088
+ type: "string"
54089
+ },
54090
+ {
54091
+ internalType: "uint256",
54092
+ name: "timestamp",
54093
+ type: "uint256"
54094
+ }
54095
+ ],
54096
+ internalType: "struct IVerifier.RequestProofStatus[]",
53162
54097
  name: "",
53163
- type: "uint256"
54098
+ type: "tuple[]"
53164
54099
  }
53165
54100
  ],
53166
54101
  stateMutability: "view",
@@ -53169,15 +54104,47 @@ var abi$2 = [
53169
54104
  {
53170
54105
  inputs: [
53171
54106
  {
53172
- internalType: "contract IStateCrossChain",
53173
- name: "stateCrossChain",
53174
- type: "address"
54107
+ internalType: "uint256",
54108
+ name: "requestId",
54109
+ type: "uint256"
53175
54110
  }
53176
54111
  ],
53177
- name: "initialize",
54112
+ name: "getRequest",
53178
54113
  outputs: [
54114
+ {
54115
+ components: [
54116
+ {
54117
+ internalType: "uint256",
54118
+ name: "requestId",
54119
+ type: "uint256"
54120
+ },
54121
+ {
54122
+ internalType: "string",
54123
+ name: "metadata",
54124
+ type: "string"
54125
+ },
54126
+ {
54127
+ internalType: "contract IRequestValidator",
54128
+ name: "validator",
54129
+ type: "address"
54130
+ },
54131
+ {
54132
+ internalType: "bytes",
54133
+ name: "params",
54134
+ type: "bytes"
54135
+ },
54136
+ {
54137
+ internalType: "address",
54138
+ name: "creator",
54139
+ type: "address"
54140
+ }
54141
+ ],
54142
+ internalType: "struct IVerifier.RequestInfo",
54143
+ name: "request",
54144
+ type: "tuple"
54145
+ }
53179
54146
  ],
53180
- stateMutability: "nonpayable",
54147
+ stateMutability: "view",
53181
54148
  type: "function"
53182
54149
  },
53183
54150
  {
@@ -53188,17 +54155,39 @@ var abi$2 = [
53188
54155
  type: "address"
53189
54156
  },
53190
54157
  {
53191
- internalType: "uint64",
54158
+ internalType: "uint256",
53192
54159
  name: "requestId",
53193
- type: "uint64"
54160
+ type: "uint256"
53194
54161
  }
53195
54162
  ],
53196
- name: "isProofVerified",
54163
+ name: "getRequestProofStatus",
53197
54164
  outputs: [
53198
54165
  {
53199
- internalType: "bool",
54166
+ components: [
54167
+ {
54168
+ internalType: "uint256",
54169
+ name: "requestId",
54170
+ type: "uint256"
54171
+ },
54172
+ {
54173
+ internalType: "bool",
54174
+ name: "isVerified",
54175
+ type: "bool"
54176
+ },
54177
+ {
54178
+ internalType: "string",
54179
+ name: "validatorVersion",
54180
+ type: "string"
54181
+ },
54182
+ {
54183
+ internalType: "uint256",
54184
+ name: "timestamp",
54185
+ type: "uint256"
54186
+ }
54187
+ ],
54188
+ internalType: "struct IVerifier.RequestProofStatus",
53200
54189
  name: "",
53201
- type: "bool"
54190
+ type: "tuple"
53202
54191
  }
53203
54192
  ],
53204
54193
  stateMutability: "view",
@@ -53206,18 +54195,13 @@ var abi$2 = [
53206
54195
  },
53207
54196
  {
53208
54197
  inputs: [
53209
- {
53210
- internalType: "contract ICircuitValidator",
53211
- name: "validator",
53212
- type: "address"
53213
- }
53214
54198
  ],
53215
- name: "isWhitelistedValidator",
54199
+ name: "getRequestsCount",
53216
54200
  outputs: [
53217
54201
  {
53218
- internalType: "bool",
54202
+ internalType: "uint256",
53219
54203
  name: "",
53220
- type: "bool"
54204
+ type: "uint256"
53221
54205
  }
53222
54206
  ],
53223
54207
  stateMutability: "view",
@@ -53226,17 +54210,27 @@ var abi$2 = [
53226
54210
  {
53227
54211
  inputs: [
53228
54212
  {
53229
- internalType: "uint64",
54213
+ internalType: "uint256",
53230
54214
  name: "requestId",
53231
- type: "uint64"
54215
+ type: "uint256"
54216
+ },
54217
+ {
54218
+ internalType: "address",
54219
+ name: "sender",
54220
+ type: "address"
54221
+ },
54222
+ {
54223
+ internalType: "string",
54224
+ name: "responseFieldName",
54225
+ type: "string"
53232
54226
  }
53233
54227
  ],
53234
- name: "isZKPRequestEnabled",
54228
+ name: "getResponseFieldValue",
53235
54229
  outputs: [
53236
54230
  {
53237
- internalType: "bool",
54231
+ internalType: "uint256",
53238
54232
  name: "",
53239
- type: "bool"
54233
+ type: "uint256"
53240
54234
  }
53241
54235
  ],
53242
54236
  stateMutability: "view",
@@ -53244,27 +54238,40 @@ var abi$2 = [
53244
54238
  },
53245
54239
  {
53246
54240
  inputs: [
53247
- ],
53248
- name: "owner",
53249
- outputs: [
54241
+ {
54242
+ internalType: "uint256",
54243
+ name: "requestId",
54244
+ type: "uint256"
54245
+ },
53250
54246
  {
53251
54247
  internalType: "address",
53252
- name: "",
54248
+ name: "sender",
53253
54249
  type: "address"
53254
54250
  }
53255
54251
  ],
53256
- stateMutability: "view",
53257
- type: "function"
53258
- },
53259
- {
53260
- inputs: [
53261
- ],
53262
- name: "pendingOwner",
54252
+ name: "getResponseFields",
53263
54253
  outputs: [
53264
54254
  {
53265
- internalType: "address",
54255
+ components: [
54256
+ {
54257
+ internalType: "string",
54258
+ name: "name",
54259
+ type: "string"
54260
+ },
54261
+ {
54262
+ internalType: "uint256",
54263
+ name: "value",
54264
+ type: "uint256"
54265
+ },
54266
+ {
54267
+ internalType: "bytes",
54268
+ name: "rawValue",
54269
+ type: "bytes"
54270
+ }
54271
+ ],
54272
+ internalType: "struct IRequestValidator.ResponseField[]",
53266
54273
  name: "",
53267
- type: "address"
54274
+ type: "tuple[]"
53268
54275
  }
53269
54276
  ],
53270
54277
  stateMutability: "view",
@@ -53273,35 +54280,55 @@ var abi$2 = [
53273
54280
  {
53274
54281
  inputs: [
53275
54282
  {
53276
- internalType: "contract ICircuitValidator",
53277
- name: "validator",
53278
- type: "address"
54283
+ internalType: "uint256",
54284
+ name: "groupId",
54285
+ type: "uint256"
53279
54286
  }
53280
54287
  ],
53281
- name: "removeValidatorFromWhitelist",
54288
+ name: "groupIdExists",
53282
54289
  outputs: [
54290
+ {
54291
+ internalType: "bool",
54292
+ name: "",
54293
+ type: "bool"
54294
+ }
53283
54295
  ],
53284
- stateMutability: "nonpayable",
54296
+ stateMutability: "view",
53285
54297
  type: "function"
53286
54298
  },
53287
54299
  {
53288
54300
  inputs: [
54301
+ {
54302
+ internalType: "address",
54303
+ name: "sender",
54304
+ type: "address"
54305
+ },
54306
+ {
54307
+ internalType: "uint256",
54308
+ name: "requestId",
54309
+ type: "uint256"
54310
+ }
53289
54311
  ],
53290
- name: "renounceOwnership",
54312
+ name: "isRequestProofVerified",
53291
54313
  outputs: [
54314
+ {
54315
+ internalType: "bool",
54316
+ name: "",
54317
+ type: "bool"
54318
+ }
53292
54319
  ],
53293
- stateMutability: "nonpayable",
54320
+ stateMutability: "view",
53294
54321
  type: "function"
53295
54322
  },
53296
54323
  {
53297
54324
  inputs: [
53298
54325
  {
53299
- internalType: "uint64",
53300
- name: "requestId",
53301
- type: "uint64"
54326
+ internalType: "uint256",
54327
+ name: "multiRequestId",
54328
+ type: "uint256"
53302
54329
  }
53303
54330
  ],
53304
- name: "requestIdExists",
54331
+ name: "multiRequestIdExists",
53305
54332
  outputs: [
53306
54333
  {
53307
54334
  internalType: "bool",
@@ -53315,53 +54342,48 @@ var abi$2 = [
53315
54342
  {
53316
54343
  inputs: [
53317
54344
  {
53318
- internalType: "uint64",
54345
+ internalType: "uint256",
53319
54346
  name: "requestId",
53320
- type: "uint64"
53321
- },
53322
- {
53323
- internalType: "address",
53324
- name: "requestOwner",
53325
- type: "address"
54347
+ type: "uint256"
53326
54348
  }
53327
54349
  ],
53328
- name: "setRequestOwner",
54350
+ name: "requestIdExists",
53329
54351
  outputs: [
54352
+ {
54353
+ internalType: "bool",
54354
+ name: "",
54355
+ type: "bool"
54356
+ }
53330
54357
  ],
53331
- stateMutability: "nonpayable",
54358
+ stateMutability: "view",
53332
54359
  type: "function"
53333
54360
  },
53334
54361
  {
53335
54362
  inputs: [
53336
- {
53337
- internalType: "uint64",
53338
- name: "requestId",
53339
- type: "uint64"
53340
- },
53341
54363
  {
53342
54364
  components: [
53343
54365
  {
53344
54366
  internalType: "string",
53345
- name: "metadata",
54367
+ name: "authMethod",
53346
54368
  type: "string"
53347
54369
  },
53348
54370
  {
53349
- internalType: "contract ICircuitValidator",
54371
+ internalType: "contract IAuthValidator",
53350
54372
  name: "validator",
53351
54373
  type: "address"
53352
54374
  },
53353
54375
  {
53354
54376
  internalType: "bytes",
53355
- name: "data",
54377
+ name: "params",
53356
54378
  type: "bytes"
53357
54379
  }
53358
54380
  ],
53359
- internalType: "struct IZKPVerifier.ZKPRequest",
53360
- name: "request",
54381
+ internalType: "struct IVerifier.AuthMethod",
54382
+ name: "authMethod",
53361
54383
  type: "tuple"
53362
54384
  }
53363
54385
  ],
53364
- name: "setZKPRequest",
54386
+ name: "setAuthMethod",
53365
54387
  outputs: [
53366
54388
  ],
53367
54389
  stateMutability: "nonpayable",
@@ -53370,32 +54392,34 @@ var abi$2 = [
53370
54392
  {
53371
54393
  inputs: [
53372
54394
  {
53373
- internalType: "uint64",
53374
- name: "requestId",
53375
- type: "uint64"
53376
- },
53377
- {
53378
- internalType: "uint256[]",
53379
- name: "inputs",
53380
- type: "uint256[]"
53381
- },
53382
- {
53383
- internalType: "uint256[2]",
53384
- name: "a",
53385
- type: "uint256[2]"
53386
- },
53387
- {
53388
- internalType: "uint256[2][2]",
53389
- name: "b",
53390
- type: "uint256[2][2]"
53391
- },
53392
- {
53393
- internalType: "uint256[2]",
53394
- name: "c",
53395
- type: "uint256[2]"
54395
+ components: [
54396
+ {
54397
+ internalType: "uint256",
54398
+ name: "multiRequestId",
54399
+ type: "uint256"
54400
+ },
54401
+ {
54402
+ internalType: "uint256[]",
54403
+ name: "requestIds",
54404
+ type: "uint256[]"
54405
+ },
54406
+ {
54407
+ internalType: "uint256[]",
54408
+ name: "groupIds",
54409
+ type: "uint256[]"
54410
+ },
54411
+ {
54412
+ internalType: "bytes",
54413
+ name: "metadata",
54414
+ type: "bytes"
54415
+ }
54416
+ ],
54417
+ internalType: "struct IVerifier.MultiRequest",
54418
+ name: "multiRequest",
54419
+ type: "tuple"
53396
54420
  }
53397
54421
  ],
53398
- name: "submitZKPResponse",
54422
+ name: "setMultiRequest",
53399
54423
  outputs: [
53400
54424
  ],
53401
54425
  stateMutability: "nonpayable",
@@ -53406,46 +54430,37 @@ var abi$2 = [
53406
54430
  {
53407
54431
  components: [
53408
54432
  {
53409
- internalType: "uint64",
54433
+ internalType: "uint256",
53410
54434
  name: "requestId",
53411
- type: "uint64"
54435
+ type: "uint256"
53412
54436
  },
53413
54437
  {
53414
- internalType: "bytes",
53415
- name: "zkProof",
53416
- type: "bytes"
54438
+ internalType: "string",
54439
+ name: "metadata",
54440
+ type: "string"
54441
+ },
54442
+ {
54443
+ internalType: "contract IRequestValidator",
54444
+ name: "validator",
54445
+ type: "address"
53417
54446
  },
53418
54447
  {
53419
54448
  internalType: "bytes",
53420
- name: "data",
54449
+ name: "params",
53421
54450
  type: "bytes"
54451
+ },
54452
+ {
54453
+ internalType: "address",
54454
+ name: "owner",
54455
+ type: "address"
53422
54456
  }
53423
54457
  ],
53424
- internalType: "struct ZKPResponse[]",
53425
- name: "responses",
54458
+ internalType: "struct IVerifier.Request[]",
54459
+ name: "requests",
53426
54460
  type: "tuple[]"
53427
- },
53428
- {
53429
- internalType: "bytes",
53430
- name: "crossChainProof",
53431
- type: "bytes"
53432
- }
53433
- ],
53434
- name: "submitZKPResponseV2",
53435
- outputs: [
53436
- ],
53437
- stateMutability: "nonpayable",
53438
- type: "function"
53439
- },
53440
- {
53441
- inputs: [
53442
- {
53443
- internalType: "address",
53444
- name: "newOwner",
53445
- type: "address"
53446
54461
  }
53447
54462
  ],
53448
- name: "transferOwnership",
54463
+ name: "setRequests",
53449
54464
  outputs: [
53450
54465
  ],
53451
54466
  stateMutability: "nonpayable",
@@ -53453,91 +54468,55 @@ var abi$2 = [
53453
54468
  },
53454
54469
  {
53455
54470
  inputs: [
53456
- {
53457
- internalType: "address",
53458
- name: "sender",
53459
- type: "address"
53460
- },
53461
- {
53462
- internalType: "uint64[]",
53463
- name: "requestIds",
53464
- type: "uint64[]"
53465
- }
53466
- ],
53467
- name: "verifyLinkedProofs",
53468
- outputs: [
53469
- ],
53470
- stateMutability: "view",
53471
- type: "function"
53472
- },
53473
- {
53474
- inputs: [
53475
- {
53476
- internalType: "uint64",
53477
- name: "requestId",
53478
- type: "uint64"
53479
- },
53480
- {
53481
- internalType: "uint256[]",
53482
- name: "inputs",
53483
- type: "uint256[]"
53484
- },
53485
- {
53486
- internalType: "uint256[2]",
53487
- name: "a",
53488
- type: "uint256[2]"
53489
- },
53490
- {
53491
- internalType: "uint256[2][2]",
53492
- name: "b",
53493
- type: "uint256[2][2]"
53494
- },
53495
- {
53496
- internalType: "uint256[2]",
53497
- name: "c",
53498
- type: "uint256[2]"
53499
- },
53500
- {
53501
- internalType: "address",
53502
- name: "sender",
53503
- type: "address"
53504
- }
53505
- ],
53506
- name: "verifyZKPResponse",
53507
- outputs: [
53508
54471
  {
53509
54472
  components: [
53510
54473
  {
53511
54474
  internalType: "string",
53512
- name: "key",
54475
+ name: "authMethod",
53513
54476
  type: "string"
53514
54477
  },
54478
+ {
54479
+ internalType: "bytes",
54480
+ name: "proof",
54481
+ type: "bytes"
54482
+ }
54483
+ ],
54484
+ internalType: "struct IVerifier.AuthResponse",
54485
+ name: "authResponse",
54486
+ type: "tuple"
54487
+ },
54488
+ {
54489
+ components: [
53515
54490
  {
53516
54491
  internalType: "uint256",
53517
- name: "inputValue",
54492
+ name: "requestId",
53518
54493
  type: "uint256"
54494
+ },
54495
+ {
54496
+ internalType: "bytes",
54497
+ name: "proof",
54498
+ type: "bytes"
54499
+ },
54500
+ {
54501
+ internalType: "bytes",
54502
+ name: "metadata",
54503
+ type: "bytes"
53519
54504
  }
53520
54505
  ],
53521
- internalType: "struct ICircuitValidator.KeyToInputValue[]",
53522
- name: "",
54506
+ internalType: "struct IVerifier.Response[]",
54507
+ name: "responses",
53523
54508
  type: "tuple[]"
54509
+ },
54510
+ {
54511
+ internalType: "bytes",
54512
+ name: "crossChainProofs",
54513
+ type: "bytes"
53524
54514
  }
53525
54515
  ],
53526
- stateMutability: "nonpayable",
53527
- type: "function"
53528
- },
53529
- {
53530
- inputs: [
53531
- ],
53532
- name: "version",
54516
+ name: "submitResponse",
53533
54517
  outputs: [
53534
- {
53535
- internalType: "string",
53536
- name: "",
53537
- type: "string"
53538
- }
53539
54518
  ],
53540
- stateMutability: "pure",
54519
+ stateMutability: "nonpayable",
53541
54520
  type: "function"
53542
54521
  }
53543
54522
  ];
@@ -53556,6 +54535,8 @@ var FunctionSignatures;
53556
54535
  FunctionSignatures["SubmitZKPResponseV1"] = "b68967e2";
53557
54536
  //function submitZKPResponseV2(tuple[](uint64 requestId,bytes zkProof,bytes data),bytes crossChainProof)
53558
54537
  FunctionSignatures["SubmitZKPResponseV2"] = "ade09fcd";
54538
+ //function submitResponse(tuple(string authMethod,bytes proof),tuple(uint256 requestId,bytes proof,bytes metadata)[],bytes crossChainProof)
54539
+ FunctionSignatures["SubmitResponse"] = "06c86a91";
53559
54540
  })(FunctionSignatures || (FunctionSignatures = {}));
53560
54541
  /**
53561
54542
  * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
@@ -53581,16 +54562,8 @@ class OnChainZKPVerifier {
53581
54562
  }
53582
54563
  const requestID = zkProofResponse.id;
53583
54564
  const inputs = zkProofResponse.pub_signals;
53584
- const payload = [
53585
- requestID,
53586
- inputs,
53587
- zkProofResponse.proof.pi_a.slice(0, 2),
53588
- [
53589
- [zkProofResponse.proof.pi_b[0][1], zkProofResponse.proof.pi_b[0][0]],
53590
- [zkProofResponse.proof.pi_b[1][1], zkProofResponse.proof.pi_b[1][0]]
53591
- ],
53592
- zkProofResponse.proof.pi_c.slice(0, 2)
53593
- ];
54565
+ const preparedZkpProof = prepareZkpProof(zkProofResponse.proof);
54566
+ const payload = [requestID, inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c];
53594
54567
  return payload;
53595
54568
  }
53596
54569
  /**
@@ -53642,25 +54615,69 @@ class OnChainZKPVerifier {
53642
54615
  const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
53643
54616
  response.set(txnHash, zkProofResponse);
53644
54617
  }
53645
- return response;
54618
+ return response;
54619
+ }
54620
+ /**
54621
+ * {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
54622
+ */
54623
+ async submitZKPResponseV2(ethSigner, txData, zkProofResponses) {
54624
+ const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
54625
+ if (!chainConfig) {
54626
+ throw new Error(`config for chain id ${txData.chain_id} was not found`);
54627
+ }
54628
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
54629
+ throw new Error(`submitZKPResponseV2 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
54630
+ }
54631
+ if (!this._opts?.didResolverUrl) {
54632
+ throw new Error(`did resolver url required for crosschain verification`);
54633
+ }
54634
+ const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
54635
+ ethSigner = ethSigner.connect(provider);
54636
+ const txDataArgs = await this.prepareTxArgsSubmitV2(txData, zkProofResponses);
54637
+ const feeData = await provider.getFeeData();
54638
+ const maxFeePerGas = chainConfig.maxFeePerGas
54639
+ ? BigInt(chainConfig.maxFeePerGas)
54640
+ : feeData.maxFeePerGas;
54641
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
54642
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
54643
+ : feeData.maxPriorityFeePerGas;
54644
+ const verifierContract = new Contract(txData.contract_address, abi$2);
54645
+ const txRequestData = await verifierContract.submitZKPResponseV2.populateTransaction(...txDataArgs);
54646
+ const request = {
54647
+ to: txData.contract_address,
54648
+ data: txRequestData.data,
54649
+ maxFeePerGas,
54650
+ maxPriorityFeePerGas
54651
+ };
54652
+ let gasLimit;
54653
+ try {
54654
+ gasLimit = await ethSigner.estimateGas(request);
54655
+ }
54656
+ catch (e) {
54657
+ gasLimit = maxGasLimit;
54658
+ }
54659
+ request.gasLimit = gasLimit;
54660
+ const transactionService = new TransactionService(provider);
54661
+ const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
54662
+ return new Map().set(txnHash, zkProofResponses);
53646
54663
  }
53647
54664
  /**
53648
- * {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
54665
+ * {@inheritDoc IOnChainVerifierMultiQuery.submitResponse}
53649
54666
  */
53650
- async submitZKPResponseV2(ethSigner, txData, zkProofResponses) {
54667
+ async submitResponse(ethSigner, txData, authResponse, responses) {
53651
54668
  const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
53652
54669
  if (!chainConfig) {
53653
54670
  throw new Error(`config for chain id ${txData.chain_id} was not found`);
53654
54671
  }
53655
- if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
53656
- throw new Error(`submitZKPResponseV2 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
54672
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitResponse) {
54673
+ throw new Error(`submitResponse function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitResponse}' is supported.`);
53657
54674
  }
53658
54675
  if (!this._opts?.didResolverUrl) {
53659
54676
  throw new Error(`did resolver url required for crosschain verification`);
53660
54677
  }
53661
54678
  const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
53662
54679
  ethSigner = ethSigner.connect(provider);
53663
- const txDataArgs = await this.prepareTxArgsSubmitV2(txData, zkProofResponses);
54680
+ const txDataArgs = await this.prepareTxArgsSubmit(txData, authResponse, responses);
53664
54681
  const feeData = await provider.getFeeData();
53665
54682
  const maxFeePerGas = chainConfig.maxFeePerGas
53666
54683
  ? BigInt(chainConfig.maxFeePerGas)
@@ -53668,8 +54685,8 @@ class OnChainZKPVerifier {
53668
54685
  const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
53669
54686
  ? BigInt(chainConfig.maxPriorityFeePerGas)
53670
54687
  : feeData.maxPriorityFeePerGas;
53671
- const verifierContract = new Contract(txData.contract_address, abi$2);
53672
- const txRequestData = await verifierContract.submitZKPResponseV2.populateTransaction(...txDataArgs);
54688
+ const verifierContract = new Contract(txData.contract_address, IVerifierABI);
54689
+ const txRequestData = await verifierContract.submitResponse.populateTransaction(...txDataArgs);
53673
54690
  const request = {
53674
54691
  to: txData.contract_address,
53675
54692
  data: txRequestData.data,
@@ -53686,7 +54703,37 @@ class OnChainZKPVerifier {
53686
54703
  request.gasLimit = gasLimit;
53687
54704
  const transactionService = new TransactionService(provider);
53688
54705
  const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
53689
- return new Map().set(txnHash, zkProofResponses);
54706
+ // return multiple responses for all the responses (single and grouped)
54707
+ return new Map().set(txnHash, {
54708
+ responses: responses,
54709
+ authProofs: [authResponse],
54710
+ crossChainProofs: [txDataArgs[2]]
54711
+ });
54712
+ }
54713
+ static async prepareTxArgsSubmit(resolverUrl, txData, authResponse, responses) {
54714
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitResponse) {
54715
+ throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitResponse}' is supported.`);
54716
+ }
54717
+ const gistUpdateArr = [];
54718
+ const stateUpdateArr = [];
54719
+ const payloadResponses = [];
54720
+ // Process all the responses
54721
+ for (const zkProof of responses) {
54722
+ const { requestID, zkProofEncoded, metadata } = await this._processProof(zkProof);
54723
+ payloadResponses.push({
54724
+ requestId: requestID,
54725
+ proof: zkProofEncoded,
54726
+ metadata: metadata
54727
+ });
54728
+ }
54729
+ const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr);
54730
+ return [authResponse, payloadResponses, crossChainProofs];
54731
+ }
54732
+ async prepareTxArgsSubmit(txData, authResponse, responses) {
54733
+ if (!this._opts?.didResolverUrl) {
54734
+ throw new Error(`did resolver url required for crosschain verification`);
54735
+ }
54736
+ return OnChainZKPVerifier.prepareTxArgsSubmit(this._opts.didResolverUrl, txData, authResponse, responses);
53690
54737
  }
53691
54738
  static getCrossChainResolvers(source, txDataChainId, type, didResolverUrl) {
53692
54739
  return [
@@ -53729,10 +54776,8 @@ class OnChainZKPVerifier {
53729
54776
  });
53730
54777
  continue;
53731
54778
  }
53732
- const zkProofEncoded = this.packZkpProof(inputs, zkProof.proof.pi_a.slice(0, 2), [
53733
- [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
53734
- [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
53735
- ], zkProof.proof.pi_c.slice(0, 2));
54779
+ const preparedZkpProof = prepareZkpProof(zkProof.proof);
54780
+ const zkProofEncoded = packZkpProof(inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c);
53736
54781
  const stateInfo = this.getOnChainGistRootStatePubSignals(proofCircuitId, inputs);
53737
54782
  const chainId = txData.chain_id;
53738
54783
  const gistUpdateResolutions = this.getCrossChainResolvers(stateInfo.gists, chainId, 'gist', resolverUrl);
@@ -53775,8 +54820,30 @@ class OnChainZKPVerifier {
53775
54820
  }
53776
54821
  return OnChainZKPVerifier.prepareTxArgsSubmitV2(this._opts.didResolverUrl, txData, zkProofResponses);
53777
54822
  }
53778
- static packZkpProof(inputs, a, b, c) {
53779
- return new AbiCoder().encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
54823
+ static async _processProof(zkProof) {
54824
+ const requestID = zkProof.id;
54825
+ const inputs = zkProof.pub_signals;
54826
+ if (!this._supportedCircuits.includes(zkProof.circuitId)) {
54827
+ throw new Error(`Circuit ${zkProof.circuitId} not supported by OnChainZKPVerifier`);
54828
+ }
54829
+ const preparedZkpProof = prepareZkpProof(zkProof.proof);
54830
+ const zkProofEncoded = packZkpProof(inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c);
54831
+ const metadataArr = [];
54832
+ if (zkProof.vp) {
54833
+ for (const key in zkProof.vp.verifiableCredential.credentialSubject) {
54834
+ if (key === '@type') {
54835
+ continue;
54836
+ }
54837
+ const metadataValue = poseidon.hashBytes(byteEncoder.encode(JSON.stringify(zkProof.vp.verifiableCredential.credentialSubject[key])));
54838
+ const bytesValue = byteEncoder.encode(metadataValue.toString());
54839
+ metadataArr.push({
54840
+ key,
54841
+ value: bytesValue
54842
+ });
54843
+ }
54844
+ }
54845
+ const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : '0x';
54846
+ return { requestID, zkProofEncoded, metadata };
53780
54847
  }
53781
54848
  static packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
53782
54849
  const proofs = [];
@@ -58343,129 +59410,6 @@ class CredentialStatusResolverRegistry {
58343
59410
  }
58344
59411
  }
58345
59412
 
58346
- const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
58347
- const DIDCOMM_PROTOCOL = 'https://didcomm.org/';
58348
- /**
58349
- * Constants for Iden3 protocol
58350
- */
58351
- const PROTOCOL_MESSAGE_TYPE = Object.freeze({
58352
- // AuthorizationV2RequestMessageType defines auth request type of the communication protocol
58353
- AUTHORIZATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/request`,
58354
- // AuthorizationResponseMessageType defines auth response type of the communication protocol
58355
- AUTHORIZATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/response`,
58356
- // CredentialIssuanceRequestMessageType accepts request for credential creation
58357
- CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-request`,
58358
- // CredentialFetchRequestMessageType is type for request of credential generation
58359
- CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/fetch-request`,
58360
- // CredentialOfferMessageType is type of message with credential offering
58361
- CREDENTIAL_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/offer`,
58362
- // CredentialIssuanceResponseMessageType is type for message with a credential issuance
58363
- CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-response`,
58364
- // CredentialRefreshMessageType is type for message with a credential issuance
58365
- CREDENTIAL_REFRESH_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/refresh`,
58366
- // DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
58367
- DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}devices/1.0/registration`,
58368
- // MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
58369
- MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}messages/1.0/fetch`,
58370
- // ProofGenerationRequestMessageType is type for request of proof generation
58371
- PROOF_GENERATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/request`,
58372
- // ProofGenerationResponseMessageType is type for response of proof generation
58373
- PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/response`,
58374
- // RevocationStatusRequestMessageType is type for request of revocation status
58375
- REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/request-status`,
58376
- // RevocationStatusResponseMessageType is type for response with a revocation status
58377
- REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status`,
58378
- // ContractInvokeRequestMessageType is type for request of contract invoke request
58379
- CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request`,
58380
- // ContractInvokeResponseMessageType is type for response of contract invoke request
58381
- CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-response`,
58382
- // CredentialOnchainOfferMessageType is type of message with credential onchain offering
58383
- CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer`,
58384
- // ProposalRequestMessageType is type for proposal-request message
58385
- PROPOSAL_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal-request`,
58386
- // ProposalMessageType is type for proposal message
58387
- PROPOSAL_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal`,
58388
- // PaymentRequestMessageType is type for payment-request message
58389
- PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
58390
- // PaymentMessageType is type for payment message
58391
- PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`,
58392
- // DiscoveryProtocolQueriesMessageType is type for didcomm discovery protocol queries
58393
- DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/queries`,
58394
- // DiscoveryProtocolDiscloseMessageType is type for didcomm discovery protocol disclose
58395
- DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/disclose`,
58396
- // ProblemReportMessageType is type for didcomm problem report
58397
- PROBLEM_REPORT_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}report-problem/2.0/problem-report`
58398
- });
58399
- /**
58400
- * Media types for iden3 comm communication protocol
58401
- *
58402
- * @enum {number}
58403
- */
58404
- var MediaType;
58405
- (function (MediaType) {
58406
- MediaType["ZKPMessage"] = "application/iden3-zkp-json";
58407
- MediaType["PlainMessage"] = "application/iden3comm-plain-json";
58408
- MediaType["SignedMessage"] = "application/iden3comm-signed-json";
58409
- })(MediaType || (MediaType = {}));
58410
- const SUPPORTED_PUBLIC_KEY_TYPES = {
58411
- ES256K: [
58412
- 'EcdsaSecp256k1VerificationKey2019',
58413
- /**
58414
- * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
58415
- */
58416
- 'EcdsaSecp256k1RecoveryMethod2020',
58417
- 'JsonWebKey2020'
58418
- ],
58419
- 'ES256K-R': [
58420
- 'EcdsaSecp256k1VerificationKey2019',
58421
- /**
58422
- * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress
58423
- */
58424
- 'EcdsaSecp256k1RecoveryMethod2020',
58425
- 'JsonWebKey2020'
58426
- ]
58427
- };
58428
- var ProtocolVersion;
58429
- (function (ProtocolVersion) {
58430
- ProtocolVersion["V1"] = "iden3comm/v1";
58431
- })(ProtocolVersion || (ProtocolVersion = {}));
58432
- var AcceptAuthCircuits;
58433
- (function (AcceptAuthCircuits) {
58434
- AcceptAuthCircuits["AuthV2"] = "authV2";
58435
- AcceptAuthCircuits["AuthV3"] = "authV3";
58436
- })(AcceptAuthCircuits || (AcceptAuthCircuits = {}));
58437
- var AcceptJwzAlgorithms;
58438
- (function (AcceptJwzAlgorithms) {
58439
- AcceptJwzAlgorithms["Groth16"] = "groth16";
58440
- })(AcceptJwzAlgorithms || (AcceptJwzAlgorithms = {}));
58441
- var AcceptJwsAlgorithms;
58442
- (function (AcceptJwsAlgorithms) {
58443
- AcceptJwsAlgorithms["ES256K"] = "ES256K";
58444
- AcceptJwsAlgorithms["ES256KR"] = "ES256K-R";
58445
- })(AcceptJwsAlgorithms || (AcceptJwsAlgorithms = {}));
58446
- const defaultAcceptProfile = {
58447
- protocolVersion: ProtocolVersion.V1,
58448
- env: MediaType.ZKPMessage,
58449
- circuits: [AcceptAuthCircuits.AuthV2],
58450
- alg: [AcceptJwzAlgorithms.Groth16]
58451
- };
58452
- const DEFAULT_PROOF_VERIFY_DELAY = 1 * 60 * 60 * 1000; // 1 hour
58453
- const DEFAULT_AUTH_VERIFY_DELAY = 5 * 60 * 1000; // 5 minutes
58454
-
58455
- var constants = /*#__PURE__*/Object.freeze({
58456
- __proto__: null,
58457
- get AcceptAuthCircuits () { return AcceptAuthCircuits; },
58458
- get AcceptJwsAlgorithms () { return AcceptJwsAlgorithms; },
58459
- get AcceptJwzAlgorithms () { return AcceptJwzAlgorithms; },
58460
- DEFAULT_AUTH_VERIFY_DELAY: DEFAULT_AUTH_VERIFY_DELAY,
58461
- DEFAULT_PROOF_VERIFY_DELAY: DEFAULT_PROOF_VERIFY_DELAY,
58462
- get MediaType () { return MediaType; },
58463
- PROTOCOL_MESSAGE_TYPE: PROTOCOL_MESSAGE_TYPE,
58464
- get ProtocolVersion () { return ProtocolVersion; },
58465
- SUPPORTED_PUBLIC_KEY_TYPES: SUPPORTED_PUBLIC_KEY_TYPES,
58466
- defaultAcceptProfile: defaultAcceptProfile
58467
- });
58468
-
58469
59413
  /**
58470
59414
  * AgentResolver is a class that allows to interact with the issuer's agent to get revocation status.
58471
59415
  *
@@ -59404,125 +60348,31 @@ class NativeProver {
59404
60348
  * @param {string} circuitId - circuit id for proof generation
59405
60349
  * @returns `Promise<ZKProof>`
59406
60350
  */
59407
- async generate(inputs, circuitId) {
59408
- const circuitData = await this._circuitStorage.loadCircuitData(circuitId);
59409
- if (!circuitData.wasm) {
59410
- throw new Error(`wasm file doesn't exist for circuit ${circuitId}`);
59411
- }
59412
- const witnessCalculator = await witnessBuilder(circuitData.wasm);
59413
- const parsedData = JSON.parse(byteDecoder.decode(inputs));
59414
- const wtnsBytes = await witnessCalculator.calculateWTNSBin(parsedData, 0);
59415
- if (!circuitData.provingKey) {
59416
- throw new Error(`proving file doesn't exist for circuit ${circuitId}`);
59417
- }
59418
- const { proof, publicSignals } = await groth16.prove(circuitData.provingKey, wtnsBytes);
59419
- // we need to terminate curve manually
59420
- await this.terminateCurve();
59421
- return {
59422
- proof,
59423
- pub_signals: publicSignals
59424
- };
59425
- }
59426
- async terminateCurve() {
59427
- const curve = await getCurveFromName(NativeProver.curveName);
59428
- curve.terminate();
59429
- }
59430
- }
59431
- NativeProver.curveName = 'bn128';
59432
-
59433
- /**
59434
- * creates empty basic message
59435
- *
59436
- * @returns BasicMessage
59437
- */
59438
- const basicMessageFactory = () => {
59439
- return {
59440
- id: '',
59441
- typ: '',
59442
- thid: '',
59443
- type: '',
59444
- body: {},
59445
- from: '',
59446
- to: ''
59447
- };
59448
- };
59449
- /**
59450
- * create empty header stub
59451
- *
59452
- * @returns {HeaderStub}
59453
- */
59454
- const headerStubFactory = () => {
59455
- return {
59456
- typ: ''
59457
- };
59458
- };
59459
-
59460
- // Envelope Errors
59461
- // Token Errors
59462
- const ErrUnknownCircuitID = "unknown circuit ID. can't verify msg sender";
59463
- const ErrSenderNotUsedTokenCreation = 'sender of message is not used for jwz token creation';
59464
- // ZKP-Packer Errors
59465
- const ErrPackedWithUnsupportedCircuit = 'message was packed with unsupported circuit';
59466
- const ErrProofIsInvalid = 'message proof is invalid';
59467
- const ErrStateVerificationFailed = 'message state verification failed';
59468
- const ErrNoProvingMethodAlg = 'unknown proving method algorithm';
59469
-
59470
- const objectIs = (obj, //eslint-disable-line @typescript-eslint/no-explicit-any
59471
- targetObj //eslint-disable-line @typescript-eslint/no-explicit-any
59472
- ) => {
59473
- Object.keys(targetObj).forEach((prop) => {
59474
- if (!obj[prop]) {
59475
- return false;
59476
- }
59477
- if (typeof targetObj[prop] !== typeof obj[prop]) {
59478
- return false;
59479
- }
59480
- });
59481
- return true;
59482
- };
59483
- //eslint-disable-next-line @typescript-eslint/no-explicit-any
59484
- const isProtocolMessage = (message) => {
59485
- const basicMessage = basicMessageFactory();
59486
- Object.keys(basicMessage).forEach((prop) => {
59487
- if (!message[prop]) {
59488
- return false;
59489
- }
59490
- if (prop !== 'body') {
59491
- const res = typeof basicMessage[prop] ===
59492
- typeof message[prop]; //eslint-disable-line @typescript-eslint/no-explicit-any
59493
- if (!res) {
59494
- return false;
59495
- }
60351
+ async generate(inputs, circuitId) {
60352
+ const circuitData = await this._circuitStorage.loadCircuitData(circuitId);
60353
+ if (!circuitData.wasm) {
60354
+ throw new Error(`wasm file doesn't exist for circuit ${circuitId}`);
59496
60355
  }
59497
- });
59498
- return true;
59499
- };
59500
- /**
59501
- * helper function to convert serialized JSON bytes to protocol message
59502
- *
59503
- * @param {Uint8Array} bytes
59504
- * @returns {BasicMessage}
59505
- */
59506
- const bytesToProtocolMessage = (bytes) => {
59507
- const str = byteDecoder.decode(bytes);
59508
- const message = JSON.parse(str);
59509
- if (!isProtocolMessage(message)) ;
59510
- return message;
59511
- };
59512
- /**
59513
- * helper function to convert serialized JSON bytes to header stub
59514
- * so we can work with know the media type of the message
59515
- *
59516
- * @param {Uint8Array} envelope
59517
- * @returns {HeaderStub}
59518
- */
59519
- const bytesToHeaderStub = (envelope) => {
59520
- const tmpObj = headerStubFactory();
59521
- const str = byteDecoder.decode(envelope);
59522
- const message = JSON.parse(str);
59523
- if (!objectIs(message, tmpObj)) ;
59524
- return message;
59525
- };
60356
+ const witnessCalculator = await witnessBuilder(circuitData.wasm);
60357
+ const parsedData = JSON.parse(byteDecoder.decode(inputs));
60358
+ const wtnsBytes = await witnessCalculator.calculateWTNSBin(parsedData, 0);
60359
+ if (!circuitData.provingKey) {
60360
+ throw new Error(`proving file doesn't exist for circuit ${circuitId}`);
60361
+ }
60362
+ const { proof, publicSignals } = await groth16.prove(circuitData.provingKey, wtnsBytes);
60363
+ // we need to terminate curve manually
60364
+ await this.terminateCurve();
60365
+ return {
60366
+ proof,
60367
+ pub_signals: publicSignals
60368
+ };
60369
+ }
60370
+ async terminateCurve() {
60371
+ const curve = await getCurveFromName(NativeProver.curveName);
60372
+ curve.terminate();
60373
+ }
60374
+ }
60375
+ NativeProver.curveName = 'bn128';
59526
60376
 
59527
60377
  /**
59528
60378
  * Basic package manager for iden3 communication protocol
@@ -59634,164 +60484,6 @@ class PackageManager {
59634
60484
  }
59635
60485
  }
59636
60486
 
59637
- const DIDAuthenticationSection = 'authentication';
59638
- const resolveVerificationMethods = (didDocument) => {
59639
- const vms = didDocument.verificationMethod || [];
59640
- // prioritize: first verification methods to be chosen are from `authentication` section.
59641
- const sortedVerificationMethods = (didDocument[DIDAuthenticationSection] || [])
59642
- .map((verificationMethod) => {
59643
- if (typeof verificationMethod === 'string') {
59644
- return vms.find((i) => i.id === verificationMethod);
59645
- }
59646
- return verificationMethod;
59647
- })
59648
- .filter((key) => key);
59649
- // add all other verification methods
59650
- for (let index = 0; index < vms.length; index++) {
59651
- const id = vms[index].id;
59652
- if (sortedVerificationMethods.findIndex((vm) => vm.id === id) === -1) {
59653
- sortedVerificationMethods.push(vms[index]);
59654
- }
59655
- }
59656
- return sortedVerificationMethods;
59657
- };
59658
- const extractPublicKeyBytes = (vm) => {
59659
- const isSupportedVmType = Object.keys(SUPPORTED_PUBLIC_KEY_TYPES).some((key) => SUPPORTED_PUBLIC_KEY_TYPES[key].includes(vm.type));
59660
- if (vm.publicKeyBase58 && isSupportedVmType) {
59661
- return { publicKeyBytes: base58ToBytes$1(vm.publicKeyBase58), kmsKeyType: KmsKeyType.Secp256k1 };
59662
- }
59663
- if (vm.publicKeyBase64 && isSupportedVmType) {
59664
- return {
59665
- publicKeyBytes: base64UrlToBytes(vm.publicKeyBase64),
59666
- kmsKeyType: KmsKeyType.Secp256k1
59667
- };
59668
- }
59669
- if (vm.publicKeyHex && isSupportedVmType) {
59670
- return { publicKeyBytes: hexToBytes$3(vm.publicKeyHex), kmsKeyType: KmsKeyType.Secp256k1 };
59671
- }
59672
- if (vm.publicKeyJwk &&
59673
- vm.publicKeyJwk.crv === 'secp256k1' &&
59674
- vm.publicKeyJwk.x &&
59675
- vm.publicKeyJwk.y) {
59676
- const [xHex, yHex] = [
59677
- base64UrlToBytes(vm.publicKeyJwk.x),
59678
- base64UrlToBytes(vm.publicKeyJwk.y)
59679
- ].map(bytesToHex$3);
59680
- const x = xHex.includes('0x') ? BigInt(xHex) : BigInt(`0x${xHex}`);
59681
- const y = yHex.includes('0x') ? BigInt(yHex) : BigInt(`0x${yHex}`);
59682
- return {
59683
- publicKeyBytes: secp256k1$1.ProjectivePoint.fromAffine({
59684
- x,
59685
- y
59686
- }).toRawBytes(false),
59687
- kmsKeyType: KmsKeyType.Secp256k1
59688
- };
59689
- }
59690
- return { publicKeyBytes: null };
59691
- };
59692
-
59693
- function isProtocolVersion(value) {
59694
- return Object.values(ProtocolVersion).includes(value);
59695
- }
59696
- function isMediaType(value) {
59697
- return Object.values(MediaType).includes(value);
59698
- }
59699
- function isAcceptAuthCircuits(value) {
59700
- return Object.values(AcceptAuthCircuits).includes(value);
59701
- }
59702
- function isAcceptJwsAlgorithms(value) {
59703
- return Object.values(AcceptJwsAlgorithms).includes(value);
59704
- }
59705
- function isAcceptJwzAlgorithms(value) {
59706
- return Object.values(AcceptJwzAlgorithms).includes(value);
59707
- }
59708
- const buildAccept = (profiles) => {
59709
- const result = [];
59710
- for (const profile of profiles) {
59711
- let accept = `${profile.protocolVersion};env=${profile.env}`;
59712
- if (profile.circuits?.length) {
59713
- accept += `;circuitId=${profile.circuits.join(',')}`;
59714
- }
59715
- if (profile.alg?.length) {
59716
- accept += `;alg=${profile.alg.join(',')}`;
59717
- }
59718
- result.push(accept);
59719
- }
59720
- return result;
59721
- };
59722
- const parseAcceptProfile = (profile) => {
59723
- const params = profile.split(';');
59724
- if (params.length < 2) {
59725
- throw new Error('Invalid accept profile');
59726
- }
59727
- const protocolVersion = params[0].trim();
59728
- if (!isProtocolVersion(protocolVersion)) {
59729
- throw new Error(`Protocol version '${protocolVersion}' not supported`);
59730
- }
59731
- const envParam = params[1].split('=');
59732
- if (envParam.length !== 2) {
59733
- throw new Error(`Invalid accept profile 'env' parameter`);
59734
- }
59735
- const env = params[1].split('=')[1].trim();
59736
- if (!isMediaType(env)) {
59737
- throw new Error(`Envelop '${env}' not supported`);
59738
- }
59739
- const circuitsIndex = params.findIndex((i) => i.includes('circuitId='));
59740
- if (env !== MediaType.ZKPMessage && circuitsIndex > 0) {
59741
- throw new Error(`Circuits not supported for env '${env}'`);
59742
- }
59743
- let circuits = undefined;
59744
- if (circuitsIndex > 0) {
59745
- circuits = params[circuitsIndex]
59746
- .split('=')[1]
59747
- .split(',')
59748
- .map((i) => i.trim())
59749
- .map((i) => {
59750
- if (!isAcceptAuthCircuits(i)) {
59751
- throw new Error(`Circuit '${i}' not supported`);
59752
- }
59753
- return i;
59754
- });
59755
- }
59756
- const algIndex = params.findIndex((i) => i.includes('alg='));
59757
- let alg = undefined;
59758
- if (algIndex > 0) {
59759
- if (env === MediaType.ZKPMessage) {
59760
- alg = params[algIndex]
59761
- .split('=')[1]
59762
- .split(',')
59763
- .map((i) => {
59764
- i = i.trim();
59765
- if (!isAcceptJwzAlgorithms(i)) {
59766
- throw new Error(`Algorithm '${i}' not supported for '${env}'`);
59767
- }
59768
- return i;
59769
- });
59770
- }
59771
- else if (env === MediaType.SignedMessage) {
59772
- alg = params[algIndex]
59773
- .split('=')[1]
59774
- .split(',')
59775
- .map((i) => {
59776
- i = i.trim();
59777
- if (!isAcceptJwsAlgorithms(i)) {
59778
- throw new Error(`Algorithm '${i}' not supported for '${env}'`);
59779
- }
59780
- return i;
59781
- });
59782
- }
59783
- else {
59784
- throw new Error(`Algorithm not supported for '${env}'`);
59785
- }
59786
- }
59787
- return {
59788
- protocolVersion,
59789
- env,
59790
- circuits,
59791
- alg
59792
- };
59793
- };
59794
-
59795
60487
  const { getProvingMethod } = proving;
59796
60488
  /**
59797
60489
  * Handler to
@@ -60218,6 +60910,12 @@ var CredentialOfferStatus;
60218
60910
  CredentialOfferStatus["Rejected"] = "rejected";
60219
60911
  })(CredentialOfferStatus || (CredentialOfferStatus = {}));
60220
60912
 
60913
+ var AuthMethod;
60914
+ (function (AuthMethod) {
60915
+ AuthMethod["AUTHV2"] = "authV2";
60916
+ AuthMethod["ETH_IDENTITY"] = "ethIdentity";
60917
+ })(AuthMethod || (AuthMethod = {}));
60918
+
60221
60919
  /** @beta DiscoverFeatureQueryType is enum for query type fields */
60222
60920
  var DiscoverFeatureQueryType;
60223
60921
  (function (DiscoverFeatureQueryType) {
@@ -60311,6 +61009,59 @@ const processZeroKnowledgeProofRequests = async (to, requests, from, proofServic
60311
61009
  }
60312
61010
  return zkpResponses;
60313
61011
  };
61012
+ /**
61013
+ * Processes auth proof requests.
61014
+ *
61015
+ * @param to - The identifier of the recipient.
61016
+ * @param proofService - The proof service.
61017
+ * @param opts - Additional options for processing the requests.
61018
+ * @returns A promise that resolves to an auth proof response.
61019
+ */
61020
+ const processProofAuth = async (to, proofService, opts) => {
61021
+ if (!opts.acceptProfile) {
61022
+ opts.acceptProfile = defaultAcceptProfile;
61023
+ }
61024
+ if (!opts.skipRevocation) {
61025
+ opts.skipRevocation = true;
61026
+ }
61027
+ switch (opts.acceptProfile.env) {
61028
+ case MediaType.ZKPMessage:
61029
+ if (!opts.acceptProfile.circuits) {
61030
+ throw new Error('Circuit not specified in accept profile');
61031
+ }
61032
+ for (const circuitId of opts.acceptProfile.circuits) {
61033
+ if (!opts.supportedCircuits.includes(circuitId)) {
61034
+ throw new Error(`Circuit ${circuitId} is not supported`);
61035
+ }
61036
+ const zkpRes = await proofService.generateAuthProof(circuitId, to, { challenge: opts.challenge, skipRevocation: opts.skipRevocation });
61037
+ switch (circuitId) {
61038
+ case CircuitId.AuthV2: {
61039
+ const preparedZkpProof = prepareZkpProof(zkpRes.proof);
61040
+ const zkProofEncoded = packZkpProof(zkpRes.pub_signals, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c);
61041
+ return {
61042
+ authMethod: AuthMethod.AUTHV2,
61043
+ proof: zkProofEncoded
61044
+ };
61045
+ }
61046
+ }
61047
+ }
61048
+ throw new Error(`Auth method is not supported`);
61049
+ case MediaType.SignedMessage:
61050
+ if (!opts.acceptProfile.alg || opts.acceptProfile.alg.length === 0) {
61051
+ throw new Error('Algorithm not specified');
61052
+ }
61053
+ if (opts.acceptProfile.alg[0] === AcceptJwsAlgorithms.ES256KR) {
61054
+ const ethIdProof = packEthIdentityProof(to);
61055
+ return {
61056
+ authMethod: AuthMethod.ETH_IDENTITY,
61057
+ proof: ethIdProof
61058
+ };
61059
+ }
61060
+ throw new Error(`Algorithm ${opts.acceptProfile.alg[0]} not supported`);
61061
+ default:
61062
+ throw new Error('Accept env not supported');
61063
+ }
61064
+ };
60314
61065
  /**
60315
61066
  * Verifies that the expires_time field of a message is not in the past. Throws an error if it is.
60316
61067
  *
@@ -60321,6 +61072,9 @@ const verifyExpiresTime = (message) => {
60321
61072
  throw new Error('Message expired');
60322
61073
  }
60323
61074
  };
61075
+ const packEthIdentityProof = (did) => {
61076
+ return `0x${bytesToHex$3(BytesHelper.intToBytes(DID.idFromDID(did).bigInt()))}`;
61077
+ };
60324
61078
 
60325
61079
  /**
60326
61080
  * Base implementation of protocol message handler
@@ -60595,7 +61349,7 @@ class AuthHandler extends AbstractMessageHandler {
60595
61349
  // group requests by query group id
60596
61350
  for (const proofRequest of requestScope) {
60597
61351
  const groupId = proofRequest.query.groupId;
60598
- const proofResp = responseScope.find((resp) => resp.id === proofRequest.id);
61352
+ const proofResp = responseScope.find((resp) => resp.id.toString() === proofRequest.id.toString());
60599
61353
  if (!proofResp) {
60600
61354
  throw new Error(`proof is not given for requestId ${proofRequest.id}`);
60601
61355
  }
@@ -60953,6 +61707,7 @@ class ContractRequestHandler extends AbstractMessageHandler {
60953
61707
  * @param {IPackageManager} _packerMgr - package manager to unpack message envelope
60954
61708
  * @param {IProofService} _proofService - proof service to verify zk proofs
60955
61709
  * @param {IOnChainZKPVerifier} _zkpVerifier - zkp verifier to submit response
61710
+ * @param {IOnChainVerifierMultiQuery} _verifierMultiQuery - verifier multi-query to submit response
60956
61711
  *
60957
61712
  */
60958
61713
  constructor(_packerMgr, _proofService, _zkpVerifier) {
@@ -60964,7 +61719,12 @@ class ContractRequestHandler extends AbstractMessageHandler {
60964
61719
  CircuitId.AuthV2,
60965
61720
  CircuitId.AtomicQueryMTPV2OnChain,
60966
61721
  CircuitId.AtomicQuerySigV2OnChain,
60967
- CircuitId.AtomicQueryV3OnChain
61722
+ CircuitId.AtomicQueryV3OnChain,
61723
+ // Now we support off-chain circuits on-chain
61724
+ // TODO: We need to create validators for them
61725
+ CircuitId.AuthV2,
61726
+ CircuitId.AtomicQueryV3,
61727
+ CircuitId.LinkedMultiQuery10
60968
61728
  ];
60969
61729
  }
60970
61730
  async handle(message, ctx) {
@@ -61000,19 +61760,64 @@ class ContractRequestHandler extends AbstractMessageHandler {
61000
61760
  });
61001
61761
  const methodId = message.body.transaction_data.method_id.replace('0x', '');
61002
61762
  switch (methodId) {
61003
- case FunctionSignatures.SubmitZKPResponseV2:
61004
- return this._zkpVerifier.submitZKPResponseV2(ethSigner, message.body.transaction_data, zkpResponses);
61763
+ case FunctionSignatures.SubmitZKPResponseV2: {
61764
+ const txHashZkpResponsesMap = await this._zkpVerifier.submitZKPResponseV2(ethSigner, message.body.transaction_data, zkpResponses);
61765
+ const response = new Map();
61766
+ for (const [txHash, zkpResponses] of txHashZkpResponsesMap) {
61767
+ response.set(txHash, { responses: zkpResponses });
61768
+ }
61769
+ return response;
61770
+ }
61005
61771
  case FunctionSignatures.SubmitZKPResponseV1: {
61006
61772
  const txHashZkpResponseMap = await this._zkpVerifier.submitZKPResponse(ethSigner, message.body.transaction_data, zkpResponses);
61007
61773
  const response = new Map();
61008
61774
  for (const [txHash, zkpResponse] of txHashZkpResponseMap) {
61009
- response.set(txHash, [zkpResponse]);
61775
+ response.set(txHash, { responses: [zkpResponse] });
61010
61776
  }
61011
61777
  return response;
61012
61778
  }
61779
+ case FunctionSignatures.SubmitResponse: {
61780
+ // We need to
61781
+ // 1. Generate auth proof from message.body.accept -> authResponse
61782
+ // 2. Generate proofs for each query in scope -> zkpResponses
61783
+ // Build auth response from accept
61784
+ if (!message.to) {
61785
+ throw new Error(`failed message. empty 'to' field`);
61786
+ }
61787
+ // Get first supported accept profile and pass it to processProofAuth
61788
+ const acceptProfile = this.getFirstSupportedProfile(PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE, message.body.accept);
61789
+ const identifier = DID.parse(message.to);
61790
+ const authResponse = await processProofAuth(identifier, this._proofService, {
61791
+ supportedCircuits: this._supportedCircuits,
61792
+ acceptProfile,
61793
+ challenge: challenge,
61794
+ skipRevocation: true
61795
+ });
61796
+ return this._zkpVerifier.submitResponse(ethSigner, message.body.transaction_data, authResponse, zkpResponses);
61797
+ }
61013
61798
  default:
61014
- throw new Error(`Not supported method id. Only '${FunctionSignatures.SubmitZKPResponseV1} and ${FunctionSignatures.SubmitZKPResponseV2} are supported.'`);
61799
+ throw new Error(`Not supported method id. Only '${FunctionSignatures.SubmitZKPResponseV1}, ${FunctionSignatures.SubmitZKPResponseV2} and ${FunctionSignatures.SubmitResponse} are supported.'`);
61800
+ }
61801
+ }
61802
+ getFirstSupportedProfile(responseType, profile) {
61803
+ if (profile?.length) {
61804
+ for (const acceptProfileString of profile) {
61805
+ // 1. check protocol version
61806
+ const acceptProfile = parseAcceptProfile(acceptProfileString);
61807
+ const responseTypeVersion = Number(responseType.split('/').at(-2));
61808
+ if (acceptProfile.protocolVersion !== ProtocolVersion.V1 ||
61809
+ (acceptProfile.protocolVersion === ProtocolVersion.V1 &&
61810
+ (responseTypeVersion < 1 || responseTypeVersion >= 2))) {
61811
+ continue;
61812
+ }
61813
+ // 2. check packer support
61814
+ if (this._packerMgr.isProfileSupported(acceptProfile.env, acceptProfileString)) {
61815
+ return acceptProfile;
61816
+ }
61817
+ }
61015
61818
  }
61819
+ // if we don't have supported profiles, we use default
61820
+ return defaultAcceptProfile;
61016
61821
  }
61017
61822
  /**
61018
61823
  * unpacks contract-invoke request
@@ -61034,7 +61839,7 @@ class ContractRequestHandler extends AbstractMessageHandler {
61034
61839
  * @private
61035
61840
  * @beta
61036
61841
  * @param {ContractInvokeRequest} request - ContractInvokeRequest
61037
- * @param { Map<string, ZeroKnowledgeProofResponse[]>} responses - map tx hash to array of ZeroKnowledgeProofResponses
61842
+ * @param { Map<string, ZeroKnowledgeInvokeResponse>} responses - map tx hash to array of ZeroKnowledgeInvokeResponse
61038
61843
  * @returns `Promise<ContractInvokeResponse>`
61039
61844
  */
61040
61845
  async createContractInvokeResponse(request, txHashToZkpResponseMap) {
@@ -61051,12 +61856,17 @@ class ContractRequestHandler extends AbstractMessageHandler {
61051
61856
  created_time: getUnixTimestamp(new Date())
61052
61857
  };
61053
61858
  for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
61054
- for (const zkpResponse of zkpResponses) {
61859
+ for (const zkpResponse of zkpResponses.responses) {
61055
61860
  contractInvokeResponse.body.scope.push({
61056
61861
  txHash,
61057
61862
  ...zkpResponse
61058
61863
  });
61059
61864
  }
61865
+ contractInvokeResponse.body = {
61866
+ ...contractInvokeResponse.body,
61867
+ crossChainProofs: zkpResponses.crossChainProofs ?? [],
61868
+ authProofs: zkpResponses.authProofs ?? []
61869
+ };
61060
61870
  }
61061
61871
  return contractInvokeResponse;
61062
61872
  }
@@ -62322,6 +63132,7 @@ class InputGenerator {
62322
63132
  return circuitInputs.inputsMarshal();
62323
63133
  };
62324
63134
  this.credentialAtomicQueryV3OnChainPrepareInputs = async ({ preparedCredential, identifier, proofReq, params, circuitQueries }) => {
63135
+ const id = DID.idFromDID(identifier);
62325
63136
  const circuitClaimData = await this.newCircuitClaimData(preparedCredential);
62326
63137
  circuitClaimData.nonRevProof = toClaimNonRevStatus(preparedCredential.revStatus);
62327
63138
  let proofType;
@@ -62371,20 +63182,17 @@ class InputGenerator {
62371
63182
  const isEthIdentity = isEthereumIdentity(identifier);
62372
63183
  circuitInputs.isBJJAuthEnabled = isEthIdentity ? 0 : 1;
62373
63184
  circuitInputs.challenge = BigInt(params.challenge ?? 0);
62374
- const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(identifier);
62375
- const id = DID.idFromDID(genesisDID);
62376
63185
  const stateProof = await this._stateStorage.getGISTProof(id.bigInt());
62377
63186
  const gistProof = toGISTProof(stateProof);
62378
63187
  circuitInputs.gistProof = gistProof;
62379
63188
  // auth inputs
62380
63189
  if (circuitInputs.isBJJAuthEnabled === 1) {
62381
- const authPrepared = await this.prepareAuthBJJCredential(genesisDID);
63190
+ const authPrepared = await this.prepareAuthBJJCredential(identifier);
62382
63191
  const authClaimData = await this.newCircuitClaimData({
62383
63192
  credential: authPrepared.credential,
62384
63193
  credentialCoreClaim: authPrepared.coreClaim
62385
63194
  });
62386
63195
  const signature = await this._identityWallet.signChallenge(circuitInputs.challenge, authPrepared.credential);
62387
- circuitInputs.profileNonce = BigInt(authProfileNonce);
62388
63196
  circuitInputs.authClaim = authClaimData.claim;
62389
63197
  circuitInputs.authClaimIncMtp = authClaimData.proof;
62390
63198
  circuitInputs.authClaimNonRevMtp = authPrepared.nonRevProof.proof;
@@ -63281,6 +64089,32 @@ class ProofService {
63281
64089
  pub_signals
63282
64090
  };
63283
64091
  }
64092
+ /** {@inheritdoc IProofService.generateAuthProof} */
64093
+ async generateAuthProof(circuitId, identifier, opts) {
64094
+ if (!opts) {
64095
+ opts = {
64096
+ skipRevocation: false,
64097
+ challenge: 0n
64098
+ };
64099
+ }
64100
+ let zkProof;
64101
+ switch (circuitId) {
64102
+ case CircuitId.AuthV2:
64103
+ {
64104
+ const challenge = opts.challenge
64105
+ ? BytesHelper.intToBytes(opts.challenge).reverse()
64106
+ : new Uint8Array(32);
64107
+ zkProof = await this.generateAuthV2Proof(challenge, identifier);
64108
+ }
64109
+ return {
64110
+ circuitId: circuitId,
64111
+ proof: zkProof.proof,
64112
+ pub_signals: zkProof.pub_signals
64113
+ };
64114
+ default:
64115
+ throw new Error(`CircuitId ${circuitId} is not supported`);
64116
+ }
64117
+ }
63284
64118
  /** {@inheritdoc IProofService.transitState} */
63285
64119
  async transitState(did, oldTreeState, isOldStateGenesis, stateStorage, // for compatibility with previous versions we leave this parameter
63286
64120
  ethSigner) {
@@ -64136,5 +64970,5 @@ class IdentityWallet {
64136
64970
  }
64137
64971
  }
64138
64972
 
64139
- export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DiscoverFeatureQueryType, DiscoveryProtocolFeatureType, DiscoveryProtocolHandler, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedDataFormat, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createDiscoveryFeatureDiscloseMessage, createDiscoveryFeatureQueryMessage, createPayment, createPaymentRequest, createProblemReportMessage, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
64973
+ export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthMethod, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DiscoverFeatureQueryType, DiscoveryProtocolFeatureType, DiscoveryProtocolHandler, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedDataFormat, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createDiscoveryFeatureDiscloseMessage, createDiscoveryFeatureQueryMessage, createPayment, createPaymentRequest, createProblemReportMessage, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, packEthIdentityProof, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processProofAuth, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
64140
64974
  //# sourceMappingURL=index.js.map