diff --git a/credentialAtomicQueryMTPWithRelay_test.go b/credentialAtomicQueryMTPWithRelay_test.go index 079f37e..83e736a 100644 --- a/credentialAtomicQueryMTPWithRelay_test.go +++ b/credentialAtomicQueryMTPWithRelay_test.go @@ -160,7 +160,7 @@ func TestAtomicQueryMTPWithRelay_PrepareInputs(t *testing.T) { query := Query{ SlotIndex: 2, Values: []*big.Int{new(big.Int).SetInt64(10)}, - Operator: 0, + Operator: EQ, } atomicInputs := AtomicQueryMTPWithRelayInputs{ @@ -183,7 +183,8 @@ func TestAtomicQueryMTPWithRelay_PrepareInputs(t *testing.T) { expectedJSONInputs := `{"userAuthClaim":["304427537360709784173770334266246861770","0", "17640206035128972995519606214765283372613874593503528180869261482403155458945", "20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"], -"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimIdenState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimMtp":["0","0","18337129644116656308842422695567930755039142442806278977230099338026575870840","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":0,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"relayProofValidClaimsTreeRoot":"8121168901305742662057879845808052431346752743553205352641990714922661618462","relayProofValidRevTreeRoot":"0","relayProofValidRootsTreeRoot":"0","relayState":"4239448240735161374561925497474400621823161116770305241717998726622296721696","userStateInRelayClaim":["795467278703584189433295357807347445218","379949150130214723420589610911161895495647789006649785264738141299135414272","0","0","0","0","18656147546666944484453899241916469544090258810192803949522794490493271005313","0"],"userStateInRelayClaimMtp":["12411413272899006501067884001808071121528224140660538219214791597550929401851","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}` +"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0", +"0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimIdenState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimMtp":["0","0","18337129644116656308842422695567930755039142442806278977230099338026575870840","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"relayProofValidClaimsTreeRoot":"8121168901305742662057879845808052431346752743553205352641990714922661618462","relayProofValidRevTreeRoot":"0","relayProofValidRootsTreeRoot":"0","relayState":"4239448240735161374561925497474400621823161116770305241717998726622296721696","userStateInRelayClaim":["795467278703584189433295357807347445218","379949150130214723420589610911161895495647789006649785264738141299135414272","0","0","0","0","18656147546666944484453899241916469544090258810192803949522794490493271005313","0"],"userStateInRelayClaimMtp":["12411413272899006501067884001808071121528224140660538219214791597550929401851","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}` var actualInputs map[string]interface{} err = json.Unmarshal(inputsJSON, &actualInputs) @@ -280,7 +281,7 @@ func TestAtomicQueryMTPWithRelayOutputs_CircuitUnmarshal(t *testing.T) { Challenge: big.NewInt(1), ClaimSchema: schema, SlotIndex: 2, - Operator: 0, + Operator: EQ, Values: values, Timestamp: int64(1642074362), IssuerID: issuerID, @@ -288,7 +289,8 @@ func TestAtomicQueryMTPWithRelayOutputs_CircuitUnmarshal(t *testing.T) { out := new(AtomicQueryMTPWithRelayPubSignals) err = out.PubSignalsUnmarshal([]byte( - `["379949150130214723420589610911161895495647789006649785264738141299135414272", "4239448240735161374561925497474400621823161116770305241717998726622296721696", "1", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "0", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`)) + `["379949150130214723420589610911161895495647789006649785264738141299135414272", +"4239448240735161374561925497474400621823161116770305241717998726622296721696", "1", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "1", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`)) assert.NoError(t, err) assert.Equal(t, expectedOut, *out) diff --git a/credentialAtomicQueryMTP_test.go b/credentialAtomicQueryMTP_test.go index 1f28a85..92344b0 100644 --- a/credentialAtomicQueryMTP_test.go +++ b/credentialAtomicQueryMTP_test.go @@ -142,7 +142,7 @@ func TestAtomicQuery_PrepareInputs(t *testing.T) { query := Query{ SlotIndex: 2, Values: []*big.Int{new(big.Int).SetInt64(10)}, - Operator: 0, + Operator: EQ, } atomicInputs := AtomicQueryMTPInputs{ @@ -161,7 +161,7 @@ func TestAtomicQuery_PrepareInputs(t *testing.T) { bytesInputs, err := atomicInputs.InputsMarshal() assert.Nil(t, err) - expectedJSONInputs := `{ "userAuthClaim": [ "304427537360709784173770334266246861770", "0", "17640206035128972995519606214765283372613874593503528180869261482403155458945", "20634138280259599560273310290025659992320584624461316485434108770067472477956", "15930428023331155902", "0", "0", "0" ], "userAuthClaimMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtpAuxHi": "0", "userAuthClaimNonRevMtpAuxHv": "0", "userAuthClaimNonRevMtpNoAux": "1", "userClaimsTreeRoot": "9763429684850732628215303952870004997159843236039795272605841029866455670219", "userState": "18656147546666944484453899241916469544090258810192803949522794490493271005313", "userRevTreeRoot": "0", "userRootsTreeRoot": "0", "userID": "379949150130214723420589610911161895495647789006649785264738141299135414272", "challenge": "1", "challengeSignatureR8x": "8553678144208642175027223770335048072652078621216414881653012537434846327449", "challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709", "challengeSignatureS": "2093461910575977345603199789919760192811763972089699387324401771367839603655", "issuerClaim": [ "3583233690122716044519380227940806650830", "379949150130214723420589610911161895495647789006649785264738141299135414272", "10", "0", "30803922965249841627828060161", "0", "0", "0" ], "issuerClaimClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimIdenState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimMtp": [ "0", "0", "18337129644116656308842422695567930755039142442806278977230099338026575870840", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimRevTreeRoot": "0", "issuerClaimRootsTreeRoot": "0", "issuerClaimNonRevClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimNonRevRevTreeRoot": "0", "issuerClaimNonRevRootsTreeRoot": "0", "issuerClaimNonRevState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimNonRevMtpAuxHi": "0", "issuerClaimNonRevMtpAuxHv": "0", "issuerClaimNonRevMtpNoAux": "1", "claimSchema": "180410020913331409885634153623124536270", "issuerID": "26599707002460144379092755370384635496563807452878989192352627271768342528", "operator": 0, "slotIndex": 2, "timestamp": "1642074362", "value": [ "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ] }` + expectedJSONInputs := `{ "userAuthClaim": [ "304427537360709784173770334266246861770", "0","17640206035128972995519606214765283372613874593503528180869261482403155458945", "20634138280259599560273310290025659992320584624461316485434108770067472477956", "15930428023331155902", "0", "0", "0" ], "userAuthClaimMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtpAuxHi": "0", "userAuthClaimNonRevMtpAuxHv": "0", "userAuthClaimNonRevMtpNoAux": "1", "userClaimsTreeRoot": "9763429684850732628215303952870004997159843236039795272605841029866455670219", "userState": "18656147546666944484453899241916469544090258810192803949522794490493271005313", "userRevTreeRoot": "0", "userRootsTreeRoot": "0", "userID": "379949150130214723420589610911161895495647789006649785264738141299135414272", "challenge": "1", "challengeSignatureR8x": "8553678144208642175027223770335048072652078621216414881653012537434846327449", "challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709", "challengeSignatureS": "2093461910575977345603199789919760192811763972089699387324401771367839603655", "issuerClaim": [ "3583233690122716044519380227940806650830", "379949150130214723420589610911161895495647789006649785264738141299135414272", "10", "0", "30803922965249841627828060161", "0", "0", "0" ], "issuerClaimClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimIdenState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimMtp": [ "0", "0", "18337129644116656308842422695567930755039142442806278977230099338026575870840", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimRevTreeRoot": "0", "issuerClaimRootsTreeRoot": "0", "issuerClaimNonRevClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimNonRevRevTreeRoot": "0", "issuerClaimNonRevRootsTreeRoot": "0", "issuerClaimNonRevState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimNonRevMtpAuxHi": "0", "issuerClaimNonRevMtpAuxHv": "0", "issuerClaimNonRevMtpNoAux": "1", "claimSchema": "180410020913331409885634153623124536270", "issuerID": "26599707002460144379092755370384635496563807452878989192352627271768342528", "operator": 1, "slotIndex": 2, "timestamp": "1642074362", "value": [ "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ] }` assert.JSONEq(t, expectedJSONInputs, string(bytesInputs)) @@ -208,13 +208,14 @@ func TestAtomicQueryMTPOutputs_CircuitUnmarshal(t *testing.T) { IssuerID: issuerID, SlotIndex: 2, Values: values, - Operator: 0, + Operator: EQ, Timestamp: timestamp, } out := new(AtomicQueryMTPPubSignals) err = out.PubSignalsUnmarshal([]byte( - `["379949150130214723420589610911161895495647789006649785264738141299135414272", "18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", "18605292738057394742004097311192572049290380262377486632479765119429313092475", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "0", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`)) + `["379949150130214723420589610911161895495647789006649785264738141299135414272", +"18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", "18605292738057394742004097311192572049290380262377486632479765119429313092475", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "1", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`)) assert.NoError(t, err) assert.Equal(t, expectedOut, *out) diff --git a/credentialAtomicQuerySig_test.go b/credentialAtomicQuerySig_test.go index 5d1cfa9..98d462e 100644 --- a/credentialAtomicQuerySig_test.go +++ b/credentialAtomicQuerySig_test.go @@ -177,7 +177,7 @@ func TestAttrQuerySig_PrepareInputs(t *testing.T) { query := Query{ SlotIndex: 2, Values: []*big.Int{new(big.Int).SetInt64(10)}, - Operator: 0, + Operator: EQ, } atomicInputs := AtomicQuerySigInputs{ @@ -197,9 +197,10 @@ func TestAttrQuerySig_PrepareInputs(t *testing.T) { assert.Nil(t, err) t.Log(string(bytesInputs)) - expectedJSONInputs := `{"userAuthClaim":["304427537360709784173770334266246861770","0","17640206035128972995519606214765283372613874593503528180869261482403155458945","20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"],"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userState":"18656147546666944484453899241916469544090258810192803949522794490493271005313","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":0,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimSignatureR8x":"18625305647089498634672127449050652473073470525382360069529718632627474482386","issuerClaimSignatureR8y":"14539700345423181413201048131770723125531044953576671601029329833956725811279","issuerClaimSignatureS":"772934080142423067561028786350670095248312416624185973552603152377549415467","issuerAuthClaim":["304427537360709784173770334266246861770","0","9582165609074695838007712438814613121302719752874385708394134542816240804696","18271435592817415588213874506882839610978320325722319742324814767882756910515","11203087622270641253","0","0","0"],"issuerAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtpAuxHi":"0","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"1","issuerAuthClaimsTreeRoot":"18337129644116656308842422695567930755039142442806278977230099338026575870840","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","issuerClaimsTreeRoot":"18337129644116656308842422695567930755039142442806278977230099338026575870840","issuerState":"6317996369756476782464660619835940615734517981889733696047139451453239145426","issuerRevTreeRoot":"0","issuerRootsTreeRoot":"0"}` + expectedJSONInputs := `{"userAuthClaim":["304427537360709784173770334266246861770","0", +"17640206035128972995519606214765283372613874593503528180869261482403155458945","20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"],"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userState":"18656147546666944484453899241916469544090258810192803949522794490493271005313","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimSignatureR8x":"18625305647089498634672127449050652473073470525382360069529718632627474482386","issuerClaimSignatureR8y":"14539700345423181413201048131770723125531044953576671601029329833956725811279","issuerClaimSignatureS":"772934080142423067561028786350670095248312416624185973552603152377549415467","issuerAuthClaim":["304427537360709784173770334266246861770","0","9582165609074695838007712438814613121302719752874385708394134542816240804696","18271435592817415588213874506882839610978320325722319742324814767882756910515","11203087622270641253","0","0","0"],"issuerAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtpAuxHi":"0","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"1","issuerAuthClaimsTreeRoot":"18337129644116656308842422695567930755039142442806278977230099338026575870840","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","issuerClaimsTreeRoot":"18337129644116656308842422695567930755039142442806278977230099338026575870840","issuerState":"6317996369756476782464660619835940615734517981889733696047139451453239145426","issuerRevTreeRoot":"0","issuerRootsTreeRoot":"0"}` - assert.Equal(t, expectedJSONInputs, string(bytesInputs)) + assert.JSONEq(t, expectedJSONInputs, string(bytesInputs)) } @@ -256,7 +257,7 @@ func TestAtomicQuerySigOutputs_CircuitUnmarshal(t *testing.T) { IssuerClaimNonRevState: issuerClaimNonRevState, SlotIndex: 2, Values: values, - Operator: 1, + Operator: EQ, Timestamp: timestamp, } diff --git a/query.go b/query.go index 00c6a5a..d83ec3d 100644 --- a/query.go +++ b/query.go @@ -8,7 +8,8 @@ import ( // List of available operators. const ( - EQ int = iota + NOOP int = iota // No operation, skip query verification in circuit + EQ LT GT IN @@ -24,11 +25,12 @@ type Query struct { // QueryOperators represents operators for atomic circuits var QueryOperators = map[string]int{ - "$eq": EQ, - "$lt": LT, - "$gt": GT, - "$in": IN, - "$nin": NIN, + "$noop": NOOP, + "$eq": EQ, + "$lt": LT, + "$gt": GT, + "$in": IN, + "$nin": NIN, } // Comparer value. diff --git a/query_test.go b/query_test.go index 1153588..d8313f4 100644 --- a/query_test.go +++ b/query_test.go @@ -1,10 +1,10 @@ package circuits import ( -"math/big" -"testing" + "math/big" + "testing" -"github.com/stretchr/testify/require" + "github.com/stretchr/testify/require" ) func TestScalarCompare(t *testing.T) { @@ -64,7 +64,7 @@ func TestScalarCompare(t *testing.T) { name: "testing unknown operator", x: big.NewInt(0), y: big.NewInt(1), - operator: 4, // unknown operator. + operator: 5, // unknown operator. expected: false, withErr: true, }, @@ -127,7 +127,7 @@ func TestVectorCompare(t *testing.T) { name: "testing unknown operator", x: big.NewInt(0), y: []*big.Int{big.NewInt(1), big.NewInt(10), big.NewInt(100)}, - operator: 5, // unknown operator. + operator: 6, // unknown operator. expected: false, withErr: true, },