Skip to content

Commit

Permalink
add issuer genesis state test
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Dec 12, 2023
1 parent 19443f4 commit 22ac304
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"desc":"BJJ: Issuer genesis state / user - first state","inputs":{"requestID":"32","userGenesisID":"23273167900576580892722615617815475823351560716009055944677723144398443009","profileNonce":"0","claimSubjectProfileNonce":"999","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["13207060137112832590622170449916258240813695457675295794859213606138142493259","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtpAuxHi":"0","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"1","challenge":"12345","challengeSignatureR8x":"15829360093371098546177008474519342171461782120259125067189481965541223738777","challengeSignatureR8y":"10840522802382821290541462398953040493080116495308402635486440290351677745960","challengeSignatureS":"1196477404779941775725836688033485533497812196897664950083199167075327114562","userClaimsTreeRoot":"11517767461750786409356202654343440087797799854420804212797270561286585478040","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"13421062220305656807332040413142908746386531813676548741852291985659124697073","gistRoot":"17324622488979108054416002082921608267177770116274256097215720923692895619238","gistMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"gistMtpAuxHi":"0","gistMtpAuxHv":"0","gistMtpNoAux":"0","issuerID":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaim":["14559690932601973492667815902177586678096","28275098119780158026040482722477442169764247619454891891569161278093595137","9213927290011334896127777675328088174434217313068333652739128278390111642646","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"2943483356559152311923412925436024635269538717812859789851139200242297094","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","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","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"267831521922558027206082390043321796944","claimPathNotExists":"0","claimPathMtp":["10589573826925462603050948846890883345903166374734689729289271532483057858782","4903363613407701830583497195848005212702896800468691857488755628900455996678","7545982957481491739149003206078420878340430249907160971377831259006673422787","0","7234734700882409562051669071537722159277854149198231521046768401160975042526","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"claimPathMtpNoAux":"0","claimPathMtpAuxHi":"0","claimPathMtpAuxHv":"0","claimPathKey":"20376033832371109177683048456014525905119173674985843915445634726167450989630","claimPathValue":"19960424","operator":2,"slotIndex":0,"timestamp":"1642074362","value":["20010101","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"5472508197866388381206604816325335748616914118588758490396973216283757878391","issuerClaimSignatureR8y":"487022569097765756306556955967994377058095043087439728980694573045440494288","issuerClaimSignatureS":"406364656466382933476187938784383717878849985640796393410767792675250006948","issuerAuthClaim":["80551937543569765027552589160822318028","0","18843627616807347027405965102907494712213509184168391784663804560181782095821","21769574296201138406688395494914474950554632404504713590270198507141791084591","17476719578317212277","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","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","0","0","0","0","0","0","0","0"],"issuerAuthClaimNonRevMtpAuxHi":"0","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"1","issuerAuthClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","proofType":"1","linkNonce":"18","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","nullifierSessionID":"1234569","authEnabled":1},"expOut":{"requestID":"32","userID":"23273167900576580892722615617815475823351560716009055944677723144398443009","issuerID":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","circuitQueryHash":"12816522451235043383360844734477263990263633888892986646884788265975859605506","gistRoot":"17324622488979108054416002082921608267177770116274256097215720923692895619238","timestamp":"1642074362","merklized":"1","proofType":"1","isRevocationChecked":"1","challenge":"12345","issuerState":"2943483356559152311923412925436024635269538717812859789851139200242297094","linkID":"21264956840473518295367401759082248638554058714792654964349049745455799782226","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","nullifierSessionID":"1234569","operatorOutput":"0","nullifier":"21540438192236855564075143333896114176485819065040531615519987653057866936972","authEnabled":"1"}}
30 changes: 18 additions & 12 deletions testvectorgen/contract_data/v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,57 @@ func Test_Generate_Test_CasesV3(t *testing.T) {

generateData(t, "BJJ: Issuer first state / user - genesis state", []*gistData{
{issuerId, issuerFirstState},
}, false, false, false, "v3/valid_bjj_user_genesis_v3", verifiable.BJJSignatureProofType, 1)
}, false, false, false, false, "v3/valid_bjj_user_genesis_v3", verifiable.BJJSignatureProofType, 1)

generateData(t, "BJJ: Issuer first state / user first state - valid proof", []*gistData{
{issuerId, issuerFirstState},
{userId, userFirstState},
}, true, false, false, "v3/valid_bjj_user_first_v3", verifiable.BJJSignatureProofType, 1)
}, true, false, false, false, "v3/valid_bjj_user_first_v3", verifiable.BJJSignatureProofType, 1)

generateData(t, "BJJ: Issuer second state / user first state - valid proof", []*gistData{
{userId, userFirstState},
{issuerId, issuerSecondState},
}, true, false, true, "v3/valid_bjj_user_first_issuer_second_v3", verifiable.BJJSignatureProofType, 1)
}, true, false, false, true, "v3/valid_bjj_user_first_issuer_second_v3", verifiable.BJJSignatureProofType, 1)

generateData(t, "BJJ: Issuer first state / user second state - valid proof", []*gistData{
{userId, userSecondState},
{issuerId, issuerSecondState},
}, true, true, false, "v3/valid_bjj_user_second_issuer_first_v3", verifiable.BJJSignatureProofType, 1)
}, true, true, false, false, "v3/valid_bjj_user_second_issuer_first_v3", verifiable.BJJSignatureProofType, 1)

generateData(t, "BJJ: Issuer first state / user - genesis state - Auth Disabled", []*gistData{
{issuerId, issuerAuthDisabledFirstState},
}, false, false, false, "v3/valid_bjj_user_genesis_auth_disabled_v3", verifiable.BJJSignatureProofType, 0)
}, false, false, false, false, "v3/valid_bjj_user_genesis_auth_disabled_v3", verifiable.BJJSignatureProofType, 0)

// MTP Data:
generateData(t, "MTP: Issuer first state / user - genesis state", []*gistData{
{issuerId, issuerFirstState},
}, false, false, false, "v3/valid_mtp_user_genesis_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)
}, false, false, false, false, "v3/valid_mtp_user_genesis_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)

generateData(t, "MTP: Issuer first state / user first state - valid proof", []*gistData{
{issuerId, issuerFirstState},
{userId, userFirstState},
}, true, false, false, "v3/valid_mtp_user_first_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)
}, true, false, false, false, "v3/valid_mtp_user_first_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)

generateData(t, "MTP: Issuer second state / user first state - valid proof", []*gistData{
{userId, userFirstState},
{issuerId, issuerSecondState},
}, true, false, true, "v3/valid_mtp_user_first_issuer_second_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)
}, true, false, false, true, "v3/valid_mtp_user_first_issuer_second_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)

generateData(t, "MTP: Issuer first state / user second state - valid proof", []*gistData{
{userId, userSecondState},
{issuerId, issuerSecondState},
}, true, true, false, "v3/valid_mtp_user_second_issuer_first_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)
}, true, true, false, false, "v3/valid_mtp_user_second_issuer_first_v3", verifiable.Iden3SparseMerkleTreeProofType, 1)

generateData(t, "MTP: Issuer first state / user - genesis state - Auth Disabled", []*gistData{
{issuerId, issuerAuthDisabledFirstState},
}, false, false, false, "v3/valid_mtp_user_genesis_auth_disabled_v3", verifiable.Iden3SparseMerkleTreeProofType, 0)
}, false, false, false, false, "v3/valid_mtp_user_genesis_auth_disabled_v3", verifiable.Iden3SparseMerkleTreeProofType, 0)

generateData(t, "BJJ: Issuer genesis state / user - first state", []*gistData{
{userId, userFirstState},
}, true, false, true, false, "v3/valid_bjj_user_first_issuer_genesis_v3", verifiable.BJJSignatureProofType, 1)
}

func generateData(t *testing.T, desc string, gistData []*gistData, userFirstState bool, userSecondState bool, issuerSecondState bool, fileName string, testProofType verifiable.ProofType, authEnabled int) {
func generateData(t *testing.T, desc string, gistData []*gistData, userFirstState bool, userSecondState bool, issuetGenesisState bool, issuerSecondState bool, fileName string, testProofType verifiable.ProofType, authEnabled int) {

var linkNonce = "18"
var nullifierSessionID string = "1234569"
Expand Down Expand Up @@ -197,7 +201,9 @@ func generateData(t *testing.T, desc string, gistData []*gistData, userFirstStat

issuerAuthClaimMtp, _ = issuer.ClaimMTP(t, issuer.AuthClaim)

issuer.AddClaim(t, claim)
if !issuetGenesisState {
issuer.AddClaim(t, claim)
}

issuerClaimMtp, _ = issuer.ClaimMTP(t, claim)
require.NoError(t, err)
Expand Down

0 comments on commit 22ac304

Please sign in to comment.