@0xpolygonid/js-sdk 1.8.3 → 1.9.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.
- package/dist/browser/esm/index.js +234 -121
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +237 -121
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +8 -25
- package/dist/node/cjs/circuits/atomic-query-v3.js +6 -5
- package/dist/node/cjs/circuits/common.js +1 -1
- package/dist/node/cjs/circuits/comparer.js +24 -3
- package/dist/node/cjs/circuits/linked-multi-query.js +6 -17
- package/dist/node/cjs/circuits/models.js +47 -3
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +2 -11
- package/dist/node/cjs/proof/common.js +11 -5
- package/dist/node/cjs/proof/provers/inputs-generator.js +6 -10
- package/dist/node/cjs/proof/verifiers/index.js +1 -0
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +37 -22
- package/dist/node/cjs/proof/verifiers/query-hash.js +40 -0
- package/dist/node/cjs/proof/verifiers/query.js +24 -16
- package/dist/node/cjs/schema-processor/utils.js +2 -2
- package/dist/node/cjs/storage/filters/jsonQuery.js +28 -2
- package/dist/node/cjs/verifiable/core-utils.js +3 -3
- package/dist/node/cjs/verifiable/credential.js +1 -1
- package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +9 -26
- package/dist/node/esm/circuits/atomic-query-v3.js +7 -6
- package/dist/node/esm/circuits/common.js +1 -1
- package/dist/node/esm/circuits/comparer.js +24 -3
- package/dist/node/esm/circuits/linked-multi-query.js +7 -18
- package/dist/node/esm/circuits/models.js +48 -4
- package/dist/node/esm/iden3comm/handlers/contract-request.js +3 -12
- package/dist/node/esm/proof/common.js +12 -6
- package/dist/node/esm/proof/provers/inputs-generator.js +7 -11
- package/dist/node/esm/proof/verifiers/index.js +1 -0
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +41 -26
- package/dist/node/esm/proof/verifiers/query-hash.js +35 -0
- package/dist/node/esm/proof/verifiers/query.js +23 -16
- package/dist/node/esm/schema-processor/utils.js +3 -3
- package/dist/node/esm/storage/filters/jsonQuery.js +28 -2
- package/dist/node/esm/verifiable/core-utils.js +1 -1
- package/dist/node/esm/verifiable/credential.js +2 -2
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +4 -8
- package/dist/types/circuits/atomic-query-v3.d.ts +2 -2
- package/dist/types/circuits/common.d.ts +1 -1
- package/dist/types/circuits/comparer.d.ts +4 -0
- package/dist/types/circuits/linked-multi-query.d.ts +0 -1
- package/dist/types/circuits/models.d.ts +7 -4
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +1 -0
- package/dist/types/proof/verifiers/index.d.ts +1 -0
- package/dist/types/proof/verifiers/query-hash.d.ts +3 -0
- package/dist/types/proof/verifiers/query.d.ts +1 -0
- package/dist/types/schema-processor/utils.d.ts +1 -1
- package/dist/types/storage/filters/jsonQuery.d.ts +1 -1
- package/dist/types/verifiable/core-utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -27300,7 +27300,7 @@ const parseCoreClaimSlots = async (ldCtx, mz, credentialType) => {
|
|
|
27300
27300
|
* @param {Uint8Array} schemaId
|
|
27301
27301
|
* @returns {*} {SchemaHash}
|
|
27302
27302
|
*/
|
|
27303
|
-
const
|
|
27303
|
+
const calculateCoreSchemaHash = (schemaId) => {
|
|
27304
27304
|
const sHash = Hex.decodeString(sha3Exports.keccak256(schemaId));
|
|
27305
27305
|
return new SchemaHash(sHash.slice(sHash.length - 16, sHash.length));
|
|
27306
27306
|
};
|
|
@@ -27415,7 +27415,7 @@ class W3CCredential {
|
|
|
27415
27415
|
if (!nonMerklized && opts.merklizedRootPosition === MerklizedRootPosition.None) {
|
|
27416
27416
|
opts.merklizedRootPosition = MerklizedRootPosition.Index;
|
|
27417
27417
|
}
|
|
27418
|
-
const schemaHash =
|
|
27418
|
+
const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(credentialType));
|
|
27419
27419
|
const claim = Claim.newClaim(schemaHash, ClaimOptions.withIndexDataBytes(slots.indexA, slots.indexB), ClaimOptions.withValueDataBytes(slots.valueA, slots.valueB), ClaimOptions.withRevocationNonce(BigInt(opts.revNonce)), ClaimOptions.withVersion(opts.version));
|
|
27420
27420
|
if (opts.updatable) {
|
|
27421
27421
|
claim.setFlagUpdatable(opts.updatable);
|
|
@@ -28347,14 +28347,14 @@ function checkDataInField(data) {
|
|
|
28347
28347
|
}
|
|
28348
28348
|
/**
|
|
28349
28349
|
*
|
|
28350
|
-
* @deprecated The method should not be used. Use
|
|
28350
|
+
* @deprecated The method should not be used. Use calculateCoreSchemaHash from verifiable.
|
|
28351
28351
|
* Calculates schema hash
|
|
28352
28352
|
*
|
|
28353
28353
|
* @param {Uint8Array} schemaId
|
|
28354
28354
|
* @returns {*} {SchemaHash}
|
|
28355
28355
|
*/
|
|
28356
28356
|
const createSchemaHash = (schemaId) => {
|
|
28357
|
-
return
|
|
28357
|
+
return calculateCoreSchemaHash(schemaId);
|
|
28358
28358
|
};
|
|
28359
28359
|
/**
|
|
28360
28360
|
*
|
|
@@ -55685,7 +55685,7 @@ class BaseConfig {
|
|
|
55685
55685
|
* @returns number
|
|
55686
55686
|
*/
|
|
55687
55687
|
getValueArrSize() {
|
|
55688
|
-
return this.
|
|
55688
|
+
return this.maxValueArraySize ? this.maxValueArraySize : defaultValueArraySize;
|
|
55689
55689
|
}
|
|
55690
55690
|
/**
|
|
55691
55691
|
* getMTLevelOnChain return level on chain for given circuit
|
|
@@ -55853,6 +55853,8 @@ var Operators;
|
|
|
55853
55853
|
Operators[Operators["LTE"] = 7] = "LTE";
|
|
55854
55854
|
Operators[Operators["GTE"] = 8] = "GTE";
|
|
55855
55855
|
Operators[Operators["BETWEEN"] = 9] = "BETWEEN";
|
|
55856
|
+
Operators[Operators["NONBETWEEN"] = 10] = "NONBETWEEN";
|
|
55857
|
+
Operators[Operators["EXISTS"] = 11] = "EXISTS";
|
|
55856
55858
|
Operators[Operators["SD"] = 16] = "SD";
|
|
55857
55859
|
Operators[Operators["NULLIFY"] = 17] = "NULLIFY";
|
|
55858
55860
|
})(Operators || (Operators = {}));
|
|
@@ -55868,12 +55870,17 @@ const QueryOperators = {
|
|
|
55868
55870
|
$lte: Operators.LTE,
|
|
55869
55871
|
$gte: Operators.GTE,
|
|
55870
55872
|
$between: Operators.BETWEEN,
|
|
55873
|
+
$nonbetween: Operators.NONBETWEEN,
|
|
55874
|
+
$exists: Operators.EXISTS,
|
|
55871
55875
|
$sd: Operators.SD,
|
|
55872
55876
|
$nullify: Operators.NULLIFY
|
|
55873
55877
|
};
|
|
55874
55878
|
const allOperations$1 = Object.values(QueryOperators);
|
|
55875
55879
|
const availableTypesOperators = new Map([
|
|
55876
|
-
[
|
|
55880
|
+
[
|
|
55881
|
+
XSDNS.Boolean,
|
|
55882
|
+
[QueryOperators.$eq, QueryOperators.$ne, QueryOperators.$sd, QueryOperators.$exists]
|
|
55883
|
+
],
|
|
55877
55884
|
[XSDNS.Integer, allOperations$1],
|
|
55878
55885
|
[XSDNS.NonNegativeInteger, allOperations$1],
|
|
55879
55886
|
[XSDNS.PositiveInteger, allOperations$1],
|
|
@@ -55884,7 +55891,8 @@ const availableTypesOperators = new Map([
|
|
|
55884
55891
|
QueryOperators.$ne,
|
|
55885
55892
|
QueryOperators.$in,
|
|
55886
55893
|
QueryOperators.$nin,
|
|
55887
|
-
QueryOperators.$sd
|
|
55894
|
+
QueryOperators.$sd,
|
|
55895
|
+
QueryOperators.$exists
|
|
55888
55896
|
]
|
|
55889
55897
|
],
|
|
55890
55898
|
[
|
|
@@ -55894,7 +55902,8 @@ const availableTypesOperators = new Map([
|
|
|
55894
55902
|
QueryOperators.$ne,
|
|
55895
55903
|
QueryOperators.$in,
|
|
55896
55904
|
QueryOperators.$nin,
|
|
55897
|
-
QueryOperators.$sd
|
|
55905
|
+
QueryOperators.$sd,
|
|
55906
|
+
QueryOperators.$exists
|
|
55898
55907
|
]
|
|
55899
55908
|
],
|
|
55900
55909
|
[XSDNS.DateTime, allOperations$1]
|
|
@@ -55985,6 +55994,16 @@ class Vector {
|
|
|
55985
55994
|
return this.y.includes(this.x);
|
|
55986
55995
|
case Operators.NIN:
|
|
55987
55996
|
return !this.y.includes(this.x);
|
|
55997
|
+
case Operators.BETWEEN:
|
|
55998
|
+
if (this.y.length !== 2) {
|
|
55999
|
+
return false;
|
|
56000
|
+
}
|
|
56001
|
+
return this.x >= this.y[0] && this.x <= this.y[1];
|
|
56002
|
+
case Operators.NONBETWEEN:
|
|
56003
|
+
if (this.y.length !== 2) {
|
|
56004
|
+
return false;
|
|
56005
|
+
}
|
|
56006
|
+
return this.x < this.y[0] || this.x > this.y[1];
|
|
55988
56007
|
default:
|
|
55989
56008
|
throw new Error('unknown compare type for vector');
|
|
55990
56009
|
}
|
|
@@ -56010,6 +56029,8 @@ const factoryComparer = (x, y, operator) => {
|
|
|
56010
56029
|
return new Scalar(x, y[0]);
|
|
56011
56030
|
case Operators.IN:
|
|
56012
56031
|
case Operators.NIN:
|
|
56032
|
+
case Operators.BETWEEN:
|
|
56033
|
+
case Operators.NONBETWEEN:
|
|
56013
56034
|
return new Vector(x, y);
|
|
56014
56035
|
default:
|
|
56015
56036
|
throw new Error('unknown compare type');
|
|
@@ -56033,6 +56054,48 @@ class Query {
|
|
|
56033
56054
|
this.values?.some((v) => typeof v !== 'bigint'))
|
|
56034
56055
|
throw new Error(CircuitError.EmptyQueryValue);
|
|
56035
56056
|
}
|
|
56057
|
+
validateValueArraySize(maxArrSize) {
|
|
56058
|
+
switch (this.values.length) {
|
|
56059
|
+
case 0: {
|
|
56060
|
+
const zeroArrSizeOps = [Operators.NOOP, Operators.SD, Operators.NULLIFY];
|
|
56061
|
+
if (!zeroArrSizeOps.includes(this.operator)) {
|
|
56062
|
+
throw new Error(CircuitError.InvalidValuesArrSize);
|
|
56063
|
+
}
|
|
56064
|
+
return;
|
|
56065
|
+
}
|
|
56066
|
+
case 1: {
|
|
56067
|
+
const oneArrSizeOps = [
|
|
56068
|
+
Operators.EQ,
|
|
56069
|
+
Operators.LT,
|
|
56070
|
+
Operators.GT,
|
|
56071
|
+
Operators.NE,
|
|
56072
|
+
Operators.LTE,
|
|
56073
|
+
Operators.GTE,
|
|
56074
|
+
Operators.EXISTS
|
|
56075
|
+
];
|
|
56076
|
+
if (!oneArrSizeOps.includes(this.operator)) {
|
|
56077
|
+
throw new Error(CircuitError.InvalidValuesArrSize);
|
|
56078
|
+
}
|
|
56079
|
+
return;
|
|
56080
|
+
}
|
|
56081
|
+
case 2: {
|
|
56082
|
+
const twoArrSizeOps = [Operators.BETWEEN, Operators.NONBETWEEN];
|
|
56083
|
+
if (!twoArrSizeOps.includes(this.operator)) {
|
|
56084
|
+
throw new Error(CircuitError.InvalidValuesArrSize);
|
|
56085
|
+
}
|
|
56086
|
+
return;
|
|
56087
|
+
}
|
|
56088
|
+
default: {
|
|
56089
|
+
const maxArrSizeOps = [Operators.IN, Operators.NIN];
|
|
56090
|
+
if (!maxArrSizeOps.includes(this.operator)) {
|
|
56091
|
+
throw new Error(CircuitError.InvalidOperationType);
|
|
56092
|
+
}
|
|
56093
|
+
if (!this.values.length || this.values.length > maxArrSize) {
|
|
56094
|
+
throw new Error(CircuitError.InvalidValuesArrSize);
|
|
56095
|
+
}
|
|
56096
|
+
}
|
|
56097
|
+
}
|
|
56098
|
+
}
|
|
56036
56099
|
}
|
|
56037
56100
|
/**
|
|
56038
56101
|
* CircuitID is alias for circuit identifier
|
|
@@ -56057,17 +56120,17 @@ var CircuitId;
|
|
|
56057
56120
|
* @beta
|
|
56058
56121
|
*/
|
|
56059
56122
|
// AtomicQueryV3CircuitID is a type for credentialAtomicQueryV3.circom
|
|
56060
|
-
CircuitId["AtomicQueryV3"] = "credentialAtomicQueryV3-beta.
|
|
56123
|
+
CircuitId["AtomicQueryV3"] = "credentialAtomicQueryV3-beta.1";
|
|
56061
56124
|
/**
|
|
56062
56125
|
* @beta
|
|
56063
56126
|
*/
|
|
56064
56127
|
// AtomicQueryV3OnChainCircuitID is a type for credentialAtomicQueryV3OnChain.circom
|
|
56065
|
-
CircuitId["AtomicQueryV3OnChain"] = "credentialAtomicQueryV3OnChain-beta.
|
|
56128
|
+
CircuitId["AtomicQueryV3OnChain"] = "credentialAtomicQueryV3OnChain-beta.1";
|
|
56066
56129
|
/**
|
|
56067
56130
|
* @beta
|
|
56068
56131
|
*/
|
|
56069
56132
|
// LinkedMultiQuery is a type for linkedMultiQuery.circom
|
|
56070
|
-
CircuitId["LinkedMultiQuery10"] = "linkedMultiQuery10-beta.
|
|
56133
|
+
CircuitId["LinkedMultiQuery10"] = "linkedMultiQuery10-beta.1";
|
|
56071
56134
|
})(CircuitId || (CircuitId = {}));
|
|
56072
56135
|
/**
|
|
56073
56136
|
* Claim structure for circuit inputs
|
|
@@ -56104,6 +56167,8 @@ var CircuitError;
|
|
|
56104
56167
|
CircuitError["EmptyTreeState"] = "empty tree state";
|
|
56105
56168
|
CircuitError["EmptyRequestID"] = "empty request ID";
|
|
56106
56169
|
CircuitError["InvalidProofType"] = "invalid proof type";
|
|
56170
|
+
CircuitError["InvalidValuesArrSize"] = "invalid query Values array size";
|
|
56171
|
+
CircuitError["InvalidOperationType"] = "invalid operation type";
|
|
56107
56172
|
})(CircuitError || (CircuitError = {}));
|
|
56108
56173
|
/**
|
|
56109
56174
|
* ValueProof represents a Merkle Proof for a value stored as MT
|
|
@@ -56713,6 +56778,7 @@ class AtomicQueryV3Inputs extends BaseConfig {
|
|
|
56713
56778
|
if (!this.query.values) {
|
|
56714
56779
|
throw new Error(CircuitError.EmptyQueryValue);
|
|
56715
56780
|
}
|
|
56781
|
+
this.query.validateValueArraySize(this.getValueArrSize());
|
|
56716
56782
|
if (!this.proofType) {
|
|
56717
56783
|
throw new Error(CircuitError.InvalidProofType);
|
|
56718
56784
|
}
|
|
@@ -56842,12 +56908,12 @@ class AtomicQueryV3Inputs extends BaseConfig {
|
|
|
56842
56908
|
s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev.key.bigInt().toString();
|
|
56843
56909
|
s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev.value.bigInt().toString();
|
|
56844
56910
|
s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev.noAux;
|
|
56845
|
-
s.claimPathNotExists = existenceToInt(valueProof.mtp.existence);
|
|
56846
56911
|
const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
|
|
56847
56912
|
s.claimPathMtpNoAux = nodAuxJSONLD.noAux;
|
|
56848
56913
|
s.claimPathMtpAuxHi = nodAuxJSONLD.key.bigInt().toString();
|
|
56849
56914
|
s.claimPathMtpAuxHv = nodAuxJSONLD.value.bigInt().toString();
|
|
56850
56915
|
s.claimPathKey = valueProof.path.toString();
|
|
56916
|
+
s.valueArraySize = this.query.values.length;
|
|
56851
56917
|
const values = prepareCircuitArrayValues(this.query.values, this.getValueArrSize());
|
|
56852
56918
|
s.value = bigIntArrayToStringArray(values);
|
|
56853
56919
|
s.linkNonce = this.linkNonce.toString();
|
|
@@ -56881,11 +56947,11 @@ class AtomicQueryV3PubSignals extends BaseConfig {
|
|
|
56881
56947
|
// issuerClaimNonRevState
|
|
56882
56948
|
// timestamp
|
|
56883
56949
|
// claimSchema
|
|
56884
|
-
// claimPathNotExists
|
|
56885
56950
|
// claimPathKey
|
|
56886
56951
|
// slotIndex
|
|
56887
56952
|
// operator
|
|
56888
56953
|
// value
|
|
56954
|
+
// valueArraySize
|
|
56889
56955
|
// verifierID
|
|
56890
56956
|
// nullifierSessionID
|
|
56891
56957
|
// 19 is a number of fields in AtomicQueryV3PubSignals before values, values is last element in the proof and
|
|
@@ -56936,9 +57002,6 @@ class AtomicQueryV3PubSignals extends BaseConfig {
|
|
|
56936
57002
|
// - claimSchema
|
|
56937
57003
|
this.claimSchema = SchemaHash.newSchemaHashFromInt(BigInt(sVals[fieldIdx]));
|
|
56938
57004
|
fieldIdx++;
|
|
56939
|
-
// - ClaimPathNotExists
|
|
56940
|
-
this.claimPathNotExists = parseInt(sVals[fieldIdx]);
|
|
56941
|
-
fieldIdx++;
|
|
56942
57005
|
// - ClaimPathKey
|
|
56943
57006
|
this.claimPathKey = BigInt(sVals[fieldIdx]);
|
|
56944
57007
|
fieldIdx++;
|
|
@@ -56953,6 +57016,9 @@ class AtomicQueryV3PubSignals extends BaseConfig {
|
|
|
56953
57016
|
this.value.push(BigInt(sVals[fieldIdx]));
|
|
56954
57017
|
fieldIdx++;
|
|
56955
57018
|
}
|
|
57019
|
+
// - valueArraySize
|
|
57020
|
+
this.valueArraySize = parseInt(sVals[fieldIdx]);
|
|
57021
|
+
fieldIdx++;
|
|
56956
57022
|
// - verifierID
|
|
56957
57023
|
if (sVals[fieldIdx] !== '0') {
|
|
56958
57024
|
this.verifierID = Id.fromBigInt(BigInt(sVals[fieldIdx]));
|
|
@@ -56983,13 +57049,14 @@ class AtomicQueryV3OnChainInputs extends BaseConfig {
|
|
|
56983
57049
|
if (!this.query.values) {
|
|
56984
57050
|
throw new Error(CircuitError.EmptyQueryValue);
|
|
56985
57051
|
}
|
|
57052
|
+
this.query.validateValueArraySize(this.getValueArrSize());
|
|
56986
57053
|
if (!this.proofType) {
|
|
56987
57054
|
throw new Error(CircuitError.InvalidProofType);
|
|
56988
57055
|
}
|
|
56989
57056
|
if (!this.challenge) {
|
|
56990
57057
|
throw new Error(CircuitError.EmptyChallenge);
|
|
56991
57058
|
}
|
|
56992
|
-
if (this.
|
|
57059
|
+
if (this.isBJJAuthEnabled === 1) {
|
|
56993
57060
|
if (!this.authClaimIncMtp) {
|
|
56994
57061
|
throw new Error(CircuitError.EmptyAuthClaimProof);
|
|
56995
57062
|
}
|
|
@@ -57105,7 +57172,7 @@ class AtomicQueryV3OnChainInputs extends BaseConfig {
|
|
|
57105
57172
|
isRevocationChecked: 1
|
|
57106
57173
|
};
|
|
57107
57174
|
s.challenge = this.challenge?.toString();
|
|
57108
|
-
if (this.
|
|
57175
|
+
if (this.isBJJAuthEnabled === 1) {
|
|
57109
57176
|
s.authClaim = this.authClaim?.marshalJson();
|
|
57110
57177
|
s.userClaimsTreeRoot = this.treeState.claimsRoot?.bigInt().toString();
|
|
57111
57178
|
s.userRevTreeRoot = this.treeState.revocationRoot?.bigInt().toString();
|
|
@@ -57180,18 +57247,18 @@ class AtomicQueryV3OnChainInputs extends BaseConfig {
|
|
|
57180
57247
|
s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev.key.bigInt().toString();
|
|
57181
57248
|
s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev.value.bigInt().toString();
|
|
57182
57249
|
s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev.noAux;
|
|
57183
|
-
s.claimPathNotExists = existenceToInt(valueProof.mtp.existence);
|
|
57184
57250
|
const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
|
|
57185
57251
|
s.claimPathMtpNoAux = nodAuxJSONLD.noAux;
|
|
57186
57252
|
s.claimPathMtpAuxHi = nodAuxJSONLD.key.bigInt().toString();
|
|
57187
57253
|
s.claimPathMtpAuxHv = nodAuxJSONLD.value.bigInt().toString();
|
|
57188
57254
|
s.claimPathKey = valueProof.path.toString();
|
|
57255
|
+
s.valueArraySize = this.query.values.length;
|
|
57189
57256
|
const values = prepareCircuitArrayValues(this.query.values, this.getValueArrSize());
|
|
57190
57257
|
s.value = bigIntArrayToStringArray(values);
|
|
57191
57258
|
s.linkNonce = this.linkNonce.toString();
|
|
57192
57259
|
s.verifierID = this.verifierID?.bigInt().toString() ?? '0';
|
|
57193
57260
|
s.nullifierSessionID = this.nullifierSessionID.toString();
|
|
57194
|
-
s.
|
|
57261
|
+
s.isBJJAuthEnabled = this.isBJJAuthEnabled.toString();
|
|
57195
57262
|
return byteEncoder.encode(JSON.stringify(s));
|
|
57196
57263
|
}
|
|
57197
57264
|
}
|
|
@@ -57203,7 +57270,6 @@ class AtomicQueryV3OnChainPubSignals extends BaseConfig {
|
|
|
57203
57270
|
// PubSignalsUnmarshal unmarshal credentialAtomicQueryV3.circom public signals
|
|
57204
57271
|
pubSignalsUnmarshal(data) {
|
|
57205
57272
|
// expected order:
|
|
57206
|
-
// merklized
|
|
57207
57273
|
// userID
|
|
57208
57274
|
// circuitQueryHash
|
|
57209
57275
|
// issuerState
|
|
@@ -57215,17 +57281,11 @@ class AtomicQueryV3OnChainPubSignals extends BaseConfig {
|
|
|
57215
57281
|
// challenge
|
|
57216
57282
|
// gistRoot
|
|
57217
57283
|
// issuerID
|
|
57218
|
-
// isRevocationChecked
|
|
57219
57284
|
// issuerClaimNonRevState
|
|
57220
57285
|
// timestamp
|
|
57221
|
-
//
|
|
57222
|
-
// nullifierSessionID
|
|
57223
|
-
// authEnabled
|
|
57286
|
+
// isBJJAuthEnabled
|
|
57224
57287
|
const sVals = JSON.parse(byteDecoder.decode(data));
|
|
57225
57288
|
let fieldIdx = 0;
|
|
57226
|
-
// -- merklized
|
|
57227
|
-
this.merklized = parseInt(sVals[fieldIdx]);
|
|
57228
|
-
fieldIdx++;
|
|
57229
57289
|
// - userID
|
|
57230
57290
|
this.userID = Id.fromBigInt(BigInt(sVals[fieldIdx]));
|
|
57231
57291
|
fieldIdx++;
|
|
@@ -57259,25 +57319,14 @@ class AtomicQueryV3OnChainPubSignals extends BaseConfig {
|
|
|
57259
57319
|
// - issuerID
|
|
57260
57320
|
this.issuerID = Id.fromBigInt(BigInt(sVals[fieldIdx]));
|
|
57261
57321
|
fieldIdx++;
|
|
57262
|
-
// - isRevocationChecked
|
|
57263
|
-
this.isRevocationChecked = parseInt(sVals[fieldIdx]);
|
|
57264
|
-
fieldIdx++;
|
|
57265
57322
|
// - issuerClaimNonRevState
|
|
57266
57323
|
this.issuerClaimNonRevState = Hash$1.fromString(sVals[fieldIdx]);
|
|
57267
57324
|
fieldIdx++;
|
|
57268
57325
|
// - timestamp
|
|
57269
57326
|
this.timestamp = parseInt(sVals[fieldIdx]);
|
|
57270
57327
|
fieldIdx++;
|
|
57271
|
-
// -
|
|
57272
|
-
|
|
57273
|
-
this.verifierID = Id.fromBigInt(BigInt(sVals[fieldIdx]));
|
|
57274
|
-
}
|
|
57275
|
-
fieldIdx++;
|
|
57276
|
-
// - nullifierSessionID
|
|
57277
|
-
this.nullifierSessionID = BigInt(sVals[fieldIdx]);
|
|
57278
|
-
fieldIdx++;
|
|
57279
|
-
// - authEnabled
|
|
57280
|
-
this.authEnabled = parseInt(sVals[fieldIdx]);
|
|
57328
|
+
// - isBJJAuthEnabled
|
|
57329
|
+
this.isBJJAuthEnabled = parseInt(sVals[fieldIdx]);
|
|
57281
57330
|
return this;
|
|
57282
57331
|
}
|
|
57283
57332
|
}
|
|
@@ -57687,8 +57736,6 @@ class StateTransitionPubSignals {
|
|
|
57687
57736
|
class LinkedMultiQueryInputs extends BaseConfig {
|
|
57688
57737
|
// InputsMarshal returns Circom private inputs for linkedMultiQueryInputs.circom
|
|
57689
57738
|
inputsMarshal() {
|
|
57690
|
-
const enabled = [];
|
|
57691
|
-
const claimPathNotExists = [];
|
|
57692
57739
|
const claimPathMtp = [];
|
|
57693
57740
|
const claimPathMtpNoAux = [];
|
|
57694
57741
|
const claimPathMtpAuxHi = [];
|
|
@@ -57698,10 +57745,9 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
57698
57745
|
const slotIndex = [];
|
|
57699
57746
|
const operator = [];
|
|
57700
57747
|
const value = [];
|
|
57748
|
+
const valueArraySize = [];
|
|
57701
57749
|
for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
|
|
57702
57750
|
if (!this.query[i]) {
|
|
57703
|
-
enabled.push(0);
|
|
57704
|
-
claimPathNotExists.push(0);
|
|
57705
57751
|
claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
|
|
57706
57752
|
claimPathMtpNoAux.push('0');
|
|
57707
57753
|
claimPathMtpAuxHi.push('0');
|
|
@@ -57712,9 +57758,9 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
57712
57758
|
operator.push(0);
|
|
57713
57759
|
const valuesArr = prepareCircuitArrayValues([], this.getValueArrSize());
|
|
57714
57760
|
value.push(bigIntArrayToStringArray(valuesArr));
|
|
57761
|
+
valueArraySize.push(0);
|
|
57715
57762
|
continue;
|
|
57716
57763
|
}
|
|
57717
|
-
enabled.push(1);
|
|
57718
57764
|
let valueProof = this.query[i].valueProof;
|
|
57719
57765
|
if (!valueProof) {
|
|
57720
57766
|
valueProof = new ValueProof();
|
|
@@ -57722,7 +57768,6 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
57722
57768
|
valueProof.value = 0n;
|
|
57723
57769
|
valueProof.mtp = new Proof();
|
|
57724
57770
|
}
|
|
57725
|
-
claimPathNotExists.push(existenceToInt(valueProof.mtp.existence));
|
|
57726
57771
|
claimPathMtp.push(prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaim()));
|
|
57727
57772
|
const nodAuxJSONLD = getNodeAuxValue(valueProof.mtp);
|
|
57728
57773
|
claimPathMtpNoAux.push(nodAuxJSONLD.noAux);
|
|
@@ -57732,15 +57777,14 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
57732
57777
|
claimPathValue.push(valueProof.value.toString());
|
|
57733
57778
|
slotIndex.push(this.query[i].slotIndex);
|
|
57734
57779
|
operator.push(this.query[i].operator);
|
|
57780
|
+
valueArraySize.push(this.query[i].values.length);
|
|
57735
57781
|
const valuesArr = prepareCircuitArrayValues(this.query[i].values, this.getValueArrSize());
|
|
57736
57782
|
value.push(bigIntArrayToStringArray(valuesArr));
|
|
57737
57783
|
}
|
|
57738
57784
|
const s = {
|
|
57739
57785
|
linkNonce: this.linkNonce.toString(),
|
|
57740
57786
|
issuerClaim: this.claim.marshalJson(),
|
|
57741
|
-
enabled,
|
|
57742
57787
|
claimSchema: this.claim.getSchemaHash().bigInt().toString(),
|
|
57743
|
-
claimPathNotExists,
|
|
57744
57788
|
claimPathMtp,
|
|
57745
57789
|
claimPathMtpNoAux,
|
|
57746
57790
|
claimPathMtpAuxHi,
|
|
@@ -57749,7 +57793,8 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
57749
57793
|
claimPathValue,
|
|
57750
57794
|
slotIndex,
|
|
57751
57795
|
operator,
|
|
57752
|
-
value
|
|
57796
|
+
value,
|
|
57797
|
+
valueArraySize
|
|
57753
57798
|
};
|
|
57754
57799
|
return byteEncoder.encode(JSON.stringify(s));
|
|
57755
57800
|
}
|
|
@@ -57771,7 +57816,7 @@ class LinkedMultiQueryPubSignals {
|
|
|
57771
57816
|
* @returns LinkedMultiQueryPubSignals
|
|
57772
57817
|
*/
|
|
57773
57818
|
pubSignalsUnmarshal(data) {
|
|
57774
|
-
const len =
|
|
57819
|
+
const len = 22;
|
|
57775
57820
|
const queryLength = LinkedMultiQueryInputs.queryCount;
|
|
57776
57821
|
const sVals = JSON.parse(byteDecoder.decode(data));
|
|
57777
57822
|
if (sVals.length !== len) {
|
|
@@ -57796,13 +57841,6 @@ class LinkedMultiQueryPubSignals {
|
|
|
57796
57841
|
this.circuitQueryHash.push(BigInt(sVals[fieldIdx]));
|
|
57797
57842
|
fieldIdx++;
|
|
57798
57843
|
}
|
|
57799
|
-
// - enabled
|
|
57800
|
-
this.enabled = [];
|
|
57801
|
-
for (let i = 0; i < queryLength; i++) {
|
|
57802
|
-
const enabledNum = parseInt(sVals[fieldIdx]);
|
|
57803
|
-
this.enabled.push(enabledNum === 1);
|
|
57804
|
-
fieldIdx++;
|
|
57805
|
-
}
|
|
57806
57844
|
return this;
|
|
57807
57845
|
}
|
|
57808
57846
|
}
|
|
@@ -59835,6 +59873,19 @@ const lessThanOrEqual = (a, b) => {
|
|
|
59835
59873
|
}
|
|
59836
59874
|
return a <= b;
|
|
59837
59875
|
};
|
|
59876
|
+
// a - field value
|
|
59877
|
+
// b - true / false (exists operator values)
|
|
59878
|
+
const existsComparator = (a, b) => {
|
|
59879
|
+
if (truthyValues.includes(b) && typeof a !== 'undefined') {
|
|
59880
|
+
// if exists val is true , a field val exists
|
|
59881
|
+
return true;
|
|
59882
|
+
}
|
|
59883
|
+
// if exists val is false , a field val doesn't exist
|
|
59884
|
+
if (falsyValues.includes(b) && (a === undefined || (Array.isArray(a) && !a.length))) {
|
|
59885
|
+
return true;
|
|
59886
|
+
}
|
|
59887
|
+
return false;
|
|
59888
|
+
};
|
|
59838
59889
|
const inOperator = (a, b) => {
|
|
59839
59890
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
59840
59891
|
return a.every((val) => b.includes(val));
|
|
@@ -59847,9 +59898,19 @@ const inOperator = (a, b) => {
|
|
|
59847
59898
|
}
|
|
59848
59899
|
return false;
|
|
59849
59900
|
};
|
|
59901
|
+
const betweenOperator = (a, b) => {
|
|
59902
|
+
if (!Array.isArray(b) || b.length !== 2) {
|
|
59903
|
+
throw new Error('$between/$nonbetween operator value should be 2 elements array');
|
|
59904
|
+
}
|
|
59905
|
+
if (Array.isArray(a)) {
|
|
59906
|
+
return a.every((val) => val >= b[0] && val <= b[1]);
|
|
59907
|
+
}
|
|
59908
|
+
return a >= b[0] && a <= b[1];
|
|
59909
|
+
};
|
|
59850
59910
|
const comparatorOptions = {
|
|
59851
59911
|
$noop: () => true,
|
|
59852
59912
|
$sd: () => true,
|
|
59913
|
+
$exists: (a, b) => existsComparator(a, b),
|
|
59853
59914
|
$eq: (a, b) => equalsComparator(a, b),
|
|
59854
59915
|
$in: (a, b) => inOperator(a, b),
|
|
59855
59916
|
$nin: (a, b) => !inOperator(a, b),
|
|
@@ -59857,7 +59918,9 @@ const comparatorOptions = {
|
|
|
59857
59918
|
$lt: (a, b) => !greaterThan(a, b),
|
|
59858
59919
|
$ne: (a, b) => !equalsComparator(a, b),
|
|
59859
59920
|
$gte: (a, b) => greaterThanOrEqual(a, b),
|
|
59860
|
-
$lte: (a, b) => lessThanOrEqual(a, b)
|
|
59921
|
+
$lte: (a, b) => lessThanOrEqual(a, b),
|
|
59922
|
+
$between: (a, b) => betweenOperator(a, b),
|
|
59923
|
+
$nonbetween: (a, b) => !betweenOperator(a, b)
|
|
59861
59924
|
};
|
|
59862
59925
|
/**
|
|
59863
59926
|
* credential search path resolver
|
|
@@ -59905,7 +59968,8 @@ class FilterQuery {
|
|
|
59905
59968
|
throw new Error(SearchError.NotDefinedComparator);
|
|
59906
59969
|
}
|
|
59907
59970
|
const credentialPathValue = resolvePath(credential, this.path);
|
|
59908
|
-
if (credentialPathValue === null || credentialPathValue === undefined)
|
|
59971
|
+
if ((credentialPathValue === null || credentialPathValue === undefined) &&
|
|
59972
|
+
this.operatorFunc !== existsComparator) {
|
|
59909
59973
|
return false;
|
|
59910
59974
|
}
|
|
59911
59975
|
if (this.isReverseParams) {
|
|
@@ -62290,16 +62354,21 @@ const parseCredentialSubject = (credentialSubject) => {
|
|
|
62290
62354
|
return queries;
|
|
62291
62355
|
};
|
|
62292
62356
|
const parseQueryMetadata = async (propertyQuery, ldContextJSON, credentialType, options) => {
|
|
62293
|
-
const datatype = await Path.newTypeFromContext(ldContextJSON, `${credentialType}.${propertyQuery.fieldName}`, options);
|
|
62294
62357
|
const query = {
|
|
62295
62358
|
...propertyQuery,
|
|
62296
62359
|
slotIndex: 0,
|
|
62297
62360
|
merklizedSchema: false,
|
|
62298
|
-
datatype:
|
|
62361
|
+
datatype: '',
|
|
62299
62362
|
claimPathKey: BigInt(0),
|
|
62300
62363
|
values: [],
|
|
62301
62364
|
path: new Path()
|
|
62302
62365
|
};
|
|
62366
|
+
if (!propertyQuery.fieldName && propertyQuery.operator !== Operators.NOOP) {
|
|
62367
|
+
throw new Error('query must have a field name if operator is not $noop');
|
|
62368
|
+
}
|
|
62369
|
+
if (propertyQuery.fieldName) {
|
|
62370
|
+
query.datatype = await Path.newTypeFromContext(ldContextJSON, `${credentialType}.${propertyQuery.fieldName}`, options);
|
|
62371
|
+
}
|
|
62303
62372
|
const serAttr = await getSerializationAttrFromContext(JSON.parse(ldContextJSON), options, credentialType);
|
|
62304
62373
|
if (!serAttr) {
|
|
62305
62374
|
query.merklizedSchema = true;
|
|
@@ -62321,9 +62390,10 @@ const parseQueryMetadata = async (propertyQuery, ldContextJSON, credentialType,
|
|
|
62321
62390
|
}
|
|
62322
62391
|
}
|
|
62323
62392
|
if (propertyQuery.operatorValue) {
|
|
62324
|
-
if (!isValidOperation(datatype, propertyQuery.operator)) {
|
|
62325
|
-
throw new Error(`operator ${propertyQuery.operator} is not supported for datatype ${datatype}`);
|
|
62393
|
+
if (!isValidOperation(query.datatype, propertyQuery.operator)) {
|
|
62394
|
+
throw new Error(`operator ${propertyQuery.operator} is not supported for datatype ${query.datatype}`);
|
|
62326
62395
|
}
|
|
62396
|
+
const datatype = propertyQuery.operator === Operators.EXISTS ? XSDNS.Boolean : query.datatype;
|
|
62327
62397
|
query.values = await transformQueryValueToBigInts(propertyQuery.operatorValue, datatype);
|
|
62328
62398
|
}
|
|
62329
62399
|
return query;
|
|
@@ -62333,7 +62403,7 @@ const parseQueriesMetadata = async (credentialType, ldContextJSON, credentialSub
|
|
|
62333
62403
|
return Promise.all(queriesMetadata.map((m) => parseQueryMetadata(m, ldContextJSON, credentialType, options)));
|
|
62334
62404
|
};
|
|
62335
62405
|
const transformQueryValueToBigInts = async (value, ldType) => {
|
|
62336
|
-
const values =
|
|
62406
|
+
const values = [];
|
|
62337
62407
|
if (Array.isArray(value)) {
|
|
62338
62408
|
for (let index = 0; index < value.length; index++) {
|
|
62339
62409
|
values[index] = await Merklizer.hashValue(ldType, value[index]);
|
|
@@ -62889,10 +62959,8 @@ class InputGenerator {
|
|
|
62889
62959
|
circuitInputs.profileNonce = BigInt(params.authProfileNonce);
|
|
62890
62960
|
circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
|
|
62891
62961
|
const query = circuitQueries[0];
|
|
62892
|
-
query.values =
|
|
62893
|
-
|
|
62894
|
-
? new Array(defaultValueArraySize).fill(0)
|
|
62895
|
-
: query.values;
|
|
62962
|
+
query.values = [Operators.SD, Operators.NOOP].includes(query.operator) ? [] : query.values;
|
|
62963
|
+
query.valueProof = query.operator === Operators.NOOP ? new ValueProof() : query.valueProof;
|
|
62896
62964
|
circuitInputs.query = query;
|
|
62897
62965
|
circuitInputs.currentTimeStamp = getUnixTimestamp(new Date());
|
|
62898
62966
|
circuitInputs.proofType = proofType;
|
|
@@ -62940,10 +63008,8 @@ class InputGenerator {
|
|
|
62940
63008
|
circuitInputs.profileNonce = BigInt(params.authProfileNonce);
|
|
62941
63009
|
circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
|
|
62942
63010
|
const query = circuitQueries[0];
|
|
62943
|
-
query.values =
|
|
62944
|
-
|
|
62945
|
-
? new Array(defaultValueArraySize).fill(0)
|
|
62946
|
-
: query.values;
|
|
63011
|
+
query.values = [Operators.SD, Operators.NOOP].includes(query.operator) ? [] : query.values;
|
|
63012
|
+
query.valueProof = query.operator === Operators.NOOP ? new ValueProof() : query.valueProof;
|
|
62947
63013
|
circuitInputs.query = query;
|
|
62948
63014
|
circuitInputs.currentTimeStamp = getUnixTimestamp(new Date());
|
|
62949
63015
|
circuitInputs.proofType = proofType;
|
|
@@ -62959,7 +63025,7 @@ class InputGenerator {
|
|
|
62959
63025
|
catch {
|
|
62960
63026
|
isEthIdentity = false;
|
|
62961
63027
|
}
|
|
62962
|
-
circuitInputs.
|
|
63028
|
+
circuitInputs.isBJJAuthEnabled = isEthIdentity ? 0 : 1;
|
|
62963
63029
|
circuitInputs.challenge = BigInt(params.challenge ?? 0);
|
|
62964
63030
|
const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(identifier);
|
|
62965
63031
|
const id = DID.idFromDID(genesisDID);
|
|
@@ -62967,7 +63033,7 @@ class InputGenerator {
|
|
|
62967
63033
|
const gistProof = toGISTProof(stateProof);
|
|
62968
63034
|
circuitInputs.gistProof = gistProof;
|
|
62969
63035
|
// auth inputs
|
|
62970
|
-
if (circuitInputs.
|
|
63036
|
+
if (circuitInputs.isBJJAuthEnabled === 1) {
|
|
62971
63037
|
const authPrepared = await this.prepareAuthBJJCredential(genesisDID);
|
|
62972
63038
|
const authClaimData = await this.newCircuitClaimData({
|
|
62973
63039
|
credential: authPrepared.credential,
|
|
@@ -63100,7 +63166,7 @@ async function checkQueryRequest(query, outputs, circuitId, schemaLoader, verifi
|
|
|
63100
63166
|
const schemaId = await Path.getTypeIDFromContext(JSON.stringify(schema), query.type, {
|
|
63101
63167
|
documentLoader: schemaLoader
|
|
63102
63168
|
});
|
|
63103
|
-
const schemaHash =
|
|
63169
|
+
const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(schemaId));
|
|
63104
63170
|
if (schemaHash.bigInt() !== outputs.schemaHash.bigInt()) {
|
|
63105
63171
|
throw new Error(`schema that was used is not equal to requested in query`);
|
|
63106
63172
|
}
|
|
@@ -63118,7 +63184,8 @@ async function checkQueryRequest(query, outputs, circuitId, schemaLoader, verifi
|
|
|
63118
63184
|
if (notSupportedOpIndx > -1) {
|
|
63119
63185
|
throw new Error(`circuit ${circuitId} not support ${queriesMetadata[notSupportedOpIndx].operator} operator`);
|
|
63120
63186
|
}
|
|
63121
|
-
queriesMetadata.
|
|
63187
|
+
for (let i = 0; i < queriesMetadata.length; i++) {
|
|
63188
|
+
const metadata = queriesMetadata[i];
|
|
63122
63189
|
if (!query.type) {
|
|
63123
63190
|
throw new Error(`proof query type is undefined`);
|
|
63124
63191
|
}
|
|
@@ -63171,7 +63238,7 @@ async function checkQueryRequest(query, outputs, circuitId, schemaLoader, verifi
|
|
|
63171
63238
|
if (timeDiff > acceptedProofGenerationDelay) {
|
|
63172
63239
|
throw new Error('generated proof is outdated');
|
|
63173
63240
|
}
|
|
63174
|
-
}
|
|
63241
|
+
}
|
|
63175
63242
|
return;
|
|
63176
63243
|
}
|
|
63177
63244
|
async function validateEmptyCredentialSubject(cq, outputs) {
|
|
@@ -63200,14 +63267,14 @@ async function validateOperators(cq, outputs) {
|
|
|
63200
63267
|
}
|
|
63201
63268
|
for (let index = 0; index < outputs.value.length; index++) {
|
|
63202
63269
|
if (outputs.value[index] !== cq.values[index]) {
|
|
63270
|
+
if (outputs.value[index] === 0n && cq.values[index] === undefined) {
|
|
63271
|
+
continue;
|
|
63272
|
+
}
|
|
63203
63273
|
throw new Error(`comparison value that was used is not equal to requested in query`);
|
|
63204
63274
|
}
|
|
63205
63275
|
}
|
|
63206
63276
|
}
|
|
63207
63277
|
async function validateDisclosure(cq, outputs, verifiablePresentation, ldLoader) {
|
|
63208
|
-
if (!verifiablePresentation) {
|
|
63209
|
-
throw new Error(`verifiablePresentation is required for selective disclosure request`);
|
|
63210
|
-
}
|
|
63211
63278
|
if (outputs.operator !== Operators.EQ) {
|
|
63212
63279
|
throw new Error(`operator for selective disclosure must be $eq`);
|
|
63213
63280
|
}
|
|
@@ -63216,6 +63283,15 @@ async function validateDisclosure(cq, outputs, verifiablePresentation, ldLoader)
|
|
|
63216
63283
|
throw new Error(`selective disclosure not available for array of values`);
|
|
63217
63284
|
}
|
|
63218
63285
|
}
|
|
63286
|
+
const bi = await fieldValueFromVerifiablePresentation(cq.fieldName, verifiablePresentation, ldLoader);
|
|
63287
|
+
if (bi !== outputs.value[0]) {
|
|
63288
|
+
throw new Error(`value that was used is not equal to requested in query`);
|
|
63289
|
+
}
|
|
63290
|
+
}
|
|
63291
|
+
const fieldValueFromVerifiablePresentation = async (fieldName, verifiablePresentation, ldLoader) => {
|
|
63292
|
+
if (!verifiablePresentation) {
|
|
63293
|
+
throw new Error(`verifiablePresentation is required for selective disclosure request`);
|
|
63294
|
+
}
|
|
63219
63295
|
let mz;
|
|
63220
63296
|
const strVerifiablePresentation = JSON.stringify(verifiablePresentation);
|
|
63221
63297
|
try {
|
|
@@ -63228,13 +63304,13 @@ async function validateDisclosure(cq, outputs, verifiablePresentation, ldLoader)
|
|
|
63228
63304
|
}
|
|
63229
63305
|
let merklizedPath;
|
|
63230
63306
|
try {
|
|
63231
|
-
const p = `verifiableCredential.credentialSubject.${
|
|
63307
|
+
const p = `verifiableCredential.credentialSubject.${fieldName}`;
|
|
63232
63308
|
merklizedPath = await Path.fromDocument(null, strVerifiablePresentation, p, {
|
|
63233
63309
|
documentLoader: ldLoader
|
|
63234
63310
|
});
|
|
63235
63311
|
}
|
|
63236
63312
|
catch (e) {
|
|
63237
|
-
throw new Error(`can't build path to '${
|
|
63313
|
+
throw new Error(`can't build path to '${fieldName}' key`);
|
|
63238
63314
|
}
|
|
63239
63315
|
let proof;
|
|
63240
63316
|
let value;
|
|
@@ -63242,18 +63318,49 @@ async function validateDisclosure(cq, outputs, verifiablePresentation, ldLoader)
|
|
|
63242
63318
|
({ proof, value } = await mz.proof(merklizedPath));
|
|
63243
63319
|
}
|
|
63244
63320
|
catch (e) {
|
|
63245
|
-
throw new Error(`can't get value by path '${
|
|
63321
|
+
throw new Error(`can't get value by path '${fieldName}'`);
|
|
63246
63322
|
}
|
|
63247
63323
|
if (!value) {
|
|
63248
|
-
throw new Error(`can't get merkle value for field '${
|
|
63324
|
+
throw new Error(`can't get merkle value for field '${fieldName}'`);
|
|
63249
63325
|
}
|
|
63250
63326
|
if (!proof.existence) {
|
|
63251
63327
|
throw new Error(`path [${merklizedPath.parts}] doesn't exist in verifiablePresentation document`);
|
|
63252
63328
|
}
|
|
63253
|
-
|
|
63254
|
-
|
|
63255
|
-
|
|
63256
|
-
|
|
63329
|
+
return await value.mtEntry();
|
|
63330
|
+
};
|
|
63331
|
+
|
|
63332
|
+
function calculateQueryHashV2(values, schema, slotIndex, operator, claimPathKey, claimPathNotExists) {
|
|
63333
|
+
const expValue = prepareCircuitArrayValues(values, 64);
|
|
63334
|
+
const valueHash = poseidon.spongeHashX(expValue, 6);
|
|
63335
|
+
return poseidon.hash([
|
|
63336
|
+
schema.bigInt(),
|
|
63337
|
+
BigInt(slotIndex),
|
|
63338
|
+
BigInt(operator),
|
|
63339
|
+
BigInt(claimPathKey),
|
|
63340
|
+
BigInt(claimPathNotExists),
|
|
63341
|
+
valueHash
|
|
63342
|
+
]);
|
|
63343
|
+
}
|
|
63344
|
+
function calculateQueryHashV3(values, schema, slotIndex, operator, claimPathKey, valueArraySize, merklized, isRevocationChecked, verifierID, nullifierSessionID) {
|
|
63345
|
+
const expValue = prepareCircuitArrayValues(values, defaultValueArraySize);
|
|
63346
|
+
const valueHash = poseidon.spongeHashX(expValue, 6);
|
|
63347
|
+
const firstPartQueryHash = poseidon.hash([
|
|
63348
|
+
schema.bigInt(),
|
|
63349
|
+
BigInt(slotIndex),
|
|
63350
|
+
BigInt(operator),
|
|
63351
|
+
BigInt(claimPathKey),
|
|
63352
|
+
BigInt(merklized),
|
|
63353
|
+
valueHash
|
|
63354
|
+
]);
|
|
63355
|
+
const queryHash = poseidon.hash([
|
|
63356
|
+
firstPartQueryHash,
|
|
63357
|
+
BigInt(valueArraySize),
|
|
63358
|
+
BigInt(isRevocationChecked),
|
|
63359
|
+
BigInt(verifierID),
|
|
63360
|
+
BigInt(nullifierSessionID),
|
|
63361
|
+
0n
|
|
63362
|
+
]);
|
|
63363
|
+
return queryHash;
|
|
63257
63364
|
}
|
|
63258
63365
|
|
|
63259
63366
|
const userStateError = new Error(`user state is not valid`);
|
|
@@ -63353,7 +63460,6 @@ class PubSignalsVerifier {
|
|
|
63353
63460
|
timestamp: v3PubSignals.timestamp,
|
|
63354
63461
|
merklized: v3PubSignals.merklized,
|
|
63355
63462
|
claimPathKey: v3PubSignals.claimPathKey,
|
|
63356
|
-
claimPathNotExists: v3PubSignals.claimPathNotExists,
|
|
63357
63463
|
valueArraySize: v3PubSignals.getValueArrSize(),
|
|
63358
63464
|
isRevocationChecked: v3PubSignals.isRevocationChecked
|
|
63359
63465
|
};
|
|
@@ -63430,7 +63536,7 @@ class PubSignalsVerifier {
|
|
|
63430
63536
|
this.verifyIdOwnership(sender, challenge);
|
|
63431
63537
|
return new BaseConfig();
|
|
63432
63538
|
};
|
|
63433
|
-
this.linkedMultiQuery10Verify = async ({ query, pubSignals }) => {
|
|
63539
|
+
this.linkedMultiQuery10Verify = async ({ query, verifiablePresentation, pubSignals }) => {
|
|
63434
63540
|
let multiQueryPubSignals = new LinkedMultiQueryPubSignals();
|
|
63435
63541
|
multiQueryPubSignals = multiQueryPubSignals.pubSignalsUnmarshal(byteEncoder.encode(JSON.stringify(pubSignals)));
|
|
63436
63542
|
// verify query
|
|
@@ -63444,26 +63550,41 @@ class PubSignalsVerifier {
|
|
|
63444
63550
|
}
|
|
63445
63551
|
const ldContextJSON = JSON.stringify(schema);
|
|
63446
63552
|
const credentialSubject = query.credentialSubject;
|
|
63447
|
-
const schemaId = await Path.getTypeIDFromContext(
|
|
63448
|
-
const schemaHash =
|
|
63553
|
+
const schemaId = await Path.getTypeIDFromContext(ldContextJSON, query.type || '', ldOpts);
|
|
63554
|
+
const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(schemaId));
|
|
63449
63555
|
const queriesMetadata = await parseQueriesMetadata(query.type || '', ldContextJSON, credentialSubject, ldOpts);
|
|
63450
|
-
const
|
|
63451
|
-
|
|
63452
|
-
|
|
63453
|
-
|
|
63454
|
-
|
|
63455
|
-
|
|
63456
|
-
|
|
63457
|
-
|
|
63458
|
-
|
|
63459
|
-
|
|
63460
|
-
|
|
63461
|
-
|
|
63462
|
-
.
|
|
63463
|
-
|
|
63464
|
-
|
|
63465
|
-
|
|
63466
|
-
|
|
63556
|
+
const request = [];
|
|
63557
|
+
const merklized = queriesMetadata[0]?.merklizedSchema ? 1 : 0;
|
|
63558
|
+
for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
|
|
63559
|
+
const queryMeta = queriesMetadata[i];
|
|
63560
|
+
const values = queryMeta?.values ?? [];
|
|
63561
|
+
const valArrSize = values.length;
|
|
63562
|
+
const queryHash = calculateQueryHashV3(values, schemaHash, queryMeta?.slotIndex ?? 0, queryMeta?.operator ?? 0, queryMeta?.claimPathKey.toString() ?? 0, valArrSize, merklized, 0, 0, 0);
|
|
63563
|
+
request.push({ queryHash, queryMeta });
|
|
63564
|
+
}
|
|
63565
|
+
const queryHashCompare = (a, b) => {
|
|
63566
|
+
if (a.queryHash < b.queryHash)
|
|
63567
|
+
return -1;
|
|
63568
|
+
if (a.queryHash > b.queryHash)
|
|
63569
|
+
return 1;
|
|
63570
|
+
return 0;
|
|
63571
|
+
};
|
|
63572
|
+
const pubSignalsMeta = multiQueryPubSignals.circuitQueryHash.map((queryHash, index) => ({
|
|
63573
|
+
queryHash,
|
|
63574
|
+
operatorOutput: multiQueryPubSignals.operatorOutput[index]
|
|
63575
|
+
}));
|
|
63576
|
+
pubSignalsMeta.sort(queryHashCompare);
|
|
63577
|
+
request.sort(queryHashCompare);
|
|
63578
|
+
for (let i = 0; i < LinkedMultiQueryInputs.queryCount; i++) {
|
|
63579
|
+
if (request[i].queryHash != pubSignalsMeta[i].queryHash) {
|
|
63580
|
+
throw new Error('query hashes do not match');
|
|
63581
|
+
}
|
|
63582
|
+
if (request[i].queryMeta?.operator === Operators.SD) {
|
|
63583
|
+
const disclosedValue = await fieldValueFromVerifiablePresentation(request[i].queryMeta.fieldName, verifiablePresentation, this._documentLoader);
|
|
63584
|
+
if (disclosedValue != pubSignalsMeta[i].operatorOutput) {
|
|
63585
|
+
throw new Error('disclosed value is not in the proof outputs');
|
|
63586
|
+
}
|
|
63587
|
+
}
|
|
63467
63588
|
}
|
|
63468
63589
|
return multiQueryPubSignals;
|
|
63469
63590
|
};
|
|
@@ -64891,19 +65012,11 @@ class ContractRequestHandler {
|
|
|
64891
65012
|
throw new Error("Can't sign transaction. Provide Signer in options.");
|
|
64892
65013
|
}
|
|
64893
65014
|
const zkRequests = [];
|
|
64894
|
-
const {
|
|
65015
|
+
const { chain_id } = ciRequest.body.transaction_data;
|
|
64895
65016
|
const networkFlag = Object.keys(ChainIds).find((key) => ChainIds[key] === chain_id);
|
|
64896
65017
|
if (!networkFlag) {
|
|
64897
65018
|
throw new Error(`Invalid chain id ${chain_id}`);
|
|
64898
65019
|
}
|
|
64899
|
-
const [blockchain, networkId] = networkFlag.split(':');
|
|
64900
|
-
const verifierId = buildVerifierId(contract_address, {
|
|
64901
|
-
blockchain,
|
|
64902
|
-
networkId,
|
|
64903
|
-
// DidMethod.Iden3 is used based on discussions: all onchain issuers have iden3 did method by default. This can be changed in the release of v3 circuit.
|
|
64904
|
-
method: DidMethod.Iden3
|
|
64905
|
-
});
|
|
64906
|
-
const verifierDid = DID.parseFromId(verifierId);
|
|
64907
65020
|
for (const proofReq of ciRequest.body.scope) {
|
|
64908
65021
|
if (!this._allowedCircuits.includes(proofReq.circuitId)) {
|
|
64909
65022
|
throw new Error(`Can't handle circuit ${proofReq.circuitId}. Only onchain circuits are allowed.`);
|
|
@@ -64912,7 +65025,7 @@ class ContractRequestHandler {
|
|
|
64912
65025
|
const zkpRes = await this._proofService.generateProof(proofReq, did, {
|
|
64913
65026
|
skipRevocation: query.skipClaimRevocationCheck ?? false,
|
|
64914
65027
|
challenge: opts.challenge,
|
|
64915
|
-
verifierDid
|
|
65028
|
+
verifierDid: ciRequest.from ? DID.parse(ciRequest.from) : undefined
|
|
64916
65029
|
});
|
|
64917
65030
|
zkRequests.push(zkpRes);
|
|
64918
65031
|
}
|
|
@@ -64985,5 +65098,5 @@ class RefreshHandler {
|
|
|
64985
65098
|
}
|
|
64986
65099
|
}
|
|
64987
65100
|
|
|
64988
|
-
export { 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, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, 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, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes, base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58, bytesToBase64, bytesToBase64url, bytesToHex$1 as bytesToHex, cacheLoader,
|
|
65101
|
+
export { 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, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, 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, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes, base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58, bytesToBase64, bytesToBase64url, bytesToHex$1 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$1 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, pushHashesToRHS, resolveDIDDocumentAuth, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateTreeState, witnessBuilder };
|
|
64989
65102
|
//# sourceMappingURL=index.js.map
|