@0xpolygonid/js-sdk 1.5.1 → 1.6.0

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 (83) hide show
  1. package/dist/browser/esm/index.js +1685 -468
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +1703 -470
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/atomic-query-mtp-v2-on-chain.js +1 -1
  6. package/dist/node/cjs/circuits/atomic-query-mtp-v2.js +1 -1
  7. package/dist/node/cjs/circuits/atomic-query-sig-v2-on-chain.js +2 -2
  8. package/dist/node/cjs/circuits/atomic-query-sig-v2.js +11 -14
  9. package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +320 -0
  10. package/dist/node/cjs/circuits/atomic-query-v3.js +275 -0
  11. package/dist/node/cjs/circuits/common.js +5 -7
  12. package/dist/node/cjs/circuits/comparer.js +57 -2
  13. package/dist/node/cjs/circuits/index.js +4 -0
  14. package/dist/node/cjs/circuits/linked-multi-query.js +128 -0
  15. package/dist/node/cjs/circuits/linked-nullifier.js +57 -0
  16. package/dist/node/cjs/circuits/models.js +25 -1
  17. package/dist/node/cjs/credentials/credential-wallet.js +2 -10
  18. package/dist/node/cjs/credentials/index.js +1 -0
  19. package/dist/node/cjs/credentials/utils.js +23 -0
  20. package/dist/node/cjs/iden3comm/handlers/auth.js +49 -8
  21. package/dist/node/cjs/iden3comm/handlers/contract-request.js +20 -8
  22. package/dist/node/cjs/proof/common.js +104 -1
  23. package/dist/node/cjs/proof/inputs-generator.js +393 -0
  24. package/dist/node/cjs/proof/proof-service.js +105 -372
  25. package/dist/node/cjs/schema-processor/json/parser.js +7 -0
  26. package/dist/node/cjs/schema-processor/json/validator.js +1 -0
  27. package/dist/node/cjs/storage/filters/jsonQuery.js +73 -8
  28. package/dist/node/cjs/utils/did-helper.js +14 -0
  29. package/dist/node/cjs/utils/index.js +2 -0
  30. package/dist/node/cjs/utils/object.js +42 -0
  31. package/dist/node/cjs/verifiable/presentation.js +34 -33
  32. package/dist/node/cjs/verifiable/proof.js +2 -0
  33. package/dist/node/esm/circuits/atomic-query-mtp-v2-on-chain.js +1 -1
  34. package/dist/node/esm/circuits/atomic-query-mtp-v2.js +1 -1
  35. package/dist/node/esm/circuits/atomic-query-sig-v2-on-chain.js +2 -2
  36. package/dist/node/esm/circuits/atomic-query-sig-v2.js +11 -14
  37. package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +315 -0
  38. package/dist/node/esm/circuits/atomic-query-v3.js +270 -0
  39. package/dist/node/esm/circuits/common.js +4 -6
  40. package/dist/node/esm/circuits/comparer.js +55 -1
  41. package/dist/node/esm/circuits/index.js +4 -0
  42. package/dist/node/esm/circuits/linked-multi-query.js +123 -0
  43. package/dist/node/esm/circuits/linked-nullifier.js +52 -0
  44. package/dist/node/esm/circuits/models.js +25 -1
  45. package/dist/node/esm/credentials/credential-wallet.js +2 -10
  46. package/dist/node/esm/credentials/index.js +1 -0
  47. package/dist/node/esm/credentials/utils.js +19 -0
  48. package/dist/node/esm/iden3comm/handlers/auth.js +50 -9
  49. package/dist/node/esm/iden3comm/handlers/contract-request.js +20 -8
  50. package/dist/node/esm/proof/common.js +101 -2
  51. package/dist/node/esm/proof/inputs-generator.js +389 -0
  52. package/dist/node/esm/proof/proof-service.js +111 -377
  53. package/dist/node/esm/schema-processor/json/parser.js +7 -0
  54. package/dist/node/esm/schema-processor/json/validator.js +1 -0
  55. package/dist/node/esm/storage/filters/jsonQuery.js +74 -9
  56. package/dist/node/esm/utils/did-helper.js +10 -0
  57. package/dist/node/esm/utils/index.js +2 -0
  58. package/dist/node/esm/utils/object.js +38 -0
  59. package/dist/node/esm/verifiable/presentation.js +30 -29
  60. package/dist/node/esm/verifiable/proof.js +2 -0
  61. package/dist/types/circuits/atomic-query-mtp-v2.d.ts +13 -13
  62. package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +142 -0
  63. package/dist/types/circuits/atomic-query-v3.d.ts +120 -0
  64. package/dist/types/circuits/common.d.ts +4 -4
  65. package/dist/types/circuits/comparer.d.ts +33 -1
  66. package/dist/types/circuits/index.d.ts +4 -0
  67. package/dist/types/circuits/linked-multi-query.d.ts +38 -0
  68. package/dist/types/circuits/linked-nullifier.d.ts +37 -0
  69. package/dist/types/circuits/models.d.ts +20 -2
  70. package/dist/types/credentials/index.d.ts +1 -0
  71. package/dist/types/credentials/utils.d.ts +12 -0
  72. package/dist/types/iden3comm/types/packer.d.ts +1 -2
  73. package/dist/types/iden3comm/types/protocol/auth.d.ts +1 -0
  74. package/dist/types/proof/common.d.ts +34 -3
  75. package/dist/types/proof/inputs-generator.d.ts +46 -0
  76. package/dist/types/proof/proof-service.d.ts +14 -25
  77. package/dist/types/schema-processor/json/parser.d.ts +1 -0
  78. package/dist/types/storage/filters/jsonQuery.d.ts +1 -1
  79. package/dist/types/utils/did-helper.d.ts +6 -0
  80. package/dist/types/utils/index.d.ts +2 -0
  81. package/dist/types/utils/object.d.ts +12 -0
  82. package/dist/types/verifiable/presentation.d.ts +6 -10
  83. package/package.json +1 -1
@@ -70,7 +70,7 @@ class AtomicQueryMTPV2OnChainInputs extends common_1.BaseConfig {
70
70
  issuerClaimNonRevRootsTreeRoot: this.claim.nonRevProof?.treeState?.rootOfRoots?.string(),
71
71
  issuerClaimNonRevState: this.claim.nonRevProof?.treeState?.state?.string(),
72
72
  claimSchema: this.claim.claim?.getSchemaHash().bigInt().toString(),
73
- claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaimMerklization()),
73
+ claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaim()),
74
74
  claimPathValue: valueProof.value.toString(),
75
75
  operator: this.query.operator,
76
76
  slotIndex: this.query.slotIndex,
@@ -61,7 +61,7 @@ class AtomicQueryMTPV2Inputs extends common_1.BaseConfig {
61
61
  .toString(),
62
62
  issuerClaimNonRevState: this.claim.nonRevProof?.treeState?.state?.bigInt().toString(),
63
63
  claimSchema: this.claim.claim?.getSchemaHash().bigInt().toString(),
64
- claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaimMerklization()),
64
+ claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaim()),
65
65
  claimPathValue: valueProof.value.toString(),
66
66
  operator: this.query.operator,
67
67
  slotIndex: this.query.slotIndex,
@@ -103,9 +103,9 @@ class AtomicQuerySigV2OnChainInputs extends common_1.BaseConfig {
103
103
  issuerAuthClaimNonRevMtp: this.claim.signatureProof?.issuerAuthNonRevProof?.proof &&
104
104
  (0, common_1.prepareSiblingsStr)(this.claim.signatureProof.issuerAuthNonRevProof.proof, this.getMTLevel()),
105
105
  claimSchema: this.claim.claim?.getSchemaHash().bigInt().toString(),
106
- claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaimMerklization()),
106
+ claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaim()),
107
107
  claimPathValue: valueProof.value.toString(),
108
- operator: this.query?.operator,
108
+ operator: this.query.operator,
109
109
  timestamp: this.currentTimeStamp,
110
110
  // value in this path in merklized json-ld document
111
111
  slotIndex: this.query?.slotIndex,
@@ -52,6 +52,9 @@ class AtomicQuerySigV2Inputs extends common_1.BaseConfig {
52
52
  this.query.valueProof.validate();
53
53
  }
54
54
  const valueProof = this.query.valueProof ?? new models_1.ValueProof();
55
+ const treeState = this.skipClaimRevocationCheck
56
+ ? this.claim.signatureProof?.issuerAuthNonRevProof.treeState
57
+ : this.claim.nonRevProof?.treeState;
55
58
  const s = {
56
59
  requestID: this.requestID.toString(),
57
60
  userGenesisID: this.id.bigInt().toString(),
@@ -59,16 +62,10 @@ class AtomicQuerySigV2Inputs extends common_1.BaseConfig {
59
62
  claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(),
60
63
  issuerID: this.claim.issuerID?.bigInt().toString(),
61
64
  issuerClaim: this.claim.claim?.marshalJson(),
62
- issuerClaimNonRevClaimsTreeRoot: this.claim.nonRevProof?.treeState?.claimsRoot
63
- ?.bigInt()
64
- .toString(),
65
- issuerClaimNonRevRevTreeRoot: this.claim.nonRevProof?.treeState?.revocationRoot
66
- ?.bigInt()
67
- .toString(),
68
- issuerClaimNonRevRootsTreeRoot: this.claim.nonRevProof?.treeState?.rootOfRoots
69
- ?.bigInt()
70
- .toString(),
71
- issuerClaimNonRevState: this.claim.nonRevProof?.treeState?.state?.bigInt().toString(),
65
+ issuerClaimNonRevClaimsTreeRoot: treeState?.claimsRoot.bigInt().toString(),
66
+ issuerClaimNonRevRevTreeRoot: treeState?.revocationRoot.bigInt().toString(),
67
+ issuerClaimNonRevRootsTreeRoot: treeState?.rootOfRoots.bigInt().toString(),
68
+ issuerClaimNonRevState: treeState?.state.bigInt().toString(),
72
69
  issuerClaimNonRevMtp: this.claim.nonRevProof?.proof &&
73
70
  (0, common_1.prepareSiblingsStr)(this.claim.nonRevProof.proof, this.getMTLevel()),
74
71
  issuerClaimSignatureR8x: this.claim.signatureProof?.signature.R8[0].toString(),
@@ -78,18 +75,18 @@ class AtomicQuerySigV2Inputs extends common_1.BaseConfig {
78
75
  issuerAuthClaimMtp: this.claim.signatureProof?.issuerAuthIncProof?.proof &&
79
76
  (0, common_1.prepareSiblingsStr)(this.claim.signatureProof.issuerAuthIncProof.proof, this.getMTLevel()),
80
77
  issuerAuthClaimsTreeRoot: this.claim.signatureProof?.issuerAuthIncProof.treeState?.claimsRoot
81
- ?.bigInt()
78
+ .bigInt()
82
79
  .toString(),
83
80
  issuerAuthRevTreeRoot: this.claim.signatureProof?.issuerAuthIncProof?.treeState?.revocationRoot
84
- ?.bigInt()
81
+ .bigInt()
85
82
  .toString(),
86
83
  issuerAuthRootsTreeRoot: this.claim.signatureProof?.issuerAuthIncProof?.treeState?.rootOfRoots
87
- ?.bigInt()
84
+ .bigInt()
88
85
  .toString(),
89
86
  issuerAuthClaimNonRevMtp: this.claim.signatureProof?.issuerAuthNonRevProof?.proof &&
90
87
  (0, common_1.prepareSiblingsStr)(this.claim.signatureProof.issuerAuthNonRevProof.proof, this.getMTLevel()),
91
88
  claimSchema: this.claim.claim?.getSchemaHash().bigInt().toString(),
92
- claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaimMerklization()),
89
+ claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaim()),
93
90
  claimPathValue: valueProof.value.toString(),
94
91
  operator: this.query.operator,
95
92
  timestamp: this.currentTimeStamp,
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AtomicQueryV3OnChainPubSignals = exports.AtomicQueryV3OnChainInputs = void 0;
4
+ const js_iden3_core_1 = require("@iden3/js-iden3-core");
5
+ const common_1 = require("./common");
6
+ const models_1 = require("./models");
7
+ const js_merkletree_1 = require("@iden3/js-merkletree");
8
+ const utils_1 = require("../utils");
9
+ const verifiable_1 = require("../verifiable");
10
+ const zero = '0';
11
+ /**
12
+ * AtomicQueryV3OnChainInputs ZK private inputs for credentialAtomicQueryV3OnChain.circom
13
+ *
14
+ * @beta
15
+ * @class AtomicQueryV3OnChainInputs
16
+ * @extends {BaseConfig}
17
+ */
18
+ class AtomicQueryV3OnChainInputs extends common_1.BaseConfig {
19
+ validate() {
20
+ if (!this.requestID) {
21
+ throw new Error(models_1.CircuitError.EmptyRequestID);
22
+ }
23
+ if (!this.claim.nonRevProof.proof) {
24
+ throw new Error(models_1.CircuitError.EmptyClaimNonRevProof);
25
+ }
26
+ if (!this.query.values) {
27
+ throw new Error(models_1.CircuitError.EmptyQueryValue);
28
+ }
29
+ if (!this.proofType) {
30
+ throw new Error(models_1.CircuitError.InvalidProofType);
31
+ }
32
+ if (!this.challenge) {
33
+ throw new Error(models_1.CircuitError.EmptyChallenge);
34
+ }
35
+ if (this.authEnabled === 1) {
36
+ if (!this.authClaimIncMtp) {
37
+ throw new Error(models_1.CircuitError.EmptyAuthClaimProof);
38
+ }
39
+ if (!this.authClaimNonRevMtp) {
40
+ throw new Error(models_1.CircuitError.EmptyAuthClaimNonRevProof);
41
+ }
42
+ if (!this.signature) {
43
+ throw new Error(models_1.CircuitError.EmptyChallengeSignature);
44
+ }
45
+ if (!this.gistProof.proof) {
46
+ throw new Error(models_1.CircuitError.EmptyGISTProof);
47
+ }
48
+ }
49
+ if (this.proofType === verifiable_1.ProofType.BJJSignature) {
50
+ if (!this.claim.signatureProof?.issuerAuthIncProof.proof) {
51
+ throw new Error(models_1.CircuitError.EmptyIssuerAuthClaimProof);
52
+ }
53
+ if (!this.claim.signatureProof.issuerAuthNonRevProof.proof) {
54
+ throw new Error(models_1.CircuitError.EmptyIssuerAuthClaimNonRevProof);
55
+ }
56
+ if (!this.claim.signatureProof.signature) {
57
+ throw new Error(models_1.CircuitError.EmptyClaimSignature);
58
+ }
59
+ }
60
+ if (this.proofType === verifiable_1.ProofType.Iden3SparseMerkleTreeProof) {
61
+ if (!this.claim?.incProof?.proof) {
62
+ throw new Error(models_1.CircuitError.EmptyClaimProof);
63
+ }
64
+ }
65
+ }
66
+ fillMTPProofsWithZero(s) {
67
+ s.issuerClaimMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevel());
68
+ s.issuerClaimClaimsTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
69
+ s.issuerClaimRevTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
70
+ s.issuerClaimRootsTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
71
+ s.issuerClaimIdenState = js_merkletree_1.ZERO_HASH.bigInt().toString();
72
+ }
73
+ fillSigProofWithZero(s) {
74
+ s.issuerClaimSignatureR8x = zero;
75
+ s.issuerClaimSignatureR8y = zero;
76
+ s.issuerClaimSignatureS = zero;
77
+ s.issuerAuthClaim = new js_iden3_core_1.Claim().marshalJson();
78
+ s.issuerAuthClaimMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevel());
79
+ s.issuerAuthClaimsTreeRoot = zero;
80
+ s.issuerAuthRevTreeRoot = zero;
81
+ s.issuerAuthRootsTreeRoot = zero;
82
+ s.issuerAuthClaimNonRevMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevel());
83
+ s.issuerAuthClaimNonRevMtpAuxHi = js_merkletree_1.ZERO_HASH.bigInt().toString();
84
+ s.issuerAuthClaimNonRevMtpAuxHv = js_merkletree_1.ZERO_HASH.bigInt().toString();
85
+ s.issuerAuthClaimNonRevMtpNoAux = zero;
86
+ s.issuerAuthState = zero;
87
+ }
88
+ fillAuthWithZero(s) {
89
+ s.authClaim = new js_iden3_core_1.Claim().marshalJson();
90
+ s.userClaimsTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
91
+ s.userRevTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
92
+ s.userRootsTreeRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
93
+ s.userState = js_merkletree_1.ZERO_HASH.bigInt().toString();
94
+ s.authClaimIncMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevel());
95
+ s.authClaimNonRevMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevel());
96
+ s.challengeSignatureR8x = zero;
97
+ s.challengeSignatureR8y = zero;
98
+ s.challengeSignatureS = zero;
99
+ s.gistRoot = js_merkletree_1.ZERO_HASH.bigInt().toString();
100
+ s.gistMtp = (0, common_1.prepareSiblingsStr)(new js_merkletree_1.Proof(), this.getMTLevelOnChain());
101
+ s.authClaimNonRevMtpAuxHi = js_merkletree_1.ZERO_HASH.bigInt().toString();
102
+ s.authClaimNonRevMtpAuxHv = js_merkletree_1.ZERO_HASH.bigInt().toString();
103
+ s.authClaimNonRevMtpNoAux = zero;
104
+ s.gistMtpAuxHi = js_merkletree_1.ZERO_HASH.bigInt().toString();
105
+ s.gistMtpAuxHv = js_merkletree_1.ZERO_HASH.bigInt().toString();
106
+ s.gistMtpNoAux = zero;
107
+ }
108
+ // InputsMarshal returns Circom private inputs for credentialAtomicQueryV3OnChain.circom
109
+ inputsMarshal() {
110
+ this.validate();
111
+ if (this.query.valueProof) {
112
+ this.query.validate();
113
+ this.query.valueProof.validate();
114
+ }
115
+ let valueProof = this.query.valueProof;
116
+ if (!valueProof) {
117
+ valueProof = new models_1.ValueProof();
118
+ valueProof.path = 0n;
119
+ valueProof.value = 0n;
120
+ valueProof.mtp = new js_merkletree_1.Proof();
121
+ }
122
+ const treeState = this.claim.nonRevProof.treeState;
123
+ if (!treeState) {
124
+ throw new Error(models_1.CircuitError.EmptyTreeState);
125
+ }
126
+ const s = {
127
+ requestID: this.requestID.toString(),
128
+ userGenesisID: this.id.bigInt().toString(),
129
+ profileNonce: this.profileNonce.toString(),
130
+ claimSubjectProfileNonce: this.claimSubjectProfileNonce.toString(),
131
+ issuerID: this.claim.issuerID.bigInt().toString(),
132
+ issuerClaim: this.claim.claim.marshalJson(),
133
+ issuerClaimNonRevClaimsTreeRoot: treeState.claimsRoot.bigInt().toString(),
134
+ issuerClaimNonRevRevTreeRoot: treeState.revocationRoot.bigInt().toString(),
135
+ issuerClaimNonRevRootsTreeRoot: treeState.rootOfRoots.bigInt().toString(),
136
+ issuerClaimNonRevState: treeState.state.bigInt().toString(),
137
+ issuerClaimNonRevMtp: (0, common_1.prepareSiblingsStr)(this.claim.nonRevProof.proof, this.getMTLevel()),
138
+ claimSchema: this.claim.claim.getSchemaHash().bigInt().toString(),
139
+ claimPathMtp: (0, common_1.prepareSiblingsStr)(valueProof.mtp, this.getMTLevelsClaim()),
140
+ claimPathValue: valueProof.value.toString(),
141
+ operator: this.query.operator,
142
+ timestamp: this.currentTimeStamp,
143
+ // value in this path in merklized json-ld document
144
+ slotIndex: this.query.slotIndex,
145
+ isRevocationChecked: 1
146
+ };
147
+ s.challenge = this.challenge?.toString();
148
+ if (this.authEnabled === 1) {
149
+ s.authClaim = this.authClaim?.marshalJson();
150
+ s.userClaimsTreeRoot = this.treeState.claimsRoot?.bigInt().toString();
151
+ s.userRevTreeRoot = this.treeState.revocationRoot?.bigInt().toString();
152
+ s.userRootsTreeRoot = this.treeState.rootOfRoots?.bigInt().toString();
153
+ s.userState = this.treeState.state?.bigInt().toString();
154
+ s.authClaimIncMtp = (0, common_1.prepareSiblingsStr)(this.authClaimIncMtp, this.getMTLevel());
155
+ s.authClaimNonRevMtp = (0, common_1.prepareSiblingsStr)(this.authClaimNonRevMtp, this.getMTLevel());
156
+ s.challengeSignatureR8x = this.signature.R8[0].toString();
157
+ s.challengeSignatureR8y = this.signature.R8[1].toString();
158
+ s.challengeSignatureS = this.signature.S.toString();
159
+ s.gistMtp =
160
+ this.gistProof && (0, common_1.prepareSiblingsStr)(this.gistProof.proof, this.getMTLevelOnChain());
161
+ const nodeAuxAuth = (0, common_1.getNodeAuxValue)(this.authClaimNonRevMtp);
162
+ s.authClaimNonRevMtpAuxHi = nodeAuxAuth.key.bigInt().toString();
163
+ s.authClaimNonRevMtpAuxHv = nodeAuxAuth.value.bigInt().toString();
164
+ s.authClaimNonRevMtpNoAux = nodeAuxAuth.noAux;
165
+ const globalNodeAux = (0, common_1.getNodeAuxValue)(this.gistProof.proof);
166
+ s.gistMtpAuxHi = globalNodeAux.key.bigInt().toString();
167
+ s.gistMtpAuxHv = globalNodeAux.value.bigInt().toString();
168
+ s.gistMtpNoAux = globalNodeAux.noAux;
169
+ s.gistRoot = this.gistProof.root.bigInt().toString();
170
+ }
171
+ else {
172
+ this.fillAuthWithZero(s);
173
+ }
174
+ if (this.skipClaimRevocationCheck) {
175
+ s.isRevocationChecked = 0;
176
+ }
177
+ if (this.proofType === verifiable_1.ProofType.BJJSignature) {
178
+ s.proofType = '1';
179
+ s.issuerClaimSignatureR8x = this.claim.signatureProof?.signature.R8[0].toString();
180
+ s.issuerClaimSignatureR8y = this.claim.signatureProof?.signature.R8[1].toString();
181
+ s.issuerClaimSignatureS = this.claim.signatureProof?.signature.S.toString();
182
+ s.issuerAuthClaim = this.claim.signatureProof?.issuerAuthClaim?.marshalJson();
183
+ s.issuerAuthClaimMtp = (0, common_1.prepareSiblingsStr)(this.claim.signatureProof?.issuerAuthIncProof.proof, this.getMTLevel());
184
+ const issuerAuthTreeState = this.claim.nonRevProof.treeState;
185
+ if (!issuerAuthTreeState) {
186
+ throw new Error(models_1.CircuitError.EmptyTreeState);
187
+ }
188
+ s.issuerAuthClaimsTreeRoot = issuerAuthTreeState.claimsRoot.bigInt().toString();
189
+ s.issuerAuthRevTreeRoot = issuerAuthTreeState.revocationRoot.bigInt().toString();
190
+ s.issuerAuthRootsTreeRoot = issuerAuthTreeState.rootOfRoots.bigInt().toString();
191
+ s.issuerAuthClaimNonRevMtp = (0, common_1.prepareSiblingsStr)(this.claim.signatureProof?.issuerAuthNonRevProof.proof, this.getMTLevel());
192
+ const nodeAuxIssuerAuthNonRev = (0, common_1.getNodeAuxValue)(this.claim.signatureProof?.issuerAuthNonRevProof.proof);
193
+ s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev.key.bigInt().toString();
194
+ s.issuerAuthClaimNonRevMtpAuxHv = nodeAuxIssuerAuthNonRev.value.bigInt().toString();
195
+ s.issuerAuthClaimNonRevMtpNoAux = nodeAuxIssuerAuthNonRev.noAux;
196
+ s.issuerAuthState = this.claim.signatureProof?.issuerAuthIncProof.treeState?.state
197
+ .bigInt()
198
+ .toString();
199
+ this.fillMTPProofsWithZero(s);
200
+ }
201
+ else if (this.proofType === verifiable_1.ProofType.Iden3SparseMerkleTreeProof) {
202
+ s.proofType = '2';
203
+ const incProofTreeState = this.claim.incProof?.treeState;
204
+ if (!incProofTreeState) {
205
+ throw new Error(models_1.CircuitError.EmptyTreeState);
206
+ }
207
+ s.issuerClaimMtp = (0, common_1.prepareSiblingsStr)(this.claim.incProof?.proof, this.getMTLevel());
208
+ s.issuerClaimClaimsTreeRoot = incProofTreeState.claimsRoot.bigInt().toString();
209
+ s.issuerClaimRevTreeRoot = incProofTreeState.revocationRoot.bigInt().toString();
210
+ s.issuerClaimRootsTreeRoot = incProofTreeState.rootOfRoots.bigInt().toString();
211
+ s.issuerClaimIdenState = incProofTreeState.state.bigInt().toString();
212
+ this.fillSigProofWithZero(s);
213
+ }
214
+ const nodeAuxNonRev = (0, common_1.getNodeAuxValue)(this.claim.nonRevProof.proof);
215
+ s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev.key.bigInt().toString();
216
+ s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev.value.bigInt().toString();
217
+ s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev.noAux;
218
+ s.claimPathNotExists = (0, common_1.existenceToInt)(valueProof.mtp.existence);
219
+ const nodAuxJSONLD = (0, common_1.getNodeAuxValue)(valueProof.mtp);
220
+ s.claimPathMtpNoAux = nodAuxJSONLD.noAux;
221
+ s.claimPathMtpAuxHi = nodAuxJSONLD.key.bigInt().toString();
222
+ s.claimPathMtpAuxHv = nodAuxJSONLD.value.bigInt().toString();
223
+ s.claimPathKey = valueProof.path.toString();
224
+ const values = (0, common_1.prepareCircuitArrayValues)(this.query.values, this.getValueArrSize());
225
+ s.value = (0, common_1.bigIntArrayToStringArray)(values);
226
+ s.linkNonce = this.linkNonce.toString();
227
+ s.verifierID = this.verifierID?.bigInt().toString() ?? '0';
228
+ s.nullifierSessionID = this.nullifierSessionID.toString();
229
+ s.authEnabled = this.authEnabled.toString();
230
+ return utils_1.byteEncoder.encode(JSON.stringify(s));
231
+ }
232
+ }
233
+ exports.AtomicQueryV3OnChainInputs = AtomicQueryV3OnChainInputs;
234
+ /**
235
+ * @beta
236
+ * AtomicQueryV3OnChainPubSignals public inputs
237
+ */
238
+ class AtomicQueryV3OnChainPubSignals extends common_1.BaseConfig {
239
+ // PubSignalsUnmarshal unmarshal credentialAtomicQueryV3.circom public signals
240
+ pubSignalsUnmarshal(data) {
241
+ // expected order:
242
+ // merklized
243
+ // userID
244
+ // circuitQueryHash
245
+ // issuerState
246
+ // linkID
247
+ // nullifier
248
+ // operatorOutput
249
+ // proofType
250
+ // requestID
251
+ // challenge
252
+ // gistRoot
253
+ // issuerID
254
+ // isRevocationChecked
255
+ // issuerClaimNonRevState
256
+ // timestamp
257
+ // verifierID
258
+ // nullifierSessionID
259
+ // authEnabled
260
+ const sVals = JSON.parse(utils_1.byteDecoder.decode(data));
261
+ let fieldIdx = 0;
262
+ // -- merklized
263
+ this.merklized = parseInt(sVals[fieldIdx]);
264
+ fieldIdx++;
265
+ // - userID
266
+ this.userID = js_iden3_core_1.Id.fromBigInt(BigInt(sVals[fieldIdx]));
267
+ fieldIdx++;
268
+ // - circuitQueryHash
269
+ this.circuitQueryHash = BigInt(sVals[fieldIdx]);
270
+ fieldIdx++;
271
+ // - issuerState
272
+ this.issuerState = js_merkletree_1.Hash.fromString(sVals[fieldIdx]);
273
+ fieldIdx++;
274
+ // - linkID
275
+ this.linkID = BigInt(sVals[fieldIdx]);
276
+ fieldIdx++;
277
+ // - nullifier
278
+ this.nullifier = BigInt(sVals[fieldIdx]);
279
+ fieldIdx++;
280
+ // - operatorOutput
281
+ this.operatorOutput = BigInt(sVals[fieldIdx]);
282
+ fieldIdx++;
283
+ // - proofType
284
+ this.proofType = parseInt(sVals[fieldIdx]);
285
+ fieldIdx++;
286
+ // - requestID
287
+ this.requestID = BigInt(sVals[fieldIdx]);
288
+ fieldIdx++;
289
+ // - challenge
290
+ this.challenge = BigInt(sVals[fieldIdx]);
291
+ fieldIdx++;
292
+ // - gistRoot
293
+ this.gistRoot = js_merkletree_1.Hash.fromString(sVals[fieldIdx]);
294
+ fieldIdx++;
295
+ // - issuerID
296
+ this.issuerID = js_iden3_core_1.Id.fromBigInt(BigInt(sVals[fieldIdx]));
297
+ fieldIdx++;
298
+ // - isRevocationChecked
299
+ this.isRevocationChecked = parseInt(sVals[fieldIdx]);
300
+ fieldIdx++;
301
+ // - issuerClaimNonRevState
302
+ this.issuerClaimNonRevState = js_merkletree_1.Hash.fromString(sVals[fieldIdx]);
303
+ fieldIdx++;
304
+ // - timestamp
305
+ this.timestamp = parseInt(sVals[fieldIdx]);
306
+ fieldIdx++;
307
+ // - verifierID
308
+ if (sVals[fieldIdx] !== '0') {
309
+ this.verifierID = js_iden3_core_1.Id.fromBigInt(BigInt(sVals[fieldIdx]));
310
+ }
311
+ fieldIdx++;
312
+ // - nullifierSessionID
313
+ this.nullifierSessionID = BigInt(sVals[fieldIdx]);
314
+ fieldIdx++;
315
+ // - authEnabled
316
+ this.authEnabled = parseInt(sVals[fieldIdx]);
317
+ return this;
318
+ }
319
+ }
320
+ exports.AtomicQueryV3OnChainPubSignals = AtomicQueryV3OnChainPubSignals;