@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
@@ -11,6 +11,17 @@ export var SearchError;
11
11
  const truthyValues = [true, 1, 'true'];
12
12
  const falsyValues = [false, 0, 'false'];
13
13
  const equalsComparator = (a, b) => {
14
+ if (Array.isArray(a) && Array.isArray(b)) {
15
+ return (a.length === b.length && a.every((val, index) => val === b[index]));
16
+ }
17
+ if (!Array.isArray(a) && Array.isArray(b)) {
18
+ return b.includes(a);
19
+ }
20
+ if (Array.isArray(a) && !Array.isArray(b)) {
21
+ return a.includes(b);
22
+ }
23
+ a = a;
24
+ b = b;
14
25
  if (truthyValues.includes(a) && truthyValues.includes(b)) {
15
26
  return true;
16
27
  }
@@ -19,14 +30,65 @@ const equalsComparator = (a, b) => {
19
30
  }
20
31
  return a === b;
21
32
  };
22
- export /** @type {*} - filter operators and their functions */ const comparatorOptions = {
33
+ const greaterThan = (a, b) => {
34
+ if (Array.isArray(a) && Array.isArray(b)) {
35
+ return a.every((val, index) => val > b[index]);
36
+ }
37
+ if (!Array.isArray(a) && Array.isArray(b)) {
38
+ return b.every((val) => a > val);
39
+ }
40
+ if (Array.isArray(a) && !Array.isArray(b)) {
41
+ return a.every((val) => val > b);
42
+ }
43
+ return a > b;
44
+ };
45
+ const greaterThanOrEqual = (a, b) => {
46
+ if (Array.isArray(a) && Array.isArray(b)) {
47
+ return a.every((val, index) => val >= b[index]);
48
+ }
49
+ if (!Array.isArray(a) && Array.isArray(b)) {
50
+ return b.every((val) => a >= val);
51
+ }
52
+ if (Array.isArray(a) && !Array.isArray(b)) {
53
+ return a.every((val) => val >= b);
54
+ }
55
+ return a >= b;
56
+ };
57
+ const lessThanOrEqual = (a, b) => {
58
+ if (Array.isArray(a) && Array.isArray(b)) {
59
+ return a.every((val, index) => val <= b[index]);
60
+ }
61
+ if (!Array.isArray(a) && Array.isArray(b)) {
62
+ return b.every((val) => a <= val);
63
+ }
64
+ if (Array.isArray(a) && !Array.isArray(b)) {
65
+ return a.every((val) => val <= b);
66
+ }
67
+ return a <= b;
68
+ };
69
+ const inOperator = (a, b) => {
70
+ if (Array.isArray(a) && Array.isArray(b)) {
71
+ return a.every((val) => b.includes(val));
72
+ }
73
+ if (!Array.isArray(a) && Array.isArray(b)) {
74
+ return b.includes(a);
75
+ }
76
+ if (Array.isArray(a) && !Array.isArray(b)) {
77
+ return a.includes(b);
78
+ }
79
+ return false;
80
+ };
81
+ export const comparatorOptions = {
23
82
  $noop: () => true,
83
+ $sd: () => true,
24
84
  $eq: (a, b) => equalsComparator(a, b),
25
- $in: (a, b) => b.includes(a),
26
- $nin: (a, b) => !b.includes(a),
27
- $gt: (a, b) => a > b,
28
- $lt: (a, b) => a < b,
29
- $ne: (a, b) => !equalsComparator(a, b)
85
+ $in: (a, b) => inOperator(a, b),
86
+ $nin: (a, b) => !inOperator(a, b),
87
+ $gt: (a, b) => greaterThan(a, b),
88
+ $lt: (a, b) => !greaterThan(a, b),
89
+ $ne: (a, b) => !equalsComparator(a, b),
90
+ $gte: (a, b) => greaterThanOrEqual(a, b),
91
+ $lte: (a, b) => lessThanOrEqual(a, b)
30
92
  };
31
93
  /**
32
94
  * credential search path resolver
@@ -110,8 +172,6 @@ export const StandardJSONCredentialsQueryFilter = (query) => {
110
172
  return acc.concat(new FilterQuery('credentialSubject.id', comparatorOptions.$eq, queryValue));
111
173
  case 'schema':
112
174
  return acc.concat(new FilterQuery('credentialSchema.id', comparatorOptions.$eq, queryValue));
113
- case 'skipClaimRevocationCheck':
114
- return acc;
115
175
  case 'credentialSubject': {
116
176
  const reqFilters = Object.keys(queryValue).reduce((acc, fieldKey) => {
117
177
  const fieldParams = queryValue[fieldKey];
@@ -129,8 +189,13 @@ export const StandardJSONCredentialsQueryFilter = (query) => {
129
189
  }, []);
130
190
  return acc.concat(reqFilters);
131
191
  }
192
+ case 'proofType':
193
+ case 'groupId':
194
+ case 'skipClaimRevocationCheck': {
195
+ return acc;
196
+ }
132
197
  default:
133
- throw new Error(SearchError.NotDefinedQueryKey);
198
+ throw new Error(`${queryKey} : ${SearchError.NotDefinedQueryKey}`);
134
199
  }
135
200
  }, []);
136
201
  };
@@ -0,0 +1,10 @@
1
+ import { Hex } from '@iden3/js-crypto';
2
+ import { Id, buildDIDType, genesisFromEthAddress } from '@iden3/js-iden3-core';
3
+ export const buildVerifierId = (address, info) => {
4
+ address = address.replace('0x', '');
5
+ const ethAddrBytes = Hex.decodeString(address);
6
+ const ethAddr = ethAddrBytes.slice(0, 20);
7
+ const genesis = genesisFromEthAddress(ethAddr);
8
+ const tp = buildDIDType(info.method, info.blockchain, info.networkId);
9
+ return new Id(tp, genesis);
10
+ };
@@ -1 +1,3 @@
1
1
  export * from './encoding';
2
+ export * from './object';
3
+ export * from './did-helper';
@@ -0,0 +1,38 @@
1
+ export function mergeObjects(credSubject, otherCredSubject) {
2
+ let result = {};
3
+ const credSubjectKeys = Object.keys(credSubject);
4
+ for (const key of credSubjectKeys) {
5
+ if (typeof otherCredSubject[key] !== 'undefined') {
6
+ if (typeof credSubject[key] !== 'object' && typeof otherCredSubject[key] !== 'object') {
7
+ throw new Error('Invalid query');
8
+ }
9
+ const subjectProperty = credSubject[key];
10
+ const otherSubjectProperty = otherCredSubject[key];
11
+ const propertyOperators = Object.keys(subjectProperty);
12
+ const subjectPropertyResult = {};
13
+ for (const operatorKey of propertyOperators) {
14
+ if (typeof otherSubjectProperty[operatorKey] !== 'undefined') {
15
+ const operatorValue1 = subjectProperty[operatorKey];
16
+ const operatorValue2 = otherSubjectProperty[operatorKey];
17
+ subjectPropertyResult[operatorKey] = [
18
+ ...new Set([
19
+ ...(subjectPropertyResult[operatorKey] ?? []),
20
+ operatorValue1,
21
+ ...(Array.isArray(operatorValue2) ? operatorValue2 : [operatorValue2])
22
+ ])
23
+ ];
24
+ }
25
+ else {
26
+ subjectPropertyResult[operatorKey] = subjectProperty[operatorKey];
27
+ }
28
+ }
29
+ result[key] = {
30
+ ...otherCredSubject[key],
31
+ ...subjectPropertyResult
32
+ };
33
+ }
34
+ }
35
+ // Add remaining keys from obj2
36
+ result = { ...credSubject, ...otherCredSubject, ...result };
37
+ return result;
38
+ }
@@ -15,19 +15,23 @@ export const stringByPath = (obj, path) => {
15
15
  }
16
16
  return value.toString();
17
17
  };
18
- export const buildQueryPath = async (contextURL, contextType, field, opts) => {
19
- let resp;
20
- try {
21
- resp = await (await fetch(contextURL)).json();
18
+ export const buildFieldPath = async (ldSchema, contextType, field, opts) => {
19
+ let path = new Path();
20
+ if (field) {
21
+ path = await Path.getContextPathKey(ldSchema, contextType, field, opts);
22
22
  }
23
- catch (error) {
24
- throw new Error(`context not found: ${error.message}`);
25
- }
26
- const path = await Path.getContextPathKey(JSON.stringify(resp), contextType, field, opts);
27
23
  path.prepend([VerifiableConstants.CREDENTIAL_SUBJECT_PATH]);
28
24
  return path;
29
25
  };
30
- export const createVerifiablePresentation = (context, tp, path, value) => {
26
+ export const findValue = (fieldName, credential) => {
27
+ const [first, ...rest] = fieldName.split('.');
28
+ let v = credential.credentialSubject[first];
29
+ for (const part of rest) {
30
+ v = v[part];
31
+ }
32
+ return v;
33
+ };
34
+ export const createVerifiablePresentation = (context, tp, credential, queries) => {
31
35
  const baseContext = [VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018];
32
36
  const ldContext = baseContext[0] === context ? baseContext : [...baseContext, context];
33
37
  const vc = VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL;
@@ -35,34 +39,31 @@ export const createVerifiablePresentation = (context, tp, path, value) => {
35
39
  if (tp !== vc) {
36
40
  vcTypes.push(tp);
37
41
  }
38
- const [first, ...rest] = path.split('.');
39
- const obj = rest.reduceRight((acc, key) => ({ [key]: acc }), value);
40
- return {
42
+ const skeleton = {
41
43
  '@context': baseContext,
42
44
  '@type': VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_PRESENTATION,
43
45
  verifiableCredential: {
44
46
  '@context': ldContext,
45
47
  '@type': vcTypes,
46
48
  credentialSubject: {
47
- '@type': tp,
48
- [first]: obj
49
+ '@type': tp
49
50
  }
50
51
  }
51
52
  };
52
- };
53
- export const verifiablePresentationFromCred = async (w3cCred, requestObj, field, opts) => {
54
- const mz = await w3cCred.merklize(opts);
55
- const request = requestObj;
56
- const contextType = stringByPath(request, 'type');
57
- const hasher = mz.hasher;
58
- const contextURL = stringByPath(request, 'context');
59
- const path = await buildQueryPath(contextURL, contextType, field, opts);
60
- const dataType = await mz.jsonLDType(path);
61
- const rawValue = mz.rawValue(path);
62
- const { value } = await mz.proof(path);
63
- const vp = createVerifiablePresentation(contextURL, contextType, field, rawValue);
64
- if (!value) {
65
- throw new Error(`can't merklize verifiable presentation`);
53
+ let result = {};
54
+ for (const query of queries) {
55
+ const parts = query.fieldName.split('.');
56
+ const current = parts.reduceRight((acc, part) => {
57
+ if (result[part]) {
58
+ return { [part]: { ...result[part], ...acc } };
59
+ }
60
+ return { [part]: acc };
61
+ }, findValue(query.fieldName, credential));
62
+ result = { ...result, ...current };
66
63
  }
67
- return { vp, mzValue: value, dataType, hasher };
64
+ skeleton.verifiableCredential.credentialSubject = {
65
+ ...skeleton.verifiableCredential.credentialSubject,
66
+ ...result
67
+ };
68
+ return skeleton;
68
69
  };
@@ -42,6 +42,7 @@ export class Iden3SparseMerkleTreeProof {
42
42
  mtp: this.mtp.toJSON()
43
43
  };
44
44
  }
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
46
  static fromJSON(obj) {
46
47
  let mtp;
47
48
  if (obj?.mtp?.notEmpties && obj?.mtp?.depth && obj?.mtp?.siblings) {
@@ -120,6 +121,7 @@ export class BJJSignatureProof2021 {
120
121
  * fromJSON is a method to deserialize BJJSignatureProof2021 from json
121
122
  * @param obj
122
123
  */
124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
125
  static fromJSON(obj) {
124
126
  return new BJJSignatureProof2021({
125
127
  issuerData: {
@@ -38,20 +38,20 @@ export declare class AtomicQueryMTPV2Inputs extends BaseConfig {
38
38
  * @extends {BaseConfig}
39
39
  */
40
40
  export declare class AtomicQueryMTPV2PubSignals extends BaseConfig {
41
- requestID?: bigint;
42
- userID?: Id;
43
- issuerID?: Id;
44
- issuerClaimIdenState?: Hash;
45
- issuerClaimNonRevState?: Hash;
46
- claimSchema?: SchemaHash;
47
- slotIndex?: number;
48
- operator?: number;
41
+ requestID: bigint;
42
+ userID: Id;
43
+ issuerID: Id;
44
+ issuerClaimIdenState: Hash;
45
+ issuerClaimNonRevState: Hash;
46
+ claimSchema: SchemaHash;
47
+ slotIndex: number;
48
+ operator: number;
49
49
  value: bigint[];
50
- timestamp?: number;
51
- merklized?: number;
52
- claimPathKey?: bigint;
53
- claimPathNotExists?: number;
54
- isRevocationChecked?: number;
50
+ timestamp: number;
51
+ merklized: number;
52
+ claimPathKey: bigint;
53
+ claimPathNotExists: number;
54
+ isRevocationChecked: number;
55
55
  /**
56
56
  * PubSignalsUnmarshal unmarshal credentialAtomicQueryMTP.circom public signals array to AtomicQueryMTPPubSignals
57
57
  *
@@ -0,0 +1,142 @@
1
+ import { Claim, Id } from '@iden3/js-iden3-core';
2
+ import { BaseConfig } from './common';
3
+ import { GISTProof, Query, TreeState } from './models';
4
+ import { Hash, Proof } from '@iden3/js-merkletree';
5
+ import { ClaimWithSigAndMTPProof } from './atomic-query-v3';
6
+ import { Signature } from '@iden3/js-crypto';
7
+ import { ProofType } from '../verifiable';
8
+ /**
9
+ * AtomicQueryV3OnChainInputs ZK private inputs for credentialAtomicQueryV3OnChain.circom
10
+ *
11
+ * @beta
12
+ * @class AtomicQueryV3OnChainInputs
13
+ * @extends {BaseConfig}
14
+ */
15
+ export declare class AtomicQueryV3OnChainInputs extends BaseConfig {
16
+ requestID: bigint;
17
+ id: Id;
18
+ profileNonce: bigint;
19
+ claimSubjectProfileNonce: bigint;
20
+ claim: ClaimWithSigAndMTPProof;
21
+ skipClaimRevocationCheck: boolean;
22
+ authClaim: Claim;
23
+ authClaimIncMtp: Proof;
24
+ authClaimNonRevMtp: Proof;
25
+ treeState: TreeState;
26
+ gistProof: GISTProof;
27
+ signature: Signature;
28
+ challenge: bigint;
29
+ query: Query;
30
+ currentTimeStamp: number;
31
+ proofType: ProofType;
32
+ linkNonce: bigint;
33
+ verifierID?: Id;
34
+ nullifierSessionID: bigint;
35
+ authEnabled: number;
36
+ validate(): void;
37
+ fillMTPProofsWithZero(s: Partial<AtomicQueryV3OnChainCircuitInputs>): void;
38
+ fillSigProofWithZero(s: Partial<AtomicQueryV3OnChainCircuitInputs>): void;
39
+ fillAuthWithZero(s: Partial<AtomicQueryV3OnChainCircuitInputs>): void;
40
+ inputsMarshal(): Uint8Array;
41
+ }
42
+ /**
43
+ * @beta
44
+ * AtomicQueryV3OnChainCircuitInputs type represents credentialAtomicQueryV3OnChain.circom private inputs required by prover
45
+ */
46
+ interface AtomicQueryV3OnChainCircuitInputs {
47
+ requestID: string;
48
+ userGenesisID: string;
49
+ profileNonce: string;
50
+ claimSubjectProfileNonce: string;
51
+ issuerID: string;
52
+ issuerClaim: string[];
53
+ issuerClaimNonRevClaimsTreeRoot: string;
54
+ issuerClaimNonRevRevTreeRoot: string;
55
+ issuerClaimNonRevRootsTreeRoot: string;
56
+ issuerClaimNonRevState: string;
57
+ issuerClaimNonRevMtp: string[];
58
+ issuerClaimNonRevMtpAuxHi: string;
59
+ issuerClaimNonRevMtpAuxHv: string;
60
+ issuerClaimNonRevMtpNoAux: string;
61
+ claimSchema: string;
62
+ issuerClaimSignatureR8x: string;
63
+ issuerClaimSignatureR8y: string;
64
+ issuerClaimSignatureS: string;
65
+ issuerAuthClaim: string[];
66
+ issuerAuthClaimMtp: string[];
67
+ issuerAuthClaimNonRevMtp: string[];
68
+ issuerAuthClaimNonRevMtpAuxHi: string;
69
+ issuerAuthClaimNonRevMtpAuxHv: string;
70
+ issuerAuthClaimNonRevMtpNoAux: string;
71
+ issuerAuthClaimsTreeRoot: string;
72
+ issuerAuthRevTreeRoot: string;
73
+ issuerAuthRootsTreeRoot: string;
74
+ issuerAuthState: string;
75
+ isRevocationChecked: number;
76
+ claimPathNotExists: number;
77
+ claimPathMtp: string[];
78
+ claimPathMtpNoAux: string;
79
+ claimPathMtpAuxHi: string;
80
+ claimPathMtpAuxHv: string;
81
+ claimPathKey: string;
82
+ claimPathValue: string;
83
+ operator: number;
84
+ slotIndex: number;
85
+ timestamp: number;
86
+ value: string[];
87
+ issuerClaimMtp: string[];
88
+ issuerClaimClaimsTreeRoot: string;
89
+ issuerClaimRevTreeRoot: string;
90
+ issuerClaimRootsTreeRoot: string;
91
+ issuerClaimIdenState: string;
92
+ proofType: string;
93
+ authClaim?: string[];
94
+ authClaimIncMtp?: string[];
95
+ authClaimNonRevMtp: string[];
96
+ authClaimNonRevMtpAuxHi?: string;
97
+ authClaimNonRevMtpAuxHv?: string;
98
+ authClaimNonRevMtpNoAux: string;
99
+ challenge: string;
100
+ challengeSignatureR8x: string;
101
+ challengeSignatureR8y: string;
102
+ challengeSignatureS: string;
103
+ userClaimsTreeRoot?: string;
104
+ userRevTreeRoot?: string;
105
+ userRootsTreeRoot?: string;
106
+ userState?: string;
107
+ gistRoot?: string;
108
+ gistMtp: string[];
109
+ gistMtpAuxHi?: string;
110
+ gistMtpAuxHv?: string;
111
+ gistMtpNoAux: string;
112
+ linkNonce: string;
113
+ verifierID: string;
114
+ nullifierSessionID: string;
115
+ authEnabled: string;
116
+ }
117
+ /**
118
+ * @beta
119
+ * AtomicQueryV3OnChainPubSignals public inputs
120
+ */
121
+ export declare class AtomicQueryV3OnChainPubSignals extends BaseConfig {
122
+ requestID: bigint;
123
+ userID: Id;
124
+ issuerID: Id;
125
+ issuerState: Hash;
126
+ issuerClaimNonRevState: Hash;
127
+ timestamp: number;
128
+ merklized: number;
129
+ isRevocationChecked: number;
130
+ circuitQueryHash: bigint;
131
+ challenge: bigint;
132
+ gistRoot: Hash;
133
+ proofType: number;
134
+ linkID: bigint;
135
+ nullifier: bigint;
136
+ operatorOutput: bigint;
137
+ verifierID: Id;
138
+ nullifierSessionID: bigint;
139
+ authEnabled: number;
140
+ pubSignalsUnmarshal(data: Uint8Array): AtomicQueryV3OnChainPubSignals;
141
+ }
142
+ export {};
@@ -0,0 +1,120 @@
1
+ import { Claim, Id, SchemaHash } from '@iden3/js-iden3-core';
2
+ import { BaseConfig } from './common';
3
+ import { BJJSignatureProof, MTProof, Query } from './models';
4
+ import { Hash } from '@iden3/js-merkletree';
5
+ import { ProofType } from '../verifiable';
6
+ export interface ClaimWithSigAndMTPProof {
7
+ issuerID: Id;
8
+ claim: Claim;
9
+ nonRevProof: MTProof;
10
+ signatureProof?: BJJSignatureProof;
11
+ incProof?: MTProof;
12
+ }
13
+ /**
14
+ * AtomicQueryV3Inputs ZK private inputs for credentialAtomicQueryV3.circom
15
+ *
16
+ * @beta
17
+ * @class AtomicQueryV3Inputs
18
+ * @extends {BaseConfig}
19
+ */
20
+ export declare class AtomicQueryV3Inputs extends BaseConfig {
21
+ requestID: bigint;
22
+ id: Id;
23
+ profileNonce: bigint;
24
+ claimSubjectProfileNonce: bigint;
25
+ claim: ClaimWithSigAndMTPProof;
26
+ skipClaimRevocationCheck: boolean;
27
+ query: Query;
28
+ currentTimeStamp: number;
29
+ proofType: ProofType;
30
+ linkNonce: bigint;
31
+ verifierID?: Id;
32
+ nullifierSessionID: bigint;
33
+ validate(): void;
34
+ fillMTPProofsWithZero(s: Partial<AtomicQueryV3CircuitInputs>): void;
35
+ fillSigProofWithZero(s: Partial<AtomicQueryV3CircuitInputs>): void;
36
+ inputsMarshal(): Uint8Array;
37
+ }
38
+ /**
39
+ * @beta
40
+ * AtomicQueryV3CircuitInputs type represents credentialAtomicQueryV3.circom private inputs required by prover
41
+ */
42
+ interface AtomicQueryV3CircuitInputs {
43
+ requestID: string;
44
+ userGenesisID: string;
45
+ profileNonce: string;
46
+ claimSubjectProfileNonce: string;
47
+ issuerID: string;
48
+ issuerClaim: string[];
49
+ issuerClaimNonRevClaimsTreeRoot: string;
50
+ issuerClaimNonRevRevTreeRoot: string;
51
+ issuerClaimNonRevRootsTreeRoot: string;
52
+ issuerClaimNonRevState: string;
53
+ issuerClaimNonRevMtp: string[];
54
+ issuerClaimNonRevMtpAuxHi: string;
55
+ issuerClaimNonRevMtpAuxHv: string;
56
+ issuerClaimNonRevMtpNoAux: string;
57
+ claimSchema: string;
58
+ issuerClaimSignatureR8x: string;
59
+ issuerClaimSignatureR8y: string;
60
+ issuerClaimSignatureS: string;
61
+ issuerAuthClaim: string[];
62
+ issuerAuthClaimMtp: string[];
63
+ issuerAuthClaimNonRevMtp: string[];
64
+ issuerAuthClaimNonRevMtpAuxHi: string;
65
+ issuerAuthClaimNonRevMtpAuxHv: string;
66
+ issuerAuthClaimNonRevMtpNoAux: string;
67
+ issuerAuthClaimsTreeRoot: string;
68
+ issuerAuthRevTreeRoot: string;
69
+ issuerAuthRootsTreeRoot: string;
70
+ issuerAuthState: string;
71
+ isRevocationChecked: number;
72
+ claimPathNotExists: number;
73
+ claimPathMtp: string[];
74
+ claimPathMtpNoAux: string;
75
+ claimPathMtpAuxHi: string;
76
+ claimPathMtpAuxHv: string;
77
+ claimPathKey: string;
78
+ claimPathValue: string;
79
+ operator: number;
80
+ slotIndex: number;
81
+ timestamp: number;
82
+ value: string[];
83
+ issuerClaimMtp: string[];
84
+ issuerClaimClaimsTreeRoot: string;
85
+ issuerClaimRevTreeRoot: string;
86
+ issuerClaimRootsTreeRoot: string;
87
+ issuerClaimIdenState: string;
88
+ proofType: string;
89
+ linkNonce: string;
90
+ verifierID: string;
91
+ nullifierSessionID: string;
92
+ }
93
+ /**
94
+ * @beta
95
+ * AtomicQueryV3PubSignals public inputs
96
+ */
97
+ export declare class AtomicQueryV3PubSignals extends BaseConfig {
98
+ requestID: bigint;
99
+ userID: Id;
100
+ issuerID: Id;
101
+ issuerState: Hash;
102
+ issuerClaimNonRevState: Hash;
103
+ claimSchema: SchemaHash;
104
+ slotIndex: number;
105
+ operator: number;
106
+ value: bigint[];
107
+ timestamp: number;
108
+ merklized: number;
109
+ claimPathKey: bigint;
110
+ claimPathNotExists: number;
111
+ isRevocationChecked: number;
112
+ proofType: number;
113
+ linkID: bigint;
114
+ nullifier: bigint;
115
+ operatorOutput: bigint;
116
+ verifierID: Id;
117
+ nullifierSessionID: bigint;
118
+ pubSignalsUnmarshal(data: Uint8Array): AtomicQueryV3PubSignals;
119
+ }
120
+ export {};
@@ -3,7 +3,7 @@ import { TreeState } from './models';
3
3
  export declare const defaultMTLevels = 40;
4
4
  export declare const defaultValueArraySize = 64;
5
5
  export declare const defaultMTLevelsOnChain = 64;
6
- export declare const defaultMTLevelsClaimsMerklization = 32;
6
+ export declare const defaultMTLevelsClaim = 32;
7
7
  export declare const ErrorEmptyAuthClaimProof = "empty auth claim mtp proof";
8
8
  export declare const ErrorEmptyAuthClaimNonRevProof = "empty auth claim non-revocation mtp proof";
9
9
  export declare const ErrorEmptyChallengeSignature = "empty challenge signature";
@@ -23,7 +23,7 @@ export declare class BaseConfig {
23
23
  mtLevel: number;
24
24
  valueArraySize: number;
25
25
  mtLevelOnChain: number;
26
- mtLevelClaimsMerklization: number;
26
+ mtLevelClaim: number;
27
27
  /**
28
28
  * getMTLevel max circuit MT levels
29
29
  *
@@ -31,11 +31,11 @@ export declare class BaseConfig {
31
31
  */
32
32
  getMTLevel(): number;
33
33
  /**
34
- * getMTLevel max circuit MT levels
34
+ * GetMTLevelsClaim max jsonld Claim levels
35
35
  *
36
36
  * @returns number
37
37
  */
38
- getMTLevelsClaimMerklization(): number;
38
+ getMTLevelsClaim(): number;
39
39
  /**
40
40
  * GetValueArrSize return size of circuits value array size
41
41
  *
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Represents the XSD namespace and its corresponding data types.
3
+ */
4
+ export declare enum XSDNS {
5
+ Boolean = "http://www.w3.org/2001/XMLSchema#boolean",
6
+ Integer = "http://www.w3.org/2001/XMLSchema#integer",
7
+ NonNegativeInteger = "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
8
+ NonPositiveInteger = "http://www.w3.org/2001/XMLSchema#nonPositiveInteger",
9
+ NegativeInteger = "http://www.w3.org/2001/XMLSchema#negativeInteger",
10
+ PositiveInteger = "http://www.w3.org/2001/XMLSchema#positiveInteger",
11
+ DateTime = "http://www.w3.org/2001/XMLSchema#dateTime",
12
+ Double = "http://www.w3.org/2001/XMLSchema#double",
13
+ String = "http://www.w3.org/2001/XMLSchema#string"
14
+ }
1
15
  /**
2
16
  * List of available operators.
3
17
  *
@@ -10,7 +24,12 @@ export declare enum Operators {
10
24
  GT = 3,
11
25
  IN = 4,
12
26
  NIN = 5,
13
- NE = 6
27
+ NE = 6,
28
+ LTE = 7,
29
+ GTE = 8,
30
+ BETWEEN = 9,
31
+ SD = 16,
32
+ NULLIFY = 17
14
33
  }
15
34
  /** QueryOperators represents operators for atomic circuits */
16
35
  export declare const QueryOperators: {
@@ -21,7 +40,20 @@ export declare const QueryOperators: {
21
40
  $in: Operators;
22
41
  $nin: Operators;
23
42
  $ne: Operators;
43
+ $lte: Operators;
44
+ $gte: Operators;
45
+ $between: Operators;
46
+ $sd: Operators;
47
+ $nullify: Operators;
24
48
  };
49
+ export declare const availableTypesOperators: Map<string, Operators[]>;
50
+ /**
51
+ * Checks if the given operation is valid for the specified datatype.
52
+ * @param datatype - The datatype to check the operation for.
53
+ * @param op - The operation to check.
54
+ * @returns True if the operation is valid, false otherwise.
55
+ */
56
+ export declare const isValidOperation: (datatype: string, op: number) => boolean;
25
57
  export interface IComparer {
26
58
  compare(int: number): boolean;
27
59
  }
@@ -4,6 +4,10 @@ export * from './comparer';
4
4
  export * from './atomic-query-mtp-v2';
5
5
  export * from './atomic-query-mtp-v2-on-chain';
6
6
  export * from './atomic-query-sig-v2';
7
+ export * from './atomic-query-v3';
8
+ export * from './atomic-query-v3-on-chain';
7
9
  export * from './atomic-query-sig-v2-on-chain';
8
10
  export * from './auth-v2';
9
11
  export * from './state-transition';
12
+ export * from './linked-nullifier';
13
+ export * from './linked-multi-query';