@0xpolygonid/js-sdk 1.17.8 → 1.18.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 (36) hide show
  1. package/dist/browser/esm/index.js +976 -64
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +976 -63
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/atomic-query-mtp-v2-on-chain.js +10 -0
  6. package/dist/node/cjs/circuits/atomic-query-sig-v2-on-chain.js +10 -0
  7. package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +10 -0
  8. package/dist/node/cjs/iden3comm/constants.js +2 -0
  9. package/dist/node/cjs/iden3comm/handlers/contract-request.js +73 -10
  10. package/dist/node/cjs/storage/blockchain/abi/ZkpVerifier.json +530 -9
  11. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +293 -42
  12. package/dist/node/cjs/utils/did-helper.js +37 -1
  13. package/dist/node/esm/circuits/atomic-query-mtp-v2-on-chain.js +10 -0
  14. package/dist/node/esm/circuits/atomic-query-sig-v2-on-chain.js +10 -0
  15. package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +10 -0
  16. package/dist/node/esm/iden3comm/constants.js +2 -0
  17. package/dist/node/esm/iden3comm/handlers/contract-request.js +73 -10
  18. package/dist/node/esm/storage/blockchain/abi/ZkpVerifier.json +530 -9
  19. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +293 -42
  20. package/dist/node/esm/utils/did-helper.js +35 -0
  21. package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts +4 -2
  22. package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts +4 -2
  23. package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +4 -2
  24. package/dist/types/circuits/common.d.ts +31 -0
  25. package/dist/types/iden3comm/constants.d.ts +1 -0
  26. package/dist/types/iden3comm/handlers/contract-request.d.ts +14 -3
  27. package/dist/types/iden3comm/types/protocol/auth.d.ts +11 -1
  28. package/dist/types/iden3comm/types/protocol/contract-request.d.ts +16 -1
  29. package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +2 -2
  30. package/dist/types/proof/verifiers/query.d.ts +4 -3
  31. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +44 -12
  32. package/dist/types/storage/entities/state.d.ts +44 -0
  33. package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts +22 -1
  34. package/dist/types/utils/did-helper.d.ts +12 -1
  35. package/dist/types/verifiable/presentation.d.ts +2 -2
  36. package/package.json +1 -1
@@ -1281,6 +1281,13 @@ var sha3 = {exports: {}};
1281
1281
 
1282
1282
  var sha3Exports = sha3.exports;
1283
1283
 
1284
+ /**
1285
+ * Supported DID Document Signatures
1286
+ */
1287
+ var DIDDocumentSignature;
1288
+ (function (DIDDocumentSignature) {
1289
+ DIDDocumentSignature["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
1290
+ })(DIDDocumentSignature || (DIDDocumentSignature = {}));
1284
1291
  /**
1285
1292
  * Checks if state is genesis state
1286
1293
  *
@@ -1344,6 +1351,34 @@ const resolveDIDDocumentAuth = async (did, resolveURL, state) => {
1344
1351
  const didResolutionRes = (await resp.json());
1345
1352
  return didResolutionRes.didDocument?.verificationMethod?.find((i) => i.type === 'Iden3StateInfo2023');
1346
1353
  };
1354
+ function emptyStateDID(did) {
1355
+ const id = DID.idFromDID(did);
1356
+ const didType = buildDIDType(DID.methodFromId(id), DID.blockchainFromId(id), DID.networkIdFromId(id));
1357
+ const identifier = Id$1.idGenesisFromIdenState(didType, 0n);
1358
+ const emptyDID = DID.parseFromId(identifier);
1359
+ return emptyDID;
1360
+ }
1361
+ const resolveDidDocument = async (did, resolverUrl, opts) => {
1362
+ let didString = did.string().replace(/:/g, '%3A');
1363
+ // for gist resolve we have to `hide` user did (look into resolver implementation)
1364
+ const isGistRequest = opts?.gist && !opts.state;
1365
+ if (isGistRequest) {
1366
+ didString = emptyStateDID(did).string();
1367
+ }
1368
+ let url = `${resolverUrl}/1.0/identifiers/${didString}`;
1369
+ if (opts?.signature) {
1370
+ url += `?signature=${opts.signature}`;
1371
+ }
1372
+ if (opts?.state) {
1373
+ url += `${url.includes('?') ? '&' : '?'}state=${opts.state.hex()}`;
1374
+ }
1375
+ if (opts?.gist) {
1376
+ url += `${url.includes('?') ? '&' : '?'}gist=${opts.gist.hex()}`;
1377
+ }
1378
+ const resp = await fetch(url);
1379
+ const data = await resp.json();
1380
+ return data;
1381
+ };
1347
1382
  const buildDIDFromEthPubKey = (didType, pubKeyEth) => {
1348
1383
  // Use Keccak-256 hash function to get public key hash
1349
1384
  const hashOfPublicKey = sha3Exports.keccak256(hexToBytes$3(pubKeyEth));
@@ -49793,6 +49828,16 @@ class AtomicQueryMTPV2OnChainPubSignals extends BaseConfig {
49793
49828
  fieldIdx++;
49794
49829
  return this;
49795
49830
  }
49831
+ /** {@inheritDoc IStateInfoPubSignals.getStatesInfo} */
49832
+ getStatesInfo() {
49833
+ return {
49834
+ states: [
49835
+ { id: this.issuerID, state: this.issuerClaimIdenState },
49836
+ { id: this.issuerID, state: this.issuerClaimNonRevState }
49837
+ ],
49838
+ gists: [{ id: this.userID, root: this.gistRoot }]
49839
+ };
49840
+ }
49796
49841
  }
49797
49842
 
49798
49843
  /**
@@ -50574,6 +50619,16 @@ class AtomicQueryV3OnChainPubSignals extends BaseConfig {
50574
50619
  this.isBJJAuthEnabled = parseInt(sVals[fieldIdx]);
50575
50620
  return this;
50576
50621
  }
50622
+ /** {@inheritDoc IStateInfoPubSignals.getStatesInfo} */
50623
+ getStatesInfo() {
50624
+ return {
50625
+ states: [
50626
+ { id: this.issuerID, state: this.issuerState },
50627
+ { id: this.issuerID, state: this.issuerClaimNonRevState }
50628
+ ],
50629
+ gists: [{ id: this.userID, root: this.gistRoot }]
50630
+ };
50631
+ }
50577
50632
  }
50578
50633
 
50579
50634
  /**
@@ -50799,6 +50854,16 @@ class AtomicQuerySigV2OnChainPubSignals extends BaseConfig {
50799
50854
  fieldIdx++;
50800
50855
  return this;
50801
50856
  }
50857
+ /** {@inheritDoc IStateInfoPubSignals.getStatesInfo} */
50858
+ getStatesInfo() {
50859
+ return {
50860
+ states: [
50861
+ { id: this.issuerID, state: this.issuerAuthState },
50862
+ { id: this.issuerID, state: this.issuerClaimNonRevState }
50863
+ ],
50864
+ gists: [{ id: this.userID, root: this.gistRoot }]
50865
+ };
50866
+ }
50802
50867
  }
50803
50868
 
50804
50869
  /**
@@ -52358,6 +52423,103 @@ class EthStateStorage {
52358
52423
  }
52359
52424
 
52360
52425
  var abi$1 = [
52426
+ {
52427
+ inputs: [
52428
+ ],
52429
+ name: "InvalidInitialization",
52430
+ type: "error"
52431
+ },
52432
+ {
52433
+ inputs: [
52434
+ {
52435
+ internalType: "string",
52436
+ name: "message",
52437
+ type: "string"
52438
+ },
52439
+ {
52440
+ internalType: "uint64",
52441
+ name: "requestId",
52442
+ type: "uint64"
52443
+ },
52444
+ {
52445
+ internalType: "uint256",
52446
+ name: "linkID",
52447
+ type: "uint256"
52448
+ },
52449
+ {
52450
+ internalType: "uint64",
52451
+ name: "requestIdToCompare",
52452
+ type: "uint64"
52453
+ },
52454
+ {
52455
+ internalType: "uint256",
52456
+ name: "linkIdToCompare",
52457
+ type: "uint256"
52458
+ }
52459
+ ],
52460
+ name: "LinkedProofError",
52461
+ type: "error"
52462
+ },
52463
+ {
52464
+ inputs: [
52465
+ ],
52466
+ name: "NotInitializing",
52467
+ type: "error"
52468
+ },
52469
+ {
52470
+ inputs: [
52471
+ {
52472
+ internalType: "address",
52473
+ name: "owner",
52474
+ type: "address"
52475
+ }
52476
+ ],
52477
+ name: "OwnableInvalidOwner",
52478
+ type: "error"
52479
+ },
52480
+ {
52481
+ inputs: [
52482
+ {
52483
+ internalType: "address",
52484
+ name: "account",
52485
+ type: "address"
52486
+ }
52487
+ ],
52488
+ name: "OwnableUnauthorizedAccount",
52489
+ type: "error"
52490
+ },
52491
+ {
52492
+ anonymous: false,
52493
+ inputs: [
52494
+ {
52495
+ indexed: false,
52496
+ internalType: "uint64",
52497
+ name: "version",
52498
+ type: "uint64"
52499
+ }
52500
+ ],
52501
+ name: "Initialized",
52502
+ type: "event"
52503
+ },
52504
+ {
52505
+ anonymous: false,
52506
+ inputs: [
52507
+ {
52508
+ indexed: true,
52509
+ internalType: "address",
52510
+ name: "previousOwner",
52511
+ type: "address"
52512
+ },
52513
+ {
52514
+ indexed: true,
52515
+ internalType: "address",
52516
+ name: "newOwner",
52517
+ type: "address"
52518
+ }
52519
+ ],
52520
+ name: "OwnershipTransferStarted",
52521
+ type: "event"
52522
+ },
52361
52523
  {
52362
52524
  anonymous: false,
52363
52525
  inputs: [
@@ -52377,6 +52539,62 @@ var abi$1 = [
52377
52539
  name: "OwnershipTransferred",
52378
52540
  type: "event"
52379
52541
  },
52542
+ {
52543
+ anonymous: false,
52544
+ inputs: [
52545
+ {
52546
+ indexed: true,
52547
+ internalType: "uint64",
52548
+ name: "requestId",
52549
+ type: "uint64"
52550
+ },
52551
+ {
52552
+ indexed: true,
52553
+ internalType: "address",
52554
+ name: "requestOwner",
52555
+ type: "address"
52556
+ },
52557
+ {
52558
+ indexed: false,
52559
+ internalType: "string",
52560
+ name: "metadata",
52561
+ type: "string"
52562
+ },
52563
+ {
52564
+ indexed: false,
52565
+ internalType: "address",
52566
+ name: "validator",
52567
+ type: "address"
52568
+ },
52569
+ {
52570
+ indexed: false,
52571
+ internalType: "bytes",
52572
+ name: "data",
52573
+ type: "bytes"
52574
+ }
52575
+ ],
52576
+ name: "ZKPRequestSet",
52577
+ type: "event"
52578
+ },
52579
+ {
52580
+ anonymous: false,
52581
+ inputs: [
52582
+ {
52583
+ indexed: true,
52584
+ internalType: "uint64",
52585
+ name: "requestId",
52586
+ type: "uint64"
52587
+ },
52588
+ {
52589
+ indexed: true,
52590
+ internalType: "address",
52591
+ name: "caller",
52592
+ type: "address"
52593
+ }
52594
+ ],
52595
+ name: "ZKPResponseSubmitted",
52596
+ type: "event"
52597
+ },
52380
52598
  {
52381
52599
  inputs: [
52382
52600
  ],
@@ -52391,6 +52609,165 @@ var abi$1 = [
52391
52609
  stateMutability: "view",
52392
52610
  type: "function"
52393
52611
  },
52612
+ {
52613
+ inputs: [
52614
+ ],
52615
+ name: "VERSION",
52616
+ outputs: [
52617
+ {
52618
+ internalType: "string",
52619
+ name: "",
52620
+ type: "string"
52621
+ }
52622
+ ],
52623
+ stateMutability: "view",
52624
+ type: "function"
52625
+ },
52626
+ {
52627
+ inputs: [
52628
+ ],
52629
+ name: "acceptOwnership",
52630
+ outputs: [
52631
+ ],
52632
+ stateMutability: "nonpayable",
52633
+ type: "function"
52634
+ },
52635
+ {
52636
+ inputs: [
52637
+ {
52638
+ internalType: "contract ICircuitValidator",
52639
+ name: "validator",
52640
+ type: "address"
52641
+ }
52642
+ ],
52643
+ name: "addValidatorToWhitelist",
52644
+ outputs: [
52645
+ ],
52646
+ stateMutability: "nonpayable",
52647
+ type: "function"
52648
+ },
52649
+ {
52650
+ inputs: [
52651
+ {
52652
+ internalType: "uint64",
52653
+ name: "requestId",
52654
+ type: "uint64"
52655
+ }
52656
+ ],
52657
+ name: "disableZKPRequest",
52658
+ outputs: [
52659
+ ],
52660
+ stateMutability: "nonpayable",
52661
+ type: "function"
52662
+ },
52663
+ {
52664
+ inputs: [
52665
+ {
52666
+ internalType: "uint64",
52667
+ name: "requestId",
52668
+ type: "uint64"
52669
+ }
52670
+ ],
52671
+ name: "enableZKPRequest",
52672
+ outputs: [
52673
+ ],
52674
+ stateMutability: "nonpayable",
52675
+ type: "function"
52676
+ },
52677
+ {
52678
+ inputs: [
52679
+ {
52680
+ internalType: "address",
52681
+ name: "sender",
52682
+ type: "address"
52683
+ },
52684
+ {
52685
+ internalType: "uint64",
52686
+ name: "requestId",
52687
+ type: "uint64"
52688
+ }
52689
+ ],
52690
+ name: "getProofStatus",
52691
+ outputs: [
52692
+ {
52693
+ components: [
52694
+ {
52695
+ internalType: "bool",
52696
+ name: "isVerified",
52697
+ type: "bool"
52698
+ },
52699
+ {
52700
+ internalType: "string",
52701
+ name: "validatorVersion",
52702
+ type: "string"
52703
+ },
52704
+ {
52705
+ internalType: "uint256",
52706
+ name: "blockNumber",
52707
+ type: "uint256"
52708
+ },
52709
+ {
52710
+ internalType: "uint256",
52711
+ name: "blockTimestamp",
52712
+ type: "uint256"
52713
+ }
52714
+ ],
52715
+ internalType: "struct IZKPVerifier.ProofStatus",
52716
+ name: "",
52717
+ type: "tuple"
52718
+ }
52719
+ ],
52720
+ stateMutability: "view",
52721
+ type: "function"
52722
+ },
52723
+ {
52724
+ inputs: [
52725
+ {
52726
+ internalType: "address",
52727
+ name: "user",
52728
+ type: "address"
52729
+ },
52730
+ {
52731
+ internalType: "uint64",
52732
+ name: "requestId",
52733
+ type: "uint64"
52734
+ },
52735
+ {
52736
+ internalType: "string",
52737
+ name: "key",
52738
+ type: "string"
52739
+ }
52740
+ ],
52741
+ name: "getProofStorageField",
52742
+ outputs: [
52743
+ {
52744
+ internalType: "uint256",
52745
+ name: "",
52746
+ type: "uint256"
52747
+ }
52748
+ ],
52749
+ stateMutability: "view",
52750
+ type: "function"
52751
+ },
52752
+ {
52753
+ inputs: [
52754
+ {
52755
+ internalType: "uint64",
52756
+ name: "requestId",
52757
+ type: "uint64"
52758
+ }
52759
+ ],
52760
+ name: "getRequestOwner",
52761
+ outputs: [
52762
+ {
52763
+ internalType: "address",
52764
+ name: "",
52765
+ type: "address"
52766
+ }
52767
+ ],
52768
+ stateMutability: "view",
52769
+ type: "function"
52770
+ },
52394
52771
  {
52395
52772
  inputs: [
52396
52773
  {
@@ -52420,7 +52797,7 @@ var abi$1 = [
52420
52797
  }
52421
52798
  ],
52422
52799
  internalType: "struct IZKPVerifier.ZKPRequest",
52423
- name: "",
52800
+ name: "zkpRequest",
52424
52801
  type: "tuple"
52425
52802
  }
52426
52803
  ],
@@ -52482,6 +52859,82 @@ var abi$1 = [
52482
52859
  stateMutability: "view",
52483
52860
  type: "function"
52484
52861
  },
52862
+ {
52863
+ inputs: [
52864
+ {
52865
+ internalType: "contract IStateCrossChain",
52866
+ name: "stateCrossChain",
52867
+ type: "address"
52868
+ }
52869
+ ],
52870
+ name: "initialize",
52871
+ outputs: [
52872
+ ],
52873
+ stateMutability: "nonpayable",
52874
+ type: "function"
52875
+ },
52876
+ {
52877
+ inputs: [
52878
+ {
52879
+ internalType: "address",
52880
+ name: "sender",
52881
+ type: "address"
52882
+ },
52883
+ {
52884
+ internalType: "uint64",
52885
+ name: "requestId",
52886
+ type: "uint64"
52887
+ }
52888
+ ],
52889
+ name: "isProofVerified",
52890
+ outputs: [
52891
+ {
52892
+ internalType: "bool",
52893
+ name: "",
52894
+ type: "bool"
52895
+ }
52896
+ ],
52897
+ stateMutability: "view",
52898
+ type: "function"
52899
+ },
52900
+ {
52901
+ inputs: [
52902
+ {
52903
+ internalType: "contract ICircuitValidator",
52904
+ name: "validator",
52905
+ type: "address"
52906
+ }
52907
+ ],
52908
+ name: "isWhitelistedValidator",
52909
+ outputs: [
52910
+ {
52911
+ internalType: "bool",
52912
+ name: "",
52913
+ type: "bool"
52914
+ }
52915
+ ],
52916
+ stateMutability: "view",
52917
+ type: "function"
52918
+ },
52919
+ {
52920
+ inputs: [
52921
+ {
52922
+ internalType: "uint64",
52923
+ name: "requestId",
52924
+ type: "uint64"
52925
+ }
52926
+ ],
52927
+ name: "isZKPRequestEnabled",
52928
+ outputs: [
52929
+ {
52930
+ internalType: "bool",
52931
+ name: "",
52932
+ type: "bool"
52933
+ }
52934
+ ],
52935
+ stateMutability: "view",
52936
+ type: "function"
52937
+ },
52485
52938
  {
52486
52939
  inputs: [
52487
52940
  ],
@@ -52498,26 +52951,30 @@ var abi$1 = [
52498
52951
  },
52499
52952
  {
52500
52953
  inputs: [
52954
+ ],
52955
+ name: "pendingOwner",
52956
+ outputs: [
52501
52957
  {
52502
52958
  internalType: "address",
52503
52959
  name: "",
52504
52960
  type: "address"
52505
- },
52506
- {
52507
- internalType: "uint64",
52508
- name: "",
52509
- type: "uint64"
52510
52961
  }
52511
52962
  ],
52512
- name: "proofs",
52513
- outputs: [
52963
+ stateMutability: "view",
52964
+ type: "function"
52965
+ },
52966
+ {
52967
+ inputs: [
52514
52968
  {
52515
- internalType: "bool",
52516
- name: "",
52517
- type: "bool"
52969
+ internalType: "contract ICircuitValidator",
52970
+ name: "validator",
52971
+ type: "address"
52518
52972
  }
52519
52973
  ],
52520
- stateMutability: "view",
52974
+ name: "removeValidatorFromWhitelist",
52975
+ outputs: [
52976
+ ],
52977
+ stateMutability: "nonpayable",
52521
52978
  type: "function"
52522
52979
  },
52523
52980
  {
@@ -52548,6 +53005,25 @@ var abi$1 = [
52548
53005
  stateMutability: "view",
52549
53006
  type: "function"
52550
53007
  },
53008
+ {
53009
+ inputs: [
53010
+ {
53011
+ internalType: "uint64",
53012
+ name: "requestId",
53013
+ type: "uint64"
53014
+ },
53015
+ {
53016
+ internalType: "address",
53017
+ name: "requestOwner",
53018
+ type: "address"
53019
+ }
53020
+ ],
53021
+ name: "setRequestOwner",
53022
+ outputs: [
53023
+ ],
53024
+ stateMutability: "nonpayable",
53025
+ type: "function"
53026
+ },
52551
53027
  {
52552
53028
  inputs: [
52553
53029
  {
@@ -52618,6 +53094,42 @@ var abi$1 = [
52618
53094
  stateMutability: "nonpayable",
52619
53095
  type: "function"
52620
53096
  },
53097
+ {
53098
+ inputs: [
53099
+ {
53100
+ components: [
53101
+ {
53102
+ internalType: "uint64",
53103
+ name: "requestId",
53104
+ type: "uint64"
53105
+ },
53106
+ {
53107
+ internalType: "bytes",
53108
+ name: "zkProof",
53109
+ type: "bytes"
53110
+ },
53111
+ {
53112
+ internalType: "bytes",
53113
+ name: "data",
53114
+ type: "bytes"
53115
+ }
53116
+ ],
53117
+ internalType: "struct ZKPResponse[]",
53118
+ name: "responses",
53119
+ type: "tuple[]"
53120
+ },
53121
+ {
53122
+ internalType: "bytes",
53123
+ name: "crossChainProof",
53124
+ type: "bytes"
53125
+ }
53126
+ ],
53127
+ name: "submitZKPResponseV2",
53128
+ outputs: [
53129
+ ],
53130
+ stateMutability: "nonpayable",
53131
+ type: "function"
53132
+ },
52621
53133
  {
52622
53134
  inputs: [
52623
53135
  {
@@ -52631,9 +53143,113 @@ var abi$1 = [
52631
53143
  ],
52632
53144
  stateMutability: "nonpayable",
52633
53145
  type: "function"
53146
+ },
53147
+ {
53148
+ inputs: [
53149
+ {
53150
+ internalType: "address",
53151
+ name: "sender",
53152
+ type: "address"
53153
+ },
53154
+ {
53155
+ internalType: "uint64[]",
53156
+ name: "requestIds",
53157
+ type: "uint64[]"
53158
+ }
53159
+ ],
53160
+ name: "verifyLinkedProofs",
53161
+ outputs: [
53162
+ ],
53163
+ stateMutability: "view",
53164
+ type: "function"
53165
+ },
53166
+ {
53167
+ inputs: [
53168
+ {
53169
+ internalType: "uint64",
53170
+ name: "requestId",
53171
+ type: "uint64"
53172
+ },
53173
+ {
53174
+ internalType: "uint256[]",
53175
+ name: "inputs",
53176
+ type: "uint256[]"
53177
+ },
53178
+ {
53179
+ internalType: "uint256[2]",
53180
+ name: "a",
53181
+ type: "uint256[2]"
53182
+ },
53183
+ {
53184
+ internalType: "uint256[2][2]",
53185
+ name: "b",
53186
+ type: "uint256[2][2]"
53187
+ },
53188
+ {
53189
+ internalType: "uint256[2]",
53190
+ name: "c",
53191
+ type: "uint256[2]"
53192
+ },
53193
+ {
53194
+ internalType: "address",
53195
+ name: "sender",
53196
+ type: "address"
53197
+ }
53198
+ ],
53199
+ name: "verifyZKPResponse",
53200
+ outputs: [
53201
+ {
53202
+ components: [
53203
+ {
53204
+ internalType: "string",
53205
+ name: "key",
53206
+ type: "string"
53207
+ },
53208
+ {
53209
+ internalType: "uint256",
53210
+ name: "inputValue",
53211
+ type: "uint256"
53212
+ }
53213
+ ],
53214
+ internalType: "struct ICircuitValidator.KeyToInputValue[]",
53215
+ name: "",
53216
+ type: "tuple[]"
53217
+ }
53218
+ ],
53219
+ stateMutability: "nonpayable",
53220
+ type: "function"
53221
+ },
53222
+ {
53223
+ inputs: [
53224
+ ],
53225
+ name: "version",
53226
+ outputs: [
53227
+ {
53228
+ internalType: "string",
53229
+ name: "",
53230
+ type: "string"
53231
+ }
53232
+ ],
53233
+ stateMutability: "pure",
53234
+ type: "function"
52634
53235
  }
52635
53236
  ];
52636
53237
 
53238
+ const maxGasLimit = 10000000n;
53239
+ /**
53240
+ * Supported function signature for SubmitZKPResponse
53241
+ */
53242
+ var FunctionSignatures;
53243
+ (function (FunctionSignatures) {
53244
+ /**
53245
+ * solidity identifier for function signature:
53246
+ * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
53247
+ * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
53248
+ */
53249
+ FunctionSignatures["SubmitZKPResponseV1"] = "b68967e2";
53250
+ //function submitZKPResponseV2(tuple[](uint64 requestId,bytes zkProof,bytes data),bytes crossChainProof)
53251
+ FunctionSignatures["SubmitZKPResponseV2"] = "ade09fcd";
53252
+ })(FunctionSignatures || (FunctionSignatures = {}));
52637
53253
  /**
52638
53254
  * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
52639
53255
  * and submitZKPResponse.
@@ -52648,71 +53264,303 @@ class OnChainZKPVerifier {
52648
53264
  * @beta
52649
53265
  * @param {EthConnectionConfig[]} - array of ETH configs
52650
53266
  */
52651
- constructor(_configs) {
53267
+ constructor(_configs, _opts) {
52652
53268
  this._configs = _configs;
53269
+ this._opts = _opts;
53270
+ /**
53271
+ * supported circuits
53272
+ */
53273
+ this._supportedCircuits = [
53274
+ CircuitId.AtomicQueryMTPV2OnChain,
53275
+ CircuitId.AtomicQuerySigV2OnChain,
53276
+ CircuitId.AtomicQueryV3OnChain
53277
+ ];
52653
53278
  /**
52654
- * solidity identifier for function signature:
52655
- * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
52656
- * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
53279
+ * abi coder to encode/decode structures to solidity bytes
52657
53280
  */
52658
- this._supportedMethodId = 'b68967e2';
53281
+ this._abiCoder = new AbiCoder();
52659
53282
  }
52660
53283
  /**
52661
- * Submit ZKP Responses to OnChainZKPVerifier contract.
52662
- * @beta
52663
- * @param {Signer} ethSigner - tx signer
52664
- * @param {txData} ContractInvokeTransactionData - transaction data
52665
- * @param {ZeroKnowledgeProofResponse[]} zkProofResponses - zkProofResponses
52666
- * @returns {Promise<Map<string, ZeroKnowledgeProofResponse>>} - map of transaction hash - ZeroKnowledgeProofResponse
53284
+ * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
53285
+ */
53286
+ async prepareTxArgsSubmitV1(txData, zkProofResponse) {
53287
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV1) {
53288
+ throw new Error(`prepareTxArgsSubmitV1 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV1}' is supported.`);
53289
+ }
53290
+ const requestID = zkProofResponse.id;
53291
+ const inputs = zkProofResponse.pub_signals;
53292
+ const payload = [
53293
+ requestID,
53294
+ inputs,
53295
+ zkProofResponse.proof.pi_a.slice(0, 2),
53296
+ [
53297
+ [zkProofResponse.proof.pi_b[0][1], zkProofResponse.proof.pi_b[0][0]],
53298
+ [zkProofResponse.proof.pi_b[1][1], zkProofResponse.proof.pi_b[1][0]]
53299
+ ],
53300
+ zkProofResponse.proof.pi_c.slice(0, 2)
53301
+ ];
53302
+ return payload;
53303
+ }
53304
+ /**
53305
+ * {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
52667
53306
  */
52668
53307
  async submitZKPResponse(ethSigner, txData, zkProofResponses) {
52669
53308
  const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
52670
53309
  if (!chainConfig) {
52671
53310
  throw new Error(`config for chain id ${txData.chain_id} was not found`);
52672
53311
  }
52673
- if (txData.method_id.replace('0x', '') !== this._supportedMethodId) {
52674
- throw new Error(`submit doesn't implement requested method id. Only '0x${this._supportedMethodId}' is supported.`);
53312
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV1) {
53313
+ throw new Error(`submitZKPResponse function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV1}' is supported.`);
52675
53314
  }
52676
53315
  const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
52677
- const verifierContract = new Contract(txData.contract_address, abi$1, provider);
52678
53316
  ethSigner = ethSigner.connect(provider);
52679
- const contract = verifierContract.connect(ethSigner);
52680
53317
  const response = new Map();
52681
- for (const zkProof of zkProofResponses) {
52682
- const requestID = zkProof.id;
52683
- const inputs = zkProof.pub_signals;
52684
- const payload = [
52685
- requestID,
52686
- inputs,
52687
- zkProof.proof.pi_a.slice(0, 2),
52688
- [
52689
- [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
52690
- [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
52691
- ],
52692
- zkProof.proof.pi_c.slice(0, 2)
52693
- ];
52694
- const feeData = await provider.getFeeData();
52695
- const maxFeePerGas = chainConfig.maxFeePerGas
52696
- ? BigInt(chainConfig.maxFeePerGas)
52697
- : feeData.maxFeePerGas;
52698
- const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
52699
- ? BigInt(chainConfig.maxPriorityFeePerGas)
52700
- : feeData.maxPriorityFeePerGas;
52701
- const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
52702
- const txData = await contract.submitZKPResponse.populateTransaction(...payload);
53318
+ const feeData = await provider.getFeeData();
53319
+ const maxFeePerGas = chainConfig.maxFeePerGas
53320
+ ? BigInt(chainConfig.maxFeePerGas)
53321
+ : feeData.maxFeePerGas;
53322
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
53323
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
53324
+ : feeData.maxPriorityFeePerGas;
53325
+ const verifierContract = new Contract(txData.contract_address, abi$1);
53326
+ for (const zkProofResponse of zkProofResponses) {
53327
+ const txArgs = await this.prepareTxArgsSubmitV1(txData, zkProofResponse);
53328
+ const payload = await verifierContract.submitZKPResponse.populateTransaction(...txArgs);
52703
53329
  const request = {
52704
- to: txData.to,
52705
- data: txData.data,
52706
- gasLimit,
53330
+ to: txData.contract_address,
53331
+ data: payload.data,
52707
53332
  maxFeePerGas,
52708
53333
  maxPriorityFeePerGas
52709
53334
  };
53335
+ let gasLimit;
53336
+ try {
53337
+ gasLimit = await ethSigner.estimateGas(request);
53338
+ }
53339
+ catch (e) {
53340
+ gasLimit = maxGasLimit;
53341
+ }
53342
+ request.gasLimit = gasLimit;
52710
53343
  const transactionService = new TransactionService(provider);
52711
53344
  const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
52712
- response.set(txnHash, zkProof);
53345
+ response.set(txnHash, zkProofResponse);
52713
53346
  }
52714
53347
  return response;
52715
53348
  }
53349
+ /**
53350
+ * {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
53351
+ */
53352
+ async submitZKPResponseV2(ethSigner, txData, zkProofResponses) {
53353
+ const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
53354
+ if (!chainConfig) {
53355
+ throw new Error(`config for chain id ${txData.chain_id} was not found`);
53356
+ }
53357
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
53358
+ throw new Error(`submitZKPResponseV2 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
53359
+ }
53360
+ if (!this._opts?.didResolverUrl) {
53361
+ throw new Error(`did resolver url required for crosschain verification`);
53362
+ }
53363
+ const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
53364
+ ethSigner = ethSigner.connect(provider);
53365
+ const txDataArgs = await this.prepareTxArgsSubmitV2(txData, zkProofResponses);
53366
+ const feeData = await provider.getFeeData();
53367
+ const maxFeePerGas = chainConfig.maxFeePerGas
53368
+ ? BigInt(chainConfig.maxFeePerGas)
53369
+ : feeData.maxFeePerGas;
53370
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
53371
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
53372
+ : feeData.maxPriorityFeePerGas;
53373
+ const verifierContract = new Contract(txData.contract_address, abi$1);
53374
+ const txRequestData = await verifierContract.submitZKPResponseV2.populateTransaction(...txDataArgs);
53375
+ const request = {
53376
+ to: txData.contract_address,
53377
+ data: txRequestData.data,
53378
+ maxFeePerGas,
53379
+ maxPriorityFeePerGas
53380
+ };
53381
+ let gasLimit;
53382
+ try {
53383
+ gasLimit = await ethSigner.estimateGas(request);
53384
+ }
53385
+ catch (e) {
53386
+ gasLimit = maxGasLimit;
53387
+ }
53388
+ request.gasLimit = gasLimit;
53389
+ const transactionService = new TransactionService(provider);
53390
+ const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
53391
+ return new Map().set(txnHash, zkProofResponses);
53392
+ }
53393
+ async prepareTxArgsSubmitV2(txData, zkProofResponses) {
53394
+ if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
53395
+ throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
53396
+ }
53397
+ if (!this._opts?.didResolverUrl) {
53398
+ throw new Error(`did resolver url required for crosschain verification`);
53399
+ }
53400
+ const gistUpdateArr = [];
53401
+ const stateUpdateArr = [];
53402
+ const payload = [];
53403
+ // Resolved gists and states to avoid duplicate requests
53404
+ const gistUpdateResolutionsPending = [];
53405
+ const stateUpdateResolutionsPending = [];
53406
+ for (const zkProof of zkProofResponses) {
53407
+ const requestID = zkProof.id;
53408
+ const inputs = zkProof.pub_signals;
53409
+ if (!this._supportedCircuits.includes(zkProof.circuitId)) {
53410
+ throw new Error(`Circuit ${zkProof.circuitId} not supported by OnChainZKPVerifier`);
53411
+ }
53412
+ const zkProofEncoded = this.packZkpProof(inputs, zkProof.proof.pi_a.slice(0, 2), [
53413
+ [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
53414
+ [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
53415
+ ], zkProof.proof.pi_c.slice(0, 2));
53416
+ const stateInfo = this.getOnChainGistRootStatePubSignals(zkProof.circuitId, zkProof.pub_signals);
53417
+ const gistUpdateResolutions = [];
53418
+ for (const gist of stateInfo.gists) {
53419
+ const gistResolutionPending = gistUpdateResolutionsPending.find((g) => g == JSON.stringify(gist));
53420
+ if (gistResolutionPending) {
53421
+ continue;
53422
+ }
53423
+ gistUpdateResolutionsPending.push(JSON.stringify(gist));
53424
+ gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(gist.id), this._opts.didResolverUrl, { gist: gist.root }));
53425
+ }
53426
+ const stateUpdateResolutions = [];
53427
+ for (const state of stateInfo.states) {
53428
+ const stateResolutionPending = stateUpdateResolutionsPending.find((s) => s == JSON.stringify(state));
53429
+ if (stateResolutionPending) {
53430
+ continue;
53431
+ }
53432
+ stateUpdateResolutionsPending.push(JSON.stringify(state));
53433
+ stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(state.id), this._opts.didResolverUrl, {
53434
+ state: state.state
53435
+ }));
53436
+ }
53437
+ if (gistUpdateResolutions.length > 0) {
53438
+ gistUpdateArr.push(...(await Promise.all(gistUpdateResolutions)));
53439
+ }
53440
+ if (stateUpdateResolutions.length > 0) {
53441
+ stateUpdateArr.push(...(await Promise.all(stateUpdateResolutions)));
53442
+ }
53443
+ const metadataArr = [];
53444
+ if (zkProof.vp) {
53445
+ for (const key in zkProof.vp.verifiableCredential.credentialSubject) {
53446
+ if (key === '@type') {
53447
+ continue;
53448
+ }
53449
+ const metadataValue = poseidon.hashBytes(byteEncoder.encode(JSON.stringify(zkProof.vp.verifiableCredential.credentialSubject[key])));
53450
+ const bytesValue = byteEncoder.encode(metadataValue.toString());
53451
+ metadataArr.push({
53452
+ key,
53453
+ value: bytesValue
53454
+ });
53455
+ }
53456
+ }
53457
+ const metadata = this.packMetadatas(metadataArr);
53458
+ payload.push({
53459
+ requestId: requestID,
53460
+ zkProof: zkProofEncoded,
53461
+ data: metadata
53462
+ });
53463
+ }
53464
+ const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr);
53465
+ return [payload, crossChainProofs];
53466
+ }
53467
+ packZkpProof(inputs, a, b, c) {
53468
+ return this._abiCoder.encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
53469
+ }
53470
+ packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
53471
+ const proofs = [];
53472
+ for (const globalStateUpdate of gistUpdateArr) {
53473
+ proofs.push({
53474
+ proofType: 'globalStateProof',
53475
+ proof: this.packGlobalStateMsg(globalStateUpdate)
53476
+ });
53477
+ }
53478
+ for (const stateUpdate of stateUpdateArr) {
53479
+ proofs.push({
53480
+ proofType: 'stateProof',
53481
+ proof: this.packIdentityStateMsg(stateUpdate)
53482
+ });
53483
+ }
53484
+ return this._abiCoder.encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
53485
+ }
53486
+ packGlobalStateMsg(msg) {
53487
+ return this._abiCoder.encode([
53488
+ 'tuple(' +
53489
+ 'tuple(' +
53490
+ 'uint256 timestamp,' +
53491
+ 'bytes2 idType,' +
53492
+ 'uint256 root,' +
53493
+ 'uint256 replacedAtTimestamp' +
53494
+ ') globalStateMsg,' +
53495
+ 'bytes signature,' +
53496
+ ')'
53497
+ ], [msg]);
53498
+ }
53499
+ packIdentityStateMsg(msg) {
53500
+ return this._abiCoder.encode([
53501
+ 'tuple(' +
53502
+ 'tuple(' +
53503
+ 'uint256 timestamp,' +
53504
+ 'uint256 id,' +
53505
+ 'uint256 state,' +
53506
+ 'uint256 replacedAtTimestamp' +
53507
+ ') idStateMsg,' +
53508
+ 'bytes signature,' +
53509
+ ')'
53510
+ ], [msg]);
53511
+ }
53512
+ packMetadatas(metas) {
53513
+ return this._abiCoder.encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
53514
+ }
53515
+ getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
53516
+ let atomicQueryPubSignals;
53517
+ switch (onChainCircuitId) {
53518
+ case CircuitId.AtomicQueryMTPV2OnChain:
53519
+ atomicQueryPubSignals = new AtomicQueryMTPV2OnChainPubSignals();
53520
+ break;
53521
+ case CircuitId.AtomicQuerySigV2OnChain:
53522
+ atomicQueryPubSignals = new AtomicQuerySigV2OnChainPubSignals();
53523
+ break;
53524
+ case CircuitId.AtomicQueryV3OnChain:
53525
+ atomicQueryPubSignals = new AtomicQueryV3OnChainPubSignals();
53526
+ break;
53527
+ }
53528
+ const encodedInputs = byteEncoder.encode(JSON.stringify(inputs));
53529
+ atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
53530
+ return atomicQueryPubSignals.getStatesInfo();
53531
+ }
53532
+ async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
53533
+ const didDoc = await resolveDidDocument(did, resolverUrl, {
53534
+ ...opts,
53535
+ signature: DIDDocumentSignature.EthereumEip712Signature2021
53536
+ });
53537
+ if (!didDoc.didResolutionMetadata.proof?.length) {
53538
+ throw new Error('No proof found in resolved DID document');
53539
+ }
53540
+ const message = didDoc.didResolutionMetadata.proof[0].eip712.message;
53541
+ const signature = didDoc.didResolutionMetadata.proof[0].proofValue;
53542
+ const isGistRequest = opts?.gist && !opts.state;
53543
+ if (isGistRequest) {
53544
+ return {
53545
+ globalStateMsg: {
53546
+ timestamp: message.timestamp,
53547
+ idType: message.idType,
53548
+ root: message.root,
53549
+ replacedAtTimestamp: message.replacedAtTimestamp
53550
+ },
53551
+ signature
53552
+ };
53553
+ }
53554
+ return {
53555
+ idStateMsg: {
53556
+ timestamp: message.timestamp,
53557
+ id: message.id,
53558
+ state: message.state,
53559
+ replacedAtTimestamp: message.replacedAtTimestamp
53560
+ },
53561
+ signature
53562
+ };
53563
+ }
52716
53564
  }
52717
53565
 
52718
53566
  var abi = [
@@ -54527,6 +55375,8 @@ const PROTOCOL_MESSAGE_TYPE = Object.freeze({
54527
55375
  REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status`,
54528
55376
  // ContractInvokeRequestMessageType is type for request of contract invoke request
54529
55377
  CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request`,
55378
+ // ContractInvokeResponseMessageType is type for response of contract invoke request
55379
+ CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-response`,
54530
55380
  // CredentialOnchainOfferMessageType is type of message with credential onchain offering
54531
55381
  CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer`,
54532
55382
  // ProposalRequestMessageType is type for proposal-request message
@@ -56827,9 +57677,11 @@ class ContractRequestHandler extends AbstractMessageHandler {
56827
57677
  }
56828
57678
  async handle(message, ctx) {
56829
57679
  switch (message.type) {
56830
- case PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE:
56831
- await this.handleContractInvoke(message, ctx);
56832
- return null;
57680
+ case PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: {
57681
+ const ciMessage = message;
57682
+ const txHashResponsesMap = await this.handleContractInvoke(ciMessage, ctx);
57683
+ return this.createContractInvokeResponse(ciMessage, txHashResponsesMap);
57684
+ }
56833
57685
  default:
56834
57686
  return super.handle(message, ctx);
56835
57687
  }
@@ -56849,7 +57701,21 @@ class ContractRequestHandler extends AbstractMessageHandler {
56849
57701
  }
56850
57702
  const verifierDid = message.from ? DID.parse(message.from) : undefined;
56851
57703
  const zkpResponses = await processZeroKnowledgeProofRequests(did, message?.body?.scope, verifierDid, this._proofService, { ethSigner, challenge, supportedCircuits: this._supportedCircuits });
56852
- return this._zkpVerifier.submitZKPResponse(ethSigner, message.body.transaction_data, zkpResponses);
57704
+ const methodId = message.body.transaction_data.method_id.replace('0x', '');
57705
+ switch (methodId) {
57706
+ case FunctionSignatures.SubmitZKPResponseV2:
57707
+ return this._zkpVerifier.submitZKPResponseV2(ethSigner, message.body.transaction_data, zkpResponses);
57708
+ case FunctionSignatures.SubmitZKPResponseV1: {
57709
+ const txHashZkpResponseMap = await this._zkpVerifier.submitZKPResponse(ethSigner, message.body.transaction_data, zkpResponses);
57710
+ const response = new Map();
57711
+ for (const [txHash, zkpResponse] of txHashZkpResponseMap) {
57712
+ response.set(txHash, [zkpResponse]);
57713
+ }
57714
+ return response;
57715
+ }
57716
+ default:
57717
+ throw new Error(`Not supported method id. Only '${FunctionSignatures.SubmitZKPResponseV1} and ${FunctionSignatures.SubmitZKPResponseV2} are supported.'`);
57718
+ }
56853
57719
  }
56854
57720
  /**
56855
57721
  * unpacks contract-invoke request
@@ -56867,8 +57733,41 @@ class ContractRequestHandler extends AbstractMessageHandler {
56867
57733
  return ciRequest;
56868
57734
  }
56869
57735
  /**
56870
- * handle contract invoker request
57736
+ * creates contract invoke response
57737
+ * @private
56871
57738
  * @beta
57739
+ * @param {ContractInvokeRequest} request - ContractInvokeRequest
57740
+ * @param { Map<string, ZeroKnowledgeProofResponse[]>} responses - map tx hash to array of ZeroKnowledgeProofResponses
57741
+ * @returns `Promise<ContractInvokeResponse>`
57742
+ */
57743
+ async createContractInvokeResponse(request, txHashToZkpResponseMap) {
57744
+ const contractInvokeResponse = {
57745
+ id: request.id,
57746
+ thid: request.thid,
57747
+ type: PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE,
57748
+ from: request.to,
57749
+ to: request.from,
57750
+ body: {
57751
+ transaction_data: request.body.transaction_data,
57752
+ reason: request.body.reason,
57753
+ scope: []
57754
+ }
57755
+ };
57756
+ for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
57757
+ for (const zkpResponse of zkpResponses) {
57758
+ contractInvokeResponse.body.scope.push({
57759
+ txHash,
57760
+ ...zkpResponse
57761
+ });
57762
+ }
57763
+ }
57764
+ return contractInvokeResponse;
57765
+ }
57766
+ /**
57767
+ * handle contract invoke request
57768
+ * supports only 0xb68967e2 method id
57769
+ * @beta
57770
+ * @deprecated
56872
57771
  * @param {did} did - sender DID
56873
57772
  * @param {ContractInvokeRequest} request - contract invoke request
56874
57773
  * @param {ContractInvokeHandlerOptions} opts - handler options
@@ -56876,11 +57775,24 @@ class ContractRequestHandler extends AbstractMessageHandler {
56876
57775
  */
56877
57776
  async handleContractInvokeRequest(did, request, opts) {
56878
57777
  const ciRequest = await this.parseContractInvokeRequest(request);
56879
- return this.handleContractInvoke(ciRequest, {
56880
- senderDid: did,
56881
- ethSigner: opts.ethSigner,
56882
- challenge: opts.challenge
56883
- });
57778
+ if (ciRequest.body.transaction_data.method_id !== FunctionSignatures.SubmitZKPResponseV1) {
57779
+ throw new Error(`please use handle method to work with other method ids`);
57780
+ }
57781
+ if (ciRequest.type !== PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
57782
+ throw new Error('Invalid message type for contract invoke request');
57783
+ }
57784
+ const { ethSigner, challenge } = opts;
57785
+ if (!ethSigner) {
57786
+ throw new Error("Can't sign transaction. Provide Signer in options.");
57787
+ }
57788
+ const { chain_id } = ciRequest.body.transaction_data;
57789
+ const networkFlag = Object.keys(ChainIds).find((key) => ChainIds[key] === chain_id);
57790
+ if (!networkFlag) {
57791
+ throw new Error(`Invalid chain id ${chain_id}`);
57792
+ }
57793
+ const verifierDid = ciRequest.from ? DID.parse(ciRequest.from) : undefined;
57794
+ const zkpResponses = await processZeroKnowledgeProofRequests(did, ciRequest?.body?.scope, verifierDid, this._proofService, { ethSigner, challenge, supportedCircuits: this._supportedCircuits });
57795
+ return this._zkpVerifier.submitZKPResponse(ethSigner, ciRequest.body.transaction_data, zkpResponses);
56884
57796
  }
56885
57797
  }
56886
57798
 
@@ -59481,5 +60393,5 @@ class IdentityWallet {
59481
60393
  }
59482
60394
  }
59483
60395
 
59484
- 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, DataPrepareHandlerFunc, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, 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, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentHandler, PaymentRequestDataType, PaymentRequestType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, 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, createPayment, createPaymentRequest, 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, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
60396
+ 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, 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, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentHandler, PaymentRequestDataType, PaymentRequestType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, 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, createPayment, createPaymentRequest, 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, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, 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, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
59485
60397
  //# sourceMappingURL=index.js.map