diff --git a/circuits/credentialAtomicQueryV3.circom b/circuits/credentialAtomicQueryV3.circom index 8b51909d..4436e315 100644 --- a/circuits/credentialAtomicQueryV3.circom +++ b/circuits/credentialAtomicQueryV3.circom @@ -16,7 +16,6 @@ component main{public [requestID, claimSchema, slotIndex, claimPathKey, - claimPathNotExists, operator, value, valueArraySize, diff --git a/circuits/credentialAtomicQueryV3OnChain.circom b/circuits/credentialAtomicQueryV3OnChain.circom index da74bf17..9e56936d 100644 --- a/circuits/credentialAtomicQueryV3OnChain.circom +++ b/circuits/credentialAtomicQueryV3OnChain.circom @@ -14,11 +14,8 @@ component main{public [requestID, issuerID, issuerClaimNonRevState, timestamp, - isRevocationChecked, challenge, gistRoot, proofType, - verifierID, - nullifierSessionID, - authEnabled + isBJJAuthEnabled ]} = credentialAtomicQueryV3OnChain(40, 32, 64, 40, 64); diff --git a/circuits/lib/query/processQueryWithModifiers.circom b/circuits/lib/query/processQueryWithModifiers.circom index 2c8ac4b9..769aa1da 100644 --- a/circuits/lib/query/processQueryWithModifiers.circom +++ b/circuits/lib/query/processQueryWithModifiers.circom @@ -8,7 +8,6 @@ include "../utils/arraySizeValidator.circom"; template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ signal input enabled; - signal input claimPathNotExists; // 0 for inclusion, 1 for non-inclusion signal input claimPathMtp[claimLevels]; signal input claimPathMtpNoAux; // 1 if aux node is empty, 0 if non-empty or for inclusion proofs signal input claimPathMtpAuxHi; // 0 for inclusion proof @@ -27,11 +26,14 @@ template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ // Modifier/Computation Operator output ($sd) signal output operatorOutput; - signal smtEnabled <== AND()(enabled, merklized); + signal operatorNotNoop <== NOT()(IsZero()(operator)); + signal merklizedAndEnabled <== AND()(enabled, merklized); + + signal claimPathNotExists <== AND()(IsZero()(value[0]), IsEqual()([operator, 11])); // for exist and value 0 operator 1, else 0 // check path/in node exists in merkletree specified by jsonldRoot SMTVerifier(claimLevels)( - enabled <== smtEnabled, // if merklize flag 0 or enabled 0 skip MTP verification + enabled <== AND()(merklizedAndEnabled, operatorNotNoop), // if merklize flag 0 or enabled 0 or NOOP operation skip MTP verification fnc <== claimPathNotExists, // inclusion root <== merklizedRoot, siblings <== claimPathMtp, @@ -53,6 +55,13 @@ template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ merklized ); + // For non-merklized credentials exists / non-exist operators don't work + signal operatorNotExists <== NOT()(IsEqual()([operator, 11])); + ForceEqualIfEnabled()( + AND()(enabled, NOT()(merklized)), + [1, operatorNotExists] + ); + ///////////////////////////////////////////////////////////////// // Query Operator Processing ///////////////////////////////////////////////////////////////// diff --git a/circuits/lib/query/query.circom b/circuits/lib/query/query.circom index 513a6282..0cb2e59c 100644 --- a/circuits/lib/query/query.circom +++ b/circuits/lib/query/query.circom @@ -20,6 +20,7 @@ include "comparators.circom"; 8 - greater than or equal 9 - between 10 - not between + 11 - exist Modifier/computation operators: 16 - selective disclosure (16 = 10000 binary) */ @@ -76,7 +77,7 @@ template Query (maxValueArraySize) { queryOpSatisfied.c[8] <== gte; // gte === !lt queryOpSatisfied.c[9] <== between; // between queryOpSatisfied.c[10] <== NOT()(between); // not between - queryOpSatisfied.c[11] <== 0; // not used + queryOpSatisfied.c[11] <== 1; // exists; queryOpSatisfied.c[12] <== 0; // not used queryOpSatisfied.c[13] <== 0; // not used queryOpSatisfied.c[14] <== 0; // not used diff --git a/circuits/lib/utils/arraySizeValidator.circom b/circuits/lib/utils/arraySizeValidator.circom index 8b188b9e..cbb2e1b5 100644 --- a/circuits/lib/utils/arraySizeValidator.circom +++ b/circuits/lib/utils/arraySizeValidator.circom @@ -19,6 +19,7 @@ include "../query/comparators.circom"; 8 - greater than or equal - 1 element 9 - between - 2 elements 10 - not between - 2 elements + 11 - exists - 1 elements (true/false) Modifier/computation operators: 16 - selective disclosure (16 = 10000 binary) - 0 elements 17-31 - 0 elements @@ -62,7 +63,7 @@ template ArraySizeValidator (maxValueArraySize) { mux.c[8] <== sizeEqOne; // gte mux.c[9] <== sizeEqTwo; // between mux.c[10] <== sizeEqTwo; // not between - mux.c[11] <== sizeEqZero; // not used + mux.c[11] <== sizeEqOne; // exist mux.c[12] <== sizeEqZero; // not used mux.c[13] <== sizeEqZero; // not used mux.c[14] <== sizeEqZero; // not used diff --git a/circuits/lib/utils/queryHash.circom b/circuits/lib/utils/queryHash.circom new file mode 100644 index 00000000..f21f53e0 --- /dev/null +++ b/circuits/lib/utils/queryHash.circom @@ -0,0 +1,42 @@ +pragma circom 2.1.1; +include "./spongeHash.circom"; + +template QueryHash(maxValueArraySize) { + signal input value[maxValueArraySize]; + signal input claimSchema; + signal input slotIndex; + signal input operator; + signal input claimPathKey; + signal input valueArraySize; + signal input merklized; + signal input isRevocationChecked; + signal input verifierID; + signal input nullifierSessionID; + + signal output out; + + signal claimPathNotExists <== AND()(IsZero()(value[0]), IsEqual()([operator, 11])); + + ///////////////////////////////////////////////////////////////// + // Calculate query hash + ///////////////////////////////////////////////////////////////// + // 4950 constraints (SpongeHash+Poseidon) + signal valueHash <== SpongeHash(maxValueArraySize, 6)(value); // 6 - max size of poseidon hash available on-chain + signal firstPartQueryHash <== Poseidon(6)([ + claimSchema, + slotIndex, + operator, + claimPathKey, + claimPathNotExists, + valueHash + ]); + + out <== Poseidon(6)([ + firstPartQueryHash, + valueArraySize, + merklized, + isRevocationChecked, + verifierID, + nullifierSessionID + ]); +} \ No newline at end of file diff --git a/circuits/linked/multiQuery.circom b/circuits/linked/multiQuery.circom index 49d3f553..c38b6f7b 100644 --- a/circuits/linked/multiQuery.circom +++ b/circuits/linked/multiQuery.circom @@ -5,19 +5,17 @@ include "../lib/query/processQueryWithModifiers.circom"; include "../lib/linked/linkId.circom"; include "../lib/utils/claimUtils.circom"; include "../lib/utils/safeOne.circom"; -include "../lib/utils/spongeHash.circom"; +include "../lib/utils/queryHash.circom"; // This circuit processes multiple query requests at once for a given claim using linked proof -template LinkedMultiQuery(N, claimLevels, valueArraySize) { +template LinkedMultiQuery(N, claimLevels, maxValueArraySize) { // linked proof signals signal input linkNonce; signal input issuerClaim[8]; // query signals - signal input enabled[N]; // 1 if query non-empty, 0 to skip query check signal input claimSchema; - signal input claimPathNotExists[N]; // 0 for inclusion, 1 for non-inclusion signal input claimPathMtp[N][claimLevels]; signal input claimPathMtpNoAux[N]; // 1 if aux node is empty, 0 if non-empty or for inclusion proofs signal input claimPathMtpAuxHi[N]; // 0 for inclusion proof @@ -26,7 +24,8 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) { signal input claimPathValue[N]; // value in this path in merklized json-ld document signal input slotIndex[N]; signal input operator[N]; - signal input value[N][valueArraySize]; + signal input value[N][maxValueArraySize]; + signal input valueArraySize[N]; // Outputs signal output linkID; @@ -55,9 +54,6 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) { // Verify issuerClaim schema verifyCredentialSchema()(one, issuerClaimHeader.schema, claimSchema); // 3 constraints - signal valueHash[N]; - signal queryHash[N]; - signal issuerClaimHash, issuerClaimHi, issuerClaimHv; (issuerClaimHash, issuerClaimHi, issuerClaimHv) <== getClaimHash()(issuerClaim); // 834 constraints //////////////////////////////////////////////////////////////////////// @@ -65,15 +61,17 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) { //////////////////////////////////////////////////////////////////////// linkID <== LinkID()(issuerClaimHash, linkNonce); // 243 constraints + + signal operatorNotNoop[N]; ///////////////////////////////////////////////////////////////// // Query Processing Loop ///////////////////////////////////////////////////////////////// for (var i=0; i { const w = await circuit.calculateWitness({ in: "0", diff --git a/testvectorgen/credentials/onchain/v3/v3_test.go b/testvectorgen/credentials/onchain/v3/v3_test.go index b0279730..2f936d39 100644 --- a/testvectorgen/credentials/onchain/v3/v3_test.go +++ b/testvectorgen/credentials/onchain/v3/v3_test.go @@ -84,13 +84,12 @@ type Inputs struct { // Query // JSON path - ClaimPathNotExists string `json:"claimPathNotExists"` // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp []string `json:"claimPathMtp"` - ClaimPathMtpNoAux string `json:"claimPathMtpNoAux"` // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi string `json:"claimPathMtpAuxHi"` // 0 for inclusion proof - ClaimPathMtpAuxHv string `json:"claimPathMtpAuxHv"` // 0 for inclusion proof - ClaimPathKey string `json:"claimPathKey"` // hash of path in merklized json-ld document - ClaimPathValue string `json:"claimPathValue"` // value in this path in merklized json-ld document + ClaimPathMtp []string `json:"claimPathMtp"` + ClaimPathMtpNoAux string `json:"claimPathMtpNoAux"` // 1 if aux node is empty, 0 if non-empty or for inclusion proofs + ClaimPathMtpAuxHi string `json:"claimPathMtpAuxHi"` // 0 for inclusion proof + ClaimPathMtpAuxHv string `json:"claimPathMtpAuxHv"` // 0 for inclusion proof + ClaimPathKey string `json:"claimPathKey"` // hash of path in merklized json-ld document + ClaimPathValue string `json:"claimPathValue"` // value in this path in merklized json-ld document Operator int `json:"operator"` SlotIndex int `json:"slotIndex"` @@ -121,7 +120,7 @@ type Inputs struct { VerifierID string `json:"verifierID"` NullifierSessionID string `json:"nullifierSessionID"` - AuthEnabled int `json:"authEnabled"` + IsBJJAuthEnabled int `json:"isBJJAuthEnabled"` } type Outputs struct { @@ -134,15 +133,12 @@ type Outputs struct { Timestamp string `json:"timestamp"` Merklized string `json:"merklized"` ProofType string `json:"proofType"` // 1 for sig, 2 for mtp - IsRevocationChecked string `json:"isRevocationChecked"` Challenge string `json:"challenge"` IssuerState string `json:"issuerState"` LinkID string `json:"linkID"` - VerifierID string `json:"verifierID"` - NullifierSessionID string `json:"nullifierSessionID"` OperatorOutput string `json:"operatorOutput"` Nullifier string `json:"nullifier"` - AuthEnabled string `json:"authEnabled"` + IsBJJAuthEnabled string `json:"isBJJAuthEnabled"` } type TestData struct { @@ -300,8 +296,8 @@ func generateRevokedTestData(t *testing.T, desc string, isUserIDProfile, isSubje } func generateTestDataWithOperator(t *testing.T, desc string, isUserIDProfile, isSubjectIDProfile bool, - linkNonce string, fileName string, operator int, value *[]string, proofType ProofType, authEnabled int) { - generateTestDataWithOperatorAndRevCheck(t, desc, isUserIDProfile, isSubjectIDProfile, linkNonce, "0", fileName, operator, value, false, 1, false, proofType, authEnabled) + linkNonce string, fileName string, operator int, value *[]string, proofType ProofType, isBJJAuthEnabled int) { + generateTestDataWithOperatorAndRevCheck(t, desc, isUserIDProfile, isSubjectIDProfile, linkNonce, "0", fileName, operator, value, false, 1, false, proofType, isBJJAuthEnabled) } func generateJSONLDTestData(t *testing.T, desc string, isUserIDProfile, isSubjectIDProfile bool, fileName string, proofType ProofType) { @@ -310,7 +306,7 @@ func generateJSONLDTestData(t *testing.T, desc string, isUserIDProfile, isSubjec func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserIDProfile, isSubjectIDProfile bool, linkNonce, nullifierSessionID, fileName string, operator int, value *[]string, isRevoked bool, isRevocationChecked int, isJSONLD bool, testProofType ProofType, - authEnabled int) { + isBJJAuthEnabled int) { var err error valueInput := []string{"10"} @@ -521,7 +517,6 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion ClaimPathMtp: claimPathMtp, ClaimPathMtpNoAux: claimPathMtpNoAux, ClaimPathMtpAuxHi: claimPathMtpAuxHi, @@ -555,39 +550,27 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID VerifierID: "21929109382993718606847853573861987353620810345503358891473103689157378049", NullifierSessionID: nullifierSessionID, - AuthEnabled: authEnabled, + IsBJJAuthEnabled: isBJJAuthEnabled, } valuesHash, err := utils.PoseidonHashValue(utils.FromStringArrayToBigIntArray(inputs.Value)) require.NoError(t, err) claimSchemaInt, ok := big.NewInt(0).SetString(inputs.ClaimSchema, 10) require.True(t, ok) - circuitQueryHash, err := poseidon.Hash([]*big.Int{ - claimSchemaInt, - big.NewInt(int64(inputs.SlotIndex)), - big.NewInt(int64(inputs.Operator)), - pathKey, - big.NewInt(0), - valuesHash, - big.NewInt(int64(valueArraySize)), - }) - require.NoError(t, err) linkID, err := utils.CalculateLinkID(linkNonce, claim) require.NoError(t, err) operatorOutput := "0" nullifier := "0" + verifierID, ok := big.NewInt(0).SetString(inputs.VerifierID, 10) + require.True(t, ok) + nullifierSessionID_, ok := big.NewInt(0).SetString(inputs.NullifierSessionID, 10) + require.True(t, ok) if inputs.NullifierSessionID != "0" { claimSchema, ok := big.NewInt(0).SetString(inputs.ClaimSchema, 10) require.True(t, ok) - verifierID, ok := big.NewInt(0).SetString(inputs.VerifierID, 10) - require.True(t, ok) - - nullifierSessionID_, ok := big.NewInt(0).SetString(inputs.NullifierSessionID, 10) - require.True(t, ok) - nullifier, err = utils.CalculateNullify( user.ID.BigInt(), nonceSubject, @@ -598,6 +581,27 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID require.NoError(t, err) } + firstPartQueryHash, err := poseidon.Hash([]*big.Int{ + claimSchemaInt, + big.NewInt(int64(inputs.SlotIndex)), + big.NewInt(int64(inputs.Operator)), + pathKey, + big.NewInt(0), + valuesHash, + }) + require.NoError(t, err) + merklizedBigInt, ok := big.NewInt(0).SetString(merklized, 10) + require.True(t, ok) + circuitQueryHash, err := poseidon.Hash([]*big.Int{ + firstPartQueryHash, + big.NewInt(int64(valueArraySize)), + merklizedBigInt, + big.NewInt(int64(isRevocationChecked)), + verifierID, + nullifierSessionID_, + }) + require.NoError(t, err) + if operator == utils.SD { operatorOutput = big.NewInt(10).String() } @@ -621,15 +625,12 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID Merklized: merklized, Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: strconv.Itoa(isRevocationChecked), ProofType: proofType, IssuerState: issuerState, LinkID: linkID, OperatorOutput: operatorOutput, - VerifierID: inputs.VerifierID, - NullifierSessionID: inputs.NullifierSessionID, Nullifier: nullifier, - AuthEnabled: strconv.Itoa(authEnabled), + IsBJJAuthEnabled: strconv.Itoa(isBJJAuthEnabled), } jsonData, err := json.Marshal(TestData{ @@ -674,6 +675,7 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj require.NoError(t, err) jsonP, _, err := mz.Proof(context.Background(), path) + require.NoError(t, err) claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) @@ -708,7 +710,7 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj gistRoot := gisTree.Root() gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - valueArraySize := utils.GetValueArraySizeForOperator(utils.NOOP) + valueArraySize := utils.GetValueArraySizeForOperator(utils.EXISTS) inputs := Inputs{ RequestID: requestID.String(), @@ -759,20 +761,19 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj IssuerAuthState: issuer.State(t).String(), ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "1", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: claimJSONLDProof, - ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, // 0 for inclusion proof - ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, // 0 for inclusion proof - ClaimPathKey: pathKey.String(), // hash of path in merklized json-ld document - ClaimPathValue: "0", // value in this path in merklized json-ld document + ClaimPathMtp: claimJSONLDProof, + ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, // 1 if aux node is empty, 0 if non-empty or for inclusion proofs + ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, // 0 for inclusion proof + ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, // 0 for inclusion proof + ClaimPathKey: pathKey.String(), // hash of path in merklized json-ld document + ClaimPathValue: "0", // value in this path in merklized json-ld document // value in this path in merklized json-ld document - Operator: utils.NOOP, + Operator: utils.EXISTS, SlotIndex: 0, Timestamp: timestamp, IsRevocationChecked: 1, - Value: utils.PrepareStrArray([]string{}, 64), + Value: utils.PrepareStrArray([]string{"0"}, 64), ValueArraySize: valueArraySize, // additional mtp inputs @@ -789,7 +790,7 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj VerifierID: "21929109382993718606847853573861987353620810345503358891473103689157378049", NullifierSessionID: "0", - AuthEnabled: 1, + IsBJJAuthEnabled: 1, } issuerAuthState := issuer.State(t) @@ -798,14 +799,28 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj require.NoError(t, err) claimSchemaInt, ok := big.NewInt(0).SetString(inputs.ClaimSchema, 10) require.True(t, ok) - circuitQueryHash, err := poseidon.Hash([]*big.Int{ + + firstPartQueryHash, err := poseidon.Hash([]*big.Int{ claimSchemaInt, big.NewInt(int64(inputs.SlotIndex)), big.NewInt(int64(inputs.Operator)), pathKey, big.NewInt(1), valuesHash, + }) + require.NoError(t, err) + verifierID, ok := big.NewInt(0).SetString(inputs.VerifierID, 10) + require.True(t, ok) + nullifierSessionID_, ok := big.NewInt(0).SetString(inputs.NullifierSessionID, 10) + require.True(t, ok) + + circuitQueryHash, err := poseidon.Hash([]*big.Int{ + firstPartQueryHash, big.NewInt(int64(valueArraySize)), + big.NewInt(1), + big.NewInt(1), + verifierID, + nullifierSessionID_, }) require.NoError(t, err) @@ -820,14 +835,11 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), IssuerState: issuerAuthState.String(), - IsRevocationChecked: "1", ProofType: "1", LinkID: "0", - VerifierID: inputs.VerifierID, - NullifierSessionID: inputs.NullifierSessionID, OperatorOutput: "0", Nullifier: "0", - AuthEnabled: "1", + IsBJJAuthEnabled: "1", } jsonData, err := json.Marshal(TestData{ diff --git a/testvectorgen/credentials/v3/v3_test.go b/testvectorgen/credentials/v3/v3_test.go index 78e08cac..799c3323 100644 --- a/testvectorgen/credentials/v3/v3_test.go +++ b/testvectorgen/credentials/v3/v3_test.go @@ -60,13 +60,12 @@ type Inputs struct { // Query // JSON path - ClaimPathNotExists string `json:"claimPathNotExists"` // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp []string `json:"claimPathMtp"` - ClaimPathMtpNoAux string `json:"claimPathMtpNoAux"` // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi string `json:"claimPathMtpAuxHi"` // 0 for inclusion proof - ClaimPathMtpAuxHv string `json:"claimPathMtpAuxHv"` // 0 for inclusion proof - ClaimPathKey string `json:"claimPathKey"` // hash of path in merklized json-ld document - ClaimPathValue string `json:"claimPathValue"` // value in this path in merklized json-ld document + ClaimPathMtp []string `json:"claimPathMtp"` + ClaimPathMtpNoAux string `json:"claimPathMtpNoAux"` // 1 if aux node is empty, 0 if non-empty or for inclusion proofs + ClaimPathMtpAuxHi string `json:"claimPathMtpAuxHi"` // 0 for inclusion proof + ClaimPathMtpAuxHv string `json:"claimPathMtpAuxHv"` // 0 for inclusion proof + ClaimPathKey string `json:"claimPathKey"` // hash of path in merklized json-ld document + ClaimPathValue string `json:"claimPathValue"` // value in this path in merklized json-ld document Operator int `json:"operator"` SlotIndex int `json:"slotIndex"` @@ -107,7 +106,6 @@ type Outputs struct { SlotIndex string `json:"slotIndex"` Operator int `json:"operator"` ClaimPathKey string `json:"claimPathKey"` - ClaimPathNotExists string `json:"claimPathNotExists"` // 0 for inclusion, 1 for non-inclusion Value []string `json:"value"` ValueArraySize int `json:"valueArraySize"` Timestamp string `json:"timestamp"` @@ -483,7 +481,6 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion ClaimPathMtp: claimPathMtp, ClaimPathMtpNoAux: claimPathMtpNoAux, ClaimPathMtpAuxHi: claimPathMtpAuxHi, @@ -565,7 +562,6 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID ClaimSchema: "180410020913331409885634153623124536270", SlotIndex: strconv.Itoa(slotIndex), ClaimPathKey: claimPathKey, - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion Operator: operator, Value: valueInput, ValueArraySize: valueArrSize, @@ -670,13 +666,12 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj IssuerAuthState: issuer.State(t).String(), ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "1", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: claimJSONLDProof, - ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, // 0 for inclusion proof - ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, // 0 for inclusion proof - ClaimPathKey: pathKey.String(), // hash of path in merklized json-ld document - ClaimPathValue: "0", // value in this path in merklized json-ld document + ClaimPathMtp: claimJSONLDProof, + ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, // 1 if aux node is empty, 0 if non-empty or for inclusion proofs + ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, // 0 for inclusion proof + ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, // 0 for inclusion proof + ClaimPathKey: pathKey.String(), // hash of path in merklized json-ld document + ClaimPathValue: "0", // value in this path in merklized json-ld document // value in this path in merklized json-ld document Operator: utils.NOOP, @@ -712,7 +707,6 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj SlotIndex: "0", Operator: utils.NOOP, ClaimPathKey: pathKey.String(), - ClaimPathNotExists: "1", Value: utils.PrepareStrArray([]string{}, 64), ValueArraySize: 0, Timestamp: timestamp, diff --git a/testvectorgen/utils/constants.go b/testvectorgen/utils/constants.go index b288639b..67961766 100644 --- a/testvectorgen/utils/constants.go +++ b/testvectorgen/utils/constants.go @@ -15,6 +15,7 @@ const ( GTE BETWEEN NOT_BETWEEN + EXISTS SD = 16 ) diff --git a/testvectorgen/utils/utils.go b/testvectorgen/utils/utils.go index 1597c7cd..7a982c09 100644 --- a/testvectorgen/utils/utils.go +++ b/testvectorgen/utils/utils.go @@ -333,7 +333,7 @@ func CalculateNullify(genesisID, claimSubjectProfileNonce, claimSchema, verifier func GetValueArraySizeForOperator(operator int) int { result := 0 - oneArrLengthOps := []int{1, 2, 3, 6, 7, 8} + oneArrLengthOps := []int{1, 2, 3, 6, 7, 8, 11} twoArrLengthOps := []int{9, 10} maxArrLengthOps := []int{4, 5}