From 696f51cbf126cefa106c3a86a1057918824c393f Mon Sep 17 00:00:00 2001 From: Oleg Lomaka Date: Wed, 15 Nov 2023 03:40:28 -0500 Subject: [PATCH 01/10] Fix getting random entropy on macOS (#114) --- compile-circuit.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compile-circuit.sh b/compile-circuit.sh index 7c7eb341..b4b22bad 100755 --- a/compile-circuit.sh +++ b/compile-circuit.sh @@ -29,9 +29,9 @@ compile_and_ts() { # time snarkjs setup -r circuit.r1cs --pk proving_key.json --vk verification_key.json time snarkjs groth16 setup circuit.r1cs "$PTAU" circuit_0000.zkey - ENTROPY1=$(head -c 1024 /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 128) - ENTROPY2=$(head -c 1024 /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 128) - ENTROPY3=$(head -c 1024 /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 128) + ENTROPY1=$(head -c 64 /dev/urandom | od -An -tx1 -v | tr -d ' \n') + ENTROPY2=$(head -c 64 /dev/urandom | od -An -tx1 -v | tr -d ' \n') + ENTROPY3=$(head -c 64 /dev/urandom | od -An -tx1 -v | tr -d ' \n') time snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="1st Contribution" -v -e="$ENTROPY1" time snarkjs zkey contribute circuit_0001.zkey circuit_0002.zkey --name="2nd Contribution" -v -e="$ENTROPY2" From 1907e1864fd83d044cc24ff5fcd4ecac0ec0d493 Mon Sep 17 00:00:00 2001 From: GopherDID <74898029+vmidyllic@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:03:27 +0200 Subject: [PATCH 02/10] Fix/claim path not exists (#127) * remove claimPathNotExists from query hash --- circuits/lib/utils/queryHash.circom | 10 ++++------ testvectorgen/credentials/onchain/v3/v3_test.go | 13 +++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/circuits/lib/utils/queryHash.circom b/circuits/lib/utils/queryHash.circom index f21f53e0..b8fa0b63 100644 --- a/circuits/lib/utils/queryHash.circom +++ b/circuits/lib/utils/queryHash.circom @@ -15,8 +15,6 @@ template QueryHash(maxValueArraySize) { signal output out; - signal claimPathNotExists <== AND()(IsZero()(value[0]), IsEqual()([operator, 11])); - ///////////////////////////////////////////////////////////////// // Calculate query hash ///////////////////////////////////////////////////////////////// @@ -27,16 +25,16 @@ template QueryHash(maxValueArraySize) { slotIndex, operator, claimPathKey, - claimPathNotExists, + merklized, valueHash ]); out <== Poseidon(6)([ firstPartQueryHash, valueArraySize, - merklized, isRevocationChecked, verifierID, - nullifierSessionID + nullifierSessionID, + 0 ]); -} \ No newline at end of file +} diff --git a/testvectorgen/credentials/onchain/v3/v3_test.go b/testvectorgen/credentials/onchain/v3/v3_test.go index 2f936d39..9fef1aac 100644 --- a/testvectorgen/credentials/onchain/v3/v3_test.go +++ b/testvectorgen/credentials/onchain/v3/v3_test.go @@ -131,7 +131,6 @@ type Outputs struct { CircuitQueryHash string `json:"circuitQueryHash"` GistRoot string `json:"gistRoot"` Timestamp string `json:"timestamp"` - Merklized string `json:"merklized"` ProofType string `json:"proofType"` // 1 for sig, 2 for mtp Challenge string `json:"challenge"` IssuerState string `json:"issuerState"` @@ -580,25 +579,25 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID ) require.NoError(t, err) } + merklizedBigInt, ok := big.NewInt(0).SetString(merklized, 10) firstPartQueryHash, err := poseidon.Hash([]*big.Int{ claimSchemaInt, big.NewInt(int64(inputs.SlotIndex)), big.NewInt(int64(inputs.Operator)), pathKey, - big.NewInt(0), + merklizedBigInt, 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_, + new(big.Int), }) require.NoError(t, err) @@ -622,7 +621,6 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID IssuerClaimNonRevState: issuer.State(t).String(), CircuitQueryHash: circuitQueryHash.String(), Timestamp: timestamp, - Merklized: merklized, Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), ProofType: proofType, @@ -805,7 +803,7 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj big.NewInt(int64(inputs.SlotIndex)), big.NewInt(int64(inputs.Operator)), pathKey, - big.NewInt(1), + big.NewInt(1), // merklized valuesHash, }) require.NoError(t, err) @@ -818,9 +816,9 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj firstPartQueryHash, big.NewInt(int64(valueArraySize)), big.NewInt(1), - big.NewInt(1), verifierID, nullifierSessionID_, + big.NewInt(0), }) require.NoError(t, err) @@ -830,7 +828,6 @@ func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubj IssuerID: issuer.ID.BigInt().String(), IssuerClaimNonRevState: issuerClaimNonRevState.String(), Timestamp: timestamp, - Merklized: "1", CircuitQueryHash: circuitQueryHash.String(), Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), From b7003892a57cc6431cf28ae3011b54569520cd20 Mon Sep 17 00:00:00 2001 From: volodymyr-basiuk <31999965+volodymyr-basiuk@users.noreply.github.com> Date: Thu, 29 Feb 2024 18:31:47 +0200 Subject: [PATCH 03/10] remove valueArraySize from multiQuery10 outputs (#128) --- circuits/linkedMultiQuery10.circom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/linkedMultiQuery10.circom b/circuits/linkedMultiQuery10.circom index 3fb243af..8b3d4c3a 100644 --- a/circuits/linkedMultiQuery10.circom +++ b/circuits/linkedMultiQuery10.circom @@ -2,4 +2,4 @@ pragma circom 2.1.1; include "linked/multiQuery.circom"; -component main {public [valueArraySize]} = LinkedMultiQuery(10, 32, 64); // 175331 constraints +component main = LinkedMultiQuery(10, 32, 64); // 175331 constraints From 3dd94b99cee4ddb50443e7952d13627a4fb51bb6 Mon Sep 17 00:00:00 2001 From: volodymyr-basiuk <31999965+volodymyr-basiuk@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:28:51 +0200 Subject: [PATCH 04/10] Fix/onchain testdata (#129) * add onchainTestData --------- Co-authored-by: vmidyllic <74898029+vmidyllic@users.noreply.github.com> --- .../credentialAtomicQueryV3OnChain.test.ts | 4 +- .../contract_data/generate_json_test.go | 30 +- testvectorgen/contract_data/v3_test.go | 606 ++++++++++++++++++ .../credentials/onchain/v3/v3_test.go | 93 ++- testvectorgen/go.mod | 9 +- testvectorgen/go.sum | 19 +- .../statetransition/stateTransition_test.go | 6 +- testvectorgen/utils/constants.go | 31 + testvectorgen/utils/identity.go | 45 ++ testvectorgen/utils/utils.go | 39 ++ update-contract-data-v3.js | 47 ++ update-contract-data.js | 60 ++ 12 files changed, 944 insertions(+), 45 deletions(-) create mode 100644 testvectorgen/contract_data/v3_test.go create mode 100644 update-contract-data-v3.js create mode 100644 update-contract-data.js diff --git a/test/onchain/credentialAtomicQueryV3OnChain.test.ts b/test/onchain/credentialAtomicQueryV3OnChain.test.ts index 64e1d4b7..07cfc7c4 100644 --- a/test/onchain/credentialAtomicQueryV3OnChain.test.ts +++ b/test/onchain/credentialAtomicQueryV3OnChain.test.ts @@ -42,8 +42,8 @@ describe("Test credentialAtomicQueryV3OnChain.circom", function () { require(`${sigBasePath}/nullify.json`), require(`${sigBasePath}/revoked_claim_without_revocation_check.json`), require(`${sigBasePath}/jsonld_non_inclusion.json`), - require(`${sigBasePath}/auth_check_disabled.json`), require(`${sigBasePath}/noop_operator.json`), + require(`${sigBasePath}/onchainIdentity.json`), // mtp require(`${mtpBasePath}/claimIssuedOnProfileID.json`), @@ -57,8 +57,8 @@ describe("Test credentialAtomicQueryV3OnChain.circom", function () { require(`${mtpBasePath}/selective_disclosure.json`), require(`${mtpBasePath}/nullify.json`), require(`${mtpBasePath}/revoked_claim_without_revocation_check.json`), - require(`${mtpBasePath}/auth_check_disabled.json`), require(`${mtpBasePath}/noop_operator.json`), + require(`${mtpBasePath}/onchainIdentity.json`), ]; tests.forEach(({ desc, inputs, expOut }) => { diff --git a/testvectorgen/contract_data/generate_json_test.go b/testvectorgen/contract_data/generate_json_test.go index 38801e35..1bfc1288 100644 --- a/testvectorgen/contract_data/generate_json_test.go +++ b/testvectorgen/contract_data/generate_json_test.go @@ -235,11 +235,11 @@ type TestDataSigV2 struct { func Test_Generate_Test_Cases(t *testing.T) { - id, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis state", "issuer_genesis_state") - nextId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "user_state_transition") + id, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis state", "issuer_genesis_state", false, false) + nextId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "user_state_transition", false, false) - generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer next transition state", "issuer_next_state_transition") - generateStateTransitionData(t, true, UserPK, IssuerPK, "User next transition state", "user_next_state_transition") + generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer next transition state", "issuer_next_state_transition", false, false) + generateStateTransitionData(t, true, UserPK, IssuerPK, "User next transition state", "user_next_state_transition", false, false) generateMTPData(t, "MTP: Issuer first state", []*gistData{ {id, issuerFirstState}, @@ -272,10 +272,19 @@ type gistData struct { state *big.Int } -func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, secondaryPK, desc, fileName string) (*big.Int, *big.Int) { +func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, secondaryPK, desc, fileName string, isSubjectIDProfile bool, isEthBased bool) (*big.Int, *big.Int) { + var err error primaryEntity := utils.NewIdentity(t, primaryPK) - secondaryEntity := utils.NewIdentity(t, secondaryPK) + + var secondaryEntity *utils.IdentityTest + + if !isEthBased { + secondaryEntity = utils.NewIdentity(t, secondaryPK) + } else { + // generate onchain identity + secondaryEntity = utils.NewEthereumBasedIdentity(t, ethAddress) + } isGenesis := "1" // user @@ -291,7 +300,14 @@ func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, second //if genesis == false { // extract pubKey - _, secondaryEntityClaim := utils.DefaultJSONUserClaim(t, secondaryEntity.ID) + subjectID := secondaryEntity.ID + if isSubjectIDProfile { + nonceSubject := big.NewInt(999) + subjectID, err = core.ProfileID(secondaryEntity.ID, nonceSubject) + require.NoError(t, err) + } + + _, secondaryEntityClaim := utils.DefaultJSONNormalUserClaim(t, subjectID) primaryEntity.AddClaim(t, secondaryEntityClaim) if nextState { diff --git a/testvectorgen/contract_data/v3_test.go b/testvectorgen/contract_data/v3_test.go new file mode 100644 index 00000000..15b7289e --- /dev/null +++ b/testvectorgen/contract_data/v3_test.go @@ -0,0 +1,606 @@ +package contractdata + +import ( + "context" + "encoding/json" + "math/big" + "strconv" + "testing" + + "github.com/ethereum/go-ethereum/common" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-crypto/babyjub" + "github.com/iden3/go-iden3-crypto/poseidon" + "github.com/iden3/go-merkletree-sql/v2" + "github.com/iden3/go-merkletree-sql/v2/db/memory" + "github.com/iden3/go-schema-processor/v2/merklize" + "github.com/iden3/go-schema-processor/v2/verifiable" + "github.com/stretchr/testify/require" + "test/utils" +) + +const ( + ethAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" +) + +func Test_Generate_Test_CasesV3(t *testing.T) { + + // genesis => first => second + issuerId, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis to first state transition", "v3/issuer_from_genesis_state_to_first_transition_v3", true, false) + userId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "v3/user_from_genesis_state_to_first_transition_v3", false, false) + + _, issuerSecondState := generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer from first to second transition", "v3/issuer_from_first_state_to_second_transition_v3", true, false) + _, userSecondState := generateStateTransitionData(t, true, UserPK, IssuerPK, "User from first to second transition", "v3/user_from_first_state_to_second_transition_v3", false, false) + + _, issuerAuthDisabledFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis to first state transition auth disabled", "v3/issuer_from_genesis_state_to_first_auth_disabled_transition_v3", false, true) + + generateData(t, "BJJ: Issuer first state / user - genesis state", []*gistData{ + {issuerId, issuerFirstState}, + }, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, issuetGenesisState bool, issuerSecondState bool, fileName string, testProofType verifiable.ProofType, isBJJAuthEnabled int) { + + var linkNonce = "18" + var nullifierSessionID string = "1234569" + operator := utils.LT + isRevocationChecked := 1 // checked + isJSONLD := true // merklized for now + var err error + + const isRevoked = false + const isSubjectIDProfile = true + + valueInput := utils.PrepareStrArray([]string{"20010101"}, 64) + + var user *utils.IdentityTest + + if isBJJAuthEnabled == 1 { + user = utils.NewIdentity(t, UserPK) + } else { + // generate onchain identity + user = utils.NewEthereumBasedIdentity(t, ethAddress) + nullifierSessionID = "0" + } + issuer := utils.NewIdentity(t, IssuerPK) + + userProfileID := user.ID + nonce := big.NewInt(0) + + subjectID := user.ID + + var nonceSubject = new(big.Int) + if isSubjectIDProfile && isBJJAuthEnabled == 1 { + nonceSubject = big.NewInt(999) + subjectID, err = core.ProfileID(user.ID, nonceSubject) + require.NoError(t, err) + } + + var claim *core.Claim + var mz *merklize.Merklizer + var claimPathMtp []string + var claimPathMtpNoAux, claimPathMtpAuxHi, claimPathMtpAuxHv, claimPathKey, claimPathValue, merklized string + var pathKey *big.Int + var slotIndex int + + if isJSONLD { + mz, claim = utils.DefaultJSONNormalUserClaim(t, subjectID) + path, err := merklize.NewPath( + "https://www.w3.org/2018/credentials#credentialSubject", + "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#birthday") + require.NoError(t, err) + jsonP, value, err := mz.Proof(context.Background(), path) + require.NoError(t, err) + valueKey, err := value.MtEntry() + require.NoError(t, err) + claimPathValue = valueKey.String() + + var claimJSONLDProofAux utils.NodeAuxValue + claimPathMtp, claimJSONLDProofAux = utils.PrepareProof(jsonP, utils.ClaimLevels) + claimPathMtpNoAux = claimJSONLDProofAux.NoAux + claimPathMtpAuxHi = claimJSONLDProofAux.Key + claimPathMtpAuxHv = claimJSONLDProofAux.Value + pathKey, err = path.MtEntry() + require.NoError(t, err) + claimPathKey = pathKey.String() + slotIndex = 0 + + //valueInput = utils.PrepareStrArray([]string{claimPathValue}, 64) + merklized = "1" + + } else { + claim = utils.DefaultUserClaim(t, subjectID, nil) + claimPathMtp = utils.PrepareStrArray([]string{}, 32) + claimPathMtpNoAux = "0" + claimPathMtpAuxHi = "0" + claimPathMtpAuxHv = "0" + claimPathKey = "0" + claimPathValue = "0" + merklized = "0" + slotIndex = 2 + pathKey = big.NewInt(0) + } + + if userFirstState { + _, claim1 := utils.DefaultJSONNormalUserClaim(t, issuer.ID) + user.AddClaim(t, claim1) + + if userSecondState { + claim2 := utils.DefaultUserClaim(t, user.ID, nil) + user.AddClaim(t, claim2) + } + } + + if isRevoked { + revNonce := claim.GetRevocationNonce() + revNonceBigInt := new(big.Int).SetUint64(revNonce) + issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) + } + + var issuerClaimMtp, issuerAuthClaimMtp, issuerAuthClaimNonRevMtp []string + var issuerClaimClaimsTreeRoot, issuerClaimRevTreeRoot, issuerClaimRootsTreeRoot *merkletree.Hash + var issuerClaimSignatureR8X, issuerClaimSignatureR8Y, issuerClaimSignatureS, + issuerAuthClaimNonRevMtpAuxHi, issuerAuthClaimNonRevMtpAuxHv, issuerAuthClaimNonRevMtpNoAux, + issuerClaimIdenState, proofType string + + var issuerAuthClaimsTreeRoot, issuerAuthRevTreeRoot, issuerAuthRootsTreeRoot string + var issuerAuthState string + var issuerAuthClaim *core.Claim + + issuerAuthClaimsTreeRoot = issuer.Clt.Root().BigInt().String() + issuerAuthRevTreeRoot = issuer.Ret.Root().BigInt().String() + issuerAuthRootsTreeRoot = issuer.Rot.Root().BigInt().String() + + issuerAuthState = issuer.State(t).String() + + issuerAuthClaimMtp, _ = issuer.ClaimMTP(t, issuer.AuthClaim) + + if !issuetGenesisState { + issuer.AddClaim(t, claim) + } + + issuerClaimMtp, _ = issuer.ClaimMTP(t, claim) + require.NoError(t, err) + issuerClaimIdenState = issuer.State(t).String() + + issuerClaimClaimsTreeRoot = issuer.Clt.Root() + issuerClaimRevTreeRoot = issuer.Ret.Root() + issuerClaimRootsTreeRoot = issuer.Rot.Root() + + // add another claim to issuer if it is a second state + if issuerSecondState { + primaryEntityClaim := utils.DefaultUserClaim(t, issuer.ID, nil) + issuer.AddClaim(t, primaryEntityClaim) + } + + // prove revocation on latest state of the issuer + issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) + + issuerAuthClaimNonRevMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) + issuerAuthClaimNonRevMtpNoAux = issuerAuthClaimNodeAux.NoAux + issuerAuthClaimNonRevMtpAuxHi = issuerAuthClaimNodeAux.Key + issuerAuthClaimNonRevMtpAuxHv = issuerAuthClaimNodeAux.Value + + if testProofType == verifiable.BJJSignatureProofType { + // Sig claim + claimSig := issuer.SignClaim(t, claim) + + issuerClaimSignatureR8X = claimSig.R8.X.String() + issuerClaimSignatureR8Y = claimSig.R8.Y.String() + issuerClaimSignatureS = claimSig.S.String() + + issuerAuthClaim = issuer.AuthClaim + + proofType = "1" + } else { + + issuerClaimSignatureR8X = "0" + issuerClaimSignatureR8Y = "0" + issuerClaimSignatureS = "0" + + issuerAuthClaimNonRevMtpAuxHi = "0" + issuerAuthClaimNonRevMtpAuxHv = "0" + issuerAuthClaimNonRevMtpNoAux = "0" + + issuerAuthClaimMtp = utils.PrepareStrArray([]string{}, 40) + + issuerAuthClaim = &core.Claim{} + + issuerAuthClaimsTreeRoot = (&merkletree.HashZero).BigInt().String() + issuerAuthRevTreeRoot = (&merkletree.HashZero).BigInt().String() + issuerAuthRootsTreeRoot = (&merkletree.HashZero).BigInt().String() + + issuerAuthState = "0" + + slotIndex = 2 + proofType = "2" + } + + gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) + require.Nil(t, err) + + for _, data := range gistData { + idPoseidonHash, _ := poseidon.Hash([]*big.Int{data.id}) + err = gisTree.Add(context.Background(), idPoseidonHash, data.state) + require.Nil(t, err) + } + + var authMTProof []string + var challenge *big.Int + var userAuthNonRevMTProof []string + var userNodeAuxNonRev utils.NodeAuxValue + var sig *babyjub.Signature + var gistRoot *merkletree.Hash + var gistProof []string + var gistNodeAux utils.NodeAuxValue + + addr := common.HexToAddress(ethAddress) + challenge = new(big.Int).SetBytes(merkletree.SwapEndianness(addr.Bytes())) + + // user + if isBJJAuthEnabled == 1 { + authMTProof = user.AuthMTPStrign(t) + userAuthNonRevMTProof, userNodeAuxNonRev = user.ClaimRevMTP(t, user.AuthClaim) + sig = user.Sign(challenge) + gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) + require.NoError(t, err) + gistRoot = gisTree.Root() + gistProof, gistNodeAux = utils.PrepareProof(gistProofRaw, utils.GistLevels) + + } else { + + emptyArr := make([]*merkletree.Hash, 0) + authMTProof = utils.PrepareSiblingsStr(emptyArr, utils.IdentityTreeLevels) + userAuthNonRevMTProof = utils.PrepareSiblingsStr(emptyArr, utils.IdentityTreeLevels) + userNodeAuxNonRev = utils.NodeAuxValue{ + Key: merkletree.HashZero.String(), + Value: merkletree.HashZero.String(), + NoAux: "0", + } + sig = &babyjub.Signature{ + R8: &babyjub.Point{ + X: new(big.Int), + Y: new(big.Int), + }, + S: new(big.Int), + } + + gistRoot = &merkletree.HashZero + gistProof = utils.PrepareSiblingsStr(emptyArr, utils.GistLevels) + gistNodeAux = utils.NodeAuxValue{ + Key: merkletree.HashZero.String(), + Value: merkletree.HashZero.String(), + NoAux: "0", + } + + user.AuthClaim = &core.Claim{} + } + t.Log(issuer.State(t).String()) + valueArraySize := utils.GetValueArraySizeForOperator(operator) + + inputs := Inputs{ + RequestID: requestID, + UserGenesisID: user.ID.BigInt().String(), + ProfileNonce: nonce.String(), + UserAuthClaim: user.AuthClaim, + UserAuthClaimMtp: authMTProof, + UserAuthClaimNonRevMtp: userAuthNonRevMTProof, + UserAuthClaimNonRevMtpAuxHi: userNodeAuxNonRev.Key, + UserAuthClaimNonRevMtpAuxHv: userNodeAuxNonRev.Value, + UserAuthClaimNonRevMtpNoAux: userNodeAuxNonRev.NoAux, + Challenge: challenge.String(), + ChallengeSignatureR8X: sig.R8.X.String(), + ChallengeSignatureR8Y: sig.R8.Y.String(), + ChallengeSignatureS: sig.S.String(), + UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), + UserRevTreeRoot: user.Ret.Root().BigInt().String(), + UserRootsTreeRoot: user.Rot.Root().BigInt().String(), + UserState: user.State(t).String(), + GistRoot: gistRoot.BigInt().String(), + GistMtp: gistProof, + GistMtpAuxHi: gistNodeAux.Key, + GistMtpAuxHv: gistNodeAux.Value, + GistMtpNoAux: gistNodeAux.NoAux, + ClaimSubjectProfileNonce: nonceSubject.String(), + IssuerID: issuer.ID.BigInt().String(), + IssuerClaim: claim, + IssuerClaimMtp: issuerClaimMtp, + IssuerClaimClaimsTreeRoot: issuerClaimClaimsTreeRoot, + IssuerClaimRevTreeRoot: issuerClaimRevTreeRoot, + IssuerClaimRootsTreeRoot: issuerClaimRootsTreeRoot, + IssuerClaimIdenState: issuerClaimIdenState, + IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), + IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), + IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), + IssuerClaimNonRevState: issuer.State(t).String(), + IssuerClaimNonRevMtp: issuerClaimNonRevMtp, + IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, + IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, + IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, + ClaimSchema: "267831521922558027206082390043321796944", + ClaimPathMtp: claimPathMtp, + ClaimPathMtpNoAux: claimPathMtpNoAux, + ClaimPathMtpAuxHi: claimPathMtpAuxHi, + ClaimPathMtpAuxHv: claimPathMtpAuxHv, + ClaimPathKey: claimPathKey, + ClaimPathValue: claimPathValue, + IsRevocationChecked: isRevocationChecked, + Operator: operator, + SlotIndex: slotIndex, + Timestamp: timestamp, + Value: valueInput, + ValueArraySize: valueArraySize, + IssuerClaimSignatureR8X: issuerClaimSignatureR8X, + IssuerClaimSignatureR8Y: issuerClaimSignatureR8Y, + IssuerClaimSignatureS: issuerClaimSignatureS, + IssuerAuthClaim: issuerAuthClaim, + IssuerAuthClaimMtp: issuerAuthClaimMtp, + IssuerAuthClaimNonRevMtp: issuerAuthClaimNonRevMtp, + IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNonRevMtpAuxHi, + IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNonRevMtpAuxHv, + IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNonRevMtpNoAux, + IssuerAuthClaimsTreeRoot: issuerAuthClaimsTreeRoot, + IssuerAuthRevTreeRoot: issuerAuthRevTreeRoot, + IssuerAuthRootsTreeRoot: issuerAuthRootsTreeRoot, + IssuerAuthState: issuerAuthState, + + LinkNonce: linkNonce, + + ProofType: proofType, + + VerifierID: "21929109382993718606847853573861987353620810345503358891473103689157378049", + NullifierSessionID: nullifierSessionID, + 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) + + 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) + + nullifier, err = utils.CalculateNullify( + user.ID.BigInt(), + nonceSubject, + claimSchema, + verifierID, + nullifierSessionID_, + ) + require.NoError(t, err) + } + merklizedBigInt, ok := big.NewInt(0).SetString(merklized, 10) + + firstPartQueryHash, err := poseidon.Hash([]*big.Int{ + claimSchemaInt, + big.NewInt(int64(inputs.SlotIndex)), + big.NewInt(int64(inputs.Operator)), + pathKey, + merklizedBigInt, + valuesHash, + }) + require.NoError(t, err) + require.True(t, ok) + circuitQueryHash, err := poseidon.Hash([]*big.Int{ + firstPartQueryHash, + big.NewInt(int64(valueArraySize)), + big.NewInt(int64(isRevocationChecked)), + verifierID, + nullifierSessionID_, + new(big.Int), + }) + require.NoError(t, err) + + if operator == utils.SD { + operatorOutput = big.NewInt(10).String() + } + + var issuerState string + if proofType == "1" { + // sig + issuerState = issuerAuthState + } else { + // mtp + issuerState = issuerClaimIdenState + } + + out := Outputs{ + RequestID: requestID, + UserID: userProfileID.BigInt().String(), + IssuerID: issuer.ID.BigInt().String(), + IssuerClaimNonRevState: issuer.State(t).String(), + CircuitQueryHash: circuitQueryHash.String(), + Timestamp: timestamp, + Merklized: merklized, + Challenge: challenge.String(), + GistRoot: gistRoot.BigInt().String(), + ProofType: proofType, + IssuerState: issuerState, + LinkID: linkID, + OperatorOutput: operatorOutput, + Nullifier: nullifier, + IsBJJAuthEnabled: strconv.Itoa(isBJJAuthEnabled), + } + + jsonData, err := json.Marshal(TestData{ + desc, + inputs, + out, + }) + require.NoError(t, err) + + utils.SaveTestVector(t, fileName, string(jsonData)) +} + +type Inputs struct { + RequestID string `json:"requestID"` + + // user data + UserGenesisID string `json:"userGenesisID"` // + ProfileNonce string `json:"profileNonce"` // + ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` // + + UserAuthClaim *core.Claim `json:"authClaim"` + UserAuthClaimMtp []string `json:"authClaimIncMtp"` + UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` + UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` + UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` + UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` + Challenge string `json:"challenge"` + ChallengeSignatureR8X string `json:"challengeSignatureR8x"` + ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` + ChallengeSignatureS string `json:"challengeSignatureS"` + UserClaimsTreeRoot string `json:"userClaimsTreeRoot"` + UserRevTreeRoot string `json:"userRevTreeRoot"` + UserRootsTreeRoot string `json:"userRootsTreeRoot"` + UserState string `json:"userState"` + GistRoot string `json:"gistRoot"` + GistMtp []string `json:"gistMtp"` + GistMtpAuxHi string `json:"gistMtpAuxHi"` + GistMtpAuxHv string `json:"gistMtpAuxHv"` + GistMtpNoAux string `json:"gistMtpNoAux"` + + IssuerID string `json:"issuerID"` + // Claim + IssuerClaim *core.Claim `json:"issuerClaim"` + // Inclusion + IssuerClaimMtp []string `json:"issuerClaimMtp"` + IssuerClaimClaimsTreeRoot *merkletree.Hash `json:"issuerClaimClaimsTreeRoot"` + IssuerClaimRevTreeRoot *merkletree.Hash `json:"issuerClaimRevTreeRoot"` + IssuerClaimRootsTreeRoot *merkletree.Hash `json:"issuerClaimRootsTreeRoot"` + IssuerClaimIdenState string `json:"issuerClaimIdenState"` + + IsRevocationChecked int `json:"isRevocationChecked"` + IssuerClaimNonRevClaimsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevClaimsTreeRoot"` + IssuerClaimNonRevRevTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRevTreeRoot"` + IssuerClaimNonRevRootsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRootsTreeRoot"` + IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` + IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` + IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` + IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` + IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` + + ClaimSchema string `json:"claimSchema"` + + // Query + // JSON path + 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 + ClaimPathValue string `json:"claimPathValue"` // value in this path in merklized json-ld document + ClaimPathKey string `json:"claimPathKey"` // hash of path in merklized json-ld document + + Operator int `json:"operator"` + SlotIndex int `json:"slotIndex"` + Timestamp string `json:"timestamp"` + Value []string `json:"value"` + ValueArraySize int `json:"valueArraySize"` + + // additional sig inputs + IssuerClaimSignatureR8X string `json:"issuerClaimSignatureR8x"` + IssuerClaimSignatureR8Y string `json:"issuerClaimSignatureR8y"` + IssuerClaimSignatureS string `json:"issuerClaimSignatureS"` + IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` + IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` + IssuerAuthClaimNonRevMtp []string `json:"issuerAuthClaimNonRevMtp"` + IssuerAuthClaimNonRevMtpAuxHi string `json:"issuerAuthClaimNonRevMtpAuxHi"` + IssuerAuthClaimNonRevMtpAuxHv string `json:"issuerAuthClaimNonRevMtpAuxHv"` + IssuerAuthClaimNonRevMtpNoAux string `json:"issuerAuthClaimNonRevMtpNoAux"` + IssuerAuthClaimsTreeRoot string `json:"issuerAuthClaimsTreeRoot"` + IssuerAuthRevTreeRoot string `json:"issuerAuthRevTreeRoot"` + IssuerAuthRootsTreeRoot string `json:"issuerAuthRootsTreeRoot"` + IssuerAuthState string `json:"issuerAuthState"` + + ProofType string `json:"proofType"` // 1 for sig, 2 for mtp + + // Private random nonce, used to generate LinkID + LinkNonce string `json:"linkNonce"` + + VerifierID string `json:"verifierID"` + NullifierSessionID string `json:"nullifierSessionID"` + + IsBJJAuthEnabled int `json:"isBJJAuthEnabled"` +} + +type Outputs struct { + RequestID string `json:"requestID"` + UserID string `json:"userID"` + IssuerID string `json:"issuerID"` + IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` + CircuitQueryHash string `json:"circuitQueryHash"` + GistRoot string `json:"gistRoot"` + Timestamp string `json:"timestamp"` + Merklized string `json:"merklized"` + ProofType string `json:"proofType"` // 1 for sig, 2 for mtp + Challenge string `json:"challenge"` + IssuerState string `json:"issuerState"` + LinkID string `json:"linkID"` + OperatorOutput string `json:"operatorOutput"` + Nullifier string `json:"nullifier"` + IsBJJAuthEnabled string `json:"isBJJAuthEnabled"` +} + +type TestData struct { + Desc string `json:"desc"` + In Inputs `json:"inputs"` + Out Outputs `json:"expOut"` +} diff --git a/testvectorgen/credentials/onchain/v3/v3_test.go b/testvectorgen/credentials/onchain/v3/v3_test.go index 9fef1aac..61e68243 100644 --- a/testvectorgen/credentials/onchain/v3/v3_test.go +++ b/testvectorgen/credentials/onchain/v3/v3_test.go @@ -7,9 +7,12 @@ import ( "strconv" "testing" + "github.com/ethereum/go-ethereum/common" + "github.com/iden3/go-iden3-crypto/babyjub" "test/utils" core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-crypto/poseidon" "github.com/iden3/go-merkletree-sql/v2" "github.com/iden3/go-merkletree-sql/v2/db/memory" @@ -18,9 +21,10 @@ import ( ) const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" + userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" + issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" + timestamp = "1642074362" + ethAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" ) var requestID = big.NewInt(41) @@ -257,13 +261,13 @@ func Test_Between(t *testing.T) { generateTestDataWithOperator(t, desc, isUserIDProfile, isSubjectIDProfile, "0", "sig/between_operator", utils.BETWEEN, &value, Sig, 1) } -func Test_No_AuthV2_Check(t *testing.T) { - desc := "Skip Auth V2 check" +func Test_OnchainIdentity(t *testing.T) { + desc := "Skip Auth V2 check. Onchain identity (based on ethereum address)" isUserIDProfile := false isSubjectIDProfile := false - value := []string{"8", "10"} - generateTestDataWithOperator(t, desc, isUserIDProfile, isSubjectIDProfile, "0", "mtp/auth_check_disabled", utils.BETWEEN, &value, Mtp, 0) - generateTestDataWithOperator(t, desc, isUserIDProfile, isSubjectIDProfile, "0", "sig/auth_check_disabled", utils.BETWEEN, &value, Sig, 0) + value := []string{"11"} + generateTestDataWithOperator(t, desc, isUserIDProfile, isSubjectIDProfile, "0", "mtp/onchainIdentity", utils.LT, &value, Mtp, 0) + generateTestDataWithOperator(t, desc, isUserIDProfile, isSubjectIDProfile, "0", "sig/onchainIdentity", utils.LT, &value, Sig, 0) } func Test_Less_Than_Eq(t *testing.T) { @@ -313,11 +317,18 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID valueInput = *value } + var user *utils.IdentityTest + + if isBJJAuthEnabled == 1 { + user = utils.NewIdentity(t, userPK) + } else { + // generate onchain identity + user = utils.NewEthereumBasedIdentity(t, ethAddress) + } valueArraySize := len(valueInput) valueInput = utils.PrepareStrArray(valueInput, 64) - user := utils.NewIdentity(t, userPK) issuer := utils.NewIdentity(t, issuerPK) userProfileID := user.ID @@ -457,24 +468,60 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - challenge := big.NewInt(12345) - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) require.Nil(t, err) err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) + var authMTProof []string + var challenge *big.Int + var authNonRevMTProof []string + var nodeAuxNonRev utils.NodeAuxValue + var sig *babyjub.Signature + var gistRoot *merkletree.Hash + var gistProof []string + var gistNodeAux utils.NodeAuxValue + // user + if isBJJAuthEnabled == 1 { + challenge = big.NewInt(12345) + authMTProof = user.AuthMTPStrign(t) + authNonRevMTProof, nodeAuxNonRev = user.ClaimRevMTP(t, user.AuthClaim) + sig = user.Sign(challenge) + gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) + require.NoError(t, err) + gistRoot = gisTree.Root() + gistProof, gistNodeAux = utils.PrepareProof(gistProofRaw, utils.GistLevels) - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) + } else { - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) + emptyArr := make([]*merkletree.Hash, 0) + addr := common.HexToAddress(ethAddress) + challenge = new(big.Int).SetBytes(merkletree.SwapEndianness(addr.Bytes())) + authMTProof = utils.PrepareSiblingsStr(emptyArr, utils.IdentityTreeLevels) + authNonRevMTProof = utils.PrepareSiblingsStr(emptyArr, utils.IdentityTreeLevels) + user.AuthClaim, err = core.NewClaim(core.AuthSchemaHash) + require.NoError(t, err) + nodeAuxNonRev = utils.NodeAuxValue{ + Key: merkletree.HashZero.String(), + Value: merkletree.HashZero.String(), + NoAux: "0", + } + sig = &babyjub.Signature{ + R8: &babyjub.Point{ + X: new(big.Int), + Y: new(big.Int), + }, + S: new(big.Int), + } + + gistRoot = &merkletree.HashZero + gistProof = utils.PrepareSiblingsStr(emptyArr, utils.GistLevels) + gistNodeAux = utils.NodeAuxValue{ + Key: merkletree.HashZero.String(), + Value: merkletree.HashZero.String(), + NoAux: "0", + } + } inputs := Inputs{ RequestID: requestID.String(), @@ -496,9 +543,9 @@ func generateTestDataWithOperatorAndRevCheck(t *testing.T, desc string, isUserID UserState: user.State(t).String(), GistRoot: gistRoot.BigInt().String(), GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, + GistMtpAuxHi: gistNodeAux.Key, + GistMtpAuxHv: gistNodeAux.Value, + GistMtpNoAux: gistNodeAux.NoAux, ClaimSubjectProfileNonce: nonceSubject.String(), IssuerID: issuer.ID.BigInt().String(), IssuerClaim: claim, diff --git a/testvectorgen/go.mod b/testvectorgen/go.mod index 55d73db8..1d7e8dca 100644 --- a/testvectorgen/go.mod +++ b/testvectorgen/go.mod @@ -3,6 +3,7 @@ module test go 1.18 require ( + github.com/iden3/go-iden3-core v1.0.2 github.com/iden3/go-iden3-core/v2 v2.0.0 github.com/iden3/go-iden3-crypto v0.0.15 github.com/iden3/go-merkletree-sql/v2 v2.0.6 @@ -10,13 +11,15 @@ require ( github.com/stretchr/testify v1.8.4 ) +require github.com/pkg/errors v0.9.1 // indirect + require ( github.com/benbjohnson/clock v1.3.5 // indirect github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dchest/blake512 v1.0.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/ethereum/go-ethereum v1.10.26 + github.com/ethereum/go-ethereum v1.13.5 github.com/ipfs/boxo v0.8.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-ipfs-api v0.6.0 // indirect @@ -40,8 +43,8 @@ require ( github.com/pquerna/cachecontrol v0.1.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/sys v0.13.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect diff --git a/testvectorgen/go.sum b/testvectorgen/go.sum index e849877c..1fe891b0 100644 --- a/testvectorgen/go.sum +++ b/testvectorgen/go.sum @@ -11,11 +11,13 @@ github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzh github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= -github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/ethereum/go-ethereum v1.13.5 h1:U6TCRciCqZRe4FPXmy1sMGxTfuk8P7u2UoinF3VbaFk= +github.com/ethereum/go-ethereum v1.13.5/go.mod h1:yMTu38GSuyxaYzQMViqNmQ1s3cE84abZexQmTgenWk0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLxGP0Y= +github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo= github.com/iden3/go-iden3-core/v2 v2.0.0 h1:sQEuuq3RLfyYSY8qPiqxQ6YBpGbiAwepHJD/vjf1adA= github.com/iden3/go-iden3-core/v2 v2.0.0/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= @@ -63,6 +65,8 @@ github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/n github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f h1:HlPa7RcxTCrva5izPfTEfvYecO7LTahgmMRD1Qp13xg= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc= @@ -75,13 +79,12 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b h1:wA3QeTsaAXybLL2kb2cKhCAQTHgYTMwuI8lBlJSv5V8= github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b/go.mod h1:xT1Y5p2JR2PfSZihE0s4mjdJaRGp1waCTf5JzhQLBck= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/testvectorgen/statetransition/stateTransition_test.go b/testvectorgen/statetransition/stateTransition_test.go index 9618e407..cef235ed 100644 --- a/testvectorgen/statetransition/stateTransition_test.go +++ b/testvectorgen/statetransition/stateTransition_test.go @@ -13,8 +13,10 @@ import ( ) const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - userPK2 = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" + userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" + userPK2 = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" + ethAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + timestamp = "1642074362" ) diff --git a/testvectorgen/utils/constants.go b/testvectorgen/utils/constants.go index 67961766..baf35dfc 100644 --- a/testvectorgen/utils/constants.go +++ b/testvectorgen/utils/constants.go @@ -55,6 +55,37 @@ const TestClaimDocument = `{ } }` +const TestNormalClaimDocument = ` +{ + "id": "urn:uuid:97fbd3d0-8eb7-11ee-8085-a27b3ddbdc29", + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld", + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld" + ], + "type": [ + "VerifiableCredential", + "KYCAgeCredential" + ], + "expirationDate": "2361-03-21T21:14:48+02:00", + "issuanceDate": "2023-11-29T15:02:47.508637+02:00", + "credentialSubject": { + "birthday": 19960424, + "documentType": 2, + "id": "did:polygonid:polygon:mumbai:2qDAxLyxvGaGqBLmoDHwohHjtevVdYvpnWcYiK6AcK", + "type": "KYCAgeCredential" + }, + "credentialStatus": { + "id": "http://localhost:8001/api/v1/identities/did%3Apolygonid%3Apolygon%3Amumbai%3A2qGF2TDJZLxzNU1mP3x5PwcUF43vMgdrhRQhaM2HnG/claims/revocation/status/239691578", + "revocationNonce": 239691578, + "type": "SparseMerkleTreeProof" + }, + "issuer": "did:polygonid:polygon:mumbai:2qGF2TDJZLxzNU1mP3x5PwcUF43vMgdrhRQhaM2HnG", + "credentialSchema": { + "id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/test/cred-array/schemas/json/KYCAgeCredential-v4-arr-list.json", + "type": "JsonSchema2023" + }}` + const ( IdentityTreeLevels = 40 GistLevels = 64 diff --git a/testvectorgen/utils/identity.go b/testvectorgen/utils/identity.go index a4cf3eed..6bcf079b 100644 --- a/testvectorgen/utils/identity.go +++ b/testvectorgen/utils/identity.go @@ -5,6 +5,7 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/common" core "github.com/iden3/go-iden3-core/v2" "github.com/iden3/go-iden3-crypto/babyjub" "github.com/iden3/go-iden3-crypto/poseidon" @@ -171,6 +172,50 @@ func NewIdentity(t testing.TB, privKHex string) *IdentityTest { return &it } +func NewEthereumBasedIdentity(t testing.TB, ethAddr string) *IdentityTest { + + it := IdentityTest{} + var err error + + // init claims tree + + it.Clt, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) + if err != nil { + t.Fatalf("Error creating Claims merkle tree: %v", err) + } + it.Ret, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) + if err != nil { + t.Fatalf("Error creating Revocation merkle tree: %v", err) + } + it.Rot, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) + if err != nil { + t.Fatalf("Error creating Roots merkle tree: %v", err) + } + + addr := common.HexToAddress(ethAddr) + currentState := core.GenesisFromEthAddress(addr) + if err != nil { + t.Fatalf("Error creating genesis state from address: %v", err) + } + + didType, err := core.BuildDIDType(core.DIDMethodPolygonID, core.Polygon, core.Mumbai) + if err != nil { + t.Fatalf("Error creating did type: %v", err) + } + + did, err := core.NewDID(didType, currentState) + if err != nil { + t.Fatalf("Error creating new did : %v", err) + } + + it.ID, err = core.IDFromDID(*did) + if err != nil { + t.Fatalf("Error creating id from did: %v", err) + } + + return &it +} + type NodeAuxValue struct { Key string Value string diff --git a/testvectorgen/utils/utils.go b/testvectorgen/utils/utils.go index 7a982c09..2d6706a5 100644 --- a/testvectorgen/utils/utils.go +++ b/testvectorgen/utils/utils.go @@ -61,6 +61,45 @@ func DefaultJSONUserClaim(t testing.TB, subject core.ID) (*merklize.Merklizer, * return mz, claim } +func DefaultJSONNormalUserClaim(t testing.TB, subject core.ID) (*merklize.Merklizer, *core.Claim) { + opts := loaders.WithEmbeddedDocumentBytes(w3cSchemaURL, w3cSchemaBody) + memoryCacheEngine, err := loaders.NewMemoryCacheEngine(opts) + if err != nil { + log.Fatalf("failed init memory cache engine: %v", err) + } + documentLoader := loaders.NewDocumentLoader(nil, "https://ipfs.io/", + loaders.WithCacheEngine(memoryCacheEngine)) + + merklizeOpts := []merklize.MerklizeOption{ + merklize.WithDocumentLoader(documentLoader), + } + mz, err := merklize.MerklizeJSONLD(context.Background(), strings.NewReader(TestNormalClaimDocument), merklizeOpts...) + if err != nil { + t.Fatalf("failed marklize claim: %v", err) + } + + schemaHash, err := core.NewSchemaHashFromHex("508991bcf0336ba99935ef498d797ec9") + if err != nil { + t.Fatalf("failed marklize claim: %v", err) + } + + nonce := 10 + + claim, err := core.NewClaim( + schemaHash, + core.WithIndexID(subject), + core.WithExpirationDate(time.Unix(1669884010, 0)), //Thu Dec 01 2022 08:40:10 GMT+0000 + core.WithRevocationNonce(uint64(nonce)), + core.WithIndexMerklizedRoot(mz.Root().BigInt())) + + if err != nil { + t.Fatalf("failed generate core claim %v", err) + } + + return mz, claim +} + + func DefaultUserClaim(t testing.TB, subject core.ID, subjValue *big.Int) *core.Claim { value := big.NewInt(10) if subjValue != nil { diff --git a/update-contract-data-v3.js b/update-contract-data-v3.js new file mode 100644 index 00000000..ad8dc95b --- /dev/null +++ b/update-contract-data-v3.js @@ -0,0 +1,47 @@ +const dataFolder = './testvectorgen/contract_data/testdata/v3'; +const contractDataBaseFolder = '../contracts/test/validators/'; +const buildFolder = './build/'; +const fs = require('fs'); +const path = require('path'); +const { execSync, execFileSync } = require('child_process'); + +const files = fs.readdirSync(dataFolder); + +let circuitName = null; +let destinationFolder = null; +for (const file of files) { + + + if (file.includes('state')) { + circuitName = 'stateTransition' + destinationFolder = 'common-data' + } else { + circuitName = 'credentialAtomicQueryV3OnChain-beta.1' + destinationFolder = 'v3/data' + } + const buildPath = `./build/${circuitName}/${circuitName}_js/`; + ['input.json', 'public.json', 'proof.json'].forEach((f) => { + const p = path.join(`./build/${circuitName}/${circuitName}_js`, f) + fs.existsSync(p) && + fs.unlinkSync(p); + console.log(`Deleted file: ${p}`); + }); + const { inputs } = require(`${dataFolder}/${file}`); + console.log(`Reading file: ${dataFolder}/${file}`); + + console.log(`Creating file: ${buildPath}/input.json`); + fs.writeFileSync(`${buildPath}/input.json`, JSON.stringify(inputs), 'utf-8'); + const child = execSync(`./generate.sh ${circuitName}`); + console.log(`execution completed`, new TextDecoder().decode(child)); + const pub_signals = JSON.parse(fs.readFileSync(`${buildPath}/public.json`).toString()); + console.log(pub_signals); + const proof = JSON.parse(fs.readFileSync(`${buildPath}/proof.json`).toString()); + console.log('Writing file: ', `${contractDataBaseFolder}/${destinationFolder}/${file}`); + fs.writeFileSync(`${contractDataBaseFolder}/${destinationFolder}/${file}`, JSON.stringify({ + pub_signals, + proof + }), 'utf-8'); + +} + +console.log('Done'); diff --git a/update-contract-data.js b/update-contract-data.js new file mode 100644 index 00000000..099a5e55 --- /dev/null +++ b/update-contract-data.js @@ -0,0 +1,60 @@ +const dataFolder = './testvectorgen/contract_data/testdata/v3'; +const contractDataBaseFolder = '../contracts/test/validators/v'; +const buildFolder = './build/'; +const fs = require('fs'); +const path = require('path'); +const { execSync, execFileSync } = require('child_process'); + +const files = fs.readdirSync(dataFolder); + +let circuitName = null; +let destinationFolder = null; +for (const file of files) { + + + if (file.includes('state')) { + circuitName = 'stateTransition' + destinationFolder = 'common-data' + } else if (file.includes('sig')) { + circuitName = 'credentialAtomicQuerySigV2OnChain' + destinationFolder = 'sig/data' + } else if (file.includes('mtp')) { + circuitName = 'credentialAtomicQueryMTPV2OnChain' + destinationFolder = 'mtp/data' + } else { + throw new Error('unknown circuit') + } + const buildPath = `./build/${circuitName}/${circuitName}_js/`; + ['input.json', 'public.json', 'proof.json'].forEach((f) => { + const p = path.join(`./build/${circuitName}/${circuitName}_js`, f) + fs.existsSync(p) && + fs.unlinkSync(p); + console.log(`Deleted file: ${p}`); + }); + const { inputs } = require(`${dataFolder}/${file}`); + console.log(`Reading file: ${dataFolder}/${file}`); + + console.log(`Creating file: ${buildPath}/input.json`); + fs.writeFileSync(`${buildPath}/input.json`, JSON.stringify(inputs), 'utf-8'); + const child = execSync(`./generate.sh ${circuitName}`); + console.log(`execution completed`, new TextDecoder().decode(child)); + const pub_signals = JSON.parse(fs.readFileSync(`${buildPath}/public.json`).toString()); + console.log(pub_signals); + const proof = JSON.parse(fs.readFileSync(`${buildPath}/proof.json`).toString()); + console.log('Writing file: ', `${contractDataBaseFolder}/${destinationFolder}/${file}`); + fs.writeFileSync(`${contractDataBaseFolder}/${destinationFolder}/${file}`, JSON.stringify({ + pub_signals, + proof + }), 'utf-8'); + +} + +console.log('UPDATE verifiers'); +for (const part of ['MTP', 'Sig']) { + const circuitName = `credentialAtomicQuery${part}V2OnChain`; + const contractName = `${buildFolder}${circuitName}/verifier.sol`; + const contractContent = fs.readFileSync(contractName).toString(); + const newContractContent = contractContent.replace('pragma solidity ^0.6.11;', 'pragma solidity ^0.8.0;').replace('contract Verifier', 'contract Verifier' + part); + fs.writeFileSync(`../contracts/contracts/lib/verifier${part}.sol`, newContractContent, 'utf-8'); +} +console.log('Done'); From 7a1e04de3e5f3a9f0cfb27a43c9f41c986c1b9ed Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Mon, 11 Mar 2024 16:55:56 +0100 Subject: [PATCH 05/10] Tags and fixes (#126) * Introduce tags. Fix some review comments from Arnau * Fixes * Wrapped circuits to fix unit tests * Update tags-managing.circom Co-authored-by: GopherDID <74898029+vmidyllic@users.noreply.github.com> --------- Co-authored-by: GopherDID <74898029+vmidyllic@users.noreply.github.com> --- circuits/auth/authV2.circom | 14 +- circuits/lib/idOwnership.circom | 2 +- circuits/lib/linked/linkId.circom | 3 +- circuits/lib/query/comparators.circom | 16 +- .../query/processQueryWithModifiers.circom | 22 +- circuits/lib/query/query.circom | 14 +- circuits/lib/stateTransition.circom | 2 +- circuits/lib/utils/claimUtils.circom | 64 +++-- circuits/lib/utils/claimUtilsWrappers.circom | 17 -- circuits/lib/utils/idUtils.circom | 5 +- circuits/lib/utils/safeOne.circom | 2 +- circuits/lib/utils/tags-managing.circom | 256 ++++++++++++++++++ circuits/lib/utils/treeUtils.circom | 10 +- .../credentialAtomicQueryV3OffChain.circom | 17 +- .../credentialAtomicQueryV3OnChain.circom | 9 +- .../claimUtils_getClaimMerklizeRoot.circom | 16 +- .../utils_checkIdenStateMatchesRoots.circom | 18 +- .../utils_getClaimSubjectOtherIden.circom | 13 +- .../utils/utils_getSubjectLocation.circom | 12 +- test/circuits/utils/utils_isExpirable.circom | 12 +- test/circuits/utils/utils_isUpdatable.circom | 12 +- .../utils/utils_verifyClaimSignature.circom | 22 +- .../utils/utils_verifyExpirationTime.circom | 14 +- 23 files changed, 469 insertions(+), 103 deletions(-) delete mode 100644 circuits/lib/utils/claimUtilsWrappers.circom create mode 100644 circuits/lib/utils/tags-managing.circom diff --git a/circuits/auth/authV2.circom b/circuits/auth/authV2.circom index 68004507..7fe9efbc 100644 --- a/circuits/auth/authV2.circom +++ b/circuits/auth/authV2.circom @@ -9,8 +9,8 @@ include "../lib/utils/safeOne.circom"; template AuthV2(IdOwnershipLevels, onChainLevels) { signal input genesisID; - // random number, which should be stored by user - // if there is a need to generate the same userID (ProfileID) output for different proofs + // random number, which should be stored by user if there is a need to + // generate the same userID (ProfileID) output for different proofs signal input profileNonce; // user state @@ -31,7 +31,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { signal input authClaimNonRevMtpAuxHi; signal input authClaimNonRevMtpAuxHv; - // challenge signature + // challenge and it's signature signal input challenge; signal input challengeSignatureR8x; signal input challengeSignatureR8y; @@ -50,7 +50,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { signal output userID; // get safe zero and one values to be used in ForceEqualIfEnabled - signal one <== SafeOne()(genesisID); + signal {binary} one <== SafeOne()(genesisID); checkAuthV2(IdOwnershipLevels, onChainLevels)( one, @@ -81,7 +81,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { } template checkAuthV2(IdOwnershipLevels, onChainLevels) { - signal input enabled; + signal input {binary} enabled; signal input genesisID; @@ -143,7 +143,7 @@ template checkAuthV2(IdOwnershipLevels, onChainLevels) { signal isStateGenesis <== IsEqual()([cutId, cutState]); - signal genesisIDhash <== Poseidon(1)([genesisID]); + signal genesisIDHash <== Poseidon(1)([genesisID]); SMTVerifier(onChainLevels)( enabled <== enabled, @@ -153,7 +153,7 @@ template checkAuthV2(IdOwnershipLevels, onChainLevels) { oldKey <== gistMtpAuxHi, oldValue <== gistMtpAuxHv, isOld0 <== gistMtpNoAux, - key <== genesisIDhash, + key <== genesisIDHash, value <== state ); } diff --git a/circuits/lib/idOwnership.circom b/circuits/lib/idOwnership.circom index fb7e96bf..ac2768f0 100644 --- a/circuits/lib/idOwnership.circom +++ b/circuits/lib/idOwnership.circom @@ -12,7 +12,7 @@ include "utils/claimUtils.circom"; include "utils/treeUtils.circom"; template IdOwnership(nLevels) { - signal input enabled; + signal input {binary} enabled; signal input userState; diff --git a/circuits/lib/linked/linkId.circom b/circuits/lib/linked/linkId.circom index 03f961f7..e7ec76f1 100644 --- a/circuits/lib/linked/linkId.circom +++ b/circuits/lib/linked/linkId.circom @@ -1,7 +1,8 @@ pragma circom 2.1.5; -include "../../../node_modules/circomlib/circuits/poseidon.circom"; include "../../../node_modules/circomlib/circuits/comparators.circom"; +include "../../../node_modules/circomlib/circuits/mux1.circom"; +include "../../../node_modules/circomlib/circuits/poseidon.circom"; template LinkID() { signal input claimHash; diff --git a/circuits/lib/query/comparators.circom b/circuits/lib/query/comparators.circom index a2740bd1..2e089bb0 100644 --- a/circuits/lib/query/comparators.circom +++ b/circuits/lib/query/comparators.circom @@ -3,9 +3,12 @@ pragma circom 2.1.1; include "../../../node_modules/circomlib/circuits/comparators.circom"; include "../../../node_modules/circomlib/circuits/gates.circom"; -// nElements - number of value elements -// Example nElements = 3, '1' in ['12', '1231', '9999'], 1 not in array of values -template IN (valueArraySize){ +// Checks if value `in` is included is in value array +// Returns 1 if at least one value is equal to `in`, 0 otherwise +// valueArraySize - size of value array +// Example: IN(3)(1, [12, 1231, 9999]) ==> 0 (1 is not in array of values) +// Example: IN(3)(1231, [12, 1231, 9999]) ==> 1 (1231 is in array of values) +template IN(valueArraySize){ signal input in; signal input value[valueArraySize]; @@ -25,7 +28,8 @@ template IN (valueArraySize){ } // Same as IN but stops checking on valueArraySize -template InWithDynamicArraySize (maxValueArraySize){ +// Example: InWithDynamicArraySize(5)(0, [12, 1231, 9999, 0, 0], 3) ==> 0 (0 is not in the first 3 elements of value array) +template InWithDynamicArraySize(maxValueArraySize){ signal input in; signal input value[maxValueArraySize]; signal input valueArraySize; @@ -38,7 +42,7 @@ template InWithDynamicArraySize (maxValueArraySize){ signal lt[maxValueArraySize]; isEq[0] <== 0; for (var i=0; i skip MTP verification + fnc <== claimPathNotExists, // inclusion (or non-inclusion in case exists==false) root <== merklizedRoot, siblings <== claimPathMtp, oldKey <== claimPathMtpAuxHi, @@ -55,11 +57,11 @@ template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ merklized ); - // For non-merklized credentials exists / non-exist operators don't work - signal operatorNotExists <== NOT()(IsEqual()([operator, 11])); + // For non-merklized credentials exists / non-exist operators should always fail + signal isOpExists <== IsEqual()([operator, 11]); ForceEqualIfEnabled()( AND()(enabled, NOT()(merklized)), - [1, operatorNotExists] + [isOpExists, 0] ); ///////////////////////////////////////////////////////////////// diff --git a/circuits/lib/query/query.circom b/circuits/lib/query/query.circom index 0cb2e59c..eff2a9c6 100644 --- a/circuits/lib/query/query.circom +++ b/circuits/lib/query/query.circom @@ -9,7 +9,7 @@ include "comparators.circom"; /* Operators: Query operators: - 0 - noop, skip execution. Ignores all `in` and `value` passed to query, out 1 + 0 - noop. Ignores all `in` and `value` passed to query, out 1 1 - equals 2 - less than 3 - greater than @@ -18,14 +18,16 @@ include "comparators.circom"; 6 - not equals 7 - less than or equal 8 - greater than or equal - 9 - between + 9 - between (value[0] <= in <= value[1]) 10 - not between - 11 - exist + 11 - exist (true / false) Modifier/computation operators: 16 - selective disclosure (16 = 10000 binary) */ -// Query template works only with Query operators (0-15), for the rest returns 0 +// Query template works only with Query operators (0-15). +// Returns 1 if query operator is satisfied, 0 otherwise. +// For modifier/computation operators (16-31) it always returns 0. template Query (maxValueArraySize) { // signals signal input in; @@ -66,7 +68,7 @@ template Query (maxValueArraySize) { // modifier/computation operator. It's used in the final mux. _ <== opBits[4]; - queryOpSatisfied.c[0] <== 1; // noop; skip execution + queryOpSatisfied.c[0] <== 1; // noop; always succeeds queryOpSatisfied.c[1] <== eq; queryOpSatisfied.c[2] <== lt; queryOpSatisfied.c[3] <== gt; @@ -77,7 +79,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] <== 1; // exists; + queryOpSatisfied.c[11] <== 1; // exists(true/false) - actual check is done by checking inclusion/non-inclusion of claimPathKey in merklized root by SMTVerifier outside queryOpSatisfied.c[12] <== 0; // not used queryOpSatisfied.c[13] <== 0; // not used queryOpSatisfied.c[14] <== 0; // not used diff --git a/circuits/lib/stateTransition.circom b/circuits/lib/stateTransition.circom index 67621806..7271fe21 100644 --- a/circuits/lib/stateTransition.circom +++ b/circuits/lib/stateTransition.circom @@ -38,7 +38,7 @@ template StateTransition(IdOwnershipLevels) { signal input newRootsTreeRoot; // get safe one values to be used in ForceEqualIfEnabled - signal one <== SafeOne()(userID); + signal {binary} one <== SafeOne()(userID); signal cutId <== cutId()(userID); diff --git a/circuits/lib/utils/claimUtils.circom b/circuits/lib/utils/claimUtils.circom index e849ca40..82a29e68 100644 --- a/circuits/lib/utils/claimUtils.circom +++ b/circuits/lib/utils/claimUtils.circom @@ -11,24 +11,27 @@ include "./idUtils.circom"; // getClaimSubjectOtherIden checks that a claim Subject is OtherIden and outputs the identity within. template getClaimSubjectOtherIden() { signal input claim[8]; - signal input claimFlags[32]; + signal input {binary} claimFlags[32]; signal output id; // get subject location from header flags. component subjectLocation = getSubjectLocation(); subjectLocation.claimFlags <== claimFlags; - component mux = Mux2(); - component n2b = Num2Bits(2); + component mux = Mux3(); + component n2b = Num2Bits(3); n2b.in <== subjectLocation.out; - mux.s[0] <== n2b.out[0]; - mux.s[1] <== n2b.out[1]; + mux.s <== n2b.out; mux.c[0] <== 0; mux.c[1] <== 0; mux.c[2] <== claim[0*4 + 1]; mux.c[3] <== claim[1*4 + 1]; + mux.c[4] <== 0; + mux.c[5] <== 0; + mux.c[6] <== 0; + mux.c[7] <== 0; id <== mux.out; @@ -41,8 +44,8 @@ template getClaimSubjectOtherIden() { // getClaimMerkilizeFlag checks that a claim flag is set and return merklized slot. template getClaimMerklizeRoot() { signal input claim[8]; - signal input claimFlags[32]; - signal output flag; // 0 non merklized, 1 merklized + signal input {binary} claimFlags[32]; + signal output {binary} flag; // 0 non merklized, 1 merklized // merklizeFlag = 0 out = 0 , non merkilized // merklizeFlag = 1 out=claim_i_2, root is stored in index slot 2 (i_2) @@ -52,26 +55,26 @@ template getClaimMerklizeRoot() { // get subject location from header flags. signal merklizeLocation <== getMerklizeLocation()(claimFlags); - component mux = Mux2(); - component n2b = Num2Bits(2); + component mux = Mux3(); + component n2b = Num2Bits(3); n2b.in <== merklizeLocation; - mux.s[0] <== n2b.out[0]; - mux.s[1] <== n2b.out[1]; + mux.s <== n2b.out; mux.c[0] <== 0; mux.c[1] <== claim[0*4 +2]; mux.c[2] <== claim[1*4 +2]; mux.c[3] <== 0; + mux.c[4] <== 0; + mux.c[5] <== 0; + mux.c[6] <== 0; + mux.c[7] <== 0; out <== mux.out; - component gt = GreaterThan(3); // there's only 3 bits in merklizeLocation - gt.in[0] <== merklizeLocation; - gt.in[1] <== 0; - flag <== gt.out; + flag <== GreaterThan(3)([merklizeLocation, 0]); // there's only 3 bits in merklizeLocation - // explicitly state that these signals are not used and it's ok + // explicitly state that some signals are not used and it's ok for (var i=0; i<8; i++) { _ <== claim[i]; } @@ -84,7 +87,7 @@ template getClaimHeader() { signal input claim[8]; signal output schema; - signal output claimFlags[32]; + signal output {binary} claimFlags[32]; component i0Bits = Num2Bits(254); i0Bits.in <== claim[0]; @@ -169,9 +172,9 @@ template getClaimHash() { // verifyCredentialSubject verifies that claim is issued to a specified identity or identity profile // if nonce 0 is used, the claim should be issued to the genesis identity template verifyCredentialSubjectProfile() { - signal input enabled; + signal input {binary} enabled; signal input claim[8]; - signal input claimFlags[32]; + signal input {binary} claimFlags[32]; signal input id; signal input nonce; @@ -190,7 +193,7 @@ template verifyCredentialSubjectProfile() { // verifyCredentialSchema verifies that claim matches provided schema template verifyCredentialSchema() { - signal input enabled; + signal input {binary} enabled; signal input claimSchema; signal input schema; @@ -202,7 +205,7 @@ template verifyCredentialSchema() { // verifyClaimSignature verifies that claim is signed with the provided public key template verifyClaimSignature() { - signal input enabled; + signal input {binary} enabled; signal input claimHash; signal input sigR8x; signal input sigR8y; @@ -223,7 +226,7 @@ template verifyClaimSignature() { } template checkDataSignatureWithPubKeyInClaim() { - signal input enabled; + signal input {binary} enabled; signal input claim[8]; signal input signatureS; signal input signatureR8X; @@ -280,10 +283,12 @@ template getValueByIndex(){ // verify that the claim has expiration time and it is less then timestamp template verifyExpirationTime() { - signal input expirationFlag; // claimFlags[3] (expiration flag) is set + signal input {binary} expirationFlag; // claimFlags[3] (expiration flag) is set signal input claim[8]; signal input timestamp; + _ <== Num2Bits(64)(timestamp); // allow max 64 bit number for timestamp + signal claimExpiration <== getClaimExpiration()(claim); // timestamp < claimExpiration @@ -302,7 +307,7 @@ template verifyExpirationTime() { template getClaimExpiration() { signal input claim[8]; - signal output expiration; + signal output {maxbit} expiration; component expirationBits = Bits2Num(64); @@ -311,6 +316,7 @@ template getClaimExpiration() { for (var i=0; i<64; i++) { expirationBits.in[i] <== v0Bits.out[i+64]; } + expiration.maxbit = 64; expiration <== expirationBits.out; // explicitly state that some of these signals are not used and it's ok @@ -324,7 +330,7 @@ template getClaimExpiration() { // getSubjectLocation extract subject from claim flags. template getSubjectLocation() { - signal input claimFlags[32]; + signal input {binary} claimFlags[32]; signal output out; component subjectBits = Bits2Num(3); @@ -344,7 +350,7 @@ template getSubjectLocation() { // getMerklizeLocation extract merklize from claim flags. // 0 - not merklized, 1 - root in index slot i_2[root], 2 - root in value slot v_2[root] template getMerklizeLocation() { - signal input claimFlags[32]; + signal input {binary} claimFlags[32]; signal output out; component mtBits = Bits2Num(3); @@ -363,7 +369,7 @@ template getMerklizeLocation() { // isExpirable return 1 if expiration flag is set otherwise 0. template isExpirable() { - signal input claimFlags[32]; + signal input {binary} claimFlags[32]; signal output out; out <== claimFlags[3]; @@ -371,8 +377,8 @@ template isExpirable() { // isUpdatable return 1 if updatable flag is set otherwise 0. template isUpdatable() { - signal input claimFlags[32]; - signal output out; + signal input {binary} claimFlags[32]; + signal output {binary} out; out <== claimFlags[4]; } diff --git a/circuits/lib/utils/claimUtilsWrappers.circom b/circuits/lib/utils/claimUtilsWrappers.circom deleted file mode 100644 index 31d91d35..00000000 --- a/circuits/lib/utils/claimUtilsWrappers.circom +++ /dev/null @@ -1,17 +0,0 @@ -pragma circom 2.1.1; - -include "../../../node_modules/circomlib/circuits/mux3.circom"; -include "../../../node_modules/circomlib/circuits/mux1.circom"; -include "../../../node_modules/circomlib/circuits/mux2.circom"; -include "./claimUtils.circom"; - -template getClaimSubjectOtherIdenWrapper() { - signal input claim[8]; - signal output id; - - // get header flags from claim. - component header = getClaimHeader(); - header.claim <== claim; - - id <== getClaimSubjectOtherIden()(claim, header.claimFlags); -} diff --git a/circuits/lib/utils/idUtils.circom b/circuits/lib/utils/idUtils.circom index 7d370579..89065e21 100644 --- a/circuits/lib/utils/idUtils.circom +++ b/circuits/lib/utils/idUtils.circom @@ -3,6 +3,7 @@ pragma circom 2.1.1; include "../../../node_modules/circomlib/circuits/bitify.circom"; include "../../../node_modules/circomlib/circuits/poseidon.circom"; include "../../../node_modules/circomlib/circuits/mux1.circom"; +include "./safeOne.circom"; template ProfileID(){ signal input in; @@ -29,7 +30,7 @@ template SplitID() { signal output genesis; signal output checksum; - component bs = Num2Bits(254); + component bs = Num2Bits(248); bs.in <== id; // checksum bytes are swapped in ID. 31-th byte is first and 30-th is second. @@ -52,7 +53,7 @@ template SplitID() { typ <== typBits.out; // explicitly state that some of these signals are not used and it's ok - for (var i=0; i<254; i++) { + for (var i=0; i<248; i++) { _ <== bs.out[i]; } } diff --git a/circuits/lib/utils/safeOne.circom b/circuits/lib/utils/safeOne.circom index cc4ac635..12620725 100644 --- a/circuits/lib/utils/safeOne.circom +++ b/circuits/lib/utils/safeOne.circom @@ -18,6 +18,6 @@ template SafeOne() { signal tmp <== IsZero()(inputSignal); signal tmp2 <== NOT()(tmp); signal zero <== IsEqual()([tmp, tmp2]); - signal output one <== IsZero()(zero); + signal output {binary} one <== IsZero()(zero); zero * one === 0; } diff --git a/circuits/lib/utils/tags-managing.circom b/circuits/lib/utils/tags-managing.circom new file mode 100644 index 00000000..880a1f60 --- /dev/null +++ b/circuits/lib/utils/tags-managing.circom @@ -0,0 +1,256 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.1.5; + +include "../../../node_modules/circomlib/circuits/bitify.circom"; +include "../../../node_modules/circomlib/circuits/comparators.circom"; + + +// The templates and functions in this file are general and work for any prime field + +// To consult the tags specifications check tags-specifications.circom + + +/* +*** AddBinaryTag(n): template that adds the constraints needed to ensure that a signal in is binary and adds the tag binary to the input + - Inputs: in -> field value + - Output: out -> same value as in, but including binary tag + satisfies tag binary + + Example: AddBinaryTag()(1) = 1 + Note: in case the input in is not binary then the generated system of constraints does not have any solution for that input. + For instance, AddBinaryTag()(10) -> no solution + +*/ + +template AddBinaryTag () { + signal input in; + signal output {binary} out; + + in * (in - 1) === 0; + out <== in; +} + +/* +*** AddBinaryArrayTag(n): template that adds the constraints needed to ensure that all signal of an array of n elements are binary and adds the tag binary to the input + - Inputs: in[n] -> array of n field elements + - Output: out[n] -> same value as in, but including binary tag + satisfies tag binary + + Example: AddBinaryArrayTag(2)([0,1]) = [0,1] + Note: in case the input contains a non binary element then the generated system of constraints does not have any solution for that input. + For instance, AddBinaryArrayTag(2)([0,10]) -> no solution + +*/ + +template AddBinaryArrayTag(n) { + signal input in[n]; + signal output {binary} out[n]; + + for (var i = 0; i < n; i++) { + in[i] * (in[i] - 1) === 0; + } + out <== in; +} + +/* +*** ForceBinary(n): template that adds the tag binary to a signal without adding the constraints needed to ensure that the signal is binary + - Inputs: in -> field value + - Output: out -> same value as in, but including binary tag + DOES NOT CHECK THAT out satisfies tag binary + + Example: ForceBinary()(5) = 5 + Note: the template does not check if the input actually satisfies the binary specification --> Use carefully, potentially dangerous template + For instance, ForceBinary()(10) = 10, including tag binary + +*/ + +template ForceBinary() { + signal input in; + signal output {binary} out; + + out <== in; +} + +/* +*** ForceBinaryArray(n): template that adds the tag binary to an array of n signals without adding the constraints needed to ensure that the signals are binary + - Inputs: in[n] -> array of field values + - Output: out[n] -> same value as in, but including binary tag + DOES NOT CHECK THAT out satisfies tag binary + + Example: ForceBinaryArray()([1,0]) = [1, 0], including tag binary + Note: the template does not check if the input actually satisfies the binary specification --> Use carefully, potentially dangerous template + For instance, ForceBinaryArray()([0, 10]) = [0, 10], including tag binary + +*/ + +template ForceBinaryArray(n) { + signal input in[n]; + signal output {binary} out[n]; + + out <== in; +} + +/* +*** AddMaxbitTag(n): template that adds the constraints needed to ensure that a signal can be expressed using n bits(that is value is in [0, 2**n)) and adds the tag maxbit = n to the input + - Inputs: in -> field value + - Output: out -> same value as in, but including maxbit tag with out.maxbit = n + satisfies tag out.maxbit = n + + Example: AddMaxbitTag(5)(14) = 14 + Note: in case the input in does not satisfy the specification of maxbit then the generated system of constraints does not have any solution for that input. + For instance, AddMaxbitTag(3)(100) -> no solution + +*/ + +template AddMaxbitTag(n) { + signal input in; + signal output {maxbit} out; + + _ <== Num2Bits(n)(in); + + out.maxbit = n; + out <== in; +} + +/* +*** AddMaxbitArrayTag(n): template that adds the constraints needed to ensure that the signals an array of length m can be expressed using n bits(that is, that is value is in [0, 2**n)) and adds the tag maxbit = n to the input + - Inputs: in[m] -> array of m field values + - Output: out[m] -> same values as in, but including maxbit tag with out.maxbit = n + satisfies tag out.maxbit = n + + Example: AddMaxbitTag(5, 2)([3,14]) = [3, 14] with tag maxbit = 5 + Note: in case the a signal of the input in does not satisfy the specification of maxbit then the generated system of constraints does not have any solution for that input. + For instance, AddMaxbitTag(3, 2)([3, 100]) -> no solution + +*/ + + +template AddMaxbitArrayTag(n,m) { + signal input in[m]; + signal output {maxbit} out[m]; + + out.maxbit = n; + + for (var i = 0; i < m; i++) { + _ <== Num2Bits(n)(in[i]); + } + + in ==> out; +} + +/* +*** ForceMaxbitTag(n): template that adds the tag maxbit = n to the input without adding any constraints to ensure that the input especification of the tag + - Inputs: in -> field value + - Output: out -> same value as in, but including maxbit tag with out.maxbit = n + DOES NOT CHECK THAT out satisfies tag out.maxbit = n + + Note: the template does not check if the input actually satisfies the maxbit specification --> Use carefully, potentially dangerous template + For instance, ForceMaxbitTag(2)(10) = 10, including tag maxbit = 2 + +*/ + + +template ForceMaxbit(n) { + signal input in; + signal output {maxbit} out; + + out.maxbit = n; + in ==> out; +} + +/* +*** ForceMaxbitArrayTag(n, m): template that adds the tag maxbit = n to the input that is an array of m signals without adding any constraints to ensure that the inputs especification of the tag + - Inputs: in[m] -> field value + - Output: out[m] -> same value as in, but including maxbit tag with out.maxbit = n + DOES NOT CHECK THAT out satisfies tag out.maxbit = n + + Note: the template does not check if the input actually satisfies the maxbit specification --> Use carefully, potentially dangerous template + For instance, ForceMaxbitTag(2,2)([0,10]) = [0,10], including tag maxbit = 2 + +*/ + +template ForceMaxbitArray(n,m) { + signal input in[m]; + signal output {maxbit} out[m]; + + out.maxbit = n; + + in ==> out; +} + + +/* +*** AddMaxValueTag(n): template that adds the constraints needed to ensure that a signal is smaller or equal than a given value n and adds the tag max = n to the input + - Inputs: in -> field value + - Output: out -> same value as in, but including max tag with out.max = n + satisfies tag out.max = n + + Example: AddMaxValueTag(15)(14) = 14 and can be satisfied + Note: in case the input in does not satisfy the specification of max then the generated system of constraints does not have any solution for that input. + For instance, AddMaxValueTag(3)(100) -> no solution + +*/ + +template AddMaxValueTag(n) { + signal input in; + signal output {max} out; + + signal {maxbit} aux[2]; + aux.maxbit = nbits(n); + aux[0] <== AddMaxbitTag(nbits(n))(in); // to ensure the correct size + aux[1] <== n; + + signal out1 <== LessEqThan(n)(aux); + out1 === 1; + out.max = n; + out <== in; +} + +/* +*** AddMaxAbsValueTag(n): template that adds the constraints needed to ensure that the absolute value of a signal is smaller or equal than a given value n and adds the tag max_abs = n to the input + - Inputs: in -> field value + - Output: out -> same value as in, but including max_abs tag with out.max_abs = n + satisfies tag out.max_abs = n + + Example: AddMaxValueTag(15)(-14) = 14 and can be satisfied + Note: in case the input in does not satisfy the specification of max_abs then the generated system of constraints does not have any solution for that input. + For instance, AddMaxAbsValueTag(33)(-100) -> no solution + +*/ + +template AddMaxAbsValueTag(n){ + signal input in; + signal output {max_abs} out; + + var needed_bits = nbits(2 * n); + + signal {maxbit} aux[2]; + aux.maxbit = needed_bits; + aux[0] <== AddMaxbitTag(needed_bits)(in + n); // to ensure that 0 <= aux[0] < 2**nbits(2 * n) + aux[1] <== 2 * n; + + signal out1 <== LessEqThan(n)(aux); // checks that 0 <= in + n <= 2 * n <==> -n <= in <= n + out1 === 1; + + out.max_abs = n; + out <== in; +} + + diff --git a/circuits/lib/utils/treeUtils.circom b/circuits/lib/utils/treeUtils.circom index 09101a4a..15292161 100644 --- a/circuits/lib/utils/treeUtils.circom +++ b/circuits/lib/utils/treeUtils.circom @@ -10,7 +10,7 @@ include "claimUtils.circom"; // checkClaimExists verifies that claim is included into the claim tree root template checkClaimExists(IssuerLevels) { - signal input enabled; + signal input {binary} enabled; signal input claimHi; signal input claimHv; signal input claimMTP[IssuerLevels]; @@ -30,7 +30,7 @@ template checkClaimExists(IssuerLevels) { } template checkClaimNotRevoked(treeLevels) { - signal input enabled; + signal input {binary} enabled; signal input claim[8]; signal input claimNonRevMTP[treeLevels]; signal input treeRoot; @@ -56,7 +56,7 @@ template checkClaimNotRevoked(treeLevels) { // checkIdenStateMatchesRoots checks that a hash of 3 tree // roots is equal to expected identity state template checkIdenStateMatchesRoots() { - signal input enabled; + signal input {binary} enabled; signal input claimsTreeRoot; signal input revTreeRoot; signal input rootsTreeRoot; @@ -76,7 +76,7 @@ template checkIdenStateMatchesRoots() { // verifyClaimIssuance verifies that claim is issued by the issuer template verifyClaimIssuance(IssuerLevels) { - signal input enabled; + signal input {binary} enabled; signal input claimHi; signal input claimHv; signal input claimIssuanceMtp[IssuerLevels]; @@ -105,7 +105,7 @@ template verifyClaimIssuance(IssuerLevels) { } template VerifyAuthClaimAndSignature(nLevels) { - signal input enabled; + signal input {binary} enabled; signal input claimsTreeRoot; signal input authClaimMtp[nLevels]; diff --git a/circuits/offchain/credentialAtomicQueryV3OffChain.circom b/circuits/offchain/credentialAtomicQueryV3OffChain.circom index 03b29aea..8406f7d5 100644 --- a/circuits/offchain/credentialAtomicQueryV3OffChain.circom +++ b/circuits/offchain/credentialAtomicQueryV3OffChain.circom @@ -11,10 +11,11 @@ include "../lib/query/processQueryWithModifiers.circom"; include "../lib/utils/nullify.circom"; include "../lib/utils/idUtils.circom"; include "../lib/utils/safeOne.circom"; +include "../lib/utils/tags-managing.circom"; template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArraySize) { // common outputs for Sig and MTP - signal output merklized; + signal output {binary} merklized; signal output userID; // common inputs for Sig and MTP @@ -95,7 +96,7 @@ template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArra signal output operatorOutput; // get safe one values to be used in ForceEqualIfEnabled - signal one <== SafeOne()(userGenesisID); + signal {binary} one <== SafeOne()(userGenesisID); ///////////////////////////////////////////////////////////////// // Claim Verification (id, schema, expiration, issuance, revocation) @@ -119,8 +120,8 @@ template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArra // verify issuerClaim expiration time verifyExpirationTime()(issuerClaimHeader.claimFlags[3], issuerClaim, timestamp); // 322 constraints - signal isSig <== IsEqual()([proofType, 1]); - signal isMTP <== IsEqual()([proofType, 2]); + signal {binary} isSig <== IsEqual()([proofType, 1]); + signal {binary} isMTP <== IsEqual()([proofType, 2]); signal validProofType <== OR()(isSig, isMTP); ForceEqualIfEnabled()(one, [validProofType, 1]); @@ -172,9 +173,11 @@ template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArra claimIssuanceIdenState <== issuerState ); // 11184 constraints + signal {binary} safeIsRevocationChecked <== AddBinaryTag()(isRevocationChecked); + // check claim is not revoked checkClaimNotRevoked(issuerLevels)( - enabled <== isRevocationChecked, + enabled <== safeIsRevocationChecked, claim <== issuerClaim, claimNonRevMTP <== issuerClaimNonRevMtp, noAux <== issuerClaimNonRevMtpNoAux, @@ -187,7 +190,7 @@ template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArra // 1. if Sig proof is provided we need to check non revocation of authClaim always // AND non revocation of issuerClaim only if isRevocationChecked = 1 // 2. if MTP proof is provided we need to check non revocation of claim only if isRevocationChecked = 1 - signal checkIssuerClaimNonRevState <== OR()(isSig, isRevocationChecked); + signal {binary} checkIssuerClaimNonRevState <== OR()(isSig, safeIsRevocationChecked); // verify issuer state for claim non-revocation proof checkIdenStateMatchesRoots()( @@ -250,7 +253,7 @@ template credentialAtomicQueryV3OffChain(issuerLevels, claimLevels, maxValueArra } template sigFlow(issuerLevels) { - signal input enabled; + signal input {binary} enabled; signal input issuerAuthClaim[8]; signal input issuerAuthClaimNonRevMtp[issuerLevels]; signal input issuerAuthClaimNonRevMtpNoAux; diff --git a/circuits/onchain/credentialAtomicQueryV3OnChain.circom b/circuits/onchain/credentialAtomicQueryV3OnChain.circom index b3aca1b5..92548dfd 100644 --- a/circuits/onchain/credentialAtomicQueryV3OnChain.circom +++ b/circuits/onchain/credentialAtomicQueryV3OnChain.circom @@ -10,6 +10,7 @@ include "../lib/utils/idUtils.circom"; include "../lib/utils/spongeHash.circom"; include "../offchain/credentialAtomicQueryV3OffChain.circom"; include "../lib/utils/queryHash.circom"; +include "../lib/utils/tags-managing.circom"; /** credentialAtomicQueryV3OnChain.circom - query claim value and verify claim issuer signature or mtp: @@ -168,16 +169,18 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArray // on root stored in the index or value slot // if it is not set verification is performed on according to the slotIndex. Value selected from the // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal merklized; + signal {binary} merklized; ///////////////////////////////////////////////////////////////// // Auth check ///////////////////////////////////////////////////////////////// - ForceEqualIfEnabled()(NOT()(isBJJAuthEnabled), [profileNonce, 0]); + signal {binary} safeIsBJJAuthEnabled <== AddBinaryTag()(isBJJAuthEnabled); + + ForceEqualIfEnabled()(NOT()(safeIsBJJAuthEnabled), [profileNonce, 0]); checkAuthV2(idOwnershipLevels, onChainLevels)( - isBJJAuthEnabled, // enabled + safeIsBJJAuthEnabled, // enabled userGenesisID, userState, // user state userClaimsTreeRoot, diff --git a/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom b/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom index 98290d70..8ed00360 100644 --- a/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom +++ b/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom @@ -1,5 +1,19 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = getClaimMerklizeRoot(); +template wrappedGetClaimMerklizeRoot() { + signal input claim[8]; + signal input claimFlags[32]; + signal output flag; + signal output out; + + component check = getClaimMerklizeRoot(); + check.claim <== claim; + check.claimFlags <== AddBinaryArrayTag(32)(claimFlags); + flag <== check.flag; + out <== check.out; +} + +component main = wrappedGetClaimMerklizeRoot(); diff --git a/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom b/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom index 9a728498..df93fa85 100644 --- a/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom +++ b/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom @@ -2,5 +2,21 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; include "../../../circuits/lib/utils/treeUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = checkIdenStateMatchesRoots(); +template wrappedCheckIdenStateMatchesRoots(){ + signal input enabled; + signal input claimsTreeRoot; + signal input revTreeRoot; + signal input rootsTreeRoot; + signal input expectedState; + + component check = checkIdenStateMatchesRoots(); + check.enabled <== AddBinaryTag()(enabled); + check.claimsTreeRoot <== claimsTreeRoot; + check.revTreeRoot <== revTreeRoot; + check.rootsTreeRoot <== rootsTreeRoot; + check.expectedState <== expectedState; +} + +component main = wrappedCheckIdenStateMatchesRoots(); diff --git a/test/circuits/utils/utils_getClaimSubjectOtherIden.circom b/test/circuits/utils/utils_getClaimSubjectOtherIden.circom index 015b9527..eb25e21c 100644 --- a/test/circuits/utils/utils_getClaimSubjectOtherIden.circom +++ b/test/circuits/utils/utils_getClaimSubjectOtherIden.circom @@ -1,5 +1,16 @@ pragma circom 2.1.1; -include "../../../circuits/lib/utils/claimUtilsWrappers.circom"; +include "../../../circuits/lib/utils/claimUtils.circom"; + +template getClaimSubjectOtherIdenWrapper() { + signal input claim[8]; + signal output id; + + // get header flags from claim. + component header = getClaimHeader(); + header.claim <== claim; + + id <== getClaimSubjectOtherIden()(claim, header.claimFlags); +} component main{public[claim]} = getClaimSubjectOtherIdenWrapper(); diff --git a/test/circuits/utils/utils_getSubjectLocation.circom b/test/circuits/utils/utils_getSubjectLocation.circom index 8b4f3710..4d39620b 100644 --- a/test/circuits/utils/utils_getSubjectLocation.circom +++ b/test/circuits/utils/utils_getSubjectLocation.circom @@ -1,5 +1,15 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = getSubjectLocation(); +template wrappedGetSubjectLocation() { + signal input claimFlags[32]; + signal output out; + + component check = getSubjectLocation(); + check.claimFlags <== AddBinaryArrayTag(32)(claimFlags); + out <== check.out; +} + +component main = wrappedGetSubjectLocation(); diff --git a/test/circuits/utils/utils_isExpirable.circom b/test/circuits/utils/utils_isExpirable.circom index 6b551081..d65e85c4 100644 --- a/test/circuits/utils/utils_isExpirable.circom +++ b/test/circuits/utils/utils_isExpirable.circom @@ -1,5 +1,15 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = isExpirable(); +template wrappedIsExpirable() { + signal input claimFlags[32]; + signal output out; + + component check = isExpirable(); + check.claimFlags <== AddBinaryArrayTag(32)(claimFlags); + out <== check.out; +} + +component main = wrappedIsExpirable(); diff --git a/test/circuits/utils/utils_isUpdatable.circom b/test/circuits/utils/utils_isUpdatable.circom index 1d04f3d7..28b2ca12 100644 --- a/test/circuits/utils/utils_isUpdatable.circom +++ b/test/circuits/utils/utils_isUpdatable.circom @@ -1,5 +1,15 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = isUpdatable(); +template wrappedIsUpdatable() { + signal input claimFlags[32]; + signal output out; + + component check = isUpdatable(); + check.claimFlags <== AddBinaryArrayTag(32)(claimFlags); + out <== check.out; +} + +component main = wrappedIsUpdatable(); diff --git a/test/circuits/utils/utils_verifyClaimSignature.circom b/test/circuits/utils/utils_verifyClaimSignature.circom index 2cf86a28..c34db683 100644 --- a/test/circuits/utils/utils_verifyClaimSignature.circom +++ b/test/circuits/utils/utils_verifyClaimSignature.circom @@ -1,5 +1,25 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = verifyClaimSignature(); +template wrappedVerifyClaimSignature(){ + signal input enabled; + signal input claimHash; + signal input sigR8x; + signal input sigR8y; + signal input sigS; + signal input pubKeyX; + signal input pubKeyY; + + component check = verifyClaimSignature(); + check.enabled <== AddBinaryTag()(enabled); + check.claimHash <== claimHash; + check.sigR8x <== sigR8x; + check.sigR8y <== sigR8y; + check.sigS <== sigS; + check.pubKeyX <== pubKeyX; + check.pubKeyY <== pubKeyY; +} + +component main = wrappedVerifyClaimSignature(); diff --git a/test/circuits/utils/utils_verifyExpirationTime.circom b/test/circuits/utils/utils_verifyExpirationTime.circom index 621cf4f5..1c0fbfb7 100644 --- a/test/circuits/utils/utils_verifyExpirationTime.circom +++ b/test/circuits/utils/utils_verifyExpirationTime.circom @@ -1,5 +1,17 @@ pragma circom 2.1.1; include "../../../circuits/lib/utils/claimUtils.circom"; +include "../../../circuits/lib/utils/tags-managing.circom"; -component main = verifyExpirationTime(); +template wrappedVerifyExpirationTime() { + signal input expirationFlag; // claimFlags[3] (expiration flag) is set + signal input claim[8]; + signal input timestamp; + + component check = verifyExpirationTime(); + check.expirationFlag <== AddBinaryTag()(expirationFlag); + check.claim <== claim; + check.timestamp <== timestamp; +} + +component main = wrappedVerifyExpirationTime(); From cdb8a594df79233c6389ef34f265d03b9905df32 Mon Sep 17 00:00:00 2001 From: GopherDID <74898029+vmidyllic@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:18:53 +0300 Subject: [PATCH 06/10] Feature/linked multi tests (#132) * add vector gen and tests --- test/linked/linked.test.ts | 44 +++ .../credentials/linked/linked_test.go | 370 ++++++++++++++++++ 2 files changed, 414 insertions(+) create mode 100644 test/linked/linked.test.ts create mode 100644 testvectorgen/credentials/linked/linked_test.go diff --git a/test/linked/linked.test.ts b/test/linked/linked.test.ts new file mode 100644 index 00000000..7b747804 --- /dev/null +++ b/test/linked/linked.test.ts @@ -0,0 +1,44 @@ +import {expect} from "chai"; +import {describe} from "mocha"; + +const path = require("path"); +const wasmTester = require("circom_tester").wasm; + +describe("Test linkedMultiQuery10.circom", function () { + + this.timeout(600000); + + let circuit; + + before(async () => { + circuit = await wasmTester( + path.join(__dirname, "../../circuits", "linkedMultiQuery10.circom"), + { + output: path.join(__dirname, "circuits", "build"), + recompile: true, + }, + ); + + }); + + after(async () => { + circuit.release() + }) + + const basePath = '../../testvectorgen/credentials/linked/testdata/linked' + const tests = [ + + require(`${basePath}/one_query.json`), + require(`${basePath}/two_queries.json`), + + ]; + + tests.forEach(({ desc, inputs, expOut }) => { + it(`${desc}`, async function () { + const w = await circuit.calculateWitness(inputs, true); + await circuit.assertOut(w, expOut); + await circuit.checkConstraints(w); + }); + }); + +}); diff --git a/testvectorgen/credentials/linked/linked_test.go b/testvectorgen/credentials/linked/linked_test.go new file mode 100644 index 00000000..e40adaa1 --- /dev/null +++ b/testvectorgen/credentials/linked/linked_test.go @@ -0,0 +1,370 @@ +package linked + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "math/big" + "testing" + + "github.com/iden3/go-iden3-crypto/poseidon" + "test/utils" + + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-merkletree-sql/v2" + "github.com/iden3/go-schema-processor/v2/merklize" + "github.com/stretchr/testify/require" +) + +const ( + userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" +) + +type Inputs struct { + LinkNonce string `json:"linkNonce"` + IssuerClaim *core.Claim `json:"issuerClaim"` + ClaimSchema string `json:"claimSchema"` + ClaimPathMtp [][]string `json:"claimPathMtp"` + ClaimPathMtpNoAux []string `json:"claimPathMtpNoAux"` // 1 if aux node is empty, 0 if non-empty or for inclusion proofs + ClaimPathMtpAuxHi []*merkletree.Hash `json:"claimPathMtpAuxHi"` // 0 for inclusion proof + ClaimPathMtpAuxHv []*merkletree.Hash `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 + SlotIndex []int `json:"slotIndex"` + Operator []int `json:"operator"` + Value [][]string `json:"value"` + ActualValueArraySize []int `json:"valueArraySize"` +} + +type Outputs struct { + LinkID string `json:"linkID"` + Merklized int `json:"merklized"` + OperatorOutput []string `json:"operatorOutput"` + CircuitQueryHash []string `json:"circuitQueryHash"` + ActualValueArraySize []int `json:"valueArraySize"` +} + +type TestData struct { + Desc string `json:"desc"` + In Inputs `json:"inputs"` + Out Outputs `json:"expOut"` +} + +func Test_OneQuery(t *testing.T) { + desc := "Linked query count: 1, operator: LT" + + queries := []Query{ + { + Operator: utils.LT, // lt + Values: []*big.Int{new(big.Int).SetInt64(20020101)}, + }, + } + generate(t, desc, "linked/one_query", queries) +} +func Test_TwoQueries(t *testing.T) { + desc := "Linked query count: 2, operator: LT , NE" + + queries := []Query{ + { + Operator: utils.LT, + Values: []*big.Int{new(big.Int).SetInt64(20020101)}, + }, + { + Operator: utils.NE, + Values: []*big.Int{new(big.Int).SetInt64(20030101)}, + }, + } + generate(t, desc, "linked/two_queries", queries) +} + +// Query represents basic request to claim field with MTP and without +type Query struct { + Operator int + Values []*big.Int +} + +func generate(t *testing.T, desc string, fileName string, queries []Query) { + var err error + + isJSONLD := true + isZeroSubjClaim := false + + linkNonce := "1" + + user := utils.NewIdentity(t, userPK) + subjectID := user.ID + + var claim *core.Claim + var mz *merklize.Merklizer + var claimPathMtp []string + var claimPathMtpNoAux, claimPathMtpAuxHi, claimPathMtpAuxHv, claimPathKey, claimPathValue string + var pathKey *big.Int + + var merklized int + var slotIndex = 0 + + if isJSONLD { + mz, claim = utils.DefaultJSONNormalUserClaim(t, subjectID) + path, err := merklize.NewPath( + "https://www.w3.org/2018/credentials#credentialSubject", + "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#birthday") + require.NoError(t, err) + jsonP, value, err := mz.Proof(context.Background(), path) + require.NoError(t, err) + valueKey, err := value.MtEntry() + require.NoError(t, err) + claimPathValue = valueKey.String() + + var claimJSONLDProofAux utils.NodeAuxValue + claimPathMtp, claimJSONLDProofAux = utils.PrepareProof(jsonP, utils.ClaimLevels) + claimPathMtpNoAux = claimJSONLDProofAux.NoAux + claimPathMtpAuxHi = claimJSONLDProofAux.Key + claimPathMtpAuxHv = claimJSONLDProofAux.Value + pathKey, err = path.MtEntry() + require.NoError(t, err) + claimPathKey = pathKey.String() + + //valueInput = utils.PrepareStrArray([]string{claimPathValue}, 64) + merklized = 1 + + } else { + var subjValue *big.Int + if isZeroSubjClaim { + subjValue = big.NewInt(0) + } + claim = utils.DefaultUserClaim(t, subjectID, subjValue) + claimPathMtp = utils.PrepareStrArray([]string{}, 32) + claimPathMtpNoAux = "0" + claimPathMtpAuxHi = "0" + claimPathMtpAuxHv = "0" + claimPathKey = "0" + claimPathValue = "0" + merklized = 0 + pathKey = big.NewInt(0) + + slotIndex = 2 + } + + hI, err := merkletree.NewHashFromString(claimPathMtpAuxHi) + require.NoError(t, err) + hV, err := merkletree.NewHashFromString(claimPathMtpAuxHv) + require.NoError(t, err) + + s := Inputs{} + + s.LinkNonce = linkNonce + s.IssuerClaim = claim + s.ClaimSchema = claim.GetSchemaHash().BigInt().String() + s.ClaimPathMtp = make([][]string, 10) + s.ClaimPathMtpNoAux = make([]string, 10) + s.ClaimPathMtpAuxHi = make([]*merkletree.Hash, 10) + s.ClaimPathMtpAuxHv = make([]*merkletree.Hash, 10) + s.ClaimPathKey = make([]string, 10) + s.ClaimPathValue = make([]string, 10) + s.SlotIndex = make([]int, 10) + s.Operator = make([]int, 10) + s.Value = make([][]string, 10) + s.ActualValueArraySize = make([]int, 10) + + for i := 0; i < 10; i++ { + if i >= 0 { + s.ClaimPathMtp[i] = utils.PrepareSiblingsStr([]*merkletree.Hash{}, 32) + + s.ClaimPathMtpNoAux[i] = "0" + s.ClaimPathMtpAuxHi[i] = &merkletree.HashZero + s.ClaimPathMtpAuxHv[i] = &merkletree.HashZero + + s.ClaimPathKey[i] = "0" + s.ClaimPathValue[i] = "0" + + s.SlotIndex[i] = 0 + s.Operator[i] = 0 + + values, err := PrepareCircuitArrayValues(make([]*big.Int, 0), 64) + if err != nil { + continue + } + s.Value[i] = bigIntArrayToStringArray(values) + s.ActualValueArraySize[i] = 0 + continue + } + } + + for i, query := range queries { + s.Operator[i] = query.Operator + s.SlotIndex[i] = slotIndex + s.ClaimPathMtp[i] = claimPathMtp + s.ClaimPathMtpNoAux[i] = claimPathMtpNoAux + s.ClaimPathMtpAuxHi[i] = hI + s.ClaimPathMtpAuxHv[i] = hV + s.ClaimPathKey[i] = claimPathKey + s.ClaimPathValue[i] = claimPathValue + s.ActualValueArraySize[i] = len(query.Values) + values, err := PrepareCircuitArrayValues(query.Values, 64) + if err != nil { + continue + } + s.Value[i] = bigIntArrayToStringArray(values) + + } + + l, _ := CalculateLinkIDBigInt(linkNonce, claim) + + out := Outputs{ + Merklized: merklized, + LinkID: l.String(), + OperatorOutput: fillOperatorOutput(queries), + CircuitQueryHash: fillCircuitQueryHash(s, merklized, queries), + ActualValueArraySize: s.ActualValueArraySize, + } + + require.NoError(t, err) + + jsonData, err := json.Marshal(TestData{ + desc, + s, + out, + }) + require.NoError(t, err) + + utils.SaveTestVector(t, fileName, string(jsonData)) +} + +func fillOperatorOutput(queries []Query) []string { + + arr := make([]string, 10) + for i, _ := range arr { + if i < len(queries) && queries[i].Operator == utils.SD { + arr[i] = queries[i].Values[0].String() + } else { + arr[i] = "0" + } + } + return arr +} + +func fillCircuitQueryHash(s Inputs, merklized int, queries []Query) []string { + merklizedBigInt := big.NewInt(0).SetInt64(int64(merklized)) + schema, _ := new(big.Int).SetString(s.ClaimSchema, 10) + + arr := make([]string, 10) + for i, _ := range arr { + if i < len(queries) { + claimPathKey, _ := new(big.Int).SetString(s.ClaimPathKey[i], 10) + + queryHash, _ := CalculateQueryHash( + queries[i].Values, + schema, + s.SlotIndex[i], + s.Operator[i], + claimPathKey, + merklizedBigInt, + ) + + arr[i] = queryHash.String() + } else { + claimPathKey, _ := new(big.Int).SetString(s.ClaimPathKey[i], 10) + + queryHash, _ := CalculateQueryHash( + []*big.Int{}, + schema, + 0, + 0, + claimPathKey, + merklizedBigInt, + ) + arr[i] = queryHash.String() + + } + + } + return arr +} +func CalculateQueryHash( + values []*big.Int, + schemaHash *big.Int, + slotIndex int, + operator int, + claimPathKey *big.Int, + merklized *big.Int, +) (*big.Int, error) { + + valArrSize := big.NewInt(int64(len(values))) + circuitValues, err := PrepareCircuitArrayValues(values, 64) + if err != nil { + return nil, err + } + + valueHash, err := poseidon.SpongeHashX(circuitValues, 6) + if err != nil { + return nil, err + } + firstPart, err := poseidon.Hash([]*big.Int{ + schemaHash, + big.NewInt(int64(slotIndex)), + big.NewInt(int64(operator)), + claimPathKey, + merklized, + valueHash, + }) + if err != nil { + return nil, err + } + return poseidon.Hash([]*big.Int{ + firstPart, + valArrSize, + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + }) + +} +func PrepareCircuitArrayValues(arr []*big.Int, size int) ([]*big.Int, error) { + if len(arr) > size { + return nil, errors.New("ff") + } + + // Add the empty values + for i := len(arr); i < size; i++ { + arr = append(arr, new(big.Int)) + } + + return arr, nil +} +func CalculateLinkIDBigInt(linkNonce string, claim *core.Claim) (*big.Int, error) { + if linkNonce == "0" { + return nil, nil + } + + nonceInt, ok := big.NewInt(0).SetString(linkNonce, 10) + + if !ok { + return nil, fmt.Errorf("invalid linkNonce value: '%s'", linkNonce) + } + + hi, hv, err := claim.HiHv() + if err != nil { + return nil, err + } + + claimHash, err := poseidon.Hash([]*big.Int{hi, hv}) + if err != nil { + return nil, err + } + + linkID, err := poseidon.Hash([]*big.Int{claimHash, nonceInt}) + if err != nil { + return nil, err + } + + return linkID, nil +} +func bigIntArrayToStringArray(array []*big.Int) []string { + res := make([]string, 0) + for i := range array { + res = append(res, array[i].String()) + } + return res +} From a135e48646311d77f96604cf8ce4b8d1d59956bb Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Wed, 17 Apr 2024 16:27:51 +0200 Subject: [PATCH 07/10] Audit fixes (#131) * Fix Num2Bits usage * Add check that signature r8x & r8y are on the curve. Small signal name fix * Restrict input values for exists operator to 0 and 1 * Check checksum * Small fixes * Restrict Num2Bits to 248 bits in cutId --- circuits/auth/authV2.circom | 18 +++++++++++++---- circuits/lib/query/comparators.circom | 4 ++-- .../query/processQueryWithModifiers.circom | 12 +++++++++-- circuits/lib/query/query.circom | 2 +- circuits/lib/stateTransition.circom | 4 ++-- circuits/lib/utils/babyjubjub.circom | 20 +++++++++++++++++++ circuits/lib/utils/claimUtils.circom | 13 ++++++++---- circuits/lib/utils/idUtils.circom | 20 ++++++++++++------- .../credentialAtomicQueryV3OnChain.circom | 1 - 9 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 circuits/lib/utils/babyjubjub.circom diff --git a/circuits/auth/authV2.circom b/circuits/auth/authV2.circom index 7fe9efbc..d55bb851 100644 --- a/circuits/auth/authV2.circom +++ b/circuits/auth/authV2.circom @@ -136,18 +136,28 @@ template checkAuthV2(IdOwnershipLevels, onChainLevels) { challengeSignatureS ); - /* Check on-chain SMT inclusion existence */ - signal cutId <== cutId()(genesisID); + /* Check if state is genesis and if genesisId is valid */ signal cutState <== cutState()(state); - signal isStateGenesis <== IsEqual()([cutId, cutState]); + component genesisIdParts = SplitID(); + genesisIdParts.id <== genesisID; + + signal calculatedChecksum <== CalculateIdChecksum()(genesisIdParts.typ, genesisIdParts.genesis); + ForceEqualIfEnabled()( + enabled, + [genesisIdParts.checksum, calculatedChecksum] + ); + + signal isStateGenesis <== IsEqual()([genesisIdParts.genesis, cutState]); + + /* Check on-chain SMT inclusion existence */ signal genesisIDHash <== Poseidon(1)([genesisID]); SMTVerifier(onChainLevels)( enabled <== enabled, - fnc <== isStateGenesis, // non-inclusion in case if genesis state, otherwise inclusion + fnc <== isStateGenesis, // non-inclusion in case of genesis state, otherwise inclusion root <== gistRoot, siblings <== gistMtp, oldKey <== gistMtpAuxHi, diff --git a/circuits/lib/query/comparators.circom b/circuits/lib/query/comparators.circom index 2e089bb0..b668c22f 100644 --- a/circuits/lib/query/comparators.circom +++ b/circuits/lib/query/comparators.circom @@ -59,10 +59,10 @@ template LessThan254() { signal input in[2]; signal output out; - component n0b = Num2Bits(254); + component n0b = Num2Bits_strict(); n0b.in <== in[0]; - component n1b = Num2Bits(254); + component n1b = Num2Bits_strict(); n1b.in <== in[1]; // numbers for high 4 bits diff --git a/circuits/lib/query/processQueryWithModifiers.circom b/circuits/lib/query/processQueryWithModifiers.circom index 5a08391b..4dd0fb40 100644 --- a/circuits/lib/query/processQueryWithModifiers.circom +++ b/circuits/lib/query/processQueryWithModifiers.circom @@ -29,9 +29,11 @@ template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ signal isOpNoop <== IsZero()(operator); signal merklizedAndEnabled <== AND()(enabled, merklized); + signal isOpExists <== IsEqual()([operator, 11]); + // if operator == exists and value[0] == 0 ($exists == false), then claimPathNotExists = 1 (check non-inclusion), // otherwise claimPathNotExists = 0 (check inclusion) - signal claimPathNotExists <== AND()(IsEqual()([operator, 11]), IsZero()(value[0])); + signal claimPathNotExists <== AND()(isOpExists, IsZero()(value[0])); // check path/in node exists in merkle tree specified by jsonldRoot SMTVerifier(claimLevels)( @@ -58,12 +60,18 @@ template ProcessQueryWithModifiers(claimLevels, maxValueArraySize){ ); // For non-merklized credentials exists / non-exist operators should always fail - signal isOpExists <== IsEqual()([operator, 11]); ForceEqualIfEnabled()( AND()(enabled, NOT()(merklized)), [isOpExists, 0] ); + // Restrict exists operator input values to 0 and 1 + ForceEqualIfEnabled()( + AND()(enabled, isOpExists), + [value[0] * (value[0] - 1), 0] + ); + + ///////////////////////////////////////////////////////////////// // Query Operator Processing ///////////////////////////////////////////////////////////////// diff --git a/circuits/lib/query/query.circom b/circuits/lib/query/query.circom index eff2a9c6..27216e73 100644 --- a/circuits/lib/query/query.circom +++ b/circuits/lib/query/query.circom @@ -20,7 +20,7 @@ include "comparators.circom"; 8 - greater than or equal 9 - between (value[0] <= in <= value[1]) 10 - not between - 11 - exist (true / false) + 11 - exists (true / false) Modifier/computation operators: 16 - selective disclosure (16 = 10000 binary) */ diff --git a/circuits/lib/stateTransition.circom b/circuits/lib/stateTransition.circom index 7271fe21..0f1c3747 100644 --- a/circuits/lib/stateTransition.circom +++ b/circuits/lib/stateTransition.circom @@ -55,8 +55,8 @@ template StateTransition(IdOwnershipLevels) { ForceEqualIfEnabled()(one, [stateIsNotZero, 0]); // old & new state checks - signal oldNewNotEqual <== IsEqual()([oldUserState, newUserState]); - ForceEqualIfEnabled()(one, [oldNewNotEqual, 0]); + signal oldNewEqual <== IsEqual()([oldUserState, newUserState]); + ForceEqualIfEnabled()(one, [oldNewEqual, 0]); // check userID ownership by correct signature of a hash of old state and new state signal challenge <== Poseidon(2)([oldUserState, newUserState]); diff --git a/circuits/lib/utils/babyjubjub.circom b/circuits/lib/utils/babyjubjub.circom new file mode 100644 index 00000000..1c114580 --- /dev/null +++ b/circuits/lib/utils/babyjubjub.circom @@ -0,0 +1,20 @@ +pragma circom 2.1.5; + +include "../../../node_modules/circomlib/circuits/comparators.circom"; + +template ForceBabyCheckIfEnabled() { + signal input {binary} enabled; + signal input x; + signal input y; + + signal x2; + signal y2; + + var a = 168700; + var d = 168696; + + x2 <== x*x; + y2 <== y*y; + + ForceEqualIfEnabled()(enabled, [a*x2 + y2, 1 + d*x2*y2]); +} \ No newline at end of file diff --git a/circuits/lib/utils/claimUtils.circom b/circuits/lib/utils/claimUtils.circom index 82a29e68..83492104 100644 --- a/circuits/lib/utils/claimUtils.circom +++ b/circuits/lib/utils/claimUtils.circom @@ -7,6 +7,7 @@ include "../../../node_modules/circomlib/circuits/mux3.circom"; include "../../../node_modules/circomlib/circuits/mux1.circom"; include "../../../node_modules/circomlib/circuits/mux2.circom"; include "./idUtils.circom"; +include "./babyjubjub.circom"; // getClaimSubjectOtherIden checks that a claim Subject is OtherIden and outputs the identity within. template getClaimSubjectOtherIden() { @@ -89,7 +90,7 @@ template getClaimHeader() { signal output schema; signal output {binary} claimFlags[32]; - component i0Bits = Num2Bits(254); + component i0Bits = Num2Bits_strict(); i0Bits.in <== claim[0]; component schemaNum = Bits2Num(128); @@ -120,7 +121,7 @@ template getClaimRevNonce() { component claimRevNonce = Bits2Num(64); - component v0Bits = Num2Bits(254); + component v0Bits = Num2Bits_strict(); v0Bits.in <== claim[4]; for (var i=0; i<64; i++) { claimRevNonce.in[i] <== v0Bits.out[i]; @@ -213,6 +214,8 @@ template verifyClaimSignature() { signal input pubKeyX; signal input pubKeyY; + ForceBabyCheckIfEnabled()(enabled, sigR8x, sigR8y); + // signature verification EdDSAPoseidonVerifier()( enabled <== enabled, @@ -236,6 +239,8 @@ template checkDataSignatureWithPubKeyInClaim() { component getPubKey = getPubKeyFromClaim(); getPubKey.claim <== claim; + ForceBabyCheckIfEnabled()(enabled, signatureR8X, signatureR8Y); + EdDSAPoseidonVerifier()( enabled <== enabled, Ax <== getPubKey.Ax, @@ -281,7 +286,7 @@ template getValueByIndex(){ value <== mux.out; } -// verify that the claim has expiration time and it is less then timestamp +// verify that provided timestamp is less than claim expiration time template verifyExpirationTime() { signal input {binary} expirationFlag; // claimFlags[3] (expiration flag) is set signal input claim[8]; @@ -311,7 +316,7 @@ template getClaimExpiration() { component expirationBits = Bits2Num(64); - component v0Bits = Num2Bits(254); + component v0Bits = Num2Bits_strict(); v0Bits.in <== claim[4]; for (var i=0; i<64; i++) { expirationBits.in[i] <== v0Bits.out[i+64]; diff --git a/circuits/lib/utils/idUtils.circom b/circuits/lib/utils/idUtils.circom index 89065e21..207ab230 100644 --- a/circuits/lib/utils/idUtils.circom +++ b/circuits/lib/utils/idUtils.circom @@ -102,8 +102,11 @@ template GatherID() { template TakeNBits(n) { signal input in; signal output out; + + assert(n <= 254); + // We take only n least significant bits from 254 bit number. - component bits = Num2Bits(254); + component bits = Num2Bits_strict(); bits.in <== in; component outBits = Bits2Num(n); @@ -178,10 +181,10 @@ template cutId() { signal input in; signal output out; - signal idBits[256] <== Num2Bits(256)(in); + signal idBits[248] <== Num2Bits(248)(in); - component cut = Bits2Num(256-16-16-8); - for (var i=16; i<256-16-8; i++) { + component cut = Bits2Num(216); + for (var i=16; i<248-16; i++) { cut.in[i-16] <== idBits[i]; } out <== cut.out; @@ -191,12 +194,15 @@ template cutState() { signal input in; signal output out; - signal stateBits[256] <== Num2Bits(256)(in); + signal stateBits[254] <== Num2Bits_strict()(in); - component cut = Bits2Num(256-16-16-8); - for (var i=0; i<256-16-16-8; i++) { + component cut = Bits2Num(216); + // two most significant bits of 256-bit number are always 0, because we have 254-bit prime field + for (var i=0; i<216-2; i++) { cut.in[i] <== stateBits[i+16+16+8]; } + cut.in[214] <== 0; + cut.in[215] <== 0; out <== cut.out; } diff --git a/circuits/onchain/credentialAtomicQueryV3OnChain.circom b/circuits/onchain/credentialAtomicQueryV3OnChain.circom index 92548dfd..a008d563 100644 --- a/circuits/onchain/credentialAtomicQueryV3OnChain.circom +++ b/circuits/onchain/credentialAtomicQueryV3OnChain.circom @@ -29,7 +29,6 @@ issuerLevels - Merkle tree depth level for claims issued by the issuer claimLevels - Merkle tree depth level for claim JSON-LD document maxValueArraySize - Number of elements in comparison array for in/notin operation if level = 3 number of values for comparison ["1", "2", "3"] -idOwnershipLevels - Merkle tree depth level for personal claims onChainLevels - Merkle tree depth level for Auth claim on-chain */ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArraySize, idOwnershipLevels, onChainLevels) { From 49992281e57db10fd6cd5e401932254c32de1219 Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Wed, 17 Apr 2024 15:29:40 +0100 Subject: [PATCH 08/10] Remove old archived circuits --- archive_circuits_V2/README.md | 9 - archive_circuits_V2/circuits/auth.circom | 5 - archive_circuits_V2/circuits/auth/auth.circom | 49 - .../circuits/auth/authV2.circom | 107 -- archive_circuits_V2/circuits/authV2.circom | 16 - .../credentialAtomicQueryMTPV2.circom | 20 - .../credentialAtomicQueryMTPV2OnChain.circom | 13 - .../credentialAtomicQuerySigV2.circom | 20 - .../credentialAtomicQuerySigV2OnChain.circom | 11 - .../circuits/lib/idOwnership.circom | 55 - .../circuits/lib/query/comparators.circom | 84 -- .../circuits/lib/query/query.circom | 67 -- .../circuits/lib/stateTransition.circom | 101 -- .../circuits/lib/utils/claimUtils.circom | 379 ------- .../circuits/lib/utils/idUtils.circom | 196 ---- .../circuits/lib/utils/spongeHash.circom | 53 - .../circuits/lib/utils/treeUtils.circom | 217 ---- .../credentialAtomicQueryMTPOffChain.circom | 180 ---- .../credentialAtomicQuerySigOffChain.circom | 240 ----- .../credentialAtomicQueryMTPOnChain.circom | 264 ----- .../credentialAtomicQuerySigOnChain.circom | 324 ------ .../circuits/stateTransition.circom | 5 - .../sybilCredentialAtomicMTPOffChain.circom | 181 ---- .../sybilCredentialAtomicSigOffChain.circom | 259 ----- .../circuits/sybil/sybilUtils.circom | 81 -- .../circuits/sybilCredentialAtomicMTP.circom | 13 - .../sybilCredentialAtomicMTPOffChain.circom | 13 - .../circuits/sybilCredentialAtomicSig.circom | 12 - .../sybilCredentialAtomicSigOffChain.circom | 12 - .../auth/authV2.circom | 159 --- .../credentialAtomicQueryMTPV2.circom | 20 - .../credentialAtomicQueryMTPV2OnChain.circom | 13 - .../credentialAtomicQuerySigV2.circom | 20 - .../credentialAtomicQuerySigV2OnChain.circom | 11 - .../lib/idOwnership.circom | 53 - .../lib/query/comparators.circom | 84 -- .../lib/query/query.circom | 67 -- .../lib/stateTransition.circom | 82 -- .../lib/utils/claimUtils.circom | 373 ------- .../lib/utils/idUtils.circom | 213 ---- .../lib/utils/spongeHash.circom | 52 - .../lib/utils/treeUtils.circom | 209 ---- .../credentialAtomicQueryMTPOffChain.circom | 195 ---- .../credentialAtomicQuerySigOffChain.circom | 248 ----- .../credentialAtomicQueryMTPOnChain.circom | 273 ----- .../credentialAtomicQuerySigOnChain.circom | 324 ------ .../sybilCredentialAtomicMTPOffChain.circom | 179 ---- .../sybilCredentialAtomicSigOffChain.circom | 258 ----- .../sybil/sybilUtils.circom | 81 -- .../sybilCredentialAtomicMTP.circom | 13 - .../sybilCredentialAtomicMTPOffChain.circom | 13 - .../sybilCredentialAtomicSig.circom | 12 - .../sybilCredentialAtomicSigOffChain.circom | 12 - archive_circuits_V2/test/auth/authV2.test.ts | 37 - .../test/circuits/authV2Test.circom | 5 - .../test/circuits/comparators.circom | 8 - .../circuits/comparators_greater_than.circom | 8 - .../test/circuits/eddsaposeidon.circom | 30 - archive_circuits_V2/test/circuits/eq.circom | 20 - .../idUtils_CalculateIdChecksum.circom | 5 - .../test/circuits/idUtils_GatherID.circom | 5 - .../test/circuits/idUtils_NewID.circom | 5 - .../test/circuits/idUtils_ProfileID.circom | 5 - .../circuits/idUtils_SelectProfile.circom | 5 - .../test/circuits/idUtils_SplitID.circom | 5 - .../test/circuits/idUtils_TakeNBits.circom | 5 - .../test/circuits/lessthan.circom | 20 - .../test/circuits/poseidon.circom | 19 - .../test/circuits/poseidon14.circom | 32 - .../test/circuits/poseidon16.circom | 32 - .../query/credentialAtomicQueryMTPTest.circom | 13 - .../query/credentialAtomicQuerySigTest.circom | 14 - .../test/circuits/query/inTest.circom | 5 - .../test/circuits/query/queryTest.circom | 5 - .../test/circuits/stateTransitionTest.circom | 5 - .../test/circuits/sybilTestMTP.circom | 13 - .../test/circuits/sybilTestSig.circom | 12 - .../claimUtils_getClaimMerklizeRoot.circom | 5 - .../utils/utils_GetValueByIndex.circom | 5 - .../utils_checkIdenStateMatchesRoots.circom | 6 - .../utils/utils_getClaimExpiration.circom | 5 - .../utils_getClaimSubjectOtherIden.circom | 5 - .../utils/utils_getSubjectLocation.circom | 5 - .../circuits/utils/utils_isExpirable.circom | 5 - .../circuits/utils/utils_isUpdatable.circom | 5 - .../utils/utils_verifyClaimSignature.circom | 5 - .../utils/utils_verifyClaimsTreeRoot.circom | 5 - .../utils/utils_verifyCredentialMtp.circom | 5 - .../utils_verifyCredentialMtpHiHv.circom | 5 - .../utils_verifyCredentialNotRevoked.circom | 5 - .../utils_verifyCredentialSubject.circom | 5 - .../utils/utils_verifyExpirationTime.circom | 5 - archive_circuits_V2/test/comparators.test.ts | 321 ------ .../test/eddsaposeidon.test.ts | 56 -- .../test/negativeNumbers.test.ts | 79 -- .../credentialAtomicQueryMTPOffChain.test.ts | 103 -- .../credentialAtomicQuerySigOffChain.test.ts | 351 ------- .../credentialAtomicQueryMTPOnChain.test.ts | 56 -- .../credentialAtomicQuerySigOnChain.test.ts | 56 -- archive_circuits_V2/test/poseidon.test.ts | 134 --- archive_circuits_V2/test/query/in.test.ts | 43 - archive_circuits_V2/test/query/query.test.ts | 643 ------------ .../test/stateTransition.test.ts | 44 - archive_circuits_V2/test/sybil/sybil.test.ts | 108 -- .../claimUtils_getClaimMerklizeRoot.test.ts | 32 - .../test/utils/getClaimExpiration.test.ts | 77 -- .../utils/getClaimSubjectOtherIden.test.ts | 68 -- .../test/utils/getSubjectLocation.test.ts | 42 - .../test/utils/getValueByIndex.test.ts | 60 -- .../utils/idUtils_CalculateIdChecksum.test.ts | 43 - .../test/utils/idUtils_GatherID.test.ts | 44 - .../test/utils/idUtils_NewID.test.ts | 43 - .../test/utils/idUtils_ProfileID.test.ts | 43 - .../test/utils/idUtils_SelectProfile.test.ts | 43 - .../test/utils/idUtils_SplitID.test.ts | 44 - .../test/utils/idUtils_TakeNBits.test.ts | 42 - .../test/utils/isExpirable.test.ts | 32 - .../test/utils/isUpdatable.test.ts | 32 - .../test/utils/spongeHash.test.ts | 122 --- .../test/utils/verifyExpirationTime.test.ts | 62 -- .../test/utils/verifyFunctions.test.ts | 75 -- .../testvectorgen/auth/authV2_test.go | 260 ----- .../auth/testdata/userID_genesis.json | 1 - .../auth/testdata/userID_profileID.json | 1 - .../auth/testdata/user_state_not_genesis.json | 1 - ...r_state_not_genesis_second_auth_claim.json | 1 - .../contract_data/generate_json_test.go | 702 ------------- .../testdata/issuer_genesis_state.json | 1 - .../issuer_next_state_transition.json | 1 - .../testdata/user_next_state_transition.json | 1 - .../testdata/user_state_transition.json | 1 - .../testdata/valid_mtp_user_genesis.json | 1 - .../testdata/valid_mtp_user_non_genesis.json | 1 - ...tp_user_non_genesis_challenge_address.json | 1 - .../testdata/valid_sig_user_genesis.json | 1 - .../testdata/valid_sig_user_non_genesis.json | 1 - ...ig_user_non_genesis_challenge_address.json | 1 - .../credentials/mtpv2/mtpv2_test.go | 492 --------- .../testdata/claimIssuedOnProfileID.json | 306 ------ .../testdata/claimIssuedOnProfileID2.json | 1 - .../mtpv2/testdata/claimIssuedOnUserID.json | 1 - .../mtpv2/testdata/claimNonMerklized.json | 1 - .../revoked_claim_with_revocation_check.json | 1 - ...evoked_claim_without_revocation_check.json | 1 - .../credentials/onchain/mtpv2/mtpv2_test.go | 699 ------------- .../testdata/claimIssuedOnProfileID.json | 1 - .../testdata/claimIssuedOnProfileID2.json | 1 - .../mtpv2/testdata/claimIssuedOnUserID.json | 1 - .../mtpv2/testdata/claimNonMerklized.json | 1 - .../revoked_claim_with_revocation_check.json | 1 - ...evoked_claim_without_revocation_check.json | 1 - .../credentials/onchain/sigv2/sigv2_test.go | 945 ------------------ .../sigv2/testdata/jsonld_non_inclusion.json | 1 - .../sigv2/testdata/profileID_subject.json | 1 - .../profileID_subject_profileID2.json | 1 - .../testdata/profileID_subject_userid.json | 1 - .../onchain/sigv2/testdata/regular_claim.json | 1 - .../revoked_claim_with_revocation_check.json | 1 - ...evoked_claim_without_revocation_check.json | 1 - .../sigv2/testdata/userID_subject.json | 1 - .../credentials/sigv2/sigv2_test.go | 704 ------------- .../sigv2/testdata/jsonld_non_inclusion.json | 1 - .../sigv2/testdata/profileID_subject.json | 1 - .../profileID_subject_profileID2.json | 1 - .../testdata/profileID_subject_userid.json | 1 - .../sigv2/testdata/regular_claim.json | 1 - .../revoked_claim_with_revocation_check.json | 1 - ...evoked_claim_without_revocation_check.json | 1 - .../sigv2/testdata/userID_subject.json | 1 - archive_circuits_V2/testvectorgen/go.mod | 24 - archive_circuits_V2/testvectorgen/go.sum | 72 -- .../statetransition/stateTransition_test.go | 161 --- .../testdata/genesis_state.json | 1 - .../testdata/not_genesis_state.json | 1 - .../testvectorgen/sybil/model.go | 139 --- .../testvectorgen/sybil/sybil.go | 277 ----- .../testvectorgen/sybil/sybil_test.go | 53 - .../sybil/testdata/happyflow - MTP.json | 1 - .../sybil/testdata/happyflow - Sig.json | 1 - .../happyflow with profile - MTP.json | 1 - .../happyflow with profile - Sig.json | 1 - ...pyflow with profile and subject - MTP.json | 1 - ...pyflow with profile and subject - Sig.json | 1 - .../sybil/testdata/invalid gist - MTP.json | 1 - .../sybil/testdata/invalid gist - Sig.json | 1 - .../testdata/invalid identity - MTP.json | 1 - .../testdata/invalid identity - Sig.json | 1 - .../testvectorgen/utils/constants.go | 53 - .../testvectorgen/utils/identity.go | 205 ---- .../testvectorgen/utils/identity_test.go | 45 - .../testvectorgen/utils/utils.go | 305 ------ 191 files changed, 14732 deletions(-) delete mode 100644 archive_circuits_V2/README.md delete mode 100644 archive_circuits_V2/circuits/auth.circom delete mode 100644 archive_circuits_V2/circuits/auth/auth.circom delete mode 100644 archive_circuits_V2/circuits/auth/authV2.circom delete mode 100644 archive_circuits_V2/circuits/authV2.circom delete mode 100644 archive_circuits_V2/circuits/credentialAtomicQueryMTPV2.circom delete mode 100644 archive_circuits_V2/circuits/credentialAtomicQueryMTPV2OnChain.circom delete mode 100644 archive_circuits_V2/circuits/credentialAtomicQuerySigV2.circom delete mode 100644 archive_circuits_V2/circuits/credentialAtomicQuerySigV2OnChain.circom delete mode 100644 archive_circuits_V2/circuits/lib/idOwnership.circom delete mode 100644 archive_circuits_V2/circuits/lib/query/comparators.circom delete mode 100644 archive_circuits_V2/circuits/lib/query/query.circom delete mode 100644 archive_circuits_V2/circuits/lib/stateTransition.circom delete mode 100644 archive_circuits_V2/circuits/lib/utils/claimUtils.circom delete mode 100644 archive_circuits_V2/circuits/lib/utils/idUtils.circom delete mode 100644 archive_circuits_V2/circuits/lib/utils/spongeHash.circom delete mode 100644 archive_circuits_V2/circuits/lib/utils/treeUtils.circom delete mode 100644 archive_circuits_V2/circuits/offchain/credentialAtomicQueryMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits/offchain/credentialAtomicQuerySigOffChain.circom delete mode 100644 archive_circuits_V2/circuits/onchain/credentialAtomicQueryMTPOnChain.circom delete mode 100644 archive_circuits_V2/circuits/onchain/credentialAtomicQuerySigOnChain.circom delete mode 100644 archive_circuits_V2/circuits/stateTransition.circom delete mode 100644 archive_circuits_V2/circuits/sybil/sybilCredentialAtomicMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits/sybil/sybilCredentialAtomicSigOffChain.circom delete mode 100644 archive_circuits_V2/circuits/sybil/sybilUtils.circom delete mode 100644 archive_circuits_V2/circuits/sybilCredentialAtomicMTP.circom delete mode 100644 archive_circuits_V2/circuits/sybilCredentialAtomicMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits/sybilCredentialAtomicSig.circom delete mode 100644 archive_circuits_V2/circuits/sybilCredentialAtomicSigOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/auth/authV2.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/credentialAtomicQueryMTPV2.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/credentialAtomicQueryMTPV2OnChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/credentialAtomicQuerySigV2.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/credentialAtomicQuerySigV2OnChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/idOwnership.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/query/comparators.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/query/query.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/stateTransition.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/utils/claimUtils.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/utils/idUtils.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/utils/spongeHash.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/lib/utils/treeUtils.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQueryMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQuerySigOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQueryMTPOnChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQuerySigOnChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybil/sybilCredentialAtomicMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybil/sybilCredentialAtomicSigOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybil/sybilUtils.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybilCredentialAtomicMTP.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybilCredentialAtomicMTPOffChain.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybilCredentialAtomicSig.circom delete mode 100644 archive_circuits_V2/circuits_after_refactoring/sybilCredentialAtomicSigOffChain.circom delete mode 100644 archive_circuits_V2/test/auth/authV2.test.ts delete mode 100644 archive_circuits_V2/test/circuits/authV2Test.circom delete mode 100644 archive_circuits_V2/test/circuits/comparators.circom delete mode 100644 archive_circuits_V2/test/circuits/comparators_greater_than.circom delete mode 100644 archive_circuits_V2/test/circuits/eddsaposeidon.circom delete mode 100644 archive_circuits_V2/test/circuits/eq.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_CalculateIdChecksum.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_GatherID.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_NewID.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_ProfileID.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_SelectProfile.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_SplitID.circom delete mode 100644 archive_circuits_V2/test/circuits/idUtils_TakeNBits.circom delete mode 100644 archive_circuits_V2/test/circuits/lessthan.circom delete mode 100644 archive_circuits_V2/test/circuits/poseidon.circom delete mode 100644 archive_circuits_V2/test/circuits/poseidon14.circom delete mode 100644 archive_circuits_V2/test/circuits/poseidon16.circom delete mode 100644 archive_circuits_V2/test/circuits/query/credentialAtomicQueryMTPTest.circom delete mode 100644 archive_circuits_V2/test/circuits/query/credentialAtomicQuerySigTest.circom delete mode 100644 archive_circuits_V2/test/circuits/query/inTest.circom delete mode 100644 archive_circuits_V2/test/circuits/query/queryTest.circom delete mode 100644 archive_circuits_V2/test/circuits/stateTransitionTest.circom delete mode 100644 archive_circuits_V2/test/circuits/sybilTestMTP.circom delete mode 100644 archive_circuits_V2/test/circuits/sybilTestSig.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_GetValueByIndex.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_getClaimExpiration.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_getClaimSubjectOtherIden.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_getSubjectLocation.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_isExpirable.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_isUpdatable.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyClaimSignature.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyClaimsTreeRoot.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtp.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtpHiHv.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyCredentialNotRevoked.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyCredentialSubject.circom delete mode 100644 archive_circuits_V2/test/circuits/utils/utils_verifyExpirationTime.circom delete mode 100644 archive_circuits_V2/test/comparators.test.ts delete mode 100644 archive_circuits_V2/test/eddsaposeidon.test.ts delete mode 100644 archive_circuits_V2/test/negativeNumbers.test.ts delete mode 100644 archive_circuits_V2/test/offchain/credentialAtomicQueryMTPOffChain.test.ts delete mode 100644 archive_circuits_V2/test/offchain/credentialAtomicQuerySigOffChain.test.ts delete mode 100644 archive_circuits_V2/test/onchain/credentialAtomicQueryMTPOnChain.test.ts delete mode 100644 archive_circuits_V2/test/onchain/credentialAtomicQuerySigOnChain.test.ts delete mode 100644 archive_circuits_V2/test/poseidon.test.ts delete mode 100644 archive_circuits_V2/test/query/in.test.ts delete mode 100644 archive_circuits_V2/test/query/query.test.ts delete mode 100644 archive_circuits_V2/test/stateTransition.test.ts delete mode 100644 archive_circuits_V2/test/sybil/sybil.test.ts delete mode 100644 archive_circuits_V2/test/utils/claimUtils_getClaimMerklizeRoot.test.ts delete mode 100644 archive_circuits_V2/test/utils/getClaimExpiration.test.ts delete mode 100644 archive_circuits_V2/test/utils/getClaimSubjectOtherIden.test.ts delete mode 100644 archive_circuits_V2/test/utils/getSubjectLocation.test.ts delete mode 100644 archive_circuits_V2/test/utils/getValueByIndex.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_CalculateIdChecksum.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_GatherID.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_NewID.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_ProfileID.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_SelectProfile.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_SplitID.test.ts delete mode 100644 archive_circuits_V2/test/utils/idUtils_TakeNBits.test.ts delete mode 100644 archive_circuits_V2/test/utils/isExpirable.test.ts delete mode 100644 archive_circuits_V2/test/utils/isUpdatable.test.ts delete mode 100644 archive_circuits_V2/test/utils/spongeHash.test.ts delete mode 100644 archive_circuits_V2/test/utils/verifyExpirationTime.test.ts delete mode 100644 archive_circuits_V2/test/utils/verifyFunctions.test.ts delete mode 100644 archive_circuits_V2/testvectorgen/auth/authV2_test.go delete mode 100644 archive_circuits_V2/testvectorgen/auth/testdata/userID_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/auth/testdata/userID_profileID.json delete mode 100644 archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis_second_auth_claim.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/generate_json_test.go delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_genesis_state.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_next_state_transition.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/user_next_state_transition.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/user_state_transition.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis_challenge_address.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis.json delete mode 100644 archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis_challenge_address.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/mtpv2_test.go delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID2.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnUserID.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimNonMerklized.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_with_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_without_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/mtpv2_test.go delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID2.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnUserID.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimNonMerklized.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_with_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_without_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/sigv2_test.go delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/jsonld_non_inclusion.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_profileID2.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_userid.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/regular_claim.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_with_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_without_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/userID_subject.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/sigv2_test.go delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/jsonld_non_inclusion.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_profileID2.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_userid.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/regular_claim.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_with_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_without_revocation_check.json delete mode 100644 archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/userID_subject.json delete mode 100644 archive_circuits_V2/testvectorgen/go.mod delete mode 100644 archive_circuits_V2/testvectorgen/go.sum delete mode 100644 archive_circuits_V2/testvectorgen/statetransition/stateTransition_test.go delete mode 100644 archive_circuits_V2/testvectorgen/statetransition/testdata/genesis_state.json delete mode 100644 archive_circuits_V2/testvectorgen/statetransition/testdata/not_genesis_state.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/model.go delete mode 100644 archive_circuits_V2/testvectorgen/sybil/sybil.go delete mode 100644 archive_circuits_V2/testvectorgen/sybil/sybil_test.go delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - MTP.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - Sig.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - MTP.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - Sig.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - MTP.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - Sig.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - MTP.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - Sig.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - MTP.json delete mode 100644 archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - Sig.json delete mode 100644 archive_circuits_V2/testvectorgen/utils/constants.go delete mode 100644 archive_circuits_V2/testvectorgen/utils/identity.go delete mode 100644 archive_circuits_V2/testvectorgen/utils/identity_test.go delete mode 100644 archive_circuits_V2/testvectorgen/utils/utils.go diff --git a/archive_circuits_V2/README.md b/archive_circuits_V2/README.md deleted file mode 100644 index 25ed91ca..00000000 --- a/archive_circuits_V2/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## Temporary archive of Circuits V2 - -Original circuits which are in production are in `circuits` directory. - -Refactored ones are in `circuits_after_refactoring`. - -Tests use `circuits` directory, so to run tests on refactored ones you need -to rename `circuits` to something else, and then `circuits_after_refactoring` -to `circuits`. diff --git a/archive_circuits_V2/circuits/auth.circom b/archive_circuits_V2/circuits/auth.circom deleted file mode 100644 index 541a26d5..00000000 --- a/archive_circuits_V2/circuits/auth.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.0.0; - -include "auth/auth.circom"; - -component main {public [userID,challenge,userState]} = Auth(32); diff --git a/archive_circuits_V2/circuits/auth/auth.circom b/archive_circuits_V2/circuits/auth/auth.circom deleted file mode 100644 index d9b471e3..00000000 --- a/archive_circuits_V2/circuits/auth/auth.circom +++ /dev/null @@ -1,49 +0,0 @@ -pragma circom 2.0.0; - -include "../lib/idOwnership.circom"; - -template Auth(IdOwnershipLevels) { - - signal input userClaimsTreeRoot; - signal input userAuthClaimMtp[IdOwnershipLevels]; - signal input userAuthClaim[8]; - - signal input userRevTreeRoot; - signal input userAuthClaimNonRevMtp[IdOwnershipLevels]; - signal input userAuthClaimNonRevMtpNoAux; - signal input userAuthClaimNonRevMtpAuxHv; - signal input userAuthClaimNonRevMtpAuxHi; - - signal input userRootsTreeRoot; - - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - signal input userState; - // we have no constraints for "userID" in this circuit, however we introduce "userID" input here - // as it serves as public input which should be the same for prover and verifier - signal input userID; - - component checkIdOwnership = IdOwnership(IdOwnershipLevels); - - checkIdOwnership.userClaimsTreeRoot <== userClaimsTreeRoot; - for (var i=0; i out; -} diff --git a/archive_circuits_V2/circuits/lib/query/query.circom b/archive_circuits_V2/circuits/lib/query/query.circom deleted file mode 100644 index a430c18b..00000000 --- a/archive_circuits_V2/circuits/lib/query/query.circom +++ /dev/null @@ -1,67 +0,0 @@ -pragma circom 2.0.0; -include "../../../../node_modules/circomlib/circuits/mux3.circom"; -include "../../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../../node_modules/circomlib/circuits/comparators.circom"; -include "comparators.circom"; - -/* - Operators: - "0" - noop, skip execution. Ignores all `in` and `value` passed to query, out 1 - "1" - equals - "2" - less-than - "3" - greater-than - "4" - in - "5" - notin - "6" - not equals -*/ -template Query (valueArraySize) { - // signals - signal input in; - signal input value[valueArraySize]; - signal input operator; - signal output out; - - // operation components - component eq = IsEqual(); - eq.in[0] <== in; - eq.in[1] <== value[0]; - - // LessThan - component lt = LessThan254(); - lt.in[0] <== in; - lt.in[1] <== value[0]; - - component gt = GreaterThan254(); - gt.in[0] <== in; - gt.in[1] <== value[0]; - - // in - component inComp = IN(valueArraySize); - inComp.in <== in; - for(var i = 0; i 0 ? arraySize - hashFnBatchSize : 0; - if (restLength > 0) { - var r = restLength % batchSize; - var diff = r == 0 ? 0 : batchSize - r; - iterationCount = (restLength + diff) / batchSize; - } - - signal fullHash[iterationCount+1]; - - fullHash[0] <== firstPoseidon.out; - - component poseidon[iterationCount]; - for(var i = 0; i < iterationCount; i++) { - var elemIdx = i * batchSize + hashFnBatchSize ; - poseidon[i] = Poseidon(hashFnBatchSize); - - poseidon[i].inputs[0] <== fullHash[i]; - - for (var j = 0; j < batchSize; j++) - { - poseidon[i].inputs[j+1] <== getArrayValueByIndex(in, arraySize, elemIdx + j); - } - - fullHash[i+1] <== poseidon[i].out; - } - - out <== fullHash[iterationCount]; -} - - -function getArrayValueByIndex(valueArray, arraySize, idx) { - - if(idx < arraySize) { - return valueArray[idx]; - } else{ - return 0; - } -} diff --git a/archive_circuits_V2/circuits/lib/utils/treeUtils.circom b/archive_circuits_V2/circuits/lib/utils/treeUtils.circom deleted file mode 100644 index 2d80ddd9..00000000 --- a/archive_circuits_V2/circuits/lib/utils/treeUtils.circom +++ /dev/null @@ -1,217 +0,0 @@ -pragma circom 2.0.0; - -include "../../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../../node_modules/circomlib/circuits/eddsaposeidon.circom"; -include "../../../../node_modules/circomlib/circuits/smt/smtverifier.circom"; -include "../../../../node_modules/circomlib/circuits/mux3.circom"; -include "../../../../node_modules/circomlib/circuits/mux1.circom"; -include "claimUtils.circom"; - -// getIdenState caclulates the Identity state out of the claims tree root, -// revocations tree root and roots tree root. -template getIdenState() { - signal input claimsTreeRoot; - signal input revTreeRoot; - signal input rootsTreeRoot; - - signal output idenState; - - component calcIdState = Poseidon(3); - calcIdState.inputs[0] <== claimsTreeRoot; - calcIdState.inputs[1] <== revTreeRoot; - calcIdState.inputs[2] <== rootsTreeRoot; - - idenState <== calcIdState.out; -} - -// checkClaimExists verifies that claim is included into the claim tree root -template checkClaimExists(IssuerLevels) { - signal input claim[8]; - signal input claimMTP[IssuerLevels]; - signal input treeRoot; - - component claimHiHv = getClaimHiHv(); - for (var i=0; i<8; i++) { claimHiHv.claim[i] <== claim[i]; } - - component smtClaimExists = SMTVerifier(IssuerLevels); - smtClaimExists.enabled <== 1; - smtClaimExists.fnc <== 0; // Inclusion - smtClaimExists.root <== treeRoot; - for (var i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - // flag indicates if merkleized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - /* issuerClaim signals */ - signal input issuerClaim[8]; - signal input issuerClaimMtp[IssuerLevels]; - signal input issuerClaimClaimsTreeRoot; - signal input issuerClaimRevTreeRoot; - signal input issuerClaimRootsTreeRoot; - signal input issuerClaimIdenState; - - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[IssuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - // verify issuerClaim issued and not revoked - component vci = verifyClaimIssuanceNonRev(IssuerLevels); - for (var i=0; i<8; i++) { vci.claim[i] <== issuerClaim[i]; } - for (var i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - // flag indicates if merkleized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - // issuer auth proof of existence - signal input issuerAuthClaim[8]; - signal input issuerAuthClaimMtp[IssuerLevels]; - signal input issuerAuthClaimsTreeRoot; - signal input issuerAuthRevTreeRoot; - signal input issuerAuthRootsTreeRoot; - signal output issuerAuthState; - - // issuer auth claim non rev proof - signal input issuerAuthClaimNonRevMtp[IssuerLevels]; - signal input issuerAuthClaimNonRevMtpNoAux; - signal input issuerAuthClaimNonRevMtpAuxHi; - signal input issuerAuthClaimNonRevMtpAuxHv; - - // claim issued by issuer to the user - signal input issuerClaim[8]; - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[IssuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - // issuerClaim signature - signal input issuerClaimSignatureR8x; - signal input issuerClaimSignatureR8y; - signal input issuerClaimSignatureS; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - // Check issuerClaim is issued to provided identity - component claimIdCheck = verifyCredentialSubjectProfile(); - for (var i=0; i<8; i++) { claimIdCheck.claim[i] <== issuerClaim[i]; } - claimIdCheck.id <== userGenesisID; - claimIdCheck.nonce <== claimSubjectProfileNonce; - - // Verify issuerClaim schema - component claimSchemaCheck = verifyCredentialSchema(); - for (var i=0; i<8; i++) { claimSchemaCheck.claim[i] <== issuerClaim[i]; } - claimSchemaCheck.schema <== claimSchema; - - // verify issuerClaim expiration time - component claimExpirationCheck = verifyExpirationTime(); - for (var i=0; i<8; i++) { claimExpirationCheck.claim[i] <== issuerClaim[i]; } - claimExpirationCheck.timestamp <== timestamp; - - - // AuthHash cca3371a6cb1b715004407e325bd993c - // BigInt: 80551937543569765027552589160822318028 - // https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential - component issuerSchemaCheck = verifyCredentialSchema(); - for (var i=0; i<8; i++) { issuerSchemaCheck.claim[i] <== issuerAuthClaim[i]; } - issuerSchemaCheck.schema <== 80551937543569765027552589160822318028; - // verify authClaim issued and not revoked - // calculate issuerAuthState - component issuerAuthStateComponent = getIdenState(); - issuerAuthStateComponent.claimsTreeRoot <== issuerAuthClaimsTreeRoot; - issuerAuthStateComponent.revTreeRoot <== issuerAuthRevTreeRoot; - issuerAuthStateComponent.rootsTreeRoot <== issuerAuthRootsTreeRoot; - - issuerAuthState <== issuerAuthStateComponent.idenState; - - // issuerAuthClaim proof of existence (isProofExist) - // - component smtIssuerAuthClaimExists = checkClaimExists(IssuerLevels); - for (var i=0; i<8; i++) { smtIssuerAuthClaimExists.claim[i] <== issuerAuthClaim[i]; } - for (var i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - // circuits query Hash - signal output circuitQueryHash; - - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - // user state - signal input userState; - signal input userClaimsTreeRoot; - signal input userRevTreeRoot; - signal input userRootsTreeRoot; - - // Auth claim - signal input authClaim[8]; - - // auth claim. merkle tree proof of inclusion to claim tree - signal input authClaimIncMtp[idOwnershipLevels]; - - // auth claim - rev nonce. merkle tree proof of non-inclusion to rev tree - signal input authClaimNonRevMtp[idOwnershipLevels]; - signal input authClaimNonRevMtpNoAux; - signal input authClaimNonRevMtpAuxHi; - signal input authClaimNonRevMtpAuxHv; - - // challenge signature - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - // global identity state tree on chain - signal input gistRoot; - // proof of inclusion or exclusion of the user in the global state - signal input gistMtp[onChainLevels]; - signal input gistMtpAuxHi; - signal input gistMtpAuxHv; - signal input gistMtpNoAux; - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - /* issuerClaim signals */ - signal input issuerClaim[8]; - signal input issuerClaimMtp[issuerLevels]; - signal input issuerClaimClaimsTreeRoot; - signal input issuerClaimRevTreeRoot; - signal input issuerClaimRootsTreeRoot; - signal input issuerClaimIdenState; - - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - component auth = AuthV2(idOwnershipLevels, onChainLevels); - - auth.genesisID <== userGenesisID; - // random number, which should be stored by user - // if there is a need to generate the same userID (ProfileID) output for different proofs - auth.profileNonce <== profileNonce; - // user state - auth.state <== userState; - auth.claimsTreeRoot <== userClaimsTreeRoot; - auth.revTreeRoot <== userRevTreeRoot; - auth.rootsTreeRoot <== userRootsTreeRoot; - - for (var i= 0; i < 8; i++) { auth.authClaim[i] <== authClaim[i]; } - for (var i= 0; i < idOwnershipLevels; i++) { - auth.authClaimIncMtp[i] <== authClaimIncMtp[i]; - auth.authClaimNonRevMtp[i] <== authClaimNonRevMtp[i]; - } - - auth.authClaimNonRevMtpNoAux <== authClaimNonRevMtpNoAux; - auth.authClaimNonRevMtpAuxHi <== authClaimNonRevMtpAuxHi; - auth.authClaimNonRevMtpAuxHv <== authClaimNonRevMtpAuxHv; - - // challenge signature - auth.challenge <== challenge; - auth.challengeSignatureR8x <== challengeSignatureR8x; - auth.challengeSignatureR8y <== challengeSignatureR8y; - auth.challengeSignatureS <== challengeSignatureS; - - // global identity state tree on chain - auth.gistRoot <== gistRoot; - - // proof of inclusion or exclusion of the user in the global state - for (var i = 0; i < onChainLevels; i++) { auth.gistMtp[i] <== gistMtp[i]; } - - auth.gistMtpAuxHi <== gistMtpAuxHi; - auth.gistMtpAuxHv <== gistMtpAuxHv; - auth.gistMtpNoAux <== gistMtpNoAux; - - // verify issuerClaim issued and not revoked - component vci = verifyClaimIssuanceNonRev(issuerLevels); - for (var i = 0; i < 8; i++) { vci.claim[i] <== issuerClaim[i]; } - for (var i = 0; i < issuerLevels; i++) { vci.claimIssuanceMtp[i] <== issuerClaimMtp[i]; } - vci.claimIssuanceClaimsTreeRoot <== issuerClaimClaimsTreeRoot; - vci.claimIssuanceRevTreeRoot <== issuerClaimRevTreeRoot; - vci.claimIssuanceRootsTreeRoot <== issuerClaimRootsTreeRoot; - vci.claimIssuanceIdenState <== issuerClaimIdenState; - - // non revocation status - vci.enabledNonRevCheck <== isRevocationChecked; - for (var i = 0; i < issuerLevels; i++) { vci.claimNonRevMtp[i] <== issuerClaimNonRevMtp[i]; } - vci.claimNonRevMtpNoAux <== issuerClaimNonRevMtpNoAux; - vci.claimNonRevMtpAuxHi <== issuerClaimNonRevMtpAuxHi; - vci.claimNonRevMtpAuxHv <== issuerClaimNonRevMtpAuxHv; - vci.claimNonRevIssuerClaimsTreeRoot <== issuerClaimNonRevClaimsTreeRoot; - vci.claimNonRevIssuerRevTreeRoot <== issuerClaimNonRevRevTreeRoot; - vci.claimNonRevIssuerRootsTreeRoot <== issuerClaimNonRevRootsTreeRoot; - vci.claimNonRevIssuerState <== issuerClaimNonRevState; - - // Check issuerClaim is issued to provided identity - component claimIdCheck = verifyCredentialSubjectProfile(); - for (var i = 0; i < 8; i++) { claimIdCheck.claim[i] <== issuerClaim[i]; } - claimIdCheck.id <== userGenesisID; - claimIdCheck.nonce <== claimSubjectProfileNonce; - - // Verify issuerClaim schema - component claimSchemaCheck = verifyCredentialSchema(); - for (var i = 0; i < 8; i++) { claimSchemaCheck.claim[i] <== issuerClaim[i]; } - claimSchemaCheck.schema <== claimSchema; - - // verify issuerClaim expiration time - component claimExpirationCheck = verifyExpirationTime(); - for (var i = 0; i < 8; i++) { claimExpirationCheck.claim[i] <== issuerClaim[i]; } - claimExpirationCheck.timestamp <== timestamp; - - component merklize = getClaimMerklizeRoot(); - for (var i = 0; i < 8; i++) { merklize.claim[i] <== issuerClaim[i]; } - merklized <== merklize.flag; - - // check path/in node exists in merkletree specified by jsonldRoot - component valueInMT = SMTVerifier(claimLevels); - valueInMT.enabled <== merklize.flag; // if merklize flag 0 skip MTP verification - valueInMT.fnc <== claimPathNotExists; // inclusion - valueInMT.root <== merklize.out; - for (var i = 0; i < claimLevels; i++) { valueInMT.siblings[i] <== claimPathMtp[i]; } - valueInMT.oldKey <== claimPathMtpAuxHi; - valueInMT.oldValue <== claimPathMtpAuxHv; - valueInMT.isOld0 <== claimPathMtpNoAux; - valueInMT.key <== claimPathKey; - valueInMT.value <== claimPathValue; - - // select value from claim by slot index (0-7) - component getClaimValue = getValueByIndex(); - for (var i = 0; i < 8; i++) { getClaimValue.claim[i] <== issuerClaim[i]; } - getClaimValue.index <== slotIndex; - - // select value for query verification, - // if claim is merklized merklizeFlag = `1|2`, take claimPathValue - // if not merklized merklizeFlag = `0`, take value from selected slot - component queryValue = Mux1(); - queryValue.s <== merklize.flag; - queryValue.c[0] <== getClaimValue.value; - queryValue.c[1] <== claimPathValue; - - // verify query - component spongeHash = SpongeHash(valueArraySize, 6); // 6 - max size of poseidon hash available on-chain - component query = Query(valueArraySize); - query.in <== queryValue.out; - for (var i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - // circuits query Hash - signal output circuitQueryHash; - - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - // user state - signal input userState; - signal input userClaimsTreeRoot; - signal input userRevTreeRoot; - signal input userRootsTreeRoot; - - // Auth claim - signal input authClaim[8]; - - // auth claim. merkle tree proof of inclusion to claim tree - signal input authClaimIncMtp[idOwnershipLevels]; - - // auth claim - rev nonce. merkle tree proof of non-inclusion to rev tree - signal input authClaimNonRevMtp[idOwnershipLevels]; - signal input authClaimNonRevMtpNoAux; - signal input authClaimNonRevMtpAuxHi; - signal input authClaimNonRevMtpAuxHv; - - // challenge signature - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - // global identity state tree on chain - signal input gistRoot; - // proof of inclusion or exclusion of the user in the global state - signal input gistMtp[onChainLevels]; - signal input gistMtpAuxHi; - signal input gistMtpAuxHv; - signal input gistMtpNoAux; - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - // issuer auth proof of existence - signal input issuerAuthClaim[8]; - signal input issuerAuthClaimMtp[issuerLevels]; - signal input issuerAuthClaimsTreeRoot; - signal input issuerAuthRevTreeRoot; - signal input issuerAuthRootsTreeRoot; - signal output issuerAuthState; - - // issuer auth claim non rev proof - signal input issuerAuthClaimNonRevMtp[issuerLevels]; - signal input issuerAuthClaimNonRevMtpNoAux; - signal input issuerAuthClaimNonRevMtpAuxHi; - signal input issuerAuthClaimNonRevMtpAuxHv; - - // claim issued by issuer to the user - signal input issuerClaim[8]; - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - // issuerClaim signature - signal input issuerClaimSignatureR8x; - signal input issuerClaimSignatureR8y; - signal input issuerClaimSignatureS; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - component auth = AuthV2(idOwnershipLevels, onChainLevels); - - auth.genesisID <== userGenesisID; - // random number, which should be stored by user - // if there is a need to generate the same userID (ProfileID) output for different proofs - auth.profileNonce <== profileNonce; - // user state - auth.state <== userState; - auth.claimsTreeRoot <== userClaimsTreeRoot; - auth.revTreeRoot <== userRevTreeRoot; - auth.rootsTreeRoot <== userRootsTreeRoot; - - for (var i= 0; i < 8; i++) { auth.authClaim[i] <== authClaim[i]; } - for (var i= 0; i < idOwnershipLevels; i++) { - auth.authClaimIncMtp[i] <== authClaimIncMtp[i]; - auth.authClaimNonRevMtp[i] <== authClaimNonRevMtp[i]; - } - - auth.authClaimNonRevMtpNoAux <== authClaimNonRevMtpNoAux; - auth.authClaimNonRevMtpAuxHi <== authClaimNonRevMtpAuxHi; - auth.authClaimNonRevMtpAuxHv <== authClaimNonRevMtpAuxHv; - - // challenge signature - auth.challenge <== challenge; - auth.challengeSignatureR8x <== challengeSignatureR8x; - auth.challengeSignatureR8y <== challengeSignatureR8y; - auth.challengeSignatureS <== challengeSignatureS; - - // global identity state tree on chain - auth.gistRoot <== gistRoot; - - // proof of inclusion or exclusion of the user in the global state - for (var i = 0; i < onChainLevels; i++) { auth.gistMtp[i] <== gistMtp[i]; } - - auth.gistMtpAuxHi <== gistMtpAuxHi; - auth.gistMtpAuxHv <== gistMtpAuxHv; - auth.gistMtpNoAux <== gistMtpNoAux; - - // Check issuerClaim is issued to provided identity - component claimIdCheck = verifyCredentialSubjectProfile(); - for (var i = 0; i < 8; i++) { claimIdCheck.claim[i] <== issuerClaim[i]; } - claimIdCheck.id <== userGenesisID; - claimIdCheck.nonce <== claimSubjectProfileNonce; - - // Verify issuerClaim schema - component claimSchemaCheck = verifyCredentialSchema(); - for (var i = 0; i < 8; i++) { claimSchemaCheck.claim[i] <== issuerClaim[i]; } - claimSchemaCheck.schema <== claimSchema; - - // verify issuerClaim expiration time - component claimExpirationCheck = verifyExpirationTime(); - for (var i = 0; i < 8; i++) { claimExpirationCheck.claim[i] <== issuerClaim[i]; } - claimExpirationCheck.timestamp <== timestamp; - - - // AuthHash cca3371a6cb1b715004407e325bd993c - // BigInt: 80551937543569765027552589160822318028 - // https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential - component issuerSchemaCheck = verifyCredentialSchema(); - for (var i=0; i<8; i++) { issuerSchemaCheck.claim[i] <== issuerAuthClaim[i]; } - issuerSchemaCheck.schema <== 80551937543569765027552589160822318028; - // verify authClaim issued and not revoked - // calculate issuerAuthState - component issuerAuthStateComponent = getIdenState(); - issuerAuthStateComponent.claimsTreeRoot <== issuerAuthClaimsTreeRoot; - issuerAuthStateComponent.revTreeRoot <== issuerAuthRevTreeRoot; - issuerAuthStateComponent.rootsTreeRoot <== issuerAuthRootsTreeRoot; - - issuerAuthState <== issuerAuthStateComponent.idenState; - - // issuerAuthClaim proof of existence (isProofExist) - // - component smtIssuerAuthClaimExists = checkClaimExists(issuerLevels); - for (var i=0; i<8; i++) { smtIssuerAuthClaimExists.claim[i] <== issuerAuthClaim[i]; } - for (var i=0; i issuerAuthState; - - component verifyStateCommitment = VerifyStateCommitment(UserLevels, GistLevels); - for (var i=0; i<8; i++) { verifyStateCommitment.claim[i] <== stateCommitmentClaim[i]; } - for (var i=0; i out; -} diff --git a/archive_circuits_V2/circuits_after_refactoring/lib/query/query.circom b/archive_circuits_V2/circuits_after_refactoring/lib/query/query.circom deleted file mode 100644 index a430c18b..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/lib/query/query.circom +++ /dev/null @@ -1,67 +0,0 @@ -pragma circom 2.0.0; -include "../../../../node_modules/circomlib/circuits/mux3.circom"; -include "../../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../../node_modules/circomlib/circuits/comparators.circom"; -include "comparators.circom"; - -/* - Operators: - "0" - noop, skip execution. Ignores all `in` and `value` passed to query, out 1 - "1" - equals - "2" - less-than - "3" - greater-than - "4" - in - "5" - notin - "6" - not equals -*/ -template Query (valueArraySize) { - // signals - signal input in; - signal input value[valueArraySize]; - signal input operator; - signal output out; - - // operation components - component eq = IsEqual(); - eq.in[0] <== in; - eq.in[1] <== value[0]; - - // LessThan - component lt = LessThan254(); - lt.in[0] <== in; - lt.in[1] <== value[0]; - - component gt = GreaterThan254(); - gt.in[0] <== in; - gt.in[1] <== value[0]; - - // in - component inComp = IN(valueArraySize); - inComp.in <== in; - for(var i = 0; i 0 ? arraySize - hashFnBatchSize : 0; - if (restLength > 0) { - var r = restLength % batchSize; - var diff = r == 0 ? 0 : batchSize - r; - iterationCount = (restLength + diff) / batchSize; - } - - signal fullHash[iterationCount+1]; - - fullHash[0] <== firstPoseidon.out; - - component poseidon[iterationCount]; - for(var i = 0; i < iterationCount; i++) { - var elemIdx = i * batchSize + hashFnBatchSize ; - poseidon[i] = Poseidon(hashFnBatchSize); - - poseidon[i].inputs[0] <== fullHash[i]; - - for (var j = 0; j < batchSize; j++) - { - poseidon[i].inputs[j+1] <== getArrayValueByIndex(in, arraySize, elemIdx + j); - } - - fullHash[i+1] <== poseidon[i].out; - } - - out <== fullHash[iterationCount]; -} - - -function getArrayValueByIndex(valueArray, arraySize, idx) { - if(idx < arraySize) { - return valueArray[idx]; - } else{ - return 0; - } -} diff --git a/archive_circuits_V2/circuits_after_refactoring/lib/utils/treeUtils.circom b/archive_circuits_V2/circuits_after_refactoring/lib/utils/treeUtils.circom deleted file mode 100644 index c9581848..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/lib/utils/treeUtils.circom +++ /dev/null @@ -1,209 +0,0 @@ -pragma circom 2.1.1; - -include "../../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../../node_modules/circomlib/circuits/comparators.circom"; -include "../../../../node_modules/circomlib/circuits/eddsaposeidon.circom"; -include "../../../../node_modules/circomlib/circuits/smt/smtverifier.circom"; -include "../../../../node_modules/circomlib/circuits/mux3.circom"; -include "../../../../node_modules/circomlib/circuits/mux1.circom"; -include "claimUtils.circom"; - -// checkClaimExists verifies that claim is included into the claim tree root -template checkClaimExists(IssuerLevels) { - signal input enabled; - signal input claim[8]; - signal input claimMTP[IssuerLevels]; - signal input treeRoot; - - component claimHiHv = getClaimHiHv(); - claimHiHv.claim <== claim; - - SMTVerifier(IssuerLevels)( - enabled <== enabled, // enabled - root <== treeRoot, // root - siblings <== claimMTP, // siblings - oldKey <== 0, // oldKey - oldValue <== 0, // oldValue - isOld0 <== 0, // isOld0 - key <== claimHiHv.hi, // key - value <== claimHiHv.hv, // value - fnc <== 0 // fnc = inclusion - ); -} - -template checkClaimNotRevoked(treeLevels) { - signal input enabled; - signal input claim[8]; - signal input claimNonRevMTP[treeLevels]; - signal input treeRoot; - signal input noAux; - signal input auxHi; - signal input auxHv; - - signal claimRevNonce <== getClaimRevNonce()(claim); - - SMTVerifier(treeLevels)( - enabled <== enabled, - root <== treeRoot, - siblings <== claimNonRevMTP, - oldKey <== auxHi, - oldValue <== auxHv, - isOld0 <== noAux, - key <== claimRevNonce, - value <== 0, - fnc <== 1 // Non-inclusion - ); -} - -// checkIdenStateMatchesRoots checks that a hash of 3 tree -// roots is equal to expected identity state -template checkIdenStateMatchesRoots() { - signal input enabled; - signal input claimsTreeRoot; - signal input revTreeRoot; - signal input rootsTreeRoot; - signal input expectedState; - - signal idenState <== getIdenState()( - claimsTreeRoot, - revTreeRoot, - rootsTreeRoot - ); - - ForceEqualIfEnabled()( - enabled, - [idenState, expectedState] - ); -} - -// verifyClaimIssuanceNonRev verifies that claim is issued by the issuer and not revoked -// TODO: review if we need both verifyClaimIssuanceNonRev and verifyClaimIssuance -template verifyClaimIssuanceNonRev(IssuerLevels) { - signal input claim[8]; - signal input claimIssuanceMtp[IssuerLevels]; - signal input claimIssuanceClaimsTreeRoot; - signal input claimIssuanceRevTreeRoot; - signal input claimIssuanceRootsTreeRoot; - signal input claimIssuanceIdenState; - - signal input enabledNonRevCheck; - signal input claimNonRevMtp[IssuerLevels]; - signal input claimNonRevMtpNoAux; - signal input claimNonRevMtpAuxHi; - signal input claimNonRevMtpAuxHv; - signal input claimNonRevIssuerClaimsTreeRoot; - signal input claimNonRevIssuerRevTreeRoot; - signal input claimNonRevIssuerRootsTreeRoot; - signal input claimNonRevIssuerState; - - verifyClaimIssuance(IssuerLevels)( - 1, - claim, - claimIssuanceMtp, - claimIssuanceClaimsTreeRoot, - claimIssuanceRevTreeRoot, - claimIssuanceRootsTreeRoot, - claimIssuanceIdenState - ); - - // check non-revocation proof for claim - checkClaimNotRevoked(IssuerLevels)( - enabledNonRevCheck, - claim, - claimNonRevMtp, - claimIssuanceRevTreeRoot, - claimNonRevMtpNoAux, - claimNonRevMtpAuxHi, - claimNonRevMtpAuxHv - ); - - // check issuer state matches for non-revocation proof - checkIdenStateMatchesRoots()( - 1, - claimNonRevIssuerClaimsTreeRoot, - claimNonRevIssuerRevTreeRoot, - claimNonRevIssuerRootsTreeRoot, - claimNonRevIssuerState - ); -} - -// verifyClaimIssuance verifies that claim is issued by the issuer -template verifyClaimIssuance(IssuerLevels) { - signal input enabled; - signal input claim[8]; - signal input claimIssuanceMtp[IssuerLevels]; - signal input claimIssuanceClaimsTreeRoot; - signal input claimIssuanceRevTreeRoot; - signal input claimIssuanceRootsTreeRoot; - signal input claimIssuanceIdenState; - - // verify country claim is included in claims tree root - checkClaimExists(IssuerLevels)( - enabled, - claim, - claimIssuanceMtp, - claimIssuanceClaimsTreeRoot - ); - - // verify issuer state includes country claim - checkIdenStateMatchesRoots()( - enabled, - claimIssuanceClaimsTreeRoot, - claimIssuanceRevTreeRoot, - claimIssuanceRootsTreeRoot, - claimIssuanceIdenState - ); -} - -template VerifyAuthClaimAndSignature(nLevels) { - signal input enabled; - - signal input claimsTreeRoot; - signal input authClaimMtp[nLevels]; - signal input authClaim[8]; - - signal input revTreeRoot; - signal input authClaimNonRevMtp[nLevels]; - signal input authClaimNonRevMtpNoAux; - signal input authClaimNonRevMtpAuxHi; - signal input authClaimNonRevMtpAuxHv; - - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - // AuthHash cca3371a6cb1b715004407e325bd993c - // BigInt: 80551937543569765027552589160822318028 - // https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential - verifyCredentialSchema()( - enabled, - authClaim, - 80551937543569765027552589160822318028 - ); - - checkClaimExists(nLevels)( - 1, - authClaim, - authClaimMtp, - claimsTreeRoot - ); - - checkClaimNotRevoked(nLevels)( - enabled, - authClaim, - authClaimNonRevMtp, - revTreeRoot, - authClaimNonRevMtpNoAux, - authClaimNonRevMtpAuxHi, - authClaimNonRevMtpAuxHv - ); - - checkDataSignatureWithPubKeyInClaim()( - authClaim, - challengeSignatureS, - challengeSignatureR8x, - challengeSignatureR8y, - challenge - ); -} diff --git a/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQueryMTPOffChain.circom b/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQueryMTPOffChain.circom deleted file mode 100644 index c5d271ba..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQueryMTPOffChain.circom +++ /dev/null @@ -1,195 +0,0 @@ -pragma circom 2.1.1; -include "../../../node_modules/circomlib/circuits/mux1.circom"; -include "../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../node_modules/circomlib/circuits/comparators.circom"; -include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; -include "../lib/query/query.circom"; -include "../lib/utils/idUtils.circom"; - - -/** -credentialJsonLDAtomicQueryMTP.circom - query claim value and verify claim MTP - -checks: -- identity ownership -- verify credential subject (verify that identity is an owner of a claim ) -- claim schema -- claim ownership and issuance state -- claim non revocation state -- claim expiration -- query JSON-LD claim's field - -idOwnershipLevels - Merkle tree depth level for personal claims -issuerLevels - Merkle tree depth level for claims issued by the issuer -claimLevels - Merkle tree depth level for claim JSON-LD document -valueArraySize - Number of elements in comparison array for in/notin operation if level = 3 number of values for -comparison ["1", "2", "3"] - -*/ -template CredentialAtomicQueryMTPOffChain(issuerLevels, claimLevels, valueArraySize) { - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - /* issuerClaim signals */ - signal input issuerClaim[8]; - signal input issuerClaimMtp[issuerLevels]; - signal input issuerClaimClaimsTreeRoot; - signal input issuerClaimRevTreeRoot; - signal input issuerClaimRootsTreeRoot; - signal input issuerClaimIdenState; - - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - ///////////////////////////////////////////////////////////////// - - // Check issuerClaim is issued to provided identity - verifyCredentialSubjectProfile()( - issuerClaim, - userGenesisID, - claimSubjectProfileNonce - ); - - // Verify issuerClaim schema - verifyCredentialSchema()(1, issuerClaim, claimSchema); - - // verify issuerClaim expiration time - verifyExpirationTime()(issuerClaim, timestamp); - - ///////////////////////////////////////////////////////////////// - - // verify issuerClaim issued - verifyClaimIssuance(issuerLevels)( - enabled <== 1, - claim <== issuerClaim, - claimIssuanceMtp <== issuerClaimMtp, - claimIssuanceClaimsTreeRoot <== issuerClaimClaimsTreeRoot, - claimIssuanceRevTreeRoot <== issuerClaimRevTreeRoot, - claimIssuanceRootsTreeRoot <== issuerClaimRootsTreeRoot, - claimIssuanceIdenState <== issuerClaimIdenState - ); - - ///////////////////////////////////////////////////////////////// - - // non revocation status - checkClaimNotRevoked(issuerLevels)( - enabled <== isRevocationChecked, - claim <== issuerClaim, - claimNonRevMTP <== issuerClaimNonRevMtp, - noAux <== issuerClaimNonRevMtpNoAux, - auxHi <== issuerClaimNonRevMtpAuxHi, - auxHv <== issuerClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - // verify issuer state for claim non-revocation proof - checkIdenStateMatchesRoots()( - 1, - issuerClaimNonRevClaimsTreeRoot, - issuerClaimNonRevRevTreeRoot, - issuerClaimNonRevRootsTreeRoot, - issuerClaimNonRevState - ); - - ///////////////////////////////////////////////////////////////// - - component merklize = getClaimMerklizeRoot(); - merklize.claim <== issuerClaim; - - merklized <== merklize.flag; - - // check path/in node exists in merkletree specified by jsonldRoot - SMTVerifier(claimLevels)( - enabled <== merklize.flag, // if merklize flag 0 skip MTP verification - fnc <== claimPathNotExists, // inclusion - root <== merklize.out, - siblings <== claimPathMtp, - oldKey <== claimPathMtpAuxHi, - oldValue <== claimPathMtpAuxHv, - isOld0 <== claimPathMtpNoAux, - key <== claimPathKey, - value <== claimPathValue - ); - - // select value from claim by slot index (0-7) - signal slotValue <== getValueByIndex()(issuerClaim, slotIndex); - - // select value for query verification, - // if claim is merklized merklizeFlag = `1|2`, take claimPathValue - // if not merklized merklizeFlag = `0`, take value from selected slot - signal fieldValue <== Mux1()( - [slotValue, claimPathValue], - merklize.flag - ); - - ///////////////////////////////////////////////////////////////// - - // verify query - signal querySatisfied <== Query(valueArraySize)( - in <== fieldValue, - value <== value, - operator <== operator - ); - - querySatisfied === 1; - - /* ProfileID calculation */ - userID <== SelectProfile()(userGenesisID, profileNonce); -} diff --git a/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQuerySigOffChain.circom b/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQuerySigOffChain.circom deleted file mode 100644 index 7be6f936..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/offchain/credentialAtomicQuerySigOffChain.circom +++ /dev/null @@ -1,248 +0,0 @@ -pragma circom 2.1.1; -include "../../../node_modules/circomlib/circuits/mux1.circom"; -include "../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../node_modules/circomlib/circuits/comparators.circom"; -include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; -include "../lib/query/query.circom"; -include "../lib/utils/idUtils.circom"; - - -/** -credentialAtomicQuerySig.circom - query claim value and verify claim issuer signature: - -checks: -- identity ownership -- verify credential subject (verify that identity is an owner of a claim ) -- claim schema -- claim ownership and issuance state -- claim non revocation state -- claim expiration -- query JSON-LD claim's field - -idOwnershipLevels - Merkle tree depth level for personal claims -issuerLevels - Merkle tree depth level for claims issued by the issuer -claimLevels - Merkle tree depth level for claim JSON-LD document -valueArraySize - Number of elements in comparison array for in/notin operation if level = 3 number of values for -comparison ["1", "2", "3"] - -*/ -template credentialAtomicQuerySigOffChain(issuerLevels, claimLevels, valueArraySize) { - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - // issuer auth proof of existence - signal input issuerAuthClaim[8]; - signal input issuerAuthClaimMtp[issuerLevels]; - signal input issuerAuthClaimsTreeRoot; - signal input issuerAuthRevTreeRoot; - signal input issuerAuthRootsTreeRoot; - signal output issuerAuthState; - - // issuer auth claim non rev proof - signal input issuerAuthClaimNonRevMtp[issuerLevels]; - signal input issuerAuthClaimNonRevMtpNoAux; - signal input issuerAuthClaimNonRevMtpAuxHi; - signal input issuerAuthClaimNonRevMtpAuxHv; - - // claim issued by issuer to the user - signal input issuerClaim[8]; - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - // issuerClaim signature - signal input issuerClaimSignatureR8x; - signal input issuerClaimSignatureR8y; - signal input issuerClaimSignatureS; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - ///////////////////////////////////////////////////////////////// - - // Check issuerClaim is issued to provided identity - verifyCredentialSubjectProfile()( - issuerClaim, - userGenesisID, - claimSubjectProfileNonce - ); - - // Verify issuerClaim schema - verifyCredentialSchema()(1, issuerClaim, claimSchema); - - // verify issuerClaim expiration time - verifyExpirationTime()(issuerClaim, timestamp); - - ///////////////////////////////////////////////////////////////// - - // verify issuerAuthClaim Schema - // AuthHash cca3371a6cb1b715004407e325bd993c - // BigInt: 80551937543569765027552589160822318028 - // https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential - verifyCredentialSchema()( - 1, - issuerAuthClaim, - 80551937543569765027552589160822318028 - ); - - // verify authClaim issued and not revoked - // calculate issuerAuthState - issuerAuthState <== getIdenState()( - issuerAuthClaimsTreeRoot, - issuerAuthRevTreeRoot, - issuerAuthRootsTreeRoot - ); - - // issuerAuthClaim proof of existence (isProofExist) - checkClaimExists(issuerLevels)( - 1, - issuerAuthClaim, - issuerAuthClaimMtp, - issuerAuthClaimsTreeRoot - ); - - // issuerAuthClaim proof of non-revocation - checkClaimNotRevoked(issuerLevels)( - enabled <== 1, - claim <== issuerAuthClaim, - claimNonRevMTP <== issuerAuthClaimNonRevMtp, - noAux <== issuerAuthClaimNonRevMtpNoAux, - auxHi <== issuerAuthClaimNonRevMtpAuxHi, - auxHv <== issuerAuthClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - component issuerAuthPubKey = getPubKeyFromClaim(); - issuerAuthPubKey.claim <== issuerAuthClaim; - - // issuerClaim check signature - verifyClaimSignature()( - 1, - issuerClaim, - issuerClaimSignatureR8x, - issuerClaimSignatureR8y, - issuerClaimSignatureS, - issuerAuthPubKey.Ax, - issuerAuthPubKey.Ay - ); - - ///////////////////////////////////////////////////////////////// - - // non revocation status - checkClaimNotRevoked(issuerLevels)( - enabled <== isRevocationChecked, - claim <== issuerClaim, - claimNonRevMTP <== issuerClaimNonRevMtp, - noAux <== issuerClaimNonRevMtpNoAux, - auxHi <== issuerClaimNonRevMtpAuxHi, - auxHv <== issuerClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - // verify issuer state for claim non-revocation proof - checkIdenStateMatchesRoots()( - 1, - issuerClaimNonRevClaimsTreeRoot, - issuerClaimNonRevRevTreeRoot, - issuerClaimNonRevRootsTreeRoot, - issuerClaimNonRevState - ); - - ///////////////////////////////////////////////////////////////// - - component merklize = getClaimMerklizeRoot(); - merklize.claim <== issuerClaim; - - merklized <== merklize.flag; - - // check path/in node exists in merkletree specified by jsonldRoot - SMTVerifier(claimLevels)( - enabled <== merklize.flag, // if merklize flag 0 skip MTP verification - fnc <== claimPathNotExists, // inclusion - root <== merklize.out, - siblings <== claimPathMtp, - oldKey <== claimPathMtpAuxHi, - oldValue <== claimPathMtpAuxHv, - isOld0 <== claimPathMtpNoAux, - key <== claimPathKey, - value <== claimPathValue - ); - - // select value from claim by slot index (0-7) - signal slotValue <== getValueByIndex()(issuerClaim, slotIndex); - - // select value for query verification, - // if claim is merklized merklizeFlag = `1|2`, take claimPathValue - // if not merklized merklizeFlag = `0`, take value from selected slot - signal fieldValue <== Mux1()( - [slotValue, claimPathValue], - merklize.flag - ); - - ///////////////////////////////////////////////////////////////// - - // verify query - signal querySatisfied <== Query(valueArraySize)( - in <== fieldValue, - value <== value, - operator <== operator - ); - - querySatisfied === 1; - - /* ProfileID calculation */ - userID <== SelectProfile()(userGenesisID, profileNonce); -} diff --git a/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQueryMTPOnChain.circom b/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQueryMTPOnChain.circom deleted file mode 100644 index 129d272f..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQueryMTPOnChain.circom +++ /dev/null @@ -1,273 +0,0 @@ -pragma circom 2.1.1; -include "../../../node_modules/circomlib/circuits/mux1.circom"; -include "../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../node_modules/circomlib/circuits/comparators.circom"; -include "../../../node_modules/circomlib/circuits/poseidon.circom"; -include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; -include "../lib/query/query.circom"; -include "../lib/utils/idUtils.circom"; -include "../lib/utils/spongeHash.circom"; - -/** -credentialJsonLDAtomicQueryMTP.circom - query claim value and verify claim MTP - -checks: -- identity ownership -- verify credential subject (verify that identity is an owner of a claim ) -- claim schema -- claim ownership and issuance state -- claim non revocation state -- claim expiration -- query JSON-LD claim's field - -idOwnershipLevels - Merkle tree depth level for personal claims -issuerLevels - Merkle tree depth level for claims issued by the issuer -claimLevels - Merkle tree depth level for claim JSON-LD document -valueArraySize - Number of elements in comparison array for in/notin operation if level = 3 number of values for -comparison ["1", "2", "3"] -idOwnershipLevels - Merkle tree depth level for personal claims -onChainLevels - Merkle tree depth level for Auth claim on-chain -*/ -template CredentialAtomicQueryMTPOnChain(issuerLevels, claimLevels, valueArraySize, idOwnershipLevels, onChainLevels) { - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - // circuits query Hash - signal output circuitQueryHash; - - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - // user state - signal input userState; - signal input userClaimsTreeRoot; - signal input userRevTreeRoot; - signal input userRootsTreeRoot; - - // Auth claim - signal input authClaim[8]; - - // auth claim. merkle tree proof of inclusion to claim tree - signal input authClaimIncMtp[idOwnershipLevels]; - - // auth claim - rev nonce. merkle tree proof of non-inclusion to rev tree - signal input authClaimNonRevMtp[idOwnershipLevels]; - signal input authClaimNonRevMtpNoAux; - signal input authClaimNonRevMtpAuxHi; - signal input authClaimNonRevMtpAuxHv; - - // challenge signature - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - // global identity state tree on chain - signal input gistRoot; - // proof of inclusion or exclusion of the user in the global state - signal input gistMtp[onChainLevels]; - signal input gistMtpAuxHi; - signal input gistMtpAuxHv; - signal input gistMtpNoAux; - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - /* issuerClaim signals */ - signal input issuerClaim[8]; - - // issuerClaim MTP of issuance - signal input issuerClaimMtp[issuerLevels]; - signal input issuerClaimClaimsTreeRoot; - signal input issuerClaimRevTreeRoot; - signal input issuerClaimRootsTreeRoot; - signal input issuerClaimIdenState; - - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - ///////////////////////////////////////////////////////////////// - - checkAuthV2(idOwnershipLevels, onChainLevels)( - 1, // enabled - userGenesisID, - profileNonce, - userState, // user state - userClaimsTreeRoot, - userRevTreeRoot, - userRootsTreeRoot, - authClaim, - authClaimIncMtp, - authClaimNonRevMtp, - authClaimNonRevMtpNoAux, - authClaimNonRevMtpAuxHi, - authClaimNonRevMtpAuxHv, - challenge, // challenge & signature - challengeSignatureR8x, - challengeSignatureR8y, - challengeSignatureS, - gistRoot, // global identity state tree on chain - gistMtp, // proof of inclusion or exclusion of the user in the global state - gistMtpAuxHi, - gistMtpAuxHv, - gistMtpNoAux - ); - - ///////////////////////////////////////////////////////////////// - - // Check issuerClaim is issued to provided identity - verifyCredentialSubjectProfile()( - issuerClaim, - userGenesisID, - claimSubjectProfileNonce - ); - - // Verify issuerClaim schema - verifyCredentialSchema()(1, issuerClaim, claimSchema); - - // verify issuerClaim expiration time - verifyExpirationTime()(issuerClaim, timestamp); - - ///////////////////////////////////////////////////////////////// - - // verify issuerClaim issued - verifyClaimIssuance(issuerLevels)( - enabled <== 1, - claim <== issuerClaim, - claimIssuanceMtp <== issuerClaimMtp, - claimIssuanceClaimsTreeRoot <== issuerClaimClaimsTreeRoot, - claimIssuanceRevTreeRoot <== issuerClaimRevTreeRoot, - claimIssuanceRootsTreeRoot <== issuerClaimRootsTreeRoot, - claimIssuanceIdenState <== issuerClaimIdenState - ); - - ///////////////////////////////////////////////////////////////// - - // non revocation status - checkClaimNotRevoked(issuerLevels)( - enabled <== isRevocationChecked, - claim <== issuerClaim, - claimNonRevMTP <== issuerClaimNonRevMtp, - noAux <== issuerClaimNonRevMtpNoAux, - auxHi <== issuerClaimNonRevMtpAuxHi, - auxHv <== issuerClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - // verify issuer state for claim non-revocation proof - checkIdenStateMatchesRoots()( - 1, - issuerClaimNonRevClaimsTreeRoot, - issuerClaimNonRevRevTreeRoot, - issuerClaimNonRevRootsTreeRoot, - issuerClaimNonRevState - ); - - ///////////////////////////////////////////////////////////////// - - component merklize = getClaimMerklizeRoot(); - merklize.claim <== issuerClaim; - - merklized <== merklize.flag; - - // check path/in node exists in merkletree specified by jsonldRoot - SMTVerifier(claimLevels)( - enabled <== merklize.flag, // if merklize flag 0 skip MTP verification - fnc <== claimPathNotExists, // inclusion - root <== merklize.out, - siblings <== claimPathMtp, - oldKey <== claimPathMtpAuxHi, - oldValue <== claimPathMtpAuxHv, - isOld0 <== claimPathMtpNoAux, - key <== claimPathKey, - value <== claimPathValue - ); - - // select value from claim by slot index (0-7) - signal slotValue <== getValueByIndex()(issuerClaim, slotIndex); - - // select value for query verification, - // if claim is merklized merklizeFlag = `1|2`, take claimPathValue - // if not merklized merklizeFlag = `0`, take value from selected slot - signal fieldValue <== Mux1()( - [slotValue, claimPathValue], - merklize.flag - ); - - ///////////////////////////////////////////////////////////////// - - // verify query - signal querySatisfied <== Query(valueArraySize)( - in <== fieldValue, - value <== value, - operator <== operator - ); - - querySatisfied === 1; - - // verify query hash matches - signal valueHash <== SpongeHash(valueArraySize, 6)(value); // 6 - max size of poseidon hash available on-chain - - circuitQueryHash <== Poseidon(6)([ - claimSchema, - slotIndex, - operator, - claimPathKey, - claimPathNotExists, // TODO: check if this value should be here - valueHash - ]); - - /* ProfileID calculation */ - userID <== SelectProfile()(userGenesisID, profileNonce); -} diff --git a/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQuerySigOnChain.circom b/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQuerySigOnChain.circom deleted file mode 100644 index 578c1f52..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/onchain/credentialAtomicQuerySigOnChain.circom +++ /dev/null @@ -1,324 +0,0 @@ -pragma circom 2.1.1; -include "../../../node_modules/circomlib/circuits/mux1.circom"; -include "../../../node_modules/circomlib/circuits/bitify.circom"; -include "../../../node_modules/circomlib/circuits/comparators.circom"; -include "../../../node_modules/circomlib/circuits/poseidon.circom"; -include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; -include "../lib/query/query.circom"; -include "../lib/utils/idUtils.circom"; -include "../lib/utils/spongeHash.circom"; - -/** -credentialAtomicQuerySigOnChain.circom - query claim value and verify claim issuer signature: - -checks: -- identity ownership -- verify credential subject (verify that identity is an owner of a claim ) -- claim schema -- claim ownership and issuance state -- claim non revocation state -- claim expiration -- query JSON-LD claim's field - -idOwnershipLevels - Merkle tree depth level for personal claims -issuerLevels - Merkle tree depth level for claims issued by the issuer -claimLevels - Merkle tree depth level for claim JSON-LD document -valueArraySize - Number of elements in comparison array for in/notin operation if level = 3 number of values for -comparison ["1", "2", "3"] -idOwnershipLevels - Merkle tree depth level for personal claims -onChainLevels - Merkle tree depth level for Auth claim on-chain -*/ -template credentialAtomicQuerySigOnChain(issuerLevels, claimLevels, valueArraySize, idOwnershipLevels, onChainLevels) { - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that - // claimPathValue and claimPathKey are stored in the merkle tree) and verification is performed - // on root stored in the index or value slot - // if it is not set verification is performed on according to the slotIndex. Value selected from the - // provided slot. For example if slotIndex is `1` value gets from `i_1` slot. If `4` from `v_1`. - signal output merklized; - - // userID output signal will be assigned with ProfileID SelectProfile(UserGenesisID, nonce) - // unless nonce == 0, in which case userID will be assigned with userGenesisID - signal output userID; - - // circuits query Hash - signal output circuitQueryHash; - - // we have no constraints for "requestID" in this circuit, it is used as a unique identifier for the request - // and verifier can use it to identify the request, and verify the proof of specific request in case of multiple query requests - signal input requestID; - - /* userID ownership signals */ - signal input userGenesisID; - signal input profileNonce; /* random number */ - - // user state - signal input userState; - signal input userClaimsTreeRoot; - signal input userRevTreeRoot; - signal input userRootsTreeRoot; - - // Auth claim - signal input authClaim[8]; - - // auth claim. merkle tree proof of inclusion to claim tree - signal input authClaimIncMtp[idOwnershipLevels]; - - // auth claim - rev nonce. merkle tree proof of non-inclusion to rev tree - signal input authClaimNonRevMtp[idOwnershipLevels]; - signal input authClaimNonRevMtpNoAux; - signal input authClaimNonRevMtpAuxHi; - signal input authClaimNonRevMtpAuxHv; - - // challenge signature - signal input challenge; - signal input challengeSignatureR8x; - signal input challengeSignatureR8y; - signal input challengeSignatureS; - - // global identity state tree on chain - signal input gistRoot; - // proof of inclusion or exclusion of the user in the global state - signal input gistMtp[onChainLevels]; - signal input gistMtpAuxHi; - signal input gistMtpAuxHv; - signal input gistMtpNoAux; - - /* issuerClaim signals */ - signal input claimSubjectProfileNonce; // nonce of the profile that claim is issued to, 0 if claim is issued to genesisID - - // issuer ID - signal input issuerID; - - // issuer auth proof of existence - signal input issuerAuthClaim[8]; - signal input issuerAuthClaimMtp[issuerLevels]; - signal input issuerAuthClaimsTreeRoot; - signal input issuerAuthRevTreeRoot; - signal input issuerAuthRootsTreeRoot; - signal output issuerAuthState; - - // issuer auth claim non rev proof - signal input issuerAuthClaimNonRevMtp[issuerLevels]; - signal input issuerAuthClaimNonRevMtpNoAux; - signal input issuerAuthClaimNonRevMtpAuxHi; - signal input issuerAuthClaimNonRevMtpAuxHv; - - // claim issued by issuer to the user - signal input issuerClaim[8]; - - // issuerClaim non rev inputs - signal input isRevocationChecked; - signal input issuerClaimNonRevMtp[issuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - signal input issuerClaimNonRevClaimsTreeRoot; - signal input issuerClaimNonRevRevTreeRoot; - signal input issuerClaimNonRevRootsTreeRoot; - signal input issuerClaimNonRevState; - - // issuerClaim signature - signal input issuerClaimSignatureR8x; - signal input issuerClaimSignatureR8y; - signal input issuerClaimSignatureS; - - /* current time */ - signal input timestamp; - - /** Query */ - signal input claimSchema; - - 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 - signal input claimPathMtpAuxHv; // 0 for inclusion proof - signal input claimPathKey; // hash of path in merklized json-ld document - signal input claimPathValue; // value in this path in merklized json-ld document - - signal input slotIndex; - signal input operator; - signal input value[valueArraySize]; - - /* - >>>>>>>>>>>>>>>>>>>>>>>>>>> End Inputs <<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - - ///////////////////////////////////////////////////////////////// - - checkAuthV2(idOwnershipLevels, onChainLevels)( - 1, // enabled - userGenesisID, - profileNonce, - userState, // user state - userClaimsTreeRoot, - userRevTreeRoot, - userRootsTreeRoot, - authClaim, - authClaimIncMtp, - authClaimNonRevMtp, - authClaimNonRevMtpNoAux, - authClaimNonRevMtpAuxHi, - authClaimNonRevMtpAuxHv, - challenge, // challenge & signature - challengeSignatureR8x, - challengeSignatureR8y, - challengeSignatureS, - gistRoot, // global identity state tree on chain - gistMtp, // proof of inclusion or exclusion of the user in the global state - gistMtpAuxHi, - gistMtpAuxHv, - gistMtpNoAux - ); - - ///////////////////////////////////////////////////////////////// - - // Check issuerClaim is issued to provided identity - verifyCredentialSubjectProfile()( - issuerClaim, - userGenesisID, - claimSubjectProfileNonce - ); - - // Verify issuerClaim schema - verifyCredentialSchema()(1, issuerClaim, claimSchema); - - // verify issuerClaim expiration time - verifyExpirationTime()(issuerClaim, timestamp); - - ///////////////////////////////////////////////////////////////// - - // verify issuerAuthClaim Schema - // AuthHash cca3371a6cb1b715004407e325bd993c - // BigInt: 80551937543569765027552589160822318028 - // https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential - verifyCredentialSchema()( - 1, - issuerAuthClaim, - 80551937543569765027552589160822318028 - ); - - // verify authClaim issued and not revoked - // calculate issuerAuthState - issuerAuthState <== getIdenState()( - issuerAuthClaimsTreeRoot, - issuerAuthRevTreeRoot, - issuerAuthRootsTreeRoot - ); - - // issuerAuthClaim proof of existence (isProofExist) - checkClaimExists(issuerLevels)( - 1, - issuerAuthClaim, - issuerAuthClaimMtp, - issuerAuthClaimsTreeRoot - ); - - // issuerAuthClaim proof of non-revocation - checkClaimNotRevoked(issuerLevels)( - enabled <== 1, - claim <== issuerAuthClaim, - claimNonRevMTP <== issuerAuthClaimNonRevMtp, - noAux <== issuerAuthClaimNonRevMtpNoAux, - auxHi <== issuerAuthClaimNonRevMtpAuxHi, - auxHv <== issuerAuthClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - component issuerAuthPubKey = getPubKeyFromClaim(); - issuerAuthPubKey.claim <== issuerAuthClaim; - - // issuerClaim check signature - verifyClaimSignature()( - 1, - issuerClaim, - issuerClaimSignatureR8x, - issuerClaimSignatureR8y, - issuerClaimSignatureS, - issuerAuthPubKey.Ax, - issuerAuthPubKey.Ay - ); - - ///////////////////////////////////////////////////////////////// - - // non revocation status - checkClaimNotRevoked(issuerLevels)( - enabled <== isRevocationChecked, - claim <== issuerClaim, - claimNonRevMTP <== issuerClaimNonRevMtp, - noAux <== issuerClaimNonRevMtpNoAux, - auxHi <== issuerClaimNonRevMtpAuxHi, - auxHv <== issuerClaimNonRevMtpAuxHv, - treeRoot <== issuerClaimNonRevRevTreeRoot - ); - - // verify issuer state for claim non-revocation proof - checkIdenStateMatchesRoots()( - 1, - issuerClaimNonRevClaimsTreeRoot, - issuerClaimNonRevRevTreeRoot, - issuerClaimNonRevRootsTreeRoot, - issuerClaimNonRevState - ); - - ///////////////////////////////////////////////////////////////// - - component merklize = getClaimMerklizeRoot(); - merklize.claim <== issuerClaim; - - merklized <== merklize.flag; - - // check path/in node exists in merkletree specified by jsonldRoot - SMTVerifier(claimLevels)( - enabled <== merklize.flag, // if merklize flag 0 skip MTP verification - fnc <== claimPathNotExists, // inclusion - root <== merklize.out, - siblings <== claimPathMtp, - oldKey <== claimPathMtpAuxHi, - oldValue <== claimPathMtpAuxHv, - isOld0 <== claimPathMtpNoAux, - key <== claimPathKey, - value <== claimPathValue - ); - - // select value from claim by slot index (0-7) - signal slotValue <== getValueByIndex()(issuerClaim, slotIndex); - - // select value for query verification, - // if claim is merklized merklizeFlag = `1|2`, take claimPathValue - // if not merklized merklizeFlag = `0`, take value from selected slot - signal fieldValue <== Mux1()( - [slotValue, claimPathValue], - merklize.flag - ); - - ///////////////////////////////////////////////////////////////// - - // verify query - signal querySatisfied <== Query(valueArraySize)( - in <== fieldValue, - value <== value, - operator <== operator - ); - - querySatisfied === 1; - - // verify query hash matches - signal valueHash <== SpongeHash(valueArraySize, 6)(value); // 6 - max size of poseidon hash available on-chain - - circuitQueryHash <== Poseidon(6)([ - claimSchema, - slotIndex, - operator, - claimPathKey, - claimPathNotExists, // TODO: check if this value should be here - valueHash - ]); - - /* ProfileID calculation */ - userID <== SelectProfile()(userGenesisID, profileNonce); -} diff --git a/archive_circuits_V2/circuits_after_refactoring/sybil/sybilCredentialAtomicMTPOffChain.circom b/archive_circuits_V2/circuits_after_refactoring/sybil/sybilCredentialAtomicMTPOffChain.circom deleted file mode 100644 index a25b0c21..00000000 --- a/archive_circuits_V2/circuits_after_refactoring/sybil/sybilCredentialAtomicMTPOffChain.circom +++ /dev/null @@ -1,179 +0,0 @@ -pragma circom 2.1.1; - -include "sybilUtils.circom"; -include "../lib/utils/idUtils.circom"; -include "../lib/utils/treeUtils.circom"; -include "../lib/utils/claimUtils.circom"; -include "../../../node_modules/circomlib/circuits/poseidon.circom"; - - -template SybilCredentialAtomicMTP(IssuerLevels, UserLevels, GistLevels) { - - // uniqueness claim - signal input issuerClaim[8]; - signal input issuerClaimMtp[IssuerLevels]; - signal input issuerClaimClaimsRoot; - signal input issuerClaimRevRoot; - signal input issuerClaimRootsRoot; - signal input issuerClaimIdenState; - - signal input issuerClaimNonRevMtp[IssuerLevels]; - signal input issuerClaimNonRevMtpNoAux; - signal input issuerClaimNonRevMtpAuxHi; - signal input issuerClaimNonRevMtpAuxHv; - - signal input issuerClaimNonRevClaimsRoot; - signal input issuerClaimNonRevRevRoot; - signal input issuerClaimNonRevRootsRoot; - signal input issuerClaimNonRevState; - - signal input claimSchema; - - // state commitment claim - signal input stateCommitmentClaim[8]; - signal input stateCommitmentClaimMtp[UserLevels]; - signal input stateCommitmentClaimClaimsRoot; - signal input stateCommitmentClaimRevRoot; - signal input stateCommitmentClaimRootsRoot; - signal input stateCommitmentClaimIdenState; - - // GIST and path to holderState - signal input gistRoot; - signal input gistMtp[GistLevels]; - signal input gistMtpAuxHi; - signal input gistMtpAuxHv; - signal input gistMtpNoAux; - - signal input crs; - - // identity - signal input userGenesisID; - signal input profileNonce; - signal input claimSubjectProfileNonce; - - signal input requestID; - signal input issuerID; - signal input timestamp; - - // outputs - signal output userID; - signal output sybilID; - - component verifyIssuerClaim = VerifyIssuerClaim(IssuerLevels); - for (var i=0; i<8; i++) { verifyIssuerClaim.claim[i] <== issuerClaim[i]; } - for (var i=0; i issuerAuthState; - - component verifyStateCommitment = VerifyStateCommitment(UserLevels, GistLevels); - for (var i=0; i<8; i++) { verifyStateCommitment.claim[i] <== stateCommitmentClaim[i]; } - for (var i=0; i { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "authV2Test.circom"), - { - output: path.join(__dirname, "../circuits", "build/authV2"), - recompile: true, - reduceConstraints: false, - }, - ); - }); - - tests.forEach(({desc, inputs, expOut}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(inputs, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, expOut); - }); - }); -}); diff --git a/archive_circuits_V2/test/circuits/authV2Test.circom b/archive_circuits_V2/test/circuits/authV2Test.circom deleted file mode 100644 index 3351d423..00000000 --- a/archive_circuits_V2/test/circuits/authV2Test.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/auth/authV2.circom"; - -component main {public [challenge, gistRoot]} = AuthV2(32,32); diff --git a/archive_circuits_V2/test/circuits/comparators.circom b/archive_circuits_V2/test/circuits/comparators.circom deleted file mode 100644 index 6d4c08b0..00000000 --- a/archive_circuits_V2/test/circuits/comparators.circom +++ /dev/null @@ -1,8 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/query/comparators.circom"; - -component main = LessThan254(); - - - diff --git a/archive_circuits_V2/test/circuits/comparators_greater_than.circom b/archive_circuits_V2/test/circuits/comparators_greater_than.circom deleted file mode 100644 index da4438f1..00000000 --- a/archive_circuits_V2/test/circuits/comparators_greater_than.circom +++ /dev/null @@ -1,8 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/query/comparators.circom"; - -component main = GreaterThan254(); - - - diff --git a/archive_circuits_V2/test/circuits/eddsaposeidon.circom b/archive_circuits_V2/test/circuits/eddsaposeidon.circom deleted file mode 100644 index c10ff5cc..00000000 --- a/archive_circuits_V2/test/circuits/eddsaposeidon.circom +++ /dev/null @@ -1,30 +0,0 @@ -pragma circom 2.1.1; - -include "../../../node_modules/circomlib/circuits/eddsaposeidon.circom"; - -template EdDSAPoseidonTest() { - signal input enabled; - signal input Ax; - signal input Ay; - - signal input S; - signal input R8x; - signal input R8y; - - signal input M; - - EdDSAPoseidonVerifier()( - enabled, - Ax, - Ay, - S, - R8x, - R8y, - M - ); -} - -component main = EdDSAPoseidonTest(); - - - diff --git a/archive_circuits_V2/test/circuits/eq.circom b/archive_circuits_V2/test/circuits/eq.circom deleted file mode 100644 index 8b040d61..00000000 --- a/archive_circuits_V2/test/circuits/eq.circom +++ /dev/null @@ -1,20 +0,0 @@ -pragma circom 2.1.1; - -//include "../../circuits/comparators.circom"; -include "../../../node_modules/circomlib/circuits/comparators.circom"; - -template EqWithLog(n) { - signal input in[2]; - signal output out; - - log(in[0]); - log(in[1]); - - component eq = IsEqual(); - eq.in[0] <== in[0]; - eq.in[1] <== in[1]; - out <== eq.out; -} - -component main = EqWithLog(252); - diff --git a/archive_circuits_V2/test/circuits/idUtils_CalculateIdChecksum.circom b/archive_circuits_V2/test/circuits/idUtils_CalculateIdChecksum.circom deleted file mode 100644 index 2b9eac50..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_CalculateIdChecksum.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = CalculateIdChecksum(); diff --git a/archive_circuits_V2/test/circuits/idUtils_GatherID.circom b/archive_circuits_V2/test/circuits/idUtils_GatherID.circom deleted file mode 100644 index dc975c53..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_GatherID.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = GatherID(); diff --git a/archive_circuits_V2/test/circuits/idUtils_NewID.circom b/archive_circuits_V2/test/circuits/idUtils_NewID.circom deleted file mode 100644 index 6c4071b3..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_NewID.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = NewID(); diff --git a/archive_circuits_V2/test/circuits/idUtils_ProfileID.circom b/archive_circuits_V2/test/circuits/idUtils_ProfileID.circom deleted file mode 100644 index 5c4a6c22..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_ProfileID.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = ProfileID(); diff --git a/archive_circuits_V2/test/circuits/idUtils_SelectProfile.circom b/archive_circuits_V2/test/circuits/idUtils_SelectProfile.circom deleted file mode 100644 index bf161a24..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_SelectProfile.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = SelectProfile(); diff --git a/archive_circuits_V2/test/circuits/idUtils_SplitID.circom b/archive_circuits_V2/test/circuits/idUtils_SplitID.circom deleted file mode 100644 index 9bee097a..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_SplitID.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = SplitID(); diff --git a/archive_circuits_V2/test/circuits/idUtils_TakeNBits.circom b/archive_circuits_V2/test/circuits/idUtils_TakeNBits.circom deleted file mode 100644 index a1d886c3..00000000 --- a/archive_circuits_V2/test/circuits/idUtils_TakeNBits.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/utils/idUtils.circom"; - -component main = TakeNBits(80); diff --git a/archive_circuits_V2/test/circuits/lessthan.circom b/archive_circuits_V2/test/circuits/lessthan.circom deleted file mode 100644 index adcd74e2..00000000 --- a/archive_circuits_V2/test/circuits/lessthan.circom +++ /dev/null @@ -1,20 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/query/comparators.circom"; -//include "../../node_modules/circomlib/circuits/comparators.circom"; - -template LessThanWithLog() { - signal input in[2]; - signal output out; - - log(in[0]); - log(in[1]); - - component lt = LessThan254(); - lt.in[0] <== in[0]; - lt.in[1] <== in[1]; - out <== lt.out; -} - -component main = LessThanWithLog(); - diff --git a/archive_circuits_V2/test/circuits/poseidon.circom b/archive_circuits_V2/test/circuits/poseidon.circom deleted file mode 100644 index 215ea60f..00000000 --- a/archive_circuits_V2/test/circuits/poseidon.circom +++ /dev/null @@ -1,19 +0,0 @@ -pragma circom 2.1.1; - -include "../../node_modules/circomlib/circuits/poseidon.circom"; - -template PoseidonTest() { - signal input in[3]; - signal output out; - - component h = Poseidon(3); - h.inputs[0] <== in[0]; - h.inputs[1] <== in[1]; - h.inputs[2] <== in[2]; - - out <== h.out; -} -component main = PoseidonTest(); - - - diff --git a/archive_circuits_V2/test/circuits/poseidon14.circom b/archive_circuits_V2/test/circuits/poseidon14.circom deleted file mode 100644 index a09ec034..00000000 --- a/archive_circuits_V2/test/circuits/poseidon14.circom +++ /dev/null @@ -1,32 +0,0 @@ -pragma circom 2.1.1; - -include "../../node_modules/circomlib/circuits/poseidon.circom"; - -template PoseidonTest() { - signal input in[14]; - signal output out; - - component h = Poseidon(14); - h.inputs[0] <== in[0]; - h.inputs[1] <== in[1]; - h.inputs[2] <== in[2]; - h.inputs[3] <== in[3]; - h.inputs[4] <== in[4]; - h.inputs[5] <== in[5]; - h.inputs[6] <== in[6]; - h.inputs[7] <== in[7]; - h.inputs[8] <== in[8]; - h.inputs[9] <== in[9]; - h.inputs[10] <== in[10]; - h.inputs[11] <== in[11]; - h.inputs[12] <== in[12]; - h.inputs[13] <== in[13]; - //h.inputs[14] <== in[14]; - //h.inputs[15] <== in[15]; - - out <== h.out; -} -component main = PoseidonTest(); - - - diff --git a/archive_circuits_V2/test/circuits/poseidon16.circom b/archive_circuits_V2/test/circuits/poseidon16.circom deleted file mode 100644 index cad3a18e..00000000 --- a/archive_circuits_V2/test/circuits/poseidon16.circom +++ /dev/null @@ -1,32 +0,0 @@ -pragma circom 2.1.1; - -include "../../node_modules/circomlib/circuits/poseidon.circom"; - -template PoseidonTest() { - signal input in[16]; - signal output out; - - component h = Poseidon(16); - h.inputs[0] <== in[0]; - h.inputs[1] <== in[1]; - h.inputs[2] <== in[2]; - h.inputs[3] <== in[3]; - h.inputs[4] <== in[4]; - h.inputs[5] <== in[5]; - h.inputs[6] <== in[6]; - h.inputs[7] <== in[7]; - h.inputs[8] <== in[8]; - h.inputs[9] <== in[9]; - h.inputs[10] <== in[10]; - h.inputs[11] <== in[11]; - h.inputs[12] <== in[12]; - h.inputs[13] <== in[13]; - h.inputs[14] <== in[14]; - h.inputs[15] <== in[15]; - - out <== h.out; -} -component main = PoseidonTest(); - - - diff --git a/archive_circuits_V2/test/circuits/query/credentialAtomicQueryMTPTest.circom b/archive_circuits_V2/test/circuits/query/credentialAtomicQueryMTPTest.circom deleted file mode 100644 index bfdcd47d..00000000 --- a/archive_circuits_V2/test/circuits/query/credentialAtomicQueryMTPTest.circom +++ /dev/null @@ -1,13 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/query/credentialAtomicQueryMTP.circom"; - -component main{public [challenge, - userID, - userState, - claimSchema, - issuerID, - slotIndex, - operator, - value, - timestamp]} = CredentialAtomicQueryMTP(32, 32, 64); diff --git a/archive_circuits_V2/test/circuits/query/credentialAtomicQuerySigTest.circom b/archive_circuits_V2/test/circuits/query/credentialAtomicQuerySigTest.circom deleted file mode 100644 index c79b6b0b..00000000 --- a/archive_circuits_V2/test/circuits/query/credentialAtomicQuerySigTest.circom +++ /dev/null @@ -1,14 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/query/credentialAtomicQuerySig.circom"; - -component main{public [challenge, - userID, - userState, - issuerID, - issuerClaimNonRevState, - claimSchema, - slotIndex, - operator, - value, - timestamp]} = CredentialAtomicQuerySig(32, 32, 64); diff --git a/archive_circuits_V2/test/circuits/query/inTest.circom b/archive_circuits_V2/test/circuits/query/inTest.circom deleted file mode 100644 index 61855848..00000000 --- a/archive_circuits_V2/test/circuits/query/inTest.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/query/comparators.circom"; - -component main = IN(3); diff --git a/archive_circuits_V2/test/circuits/query/queryTest.circom b/archive_circuits_V2/test/circuits/query/queryTest.circom deleted file mode 100644 index 25b55d36..00000000 --- a/archive_circuits_V2/test/circuits/query/queryTest.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/query/query.circom"; - -component main { public [value] } = Query(3); diff --git a/archive_circuits_V2/test/circuits/stateTransitionTest.circom b/archive_circuits_V2/test/circuits/stateTransitionTest.circom deleted file mode 100644 index 7d7c40c5..00000000 --- a/archive_circuits_V2/test/circuits/stateTransitionTest.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/lib/stateTransition.circom"; - -component main {public [userID,oldUserState,newUserState,isOldStateGenesis]} = StateTransition(32); diff --git a/archive_circuits_V2/test/circuits/sybilTestMTP.circom b/archive_circuits_V2/test/circuits/sybilTestMTP.circom deleted file mode 100644 index 399a73cd..00000000 --- a/archive_circuits_V2/test/circuits/sybilTestMTP.circom +++ /dev/null @@ -1,13 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/sybil/sybilCredentialAtomicMTPOffChain.circom"; - -component main{public [ - requestID, - issuerID, - timestamp, - claimSchema, - issuerClaimIdenState, - issuerClaimNonRevState, - crs, - gistRoot]} = SybilCredentialAtomicMTP(32, 32, 32); diff --git a/archive_circuits_V2/test/circuits/sybilTestSig.circom b/archive_circuits_V2/test/circuits/sybilTestSig.circom deleted file mode 100644 index 8b8d6a9b..00000000 --- a/archive_circuits_V2/test/circuits/sybilTestSig.circom +++ /dev/null @@ -1,12 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/sybil/sybilCredentialAtomicSigOffChain.circom"; - -component main{public [ - requestID, - issuerID, - timestamp, - claimSchema, - issuerClaimNonRevState, - crs, - gistRoot]} = SybilCredentialAtomicSig(32, 32, 32); diff --git a/archive_circuits_V2/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom b/archive_circuits_V2/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom deleted file mode 100644 index 98290d70..00000000 --- a/archive_circuits_V2/test/circuits/utils/claimUtils_getClaimMerklizeRoot.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = getClaimMerklizeRoot(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_GetValueByIndex.circom b/archive_circuits_V2/test/circuits/utils/utils_GetValueByIndex.circom deleted file mode 100644 index dd45de83..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_GetValueByIndex.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = getValueByIndex(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom b/archive_circuits_V2/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom deleted file mode 100644 index 9a728498..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_checkIdenStateMatchesRoots.circom +++ /dev/null @@ -1,6 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; -include "../../../circuits/lib/utils/treeUtils.circom"; - -component main = checkIdenStateMatchesRoots(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_getClaimExpiration.circom b/archive_circuits_V2/test/circuits/utils/utils_getClaimExpiration.circom deleted file mode 100644 index d1b116a1..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_getClaimExpiration.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main{public[claim]} = getClaimExpiration(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_getClaimSubjectOtherIden.circom b/archive_circuits_V2/test/circuits/utils/utils_getClaimSubjectOtherIden.circom deleted file mode 100644 index 74fc1e77..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_getClaimSubjectOtherIden.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main{public[claim]} = getClaimSubjectOtherIden(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_getSubjectLocation.circom b/archive_circuits_V2/test/circuits/utils/utils_getSubjectLocation.circom deleted file mode 100644 index 8b4f3710..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_getSubjectLocation.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = getSubjectLocation(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_isExpirable.circom b/archive_circuits_V2/test/circuits/utils/utils_isExpirable.circom deleted file mode 100644 index 6b551081..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_isExpirable.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = isExpirable(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_isUpdatable.circom b/archive_circuits_V2/test/circuits/utils/utils_isUpdatable.circom deleted file mode 100644 index 1d04f3d7..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_isUpdatable.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = isUpdatable(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyClaimSignature.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyClaimSignature.circom deleted file mode 100644 index 2cf86a28..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyClaimSignature.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = verifyClaimSignature(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyClaimsTreeRoot.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyClaimsTreeRoot.circom deleted file mode 100644 index 5e2ad5b5..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyClaimsTreeRoot.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/treeUtils.circom"; - -component main = verifyClaimsTreeRoot(17); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtp.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtp.circom deleted file mode 100644 index c70c182a..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtp.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = verifyCredentialMtp(17); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtpHiHv.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtpHiHv.circom deleted file mode 100644 index 5bdcd0cc..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialMtpHiHv.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = verifyCredentialMtpHiHv(4); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialNotRevoked.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialNotRevoked.circom deleted file mode 100644 index ee9d6691..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialNotRevoked.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/treeUtils.circom"; - -component main = verifyCredentialNotRevoked(17); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialSubject.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialSubject.circom deleted file mode 100644 index 4718be52..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyCredentialSubject.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = verifyCredentialSubject(); diff --git a/archive_circuits_V2/test/circuits/utils/utils_verifyExpirationTime.circom b/archive_circuits_V2/test/circuits/utils/utils_verifyExpirationTime.circom deleted file mode 100644 index 621cf4f5..00000000 --- a/archive_circuits_V2/test/circuits/utils/utils_verifyExpirationTime.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../../circuits/lib/utils/claimUtils.circom"; - -component main = verifyExpirationTime(); diff --git a/archive_circuits_V2/test/comparators.test.ts b/archive_circuits_V2/test/comparators.test.ts deleted file mode 100644 index c4e6c2a1..00000000 --- a/archive_circuits_V2/test/comparators.test.ts +++ /dev/null @@ -1,321 +0,0 @@ -const path = require("path"); -const tester = require("circom_tester").wasm; -const F1Field = require("ffjavascript").F1Field; -const Scalar = require("ffjavascript").Scalar; -exports.p = Scalar.fromString("21888242871839275222246405745257275088548364400416034343698204186575808495617"); -const Fr = new F1Field(exports.p); - -const wasm_tester = require("circom_tester").wasm; -const c_tester = require("circom_tester").c; - -export {}; - -describe("comparator test", function () { - this.timeout(200000); - - it("LessThan254", async () => { - const circuit = await tester( - path.join(__dirname, "circuits", "comparators.circom"), - { reduceConstraints: false } - ); - - var witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "2"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["2", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495615", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - witness = await circuit.calculateWitness({ - in: ["14700167578956157622133035206181082051684666022005149731571763594754596536320", "14813245791101974219226366246228628836697624991405189344891546391637324201984"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - witness = await circuit.calculateWitness({ - in: ["21711016745476759975494879586462490265997937461626177968668583242035516932096", "14474011174884484428309352972086249796923471088432928821837627361816848891904"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - // high part greater, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011174884484428309352972086249796923471088432928821837627361816848891904", "7237005597552222214336166409043255556094097046830393569371528361322278289408"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - // high part less, low part less - witness = await circuit.calculateWitness({ - in: ["7237005584072248880760846511709748012584281710011821358101242120770473164800", "14474011168144497761521693023419496025168563420023642716202484241540946329600"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - // high part less, low part equal - witness = await circuit.calculateWitness({ - in: ["7237005584072248880760846511709748012584281710011821358101242120770473164800", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - // high part less, low part greater - witness = await circuit.calculateWitness({ - in: ["7237005590812235547548506460376501784339189378421107463736385241046375727104", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - // high part equal, low part less - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "14474011168144497761521693023419496025168563420023642716202484241540946329600"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - // high part equal, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part equal, low part greater - witness = await circuit.calculateWitness({ - in: ["14474011168144497761521693023419496025168563420023642716202484241540946329600", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - // high part greater, low part less - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "7237005590812235547548506460376501784339189378421107463736385241046375727104"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part greater, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "7237005584072248880760846511709748012584281710011821358101242120770473164800"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part greater, low part greater - witness = await circuit.calculateWitness({ - in: ["14474011168144497761521693023419496025168563420023642716202484241540946329600", "7237005584072248880760846511709748012584281710011821358101242120770473164800"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - }); - - it("GreaterThan254", async () => { - const circuit = await tester( - path.join(__dirname, "circuits", "comparators_greater_than.circom"), - { reduceConstraints: false } - ); - - var witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "2"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - witness = await circuit.calculateWitness({ - in: ["2", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["21888242871839275222246405745257275088548364400416034343698204186575808495615", "21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["14700167578956157622133035206181082051684666022005149731571763594754596536320", "14813245791101974219226366246228628836697624991405189344891546391637324201984"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - witness = await circuit.calculateWitness({ - in: ["21711016745476759975494879586462490265997937461626177968668583242035516932096", "14474011174884484428309352972086249796923471088432928821837627361816848891904"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - // high part greater, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011174884484428309352972086249796923471088432928821837627361816848891904", "7237005597552222214336166409043255556094097046830393569371528361322278289408"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - // high part less, low part less - witness = await circuit.calculateWitness({ - in: ["7237005584072248880760846511709748012584281710011821358101242120770473164800", "14474011168144497761521693023419496025168563420023642716202484241540946329600"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part less, low part equal - witness = await circuit.calculateWitness({ - in: ["7237005584072248880760846511709748012584281710011821358101242120770473164800", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part less, low part greater - witness = await circuit.calculateWitness({ - in: ["7237005590812235547548506460376501784339189378421107463736385241046375727104", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - - // high part equal, low part less - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "14474011168144497761521693023419496025168563420023642716202484241540946329600"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part equal, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "0"}); - // high part equal, low part greater - witness = await circuit.calculateWitness({ - in: ["14474011168144497761521693023419496025168563420023642716202484241540946329600", "14474011161404511094734033074752742253413655751614356610567341121265043767296"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - - // high part greater, low part less - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "7237005590812235547548506460376501784339189378421107463736385241046375727104"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - // high part greater, low part equal - witness = await circuit.calculateWitness({ - in: ["14474011161404511094734033074752742253413655751614356610567341121265043767296", "7237005584072248880760846511709748012584281710011821358101242120770473164800"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - // high part greater, low part greater - witness = await circuit.calculateWitness({ - in: ["14474011168144497761521693023419496025168563420023642716202484241540946329600", "7237005584072248880760846511709748012584281710011821358101242120770473164800"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "1"}); - }); - -}); - -const test_vectors = { - "10 < 0": { - "in": ["10", "0"], - "expected": 0 - }, - "10 < 10": { - "in": ["10", "10"], - "expected": 0 - }, - "10 < 11": { - "in": ["10", "11"], - "expected": 1 - }, - "10 < -1": { - "in": ["10", "-1"], - "expected": 1 - }, - "10 < -max(uint32)": { - "in": ["10", "-4294967295"], - "expected": 1 - }, - "10 < -(max(uint32)-10)": { - "in": ["10", "-4294967285"], - "expected": 1 - }, - "10 < -(max(uint32)-20)": { - "in": ["10", "-4294967275"], - "expected": 1 - }, - "10 < -(max(uint32)+1)": { - "in": ["10", "-4294967296"], - "expected": 1 - }, - "10 < p/2": { - "in": ["10", "10944121435919637611123202872628637544274182200208017171849102093287904247808"], - "expected": 1 - }, - "10 < p/2+1": { - "in": ["10", "10944121435919637611123202872628637544274182200208017171849102093287904247809"], - "expected": 1 - }, - "10 < p-1 (eq to -1)": { - "in": ["10", "21888242871839275222246405745257275088548364400416034343698204186575808495616"], - "expected": 1 - }, - "10 < x, x > (p-1)/2, x < p-1": { - "in": ["10", "14651237294507013008273219182214280847718990358813499091232105186081237893131"], - "expected": 1 - }, - -}; - - -describe("WASM: Less than", function () { - let circuit; - this.timeout(100000); - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "./circuits/", "lessthan.circom")); - }); - - for (const test_name in test_vectors) { - it(test_name, async() => { - let w = await circuit.calculateWitness({ "in": test_vectors[test_name].in }, true); - const expOut = {out: test_vectors[test_name].expected} - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - } -}); - -describe.skip("C: Less than", function () { - let circuit; - this.timeout(100000); - - before(async function() { - circuit = await c_tester(path.join(__dirname, "./circuits/", "lessthan.circom")) - }); - - for (const test_name in test_vectors) { - it(test_name, async() => { - let w = await circuit.calculateWitness({ "in": test_vectors[test_name].in }, true); - const expOut = {out: test_vectors[test_name].expected} - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - } -}); diff --git a/archive_circuits_V2/test/eddsaposeidon.test.ts b/archive_circuits_V2/test/eddsaposeidon.test.ts deleted file mode 100644 index 9a96a52d..00000000 --- a/archive_circuits_V2/test/eddsaposeidon.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -const path = require("path"); -const tester = require("circom_tester").wasm; -const buildEddsa = require("circomlibjs").buildEddsa; -const buildBabyjub = require("circomlibjs").buildBabyjub; -const chai = require("chai"); -const assert = chai.assert; - -export {}; - -describe("EdDSA Poseidon test", function () { - this.timeout(200000); - let circuit; - let eddsa; - let babyJub; - let F; - - before(async function() { - eddsa = await buildEddsa(); - babyJub = await buildBabyjub(); - F = babyJub.F; - - circuit = await tester(path.join(__dirname, "circuits", "eddsaposeidon.circom")); - }); - - it("Sign a single number", async () => { - - const prvKey = Buffer.from("0001020304050607080900010203040506070809000102030405060708090001", "hex"); - const pubKey = eddsa.prv2pub(prvKey); - - for (var i=0; i<100; i++) { - - const msg = F.e(Math.round(Math.random() * 1e10)); - const signature = eddsa.signPoseidon(prvKey, msg); - - assert(eddsa.verifyPoseidon(msg, signature, pubKey)); - - const input = { - enabled: 1, - Ax: F.toObject(pubKey[0]), - Ay: F.toObject(pubKey[1]), - R8x: F.toObject(signature.R8[0]), - R8y: F.toObject(signature.R8[1]), - S: signature.S, - M: F.toObject(msg) - }; - - // console.log(JSON.stringify(utils.stringifyBigInts(input))); - - const w = await circuit.calculateWitness(input, true); - - await circuit.checkConstraints(w); - } - }); - -}); - diff --git a/archive_circuits_V2/test/negativeNumbers.test.ts b/archive_circuits_V2/test/negativeNumbers.test.ts deleted file mode 100644 index e78731f5..00000000 --- a/archive_circuits_V2/test/negativeNumbers.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -const path = require("path"); - -const wasm_tester = require("circom_tester").wasm; -const c_tester = require("circom_tester").c; - -// Negative numbers are transformed to positive, -x == p-x -// p == 21888242871839275222246405745257275088548364400416034343698204186575808495617 -// Wasm witness calculator calculates negative numbers -const test_vectors = { - "0 == p": { - "in": ["0", "21888242871839275222246405745257275088548364400416034343698204186575808495617"], - }, - "1 == p+1 overflow": { - "in": ["1", "21888242871839275222246405745257275088548364400416034343698204186575808495618"], - }, - "-1 == p-1": { - "in": ["-1", "21888242871839275222246405745257275088548364400416034343698204186575808495616"], - }, - "-max(uint32) == p-max(uint32)": { // abs value of number fits into uint32 - "in": ["-4294967295", "21888242871839275222246405745257275088548364400416034343698204186571513528322"], - }, - "-(max(uint32)-10) == p-(max(uint32)-10)": { // abs value of number fits into uint32 - "in": ["-4294967285", "21888242871839275222246405745257275088548364400416034343698204186571513528332"], - }, - "-(max(uint32)+1) == p-(max(uint32)+1)": { // (max(uint32)+1) will not fit into uint32, so it becomes uint64 - "in": ["-4294967296", "21888242871839275222246405745257275088548364400416034343698204186571513528321"], - }, - "-(max(uint64)) == p-(max(uint64))": { // max(uint64) fits into uint64 - "in": ["-18446744073709551615", "21888242871839275222246405745257275088548364400416034343679757442502098944002"], - }, - "-(max(uint64)+1) == p-(max(uint64)+1)": { // (max(uint64)+1) will not fit into uint64, so it becomes uint96 - "in": ["-18446744073709551616", "21888242871839275222246405745257275088548364400416034343679757442502098944001"], - }, - "-(max(uint96)+1) == p-(max(uint96)+1)": { // (max(uint64)+1) will not fit into uint64, so it becomes uint96 - "in": ["-79228162514264337593543950337", "21888242871839275222246405745257275088548364400336806181183939848982264545280"], - }, - "-p/2": { - "in": ["-10944121435919637611123202872628637544274182200208017171849102093287904247808", "10944121435919637611123202872628637544274182200208017171849102093287904247809"], - }, -}; - - -describe("WASM: Eq", function () { - let circuit; - this.timeout(100000); - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "./circuits/", "eq.circom")); - }); - - for (const test_name in test_vectors) { - it(test_name, async() => { - let w = await circuit.calculateWitness({ "in": test_vectors[test_name].in }, true); - const expOut = {out: 1} - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - } -}); - -describe.skip("C: Eq", function () { - let circuit; - this.timeout(100000); - - before(async function() { - circuit = await c_tester(path.join(__dirname, "./circuits/", "eq.circom")) - }); - - for (const test_name in test_vectors) { - it(test_name, async() => { - let w = await circuit.calculateWitness({ "in": test_vectors[test_name].in }, true); - const expOut = {out: 1} - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - } -}); diff --git a/archive_circuits_V2/test/offchain/credentialAtomicQueryMTPOffChain.test.ts b/archive_circuits_V2/test/offchain/credentialAtomicQueryMTPOffChain.test.ts deleted file mode 100644 index ac2bfd94..00000000 --- a/archive_circuits_V2/test/offchain/credentialAtomicQueryMTPOffChain.test.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { describe } from "mocha"; - -const path = require("path"); -const wasmTester = require("circom_tester").wasm; -const chai = require("chai"); -const expect = chai.expect; - -describe("Test credentialAtomicQueryMTPOffChain.circom", function () { - - this.timeout(600000); - - let circuit; - - before(async () => { - circuit = await wasmTester( - path.join(__dirname, "../../circuits", "credentialAtomicQueryMTPV2.circom"), - { - output: path.join(__dirname, "circuits", "build"), - recompile: true, - }, - ); - - }); - - after(async () => { - circuit.release() - }) - - const basePath = '../../testvectorgen/credentials/mtpv2/testdata' - const tests = [ - require(`${basePath}/claimIssuedOnProfileID.json`), - require(`${basePath}/claimIssuedOnProfileID2.json`), - require(`${basePath}/claimIssuedOnUserID.json`), - require(`${basePath}/claimNonMerklized.json`), - require(`${basePath}/revoked_claim_without_revocation_check.json`), - ]; - - tests.forEach(({ desc, inputs, expOut }) => { - it(`${desc}`, async function () { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - const failTestCase = [ - require(`${basePath}/revoked_claim_with_revocation_check.json`), - ] - - failTestCase.forEach(({ desc, inputs, expOut }) => { - it(`${desc}`, async function () { - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }) - }); - - it("Checking revoked status when claim is revoked (MTP)", async () => { - const inputs = { - "requestID": "23", - "userGenesisID": "19104853439462320209059061537253618984153217267677512271018416655565783041", - "profileNonce": "0", - "claimSubjectProfileNonce": "0", - "issuerID": "23528770672049181535970744460798517976688641688582489375761566420828291073", - "issuerClaim": ["3583233690122716044519380227940806650830", "19104853439462320209059061537253618984153217267677512271018416655565783041", "10", "0", "30803922965249841627828060161", "0", "0", "0"], - "issuerClaimMtp": ["0", "0", "0", "0", "20705360459443886266589173521200199826970601318029396875976898748762842059297", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "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": "4291331108778058814748735252751774985133130667958634779040926608237236193887", - "issuerClaimRevTreeRoot": "19374975721259875597650302716689543547647001662517455822229477759190533109280", - "issuerClaimRootsTreeRoot": "0", - "issuerClaimIdenState": "6344923704725747138709470083565649368088034914458130592289968871891196214095", - "isRevocationChecked": 1, - "issuerClaimNonRevClaimsTreeRoot": "4291331108778058814748735252751774985133130667958634779040926608237236193887", - "issuerClaimNonRevRevTreeRoot": "19374975721259875597650302716689543547647001662517455822229477759190533109280", - "issuerClaimNonRevRootsTreeRoot": "0", - "issuerClaimNonRevState": "6344923704725747138709470083565649368088034914458130592289968871891196214095", - "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": "0", - "claimSchema": "180410020913331409885634153623124536270", - "claimPathNotExists": "0", - "claimPathMtp": ["0", "0", "0", "0", "0", "0", "0", "0", "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": "0", - "claimPathValue": "0", - "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"] - }; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }); - -}); diff --git a/archive_circuits_V2/test/offchain/credentialAtomicQuerySigOffChain.test.ts b/archive_circuits_V2/test/offchain/credentialAtomicQuerySigOffChain.test.ts deleted file mode 100644 index 45bf4b3b..00000000 --- a/archive_circuits_V2/test/offchain/credentialAtomicQuerySigOffChain.test.ts +++ /dev/null @@ -1,351 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasmTester = require("circom_tester").wasm; -const chai = require("chai"); -const expect = chai.expect; - -describe("Test credentialAtomicQuerySigOffChain.circom", function () { - - this.timeout(600000); - - let circuit; - - before(async () => { - circuit = await wasmTester( - path.join(__dirname, "../../circuits", "credentialAtomicQuerySigV2.circom"), - { - output: path.join(__dirname, "circuits", "build"), - recompile: true, - }, - ); - - }); - - after(async () => { - circuit.release() - }) - - const basePath = '../../testvectorgen/credentials/sigv2/testdata' - const tests = [ - require(`${basePath}/jsonld_non_inclusion.json`), - require(`${basePath}/profileID_subject.json`), - require(`${basePath}/profileID_subject_profileID2.json`), - require(`${basePath}/profileID_subject_userid.json`), - require(`${basePath}/regular_claim.json`), - require(`${basePath}/revoked_claim_without_revocation_check.json`), - require(`${basePath}/userID_subject.json`) - ]; - - tests.forEach(({desc, inputs, expOut}) => { - it(`${desc}`, async function () { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - const failTestCase = [ - require(`${basePath}/revoked_claim_with_revocation_check.json`) - ] - - failTestCase.forEach(({ desc, inputs, expOut }) => { - it(`${desc}`, async function () { - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }) - }); - - - it("Checking revoked status when claim is revoked (Sig)", async () => { - const inputs = { - "requestID": "23", - "userGenesisID": "23148936466334350744548790012294489365207440754509988986684797708370051073", - "profileNonce": "0", - "claimSubjectProfileNonce": "0", - "issuerID": "21933750065545691586450392143787330185992517860945727248803138245838110721", - "issuerClaim": [ - "3583233690122716044519380227940806650830", - "23148936466334350744548790012294489365207440754509988986684797708370051073", - "10", - "0", - "30803922965249841627828060161", - "0", - "0", - "0" - ], - "issuerClaimNonRevClaimsTreeRoot": "20643387758736831799596675626240785455902781070167728593409367019626753600795", - "issuerClaimNonRevRevTreeRoot": "19374975721259875597650302716689543547647001662517455822229477759190533109280", - "issuerClaimNonRevRootsTreeRoot": "0", - "issuerClaimNonRevState": "20420704177203139055971454163395877029462021737850567671726924780413332537", - "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": "0", - "claimSchema": "180410020913331409885634153623124536270", - "issuerClaimSignatureR8x": "6009541096871527792243386384096231340067474190101091530507148551135935669869", - "issuerClaimSignatureR8y": "21407298901003665469054234025891175478757417093942142815529365365949388290718", - "issuerClaimSignatureS": "1061441685873832236639155829779552898548912415538872104865210006348646647963", - "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": "1", - "issuerAuthClaimNonRevMtpAuxHv": "0", - "issuerAuthClaimNonRevMtpNoAux": "0", - "issuerAuthClaimsTreeRoot": "20643387758736831799596675626240785455902781070167728593409367019626753600795", - "issuerAuthRevTreeRoot": "19374975721259875597650302716689543547647001662517455822229477759190533109280", - "issuerAuthRootsTreeRoot": "0", - "claimPathNotExists": "0", - "claimPathMtp": [ - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "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": "0", - "claimPathValue": "0", - "operator": 1, - "slotIndex": 2, - "timestamp": "1642074362", - "isRevocationChecked": 1, - "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" - ] - }; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }); -}); diff --git a/archive_circuits_V2/test/onchain/credentialAtomicQueryMTPOnChain.test.ts b/archive_circuits_V2/test/onchain/credentialAtomicQueryMTPOnChain.test.ts deleted file mode 100644 index 816c85eb..00000000 --- a/archive_circuits_V2/test/onchain/credentialAtomicQueryMTPOnChain.test.ts +++ /dev/null @@ -1,56 +0,0 @@ - - -import { expect } from "chai" -import path from "path"; -import { wasm } from "circom_tester"; - -describe("Test On Chain credentialAtomicQueryMTPOnChain.circom", function () { - - this.timeout(600000); - - let circuit; - - before(async () => { - - circuit = await wasm( - path.join(__dirname, "../../circuits/", "credentialAtomicQueryMTPV2OnChain.circom"), - { - output: path.join(__dirname, "circuits", "build"), - recompile: true, - }, - ); - - }); - - after(async () => { - circuit.release() - }) - const basePath = '../../testvectorgen/credentials/onchain/mtpv2/testdata' - const tests = [ - require(`${basePath}/claimIssuedOnProfileID.json`), - require(`${basePath}/claimIssuedOnProfileID2.json`), - require(`${basePath}/claimIssuedOnUserID.json`), - require(`${basePath}/claimNonMerklized.json`), - require(`${basePath}/revoked_claim_without_revocation_check.json`) - ]; - - tests.forEach(({ desc, inputs, expOut }) => { - it(`${desc}`, async function () { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - const failTestCase = require(`${basePath}/revoked_claim_with_revocation_check.json`) - it(failTestCase.desc, async () => { - const { inputs } = failTestCase - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }); - -}); diff --git a/archive_circuits_V2/test/onchain/credentialAtomicQuerySigOnChain.test.ts b/archive_circuits_V2/test/onchain/credentialAtomicQuerySigOnChain.test.ts deleted file mode 100644 index 270e43a9..00000000 --- a/archive_circuits_V2/test/onchain/credentialAtomicQuerySigOnChain.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { expect } from "chai" -import path from "path"; -import { wasm } from "circom_tester"; - -describe("On Chain: Test credentialAtomicQuerySigOnChain.circom", function () { - - this.timeout(600000); - - let circuit; - - before(async () => { - circuit = await wasm( - path.join(__dirname, "../../circuits", "credentialAtomicQuerySigV2OnChain.circom"), - { - output: path.join(__dirname, "circuits", "build"), - recompile: true, - }, - ); - - }); - - after(async () => { - circuit.release() - }) - - const basePath = '../../testvectorgen/credentials/onchain/sigv2/testdata' - const tests = [ - - require(`${basePath}/jsonld_non_inclusion.json`), - require(`${basePath}/profileID_subject_profileID2.json`), - require(`${basePath}/profileID_subject_userid.json`), - require(`${basePath}/profileID_subject.json`), - require(`${basePath}/regular_claim.json`), - require(`${basePath}/revoked_claim_without_revocation_check.json`), - require(`${basePath}/userID_subject.json`) - ]; - - tests.forEach(({ desc, inputs, expOut }) => { - it(`${desc}`, async function () { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - const failTestCase = require(`${basePath}/revoked_claim_with_revocation_check.json`); - it(failTestCase.desc, async () => { - const { inputs } = failTestCase - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template checkClaimNotRevoked"); - }); -}); diff --git a/archive_circuits_V2/test/poseidon.test.ts b/archive_circuits_V2/test/poseidon.test.ts deleted file mode 100644 index 90001183..00000000 --- a/archive_circuits_V2/test/poseidon.test.ts +++ /dev/null @@ -1,134 +0,0 @@ -const path = require("path"); -const tester = require("circom_tester").wasm; -const buildPoseidon = require("circomlibjs").buildPoseidonOpt; -let poseidon; -const chai = require("chai"); -const assert = chai.assert; - -export {}; - -describe("poseidon test", function () { - this.timeout(200000); - - before(async function() { - poseidon = await buildPoseidon(); - }); - - // before(async () => { - // poseidon = await circomlibjs.buildPoseidon(); - // }); - // before(async () => { - // globalThis.curve_bn128.terminate(); - // }); - - it("Test circomlib/poseidon. 3 inputs", async () => { - const circuit = await tester( - path.join(__dirname, "circuits", "poseidon.circom"), - { reduceConstraints: false } - ); - - let witness = await circuit.calculateWitness({ - in: ["0", "0", "0"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "5317387130258456662214331362918410991734007599705406860481038345552731150762"}); - - witness = await circuit.calculateWitness({ - in: ["1", "0", "0"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "16319005924338521988144249782199320915969277491928916027259324394544057385749"}); - - // check with different inputs - witness = await circuit.calculateWitness({ - in: ["2", "0", "0"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "13234400070188801104792523922697988244748411503422448631147834118387475842488"}); - - const testValues = ["72057594037927936", "1", "20634138280259599560273310290025659992320584624461316485434108770067472477956"]; - witness = await circuit.calculateWitness({ - in: testValues - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "3135714887432857880402997813814046724922969450336546007917491784497158924950"}); - }); - - it("Test circomlibjs/poseidon. 3 inputs", async () => { - // check circomlib javascript poseidon output - let jsOut = poseidon([1, 0, 0]); - assert(poseidon.F.eq(poseidon.F.e("16319005924338521988144249782199320915969277491928916027259324394544057385749"), jsOut)); - - // check circomlib javascript poseidon output - const testValues = ["72057594037927936", "1", "20634138280259599560273310290025659992320584624461316485434108770067472477956"]; - jsOut = poseidon(testValues); - assert(poseidon.F.eq(poseidon.F.e("3135714887432857880402997813814046724922969450336546007917491784497158924950"), jsOut)); - }); - - it("Test circomlib/poseidon. 14 inputs", async () => { - - // poseidon with 14 inputs - const circuit = await tester( - path.join(__dirname, "circuits", "poseidon14.circom"), - { reduceConstraints: false } - ); - - let witness = await circuit.calculateWitness({ - in: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "8354478399926161176778659061636406690034081872658507739535256090879947077494"}); - - // different inputs - witness = await circuit.calculateWitness({ - in: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "0", "0", "0", "0"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "5540388656744764564518487011617040650780060800286365721923524861648744699539"}); - - }); - - it("Test circomlibjs/poseidon. 14 inputs", async () => { - - // check circomlib javascript poseidon output - let jsOut = poseidon([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]); - assert(poseidon.F.eq(poseidon.F.e("8354478399926161176778659061636406690034081872658507739535256090879947077494"), jsOut)); - - // check circomlib javascript poseidon output - jsOut = poseidon([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0]); - assert(poseidon.F.eq(poseidon.F.e("5540388656744764564518487011617040650780060800286365721923524861648744699539"), jsOut)); - }); - - it("Test circomlib/poseidon. 16 inputs", async () => { - - // poseidon with 16 inputs - const circuit = await tester( - path.join(__dirname, "circuits", "poseidon16.circom"), - { reduceConstraints: false } - ); - - let witness = await circuit.calculateWitness({ - in: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "9989051620750914585850546081941653841776809718687451684622678807385399211877"}); - - witness = await circuit.calculateWitness({ - in: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "0", "0", "0", "0", "0", "0"] - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, {out: "11882816200654282475720830292386643970958445617880627439994635298904836126497"}); - }); - - it("Test circomlibjs/poseidon. 16 inputs", async () => { - - // check circomlib javascript poseidon output - let jsOut = poseidon([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); - assert(poseidon.F.eq(poseidon.F.e("9989051620750914585850546081941653841776809718687451684622678807385399211877"), jsOut)); - - // check circomlib javascript poseidon output - jsOut = poseidon([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0]); - assert(poseidon.F.eq(poseidon.F.e("11882816200654282475720830292386643970958445617880627439994635298904836126497"), jsOut)); - }); -}); - diff --git a/archive_circuits_V2/test/query/in.test.ts b/archive_circuits_V2/test/query/in.test.ts deleted file mode 100644 index 6a47e67e..00000000 --- a/archive_circuits_V2/test/query/in.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test IN operator:", async function() { - const tests = [ - {desc: "value in the list", - input: { - in: "123", - value: ["123", "9999", "5555"], - }, - expOut: {out: "1"}}, - - {desc: "multiple values in the list", - input: { - in: "123", - value: ["123", "123", "999"], - }, - expOut: {out: "1"}}, - {desc: "value not in the list", - input: { - in: "123", - value: ["124", "888", "999"], - }, - expOut: {out: "0"}}, - - ]; - - let circuit; - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/query/", "inTest.circom")); - }); - - tests.forEach(({desc, input, expOut}) => { - it(`${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); -}); diff --git a/archive_circuits_V2/test/query/query.test.ts b/archive_circuits_V2/test/query/query.test.ts deleted file mode 100644 index d4381af6..00000000 --- a/archive_circuits_V2/test/query/query.test.ts +++ /dev/null @@ -1,643 +0,0 @@ -import {describe} from "mocha"; -import {expect} from "chai"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; -const c_tester = require("circom_tester").c; -const chai = require("chai"); -const assert = chai.assert; - -export {}; - -const NOOP = "0"; // no operation, skip query verification if set -const EQ = "1"; // equals -const LT = "2"; // less than -const GT = "3"; // greater than -const IN = "4"; // in -const NIN = "5"; // not in -const NEQ = "6"; // not equals - - -describe("Test query", function () { - let circuit; - - before(async function () { - this.timeout(60000) - circuit = await wasm_tester(path.join(__dirname, "../circuits/query/", "queryTest.circom")); - }); - - describe("#Noop", function () { - it("#Noop (true)", async () => { - const inputs = { - in: "10", - operator: NOOP, - value: ["11", "0", "0"], - } - - const expOut = { out: 1, value: ["11", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#Noop (true)", async () => { - const inputs = { - in: "0", - operator: NOOP, - value: ["0", "0", "0"], - } - - const expOut = { out: 1, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - describe("#IsEqual", function () { - it("#IsEqual (false)", async () => { - const inputs = { - in: "10", - operator: EQ, - value: ["11", "0", "0"], - } - - const expOut = { out: 0, value: ["11", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IsEqual (true)", async () => { - const inputs = { - in: "10", - operator: EQ, - value: ["10", "0", "0"], - } - - const expOut = { out: 1, value: ["10", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IsEqual. Zero in. (false)", async () => { - const inputs = { - in: "0", - operator: EQ, - value: ["11", "0", "0"], - } - - const expOut = { out: 0, value: ["11", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IsEqual. Zero value. (false)", async () => { - const inputs = { - in: "10", - operator: EQ, - value: ["0", "0", "0"], - } - - const expOut = { out: 0, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IsEqual. Zero both. (true)", async () => { - const inputs = { - in: "0", - operator: EQ, - value: ["0", "0", "0"], - } - - const expOut = { out: 1, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - }); - - describe("#LessThan", function () { - it("#LessThan - 10 < 11 (true)", async () => { - const w = await circuit.calculateWitness({ - in: "10", - operator: LT, - value: ["11", "0", "0"], - }, true); - - const expOut = { out: 1, value: ["11", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan - 10 = 10 (false)", async () => { - - const w1 = await circuit.calculateWitness({ - in: "10", - operator: LT, - value: ["10", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["10", "0", "0"] } - - await circuit.assertOut(w1, expOut); - await circuit.checkConstraints(w1); - }); - - it("#LessThan - 10 < 9 (false)", async () => { - const w2 = await circuit.calculateWitness({ - in: "10", - operator: LT, - value: ["9", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["9", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#LessThan - 0 < 11 (true)", async () => { - const w = await circuit.calculateWitness({ - in: "0", - operator: LT, - value: ["11", "0", "0"], - }, true); - - const expOut = { out: 1, value: ["11", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan - 10 < 0 (false)", async () => { - const w = await circuit.calculateWitness({ - in: "10", - operator: LT, - value: ["0", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["0", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan - 0 < 0 (false)", async () => { - const w = await circuit.calculateWitness({ - in: "0", - operator: LT, - value: ["0", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["0", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan: p-1 < 10 should be false", async () => { - const w = await circuit.calculateWitness({ - in: "-1", - operator: LT, - value: ["10", "0", "0"], - }, false); - - const expOut = { out: 0, value: ["10", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan: 10 < p-1 should be true", async () => { - const w = await circuit.calculateWitness({ - in: "10", - operator: LT, - value: ["-1", "0", "0"], - }, false); - - const expOut = { - out: 1, - value: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "0", "0"] - } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan: p-4294967290 < 10 should be false", async () => { - const w = await circuit.calculateWitness({ - in: "-4294967290", - operator: LT, - value: ["10", "0", "0"], - }, false); - - const expOut = { out: 0, value: ["10", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan: p-345345345345345114294967290 < 10 should false", async () => { - const w = await circuit.calculateWitness({ - in: "-345345345345345114294967290", - // 1111111111111111111111111110011001100011011111010011010000000110 - // 111111101110001001010110010010000101000011100001100000100111000000101101001001000010010000000110 - operator: LT, - value: ["10", "0", "0"], - }, false); - - const expOut = { out: 0, value: ["10", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#LessThan: 1465...3131 < 10 should be false", async () => { - const w = await circuit.calculateWitness({ - in: "14651237294507013008273219182214280847718990358813499091232105186081237893131", - operator: LT, - value: ["10", "0", "0"], - }, false); - - const expOut = { out: 0, value: ["10", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - - describe("#GreaterThan", function () { - it("#GreaterThan - 11 > 10 (true)", async () => { - const w = await circuit.calculateWitness({ - in: "11", - operator: GT, - value: ["10", "0", "0"], - }, true); - - const expOut = { out: 1, value: ["10", "0", "0"] } - - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#GreaterThan - 11 > 11 (false)", async () => { - - const w1 = await circuit.calculateWitness({ - in: "11", - operator: GT, - value: ["11", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["11", "0", "0"] } - - await circuit.assertOut(w1, expOut); - await circuit.checkConstraints(w1); - }); - - it("#GreaterThan - 11 > 12 (false) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "11", - operator: GT, - value: ["12", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["12", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - 0 > 12 (false) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "0", - operator: GT, - value: ["12", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["12", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - 12 > 0 (true) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "12", - operator: GT, - value: ["0", "0", "0"], - }, true); - - const expOut = { out: 1, value: ["0", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - 0 > 0 (false) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "0", - operator: GT, - value: ["0", "0", "0"], - }, true); - - const expOut = { out: 0, value: ["0", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - p-1 > p-2 (true) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "-1", - operator: GT, - value: ["-2", "0", "0"], - }, true); - - const expOut = { - out: 1, - value: ["21888242871839275222246405745257275088548364400416034343698204186575808495615", "0", "0"] - } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - p-2 > p-1 (false) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "-2", - operator: GT, - value: ["-1", "0", "0"], - }, true); - - const expOut = { - out: 0, - value: ["21888242871839275222246405745257275088548364400416034343698204186575808495616", "0", "0"] - } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - it("#GreaterThan - p-1 > 0 (true) ", async () => { - const w2 = await circuit.calculateWitness({ - in: "-1", - operator: GT, - value: ["0", "0", "0"], - }, true); - - const expOut = { out: 1, value: ["0", "0", "0"] } - - await circuit.assertOut(w2, expOut); - await circuit.checkConstraints(w2); - }); - - }); - - describe("#IN", function () { - it("#IN 10 in ['12', '11', '10'] (true)", async () => { - const inputs = { - in: "10", - operator: IN, - value: ["12", "11", "10"], - } - - const expOut = { out: 1, value: ["12", "11", "10"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IN 11 in [`10`, `10`, `0`] (false)", async () => { - const inputs = { - in: "11", - operator: IN, - value: ["10", "10", "0"], - } - - const expOut = { out: 0, value: ["10", "10", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IN 0 in [`0`, `10`, `0`] (true)", async () => { - const inputs = { - in: "0", - operator: IN, - value: ["0", "10", "0"], - } - - const expOut = { out: 1, value: ["0", "10", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IN 0 IN [`10`, `11`, `12`] (false)", async () => { - const inputs = { - in: "0", - operator: IN, - value: ["10", "11", "12"], - } - - const expOut = { out: 0, value: ["10", "11", "12"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IN 11 in [`0`, `0`, `0`] (false)", async () => { - const inputs = { - in: "11", - operator: IN, - value: ["0", "0", "0"], - } - - const expOut = { out: 0, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#IN 0 in [`0`, `0`, `0`] (true)", async () => { - const inputs = { - in: "0", - operator: IN, - value: ["0", "0", "0"], - } - - const expOut = { out: 1, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - }); - - describe("#NOTIN", function () { - it("#NOTIN 10 NOT in ['12', '11', '11'] (true)", async () => { - const inputs = { - in: "10", - operator: NIN, - value: ["12", "11", "13"], - } - - const expOut = { out: 1, value: ["12", "11", "13"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#NOTIN 10 NOT in [`10`, `10`, `0`] (false)", async () => { - const inputs = { - in: "10", - operator: NIN, - value: ["10", "10", "0"], - } - - const expOut = { out: 0, value: ["10", "10", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#NOTIN 0 NOT in [`10`, `10`, `10`] (true)", async () => { - const inputs = { - in: "0", - operator: NIN, - value: ["10", "10", "10"], - } - - const expOut = { out: 1, value: ["10", "10", "10"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#NOTIN 10 NOT in [`0`, `0`, `0`] (true)", async () => { - const inputs = { - in: "10", - operator: NIN, - value: ["0", "0", "0"], - } - - const expOut = { out: 1, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("#NOTIN 0 NOT in [`0`, `0`, `0`] (false)", async () => { - const inputs = { - in: "0", - operator: NIN, - value: ["0", "0", "0"], - } - - const expOut = { out: 0, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - }); - - describe("#NotEqual", function () { - it("10 != 11 (true)", async () => { - const inputs = { - in: "10", - operator: NEQ, - value: ["11", "0", "0"], - } - - const expOut = { out: 1, value: ["11", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("10 != 10 (false)", async () => { - const inputs = { - in: "10", - operator: NEQ, - value: ["10", "0", "0"], - } - - const expOut = { out: 0, value: ["10", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("0 != 11 (true)", async () => { - const inputs = { - in: "0", - operator: NEQ, - value: ["11", "0", "0"], - } - - const expOut = { out: 1, value: ["11", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("10 != 0 (true)", async () => { - const inputs = { - in: "10", - operator: NEQ, - value: ["0", "0", "0"], - } - - const expOut = { out: 1, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - it("0 != 0 (false)", async () => { - const inputs = { - in: "0", - operator: NEQ, - value: ["0", "0", "0"], - } - - const expOut = { out: 0, value: ["0", "0", "0"] } - - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - - }); - -}); diff --git a/archive_circuits_V2/test/stateTransition.test.ts b/archive_circuits_V2/test/stateTransition.test.ts deleted file mode 100644 index 5121b8f9..00000000 --- a/archive_circuits_V2/test/stateTransition.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasmTester = require("circom_tester").wasm; - -// export {}; - -describe("Test stateTransition.circom", function() { - - this.timeout(600000); - - let circuit; - - before(async () => { - circuit = await wasmTester( - path.join(__dirname, "../circuits/", "stateTransition.circom"), - { - output: path.join(__dirname, "circuits", "build"), - recompile: true, - reduceConstraints: false, - }, - ); - - }); - - after(async () => { - circuit.release() - }) - - const basePath = '../testvectorgen/statetransition/testdata' - const tests = [ - require(`${basePath}/genesis_state.json`), - require(`${basePath}/not_genesis_state.json`), - ]; - - tests.forEach(({desc, inputs, expOut}) => { - it(`${desc}`, async function() { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - await circuit.checkConstraints(w); - }); - }); - -}); diff --git a/archive_circuits_V2/test/sybil/sybil.test.ts b/archive_circuits_V2/test/sybil/sybil.test.ts deleted file mode 100644 index da1831b9..00000000 --- a/archive_circuits_V2/test/sybil/sybil.test.ts +++ /dev/null @@ -1,108 +0,0 @@ -import {describe} from "mocha"; -import {expect} from "chai"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("sybilTestMTP.circom:", async function() { - - const tests = [ - {"desc":"Sybil resistance - Happy flow - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}}, - {"desc":"Sybil resistance - Happy flow with Profile - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}}, - {"desc":"Sybil resistance - Happy flow with Profile and Subject - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","24497320812635010775435456013830217801375919178980935564312517783529521153","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"7548989542047724266078821565632990941857981951889314326285276071945019646899","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"5506222531691139844295896785526877493099929256302137379679372984046649128508","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"7548989542047724266078821565632990941857981951889314326285276071945019646899","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"5506222531691139844295896785526877493099929256302137379679372984046649128508","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} - ]; - - let circuit; - this.timeout(300000); - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "sybilTestMTP.circom"), - { - output: path.join(__dirname, "../circuits", "build/sybil"), - recompile: true, - }, - ); - }); - - tests.forEach(({desc, inputs, expOut}) => { - it(`${desc}`, async function() { - const w = await circuit.calculateWitness(inputs, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, expOut); - }); - }); - - it("Invalid identity - MTP (negative test)", async () => { - const inputs = {"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"10641123066370855533694855298155407650121731682640157844161931325402134200022","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"198033221994711363624188984527345351988850209115289407611174288334185461348","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23921464641675944808093348635977316854285344821293312922130083879572996097","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"}; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template verifyCredentialSubjectProfile"); - }); - - it("Invalid GIST - MTP (negative test)", async () => { - const inputs = {"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"9031636983330134044879452748194793133599690422740028335553282168244414780237","gistMtp":["9054077202653694725190129562729426419405710792276939073869944863201489138082","14218827602097913497782608311388761513660285528499590827800641410537362569671","0","0","0","0","0","0","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":"5","gistMtpAuxHv":"5","gistMtpNoAux":"0","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"}; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template SMTVerifier"); - }); - -}); - - - -describe("sybilTestSig.circom:", async function() { - - const tests = [ - {"desc":"Sybil resistance - Happy flow - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}}, - {"desc":"Sybil resistance - Happy flow with Profile - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}}, - {"desc":"Sybil resistance - Happy flow with Profile and Subject - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","24497320812635010775435456013830217801375919178980935564312517783529521153","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","issuerClaimSignatureR8x":"5062489673270143139851128901418434272852532085699303350493305260614640477937","issuerClaimSignatureR8y":"8809727142363129669248157438827701160102550085774460055216619833243024377146","issuerClaimSignatureS":"319962668067660034966032225712389365026815048082152194780874537233943145769","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} - ]; - let circuit; - this.timeout(300000); - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "sybilTestSig.circom"), - { - output: path.join(__dirname, "../circuits", "build/sybilSig"), - recompile: true, - }, - ); - }); - - tests.forEach(({desc, inputs, expOut}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(inputs, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, expOut); - }); - }); - - - it("Invalid identity - Sig (negative test)", async () => { - const inputs = {"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"19930074693582080090599965271438492109206824237895138094604303433173470305999","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"13286474075154368429629578180874038947877009895753065839532953608118877058377","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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","crs":"123456789","userGenesisID":"28912207382273238718376665459845931532162180112258438815303287050888282113","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"}; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template verifyCredentialSubjectProfile"); - }); - - it("Invalid GIST - Sig (negative test)", async () => { - const inputs = {"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"9031636983330134044879452748194793133599690422740028335553282168244414780237","gistMtp":["9054077202653694725190129562729426419405710792276939073869944863201489138082","14218827602097913497782608311388761513660285528499590827800641410537362569671","0","0","0","0","0","0","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":"5","gistMtpAuxHv":"5","gistMtpNoAux":"0","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"}; - - let error; - await circuit.calculateWitness(inputs, true).catch((err) => { - error = err; - }); - expect(error.message).to.include("Error in template SMTVerifier"); - }); -}); \ No newline at end of file diff --git a/archive_circuits_V2/test/utils/claimUtils_getClaimMerklizeRoot.test.ts b/archive_circuits_V2/test/utils/claimUtils_getClaimMerklizeRoot.test.ts deleted file mode 100644 index e23310c0..00000000 --- a/archive_circuits_V2/test/utils/claimUtils_getClaimMerklizeRoot.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test getClaimMerklizeRoot:", async function() { - const tests = [ - { - desc: "Test claim merklize flag", - inputs: {claim: ["10889035741470030830827987437816582766592", "0", "999", "0", "0", "0", "0", "0"]}, - expOut: {out: 999, flag: 1}, - }, - { - desc: "Test claim merklize flag", - inputs: {claim: ["21778071482940061661655974875633165533184", "0", "999", "888", "0", "0", "777", "666"]}, - expOut: {out: 777, flag: 1}, - }, - ]; - - let circuit; - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "claimUtils_getClaimMerklizeRoot.circom")); - }); - - tests.forEach(({desc, inputs, expOut}) => { - it(`getClaimMerklizeFlag ${desc}`, async function() { - const w = await circuit.calculateWitness(inputs, true); - await circuit.assertOut(w, expOut); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/getClaimExpiration.test.ts b/archive_circuits_V2/test/utils/getClaimExpiration.test.ts deleted file mode 100644 index 2633362a..00000000 --- a/archive_circuits_V2/test/utils/getClaimExpiration.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe('Test getClaimExpiration:', async function() { - const tests = [ - {desc:'success', - input: {claim:["2722258935367507707706996859454145691697", - "0", - "0", - "0", - "30803922974473213664682835967", // expiration 1669884010 - "0", - "0", - "0"],}, - expOut: {expiration:1669884010}}, - - { - desc: 'expiration 0 revocation 0', - input: {claim:["2722258935367507707706996859454145691697", - "0", - "0", - "0", - "0", // revocation 0 && expiration 0 - "0", - "0", - "0"]}, - expOut: {expiration: 0} - }, - - { - desc: "expiration max revocation 0", - input: { - claim: ["2722258935367507707706996859454145691697", - "0", - "0", - "0", - "170141183460469231713240559642174554112", // revocation 0 && expiration MAX - "0", - "0", - "0"] - }, - expOut: {expiration: "9223372036854775807"} - }, - - { - desc: 'expiration max & revocation max', - input: { - claim: ["2722258935367507707706996859454145691697", - "0", - "0", - "0", - "170141183460469231731687303715884105727", // revocation MAX && expiration MAX - "0", - "0", - "0"] - }, - expOut: {expiration: "9223372036854775807"} - } - - - ]; - - let circuit; - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_getClaimExpiration.circom")); - }); - - tests.forEach(({desc, input,expOut}) => { - it(`getClaimExpiration ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.assertOut(w, expOut); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/getClaimSubjectOtherIden.test.ts b/archive_circuits_V2/test/utils/getClaimSubjectOtherIden.test.ts deleted file mode 100644 index cdfa3631..00000000 --- a/archive_circuits_V2/test/utils/getClaimSubjectOtherIden.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test", function () { - let circuit; - let testData = {in:{},expOut:{}} - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_getClaimSubjectOtherIden.circom")); - }) - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - }) - - it("#self subject", async () => { - // generated with: claim, err := NewClaim(schemaHash) - const claim = ["0", "0", "0", "0", "0", "0", "0", "0"] - - testData.in = {claim: claim}; - testData.expOut = {id: "0"}; - }) - - it("#subject position index", async () => { - // generated with - /* - id, err := IDFromString("114vgnnCupQMX4wqUBjg5kUya3zMXfPmKc9HNH4TSE") - claim, err := NewClaim(schemaHash, WithID(id, IDPositionIndex)) - */ - const claim = [ - "680564733841876926926749214863536422912", - "436519927146362718106026092069337374589932286960467750019485473174216638464", - "0", - "0", - "0", - "0", - "0", - "0", - ]; - - testData.in = {claim: claim}; - testData.expOut = {id: "436519927146362718106026092069337374589932286960467750019485473174216638464"}; - }); - - it("#subject position value", async () => { - // generated with - /* - id, err := IDFromString("114vgnnCupQMX4wqUBjg5kUya3zMXfPmKc9HNH4TSE") - claim, err := NewClaim(schemaHash, WithID(id, IDPositionValue)) - */ - const claim = [ - "1020847100762815390390123822295304634368", - "0", - "0", - "0", - "0", - "436519927146362718106026092069337374589932286960467750019485473174216638464", - "0", - "0", - ]; - - testData.in = {claim: claim}; - testData.expOut = {id: "436519927146362718106026092069337374589932286960467750019485473174216638464"}; - }); -}) diff --git a/archive_circuits_V2/test/utils/getSubjectLocation.test.ts b/archive_circuits_V2/test/utils/getSubjectLocation.test.ts deleted file mode 100644 index afbc9df4..00000000 --- a/archive_circuits_V2/test/utils/getSubjectLocation.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test", function () { - let circuit; - let testData = {in:{},expOut:{}} - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_getSubjectLocation.circom")); - }) - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - }) - - it("#self location", async () => { - // this claim generated with claim, err := NewClaim(schemaHash) - const claim = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 0}; - }); - - it("#index location", async () => { - // this claim generated with claim, err := NewClaim(schemaHash, WithID(ID{}, IDPositionIndex)) - const claim = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 2}; - }); - - it("#value location", async () => { - // this claim generated with `claim, err := NewClaim(schemaHash, WithID(ID{}, IDPositionValue))` - const claim = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 3}; - }); -}) diff --git a/archive_circuits_V2/test/utils/getValueByIndex.test.ts b/archive_circuits_V2/test/utils/getValueByIndex.test.ts deleted file mode 100644 index 0cbfe51a..00000000 --- a/archive_circuits_V2/test/utils/getValueByIndex.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const tester = require("circom_tester").wasm; -const chai = require("chai"); -const assert = chai.assert; - -export {}; - -const Q = "21888242871839275222246405745257275088548364400416034343698204186575808495616"; - -describe("utils#getValueByIndex", function() { - let circuit; - let testData = {in:{},expOut:{}}; - const claim =["0", - "1", - "2", - "3", - "4", - "5", - Q, - "7"]; - - before(async function() { - circuit = await tester( - path.join(__dirname, "../circuits/utils", "utils_GetValueByIndex.circom"), - ); - }); - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - circuit.release(); - }) - - it("#Get slot index 0", async () => { - testData.in = {claim: claim, index: "0"}; - testData.expOut = {value: 0}; - }); - - it("#Get slot index 1", async () => { - testData.in = {claim: claim, index: "1"}; - testData.expOut = {value: 1}; - }); - - it("#Get slot index 2", async () => { - testData.in = {claim: claim, index: "2"}; - testData.expOut = {value: 2}; - }); - - it("#Get slot index 7 max field value", async () => { - testData.in = {claim: claim, index: "6"}; - testData.expOut = {value: Q}; - }); - - it("#Get slot index 8", async () => { - testData.in = {claim: claim, index: "7"}; - testData.expOut = {value: 7}; - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_CalculateIdChecksum.test.ts b/archive_circuits_V2/test/utils/idUtils_CalculateIdChecksum.test.ts deleted file mode 100644 index 1ad682fd..00000000 --- a/archive_circuits_V2/test/utils/idUtils_CalculateIdChecksum.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "First", - input: { - typ: "49648", - genesis: "12590477270745565760216918871818154904274440992307045641577748017", - }, - output: { - out: "4565", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_CalculateIdChecksum.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_CalculateIdChecksum"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_GatherID.test.ts b/archive_circuits_V2/test/utils/idUtils_GatherID.test.ts deleted file mode 100644 index 0124ef1c..00000000 --- a/archive_circuits_V2/test/utils/idUtils_GatherID.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "First", - input: { - typ: "49648", - genesis: "12590477270745565760216918871818154904274440992307045641577748017", - checksum: "4565", - }, - output: { - out: "31507297202617339271037322087289804665039118987722686458860089520937878000", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_GatherID.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_GatherID"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_NewID.test.ts b/archive_circuits_V2/test/utils/idUtils_NewID.test.ts deleted file mode 100644 index 63aeaf47..00000000 --- a/archive_circuits_V2/test/utils/idUtils_NewID.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "First", - input: { - typ: "49648", - genesis: "12590477270745565760216918871818154904274440992307045641577748017", - }, - output: { - out: "31507297202617339271037322087289804665039118987722686458860089520937878000", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_NewID.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_NewID"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_ProfileID.test.ts b/archive_circuits_V2/test/utils/idUtils_ProfileID.test.ts deleted file mode 100644 index 9a4c4629..00000000 --- a/archive_circuits_V2/test/utils/idUtils_ProfileID.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "Salted hash", - input: { - in: "23630567111950550539435915649280822148510307443797111728722609533581131776", //379949150130214723420589610911161895495647789006649785264738141299135414272 - nonce: "10", - }, - output: { - out: "25425363284463910957419549722021124450832239517990785975889689633068548096", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_ProfileID.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_ProfileID"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_SelectProfile.test.ts b/archive_circuits_V2/test/utils/idUtils_SelectProfile.test.ts deleted file mode 100644 index 1c56afbe..00000000 --- a/archive_circuits_V2/test/utils/idUtils_SelectProfile.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils_SelectProfile.circom:", async function() { - - const tests = [ - { - desc: "Salted hash", - input: { - in: "23630567111950550539435915649280822148510307443797111728722609533581131776", //379949150130214723420589610911161895495647789006649785264738141299135414272 - nonce: "10", - }, - output: { - out: "25425363284463910957419549722021124450832239517990785975889689633068548096", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_SelectProfile.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_ProfileID"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`idUtils ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_SplitID.test.ts b/archive_circuits_V2/test/utils/idUtils_SplitID.test.ts deleted file mode 100644 index f8d61d80..00000000 --- a/archive_circuits_V2/test/utils/idUtils_SplitID.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "First", - input: { - id: "23630567111950550539435915649280822148510307443797111728722609533581131776", - }, - output: { - typ: "0", - genesis: "89864607032023545024815867714905163118918335844094091816545341738", - checksum: "3423", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_SplitID.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_SplitID"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/idUtils_TakeNBits.test.ts b/archive_circuits_V2/test/utils/idUtils_TakeNBits.test.ts deleted file mode 100644 index 8d496b97..00000000 --- a/archive_circuits_V2/test/utils/idUtils_TakeNBits.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -// inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("idUtils.circom:", async function() { - - const tests = [ - { - desc: "First", - input: { - in: "13843376158434186874150155371608112991467708075683980446964675987616037973262", - }, - output: { - out: "423621611607500778482958", - }, - }, - ]; - - let circuit; - this.timeout(300000) - - before(async () => { - circuit = await wasm_tester( - path.join(__dirname, "../circuits", "idUtils_TakeNBits.circom"), - { - output: path.join(__dirname, "../circuits", "build/idUtils_TakeNBits"), - recompile: true, - reduceConstraints: true, - }, - ); - }); - - tests.forEach(({desc, input, output}) => { - it(`auth ${desc}`, async function() { - const w = await circuit.calculateWitness(input, true); - await circuit.checkConstraints(w); - await circuit.assertOut(w, output); - }); - }); -}); diff --git a/archive_circuits_V2/test/utils/isExpirable.test.ts b/archive_circuits_V2/test/utils/isExpirable.test.ts deleted file mode 100644 index f9878463..00000000 --- a/archive_circuits_V2/test/utils/isExpirable.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test", function () { - let circuit; - let testData = {in:{},expOut:{}} - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_isExpirable.circom")); - }) - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - }) - - it("#not expirable", async () => { - const claim = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 0}; - }); - - it("#expirable", async () => { - const claim = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 1}; - }); -}) diff --git a/archive_circuits_V2/test/utils/isUpdatable.test.ts b/archive_circuits_V2/test/utils/isUpdatable.test.ts deleted file mode 100644 index 29e7a8c5..00000000 --- a/archive_circuits_V2/test/utils/isUpdatable.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test", function () { - let circuit; - let testData = {in:{},expOut:{}} - - before(async function() { - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_isUpdatable.circom")); - }) - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - }) - - it("#not updatable", async () => { - const claim = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 0}; - }); - - it("#updatable", async () => { - const claim = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - - testData.in = {claimFlags: claim}; - testData.expOut = {out: 1}; - }); -}) diff --git a/archive_circuits_V2/test/utils/spongeHash.test.ts b/archive_circuits_V2/test/utils/spongeHash.test.ts deleted file mode 100644 index 005410b3..00000000 --- a/archive_circuits_V2/test/utils/spongeHash.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -import * as fs from "fs"; -import path from "path"; -import { wasm } from "circom_tester"; - -const templateName = "SpongeHash"; -const relativePath = "../circuits"; -const generateTemplate = ( - size: number, - circuitTemplateName = "SpongeHash" -): void => { - const template = ` -pragma circom 2.1.1; -include "../../circuits/lib/utils/spongeHash.circom"; -template ${circuitTemplateName}Test() { -signal input in[{{n}}]; -signal output out; -component h = ${circuitTemplateName}({{n}},6); -for(var i = 0; i < {{n}}; i++) { -h.in[i] <== in[i]; -} -out <== h.out; -} -component main = ${circuitTemplateName}Test(); -`; - - const circuitName = `${circuitTemplateName}${size}.circom`; - if (!fs.existsSync(path.join(__dirname, relativePath, circuitName))) { - fs.writeFileSync( - path.join(__dirname, relativePath, circuitName), - template.replace(/{{n}}/g, size.toString()) - ); - } -}; - -describe("Sponge Hash tests", function () { - this.timeout(400000); - it("Test SpongeHash util using hash for different size inputs", async () => { - const testCases = [ - new Array(64).fill(0), - new Array(63).fill(0).map((_, i) => i + 1), - new Array(60).fill(0).map((_, i) => 60 - i), - new Array(5).fill(0).map((_, i) => i + 1), - [0], - new Array(6).fill(0).map((_, i) => i + 1), - new Array(16).fill(0).map((_, i) => i + 1), - ]; - - const expected = [ - "7368935780301629035733097554153370898490964345621267223639562510928947240459", - "3027148895471770401984833121350831002277377476084832804937751928355120074994", - "13254546416358473313457812414193018870743005197521155619424967381510427667259", - "6186895146109816025093019628248576250523388957868658785525378722128520330607", - "14408838593220040598588012778523101864903887657864399481915450526643617223637", - "20400040500897583745843009878988256314335038853985262692600694741116813247201", - "5605330091169856132381694679994923791994681609858984566508182442210285386845", - ]; - - await createCircuit(testCases, expected); - }); - - it("Compare SpongeHash with go-iden3-crypto", async () => { - const expected = [ - "7757418611592686851480213421395023492910069335464834810473637859830874759279", - "15336558801450556532856248569924170992202208561737609669134139141992924267169", - "1144067817111460038464347636467015864025755473684726783913963849059920017972", - "17412321031092738336952455023828291176350572898965143678124844674611030278684", - "6186895146109816025093019628248576250523388957868658785525378722128520330607", - "20400040500897583745843009878988256314335038853985262692600694741116813247201", - "5577102071379540901883430718956859114277228199376926918690006383418752242436", - "1152305401687934645444055619201663931885907446826162025284948369145242973368", - "8211686227523893359273736667704216885003209084307215502943363750368107369620", - "7108881484930248270303049372327318360896856726757123411260066018366897025567", - "2265321027947983264707184154085264659877433648022878713272356019112959947364", - "12651359110916308876830620694657526370832930110397701742810260795463743022206", - "5448696623590242880008365208951082811870613001921911478755586779573529615712", - "12138957412533147284529235731676849096990688866708298976199544475739215311830", - "4296304251107177078079123684673490646100950885652358062546507066452904816259", - "5605330091169856132381694679994923791994681609858984566508182442210285386845", - "13988934542900192765733497388343315006075364569889174469414974142779436870312", - "15403024279602420951485303794282139684443426339931496210157338841814828581711", - "21456291545549982243960095968662564139932500401819177068272967144559313156981", - "18204869441381241555967353898895621136239168759533159329850061388567652528934", - "13038015408593191211490686165474468640092531721798660195788216465453248480728", - ]; - - const testCases = expected.map((_, i) => - new Array(i + 1).fill(0).map((_, i) => i + 1) - ); - - await createCircuit(testCases, expected); - }); - - async function createCircuit(testCases: number[][], expected: string[]) { - for (let index = 0; index < expected.length; index++) { - generateTemplate(testCases[index].length); - const circuit = await wasm( - path.join( - __dirname, - relativePath, - `${templateName}${testCases[index].length}.circom` - ), - { reduceConstraints: false } - ); - - const witness = await circuit.calculateWitness({ - in: testCases[index], - }); - await circuit.checkConstraints(witness); - await circuit.assertOut(witness, { - out: expected[index], - }); - - fs.unlinkSync( - path.join( - __dirname, - relativePath, - `${templateName}${testCases[index].length}.circom` - ) - ); - } - } -}); diff --git a/archive_circuits_V2/test/utils/verifyExpirationTime.test.ts b/archive_circuits_V2/test/utils/verifyExpirationTime.test.ts deleted file mode 100644 index 88cfb1a5..00000000 --- a/archive_circuits_V2/test/utils/verifyExpirationTime.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const wasm_tester = require("circom_tester").wasm; - -describe("Test verifyExpirationTime", function() { - let circuit; - let testData = {in:{},expOut:{}}; - - before(async function() { - this.timeout(5000); - circuit = await wasm_tester(path.join(__dirname, "../circuits/utils", "utils_verifyExpirationTime.circom")); - }); - - afterEach( async ()=>{ - const w = await circuit.calculateWitness(testData.in, true); - await circuit.assertOut(w, testData.expOut); - }) - - it("#success claim with expiration time", async () => { - const claim = ["8166776806102523123120990578362437074969", // claim type = 25, expiration flag 1 - "0", - "0", - "0", - "30803922974473213664682835967", // expiration 1669884010 - "0", - "0", - "0"]; - - testData.in = {claim: claim, timestamp: 1669884009}; - testData.expOut = {}; - }); - - it("#success expiration flag 0", async () => { - const claim = ["5444517870735015415413993718908291383321", // claim type = 25, expiration flag 0, expiration 0 - "0", - "0", - "0", - "18446744073709551615", // expiration 0 - "0", - "0", - "0"]; - - testData.in = {claim: claim, timestamp: 1669884009}; - testData.expOut = {}; - }); - - it("#success expiration flag 1, timestamp equal to expiration", async () => { - const claim = ["2722258935367507707706996859454145691673", // claim type = 25, expiration flag 1 - "0", - "0", - "0", - "30802373438747650025492316159", // expiration 1669800009 - "0", - "0", - "0"]; - - testData.in = {claim: claim, timestamp: 1669800009}; - testData.expOut = {}; - }); - -}); diff --git a/archive_circuits_V2/test/utils/verifyFunctions.test.ts b/archive_circuits_V2/test/utils/verifyFunctions.test.ts deleted file mode 100644 index 77d8c6f0..00000000 --- a/archive_circuits_V2/test/utils/verifyFunctions.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -import {describe} from "mocha"; - -const path = require("path"); -const tester = require("circom_tester").wasm; -const chai = require("chai"); -const assert = chai.assert; - -export {}; - -const verifyCredentialSubject = { - claim: [ - "700576110560149417265602648140262015232", - "197990912273762023075897629417744831667514652778362723486029975898079821824", - "0", - "0", - "123", - "0", - "0", - "0", - ], - id: "197990912273762023075897629417744831667514652778362723486029975898079821824", // 117twYCgGzxHUtMsAfjM3muCrypTXcu6oc7cSsuGHM -} - -describe("utils verifyCredentialSubject test", function () { - this.timeout(200000); - it("Test utils verifyCredentialSubject", async () => { - const circuit = await tester( - path.join(__dirname, "../circuits/utils", "utils_verifyCredentialSubject.circom"), - {reduceConstraints: false}, - ); - - const witness = await circuit.calculateWitness(verifyCredentialSubject, true); - await circuit.checkConstraints(witness); - }); -}); - -describe("utils checkIdenStateMatchesRoots test", function () { - this.timeout(200000); - it("Test utils checkIdenStateMatchesRoots", async () => { - const circuit = await tester( - path.join(__dirname, "../circuits/utils", "utils_checkIdenStateMatchesRoots.circom"), - //{reduceConstraints: false}, - ); - - const witness = await circuit.calculateWitness({ - "enabled": "1", - "claimsTreeRoot": "5390978791160263927985161830452830346003784422812143177724675599288112176057", - "revTreeRoot": "0", - "rootsTreeRoot": "0", - "expectedState": "17685575544241839934776615609352503109564813484662571173826983469932580732343" - }, true); - await circuit.checkConstraints(witness); - }); -}); - -describe("utils verifyClaimSignature test", function () { - this.timeout(200000); - it("Test utils verifyClaimSignature", async () => { - const circuit = await tester( - path.join(__dirname, "../circuits/utils", "utils_verifyClaimSignature.circom"), - //{reduceConstraints: false}, - ); - - const witness = await circuit.calculateWitness({ - "enabled": "1", - "claim": ["0","0","0","0","0","0","0","0"], - "sigR8x": "9813265844413837380082826071463892301278045128546516139211810884421030840917", - "sigR8y": "7110066446166689493462986682910785889642607369745074815971396692733663407188", - "sigS": "1837652275043347007743363280039859735198580922853822340283578942174886737707", - "pubKeyX": "11356572759147270709631238494624398626863089762419266085446886102966874017086", - "pubKeyY": "6952793560627676182867513788009876275064024476317357446458237628508619978750" - }, true); - await circuit.checkConstraints(witness); - }); -}); diff --git a/archive_circuits_V2/testvectorgen/auth/authV2_test.go b/archive_circuits_V2/testvectorgen/auth/authV2_test.go deleted file mode 100644 index 4bbeb94a..00000000 --- a/archive_circuits_V2/testvectorgen/auth/authV2_test.go +++ /dev/null @@ -1,260 +0,0 @@ -package main - -import ( - "context" - "encoding/hex" - json2 "encoding/json" - "fmt" - "math/big" - "testing" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-merkletree-sql/v2/db/memory" - "github.com/stretchr/testify/require" - "test/utils" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - userPK2 = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" -) - -type AuthV2Inputs struct { - UserGenesisID string `json:"genesisID"` - Nonce string `json:"profileNonce"` - UserAuthClaim *core.Claim `json:"authClaim"` - UserAuthClaimMtp []string `json:"authClaimIncMtp"` - UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - Challenge string `json:"challenge"` - ChallengeSignatureR8X string `json:"challengeSignatureR8x"` - ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` - ChallengeSignatureS string `json:"challengeSignatureS"` - UserClaimsTreeRoot string `json:"claimsTreeRoot"` - UserRevTreeRoot string `json:"revTreeRoot"` - UserRootsTreeRoot string `json:"rootsTreeRoot"` - UserState string `json:"state"` - GistRoot string `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` -} - -type AuthV2Outputs struct { - ID string `json:"userID"` - GistRoot string `json:"gistRoot"` - Challenge string `json:"challenge"` -} - -type TestDataAuthV2 struct { - Desc string `json:"desc"` - In AuthV2Inputs `json:"inputs"` - Out AuthV2Outputs `json:"expOut"` -} - -func Test_UserID_Subject(t *testing.T) { - - desc := "Ownership true. User state: genesis. Auth claims total/signedWith/revoked: 1/1/none" - isUserIDProfile := false - isSecondAuthClaim := false - isUserStateGenesis := true - - generateAuthTestData(t, isUserIDProfile, isUserStateGenesis, isSecondAuthClaim, desc, "userID_genesis") -} - -func TestNotGenesisUserSate(t *testing.T) { - - desc := "Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none" - isUserIDProfile := false - - isUserStateGenesis := false - isSecondAuthClaim := false - - generateAuthTestData(t, isUserIDProfile, isUserStateGenesis, isSecondAuthClaim, desc, "user_state_not_genesis") -} - -func TestNotGenesisUserSateWithRevokedClaims(t *testing.T) { - desc := "Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none" - isUserIDProfile := false - isUserStateGenesis := false - isSecondAuthClaim := true - generateAuthTestData(t, isUserIDProfile, isUserStateGenesis, isSecondAuthClaim, desc, - "user_state_not_genesis_second_auth_claim") -} - -func Test_ProfileID(t *testing.T) { - - desc := "nonce=10. ProfileID == UserID should be true. Ownership true. User state: genesis. Auth claims total/signedWith/revoked: 1/1/none" - isUserIDProfile := true - isSecondAuthClaim := false - isUserStateGenesis := true - - generateAuthTestData(t, isUserIDProfile, isUserStateGenesis, isSecondAuthClaim, desc, "userID_profileID") -} - -func generateAuthTestData(t *testing.T, profile, genesis, isSecondAuthClaim bool, desc, fileName string) { - - nonce := big.NewInt(0) - - challenge := big.NewInt(12345) - - user := utils.NewIdentity(t, userPK) - - var err error - - userProfile := user.ID - if profile { - nonce = big.NewInt(10) - userProfile, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 40) - require.Nil(t, err) - gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - - if genesis == false { - // extract pubKey - authClaim2, pk2 := utils.NewAuthClaim(t, userPK2) - - user.AddClaim(t, authClaim2) - - if isSecondAuthClaim { - - // revoke auth claim - revNonce := user.AuthClaim.GetRevocationNonce() - err = user.Ret.Add(context.Background(), new(big.Int).SetUint64(revNonce), big.NewInt(0)) - require.NoError(t, err) - - // set new auth claim - user.AuthClaim = authClaim2 - user.PK = pk2 - - } - - err = gisTree.Add(context.Background(), user.IDHash(t), user.State(t)) - require.NoError(t, err) - - } - - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := AuthV2Inputs{ - UserGenesisID: user.ID.BigInt().String(), - Nonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - } - - out := AuthV2Outputs{ - ID: userProfile.BigInt().String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - } - - json, err := json2.Marshal(TestDataAuthV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func TestTre(t *testing.T) { - - tree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 40) - require.Nil(t, err) - - X, ok := new(big.Int).SetString("17640206035128972995519606214765283372613874593503528180869261482403155458945", 10) - require.True(t, ok) - - Y, ok := new(big.Int).SetString("20634138280259599560273310290025659992320584624461316485434108770067472477956", 10) - require.True(t, ok) - - var schemaHash core.SchemaHash - schemaEncodedBytes, _ := hex.DecodeString("ca938857241db9451ea329256b9c06e5") // V1 - //schemaEncodedBytes, _ := hex.DecodeString("013fd3f623559d850fb5b02ff012d0e2") // V2 - copy(schemaHash[:], schemaEncodedBytes) - - // NOTE: We take nonce as hash of public key to make it random - // We don't use random number here because this test vectors will be used for tests - // and have randomization inside tests is usually a bad idea - revNonce := uint64(15930428023331155902) - require.NoError(t, err) - - claim, err := core.NewClaim(schemaHash, - core.WithIndexDataInts(X, Y), - core.WithRevocationNonce(revNonce)) - require.NoError(t, err) - - marshal, err := json2.Marshal(claim) - require.NoError(t, err) - fmt.Println(string(marshal)) - - hi, hv, err := claim.HiHv() - require.NoError(t, err) - - fmt.Println("hi", hi) - fmt.Println("hv", hv) - - err = tree.Add(context.Background(), hi, hv) - require.NoError(t, err) - - fmt.Println("root", tree.Root().BigInt()) - - clr, _ := new(big.Int).SetString("9763429684850732628215303952870004997159843236039795272605841029866455670219", 10) - state, err := core.IdenState(clr, big.NewInt(0), big.NewInt(0)) - require.NoError(t, err) - - typ, err := core.BuildDIDType(core.DIDMethodIden3, core.Polygon, core.Mumbai) - require.NoError(t, err) - id, err := core.IdGenesisFromIdenState(typ, state) - require.NoError(t, err) - - fmt.Println("id", id.BigInt()) - fmt.Println("id", id.String()) - - did, err := core.ParseDIDFromID(*id) - require.NoError(t, err) - fmt.Println("did", did.String()) - - //{“schema":"ca938857241db9451ea329256b9c06e5", - //"nonce":"15930428023331155902"," + - //"indexSlotA":"17640206035128972995519606214765283372613874593503528180869261482403155458945", - // "indexSlotB":"20634138280259599560273310290025659992320584624461316485434108770067472477956"} -} diff --git a/archive_circuits_V2/testvectorgen/auth/testdata/userID_genesis.json b/archive_circuits_V2/testvectorgen/auth/testdata/userID_genesis.json deleted file mode 100644 index 519d173a..00000000 --- a/archive_circuits_V2/testvectorgen/auth/testdata/userID_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Ownership true. User state: genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8162166103065016664685834856644195001371303013149727027131225893397958846382","revTreeRoot":"0","rootsTreeRoot":"0","state":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/auth/testdata/userID_profileID.json b/archive_circuits_V2/testvectorgen/auth/testdata/userID_profileID.json deleted file mode 100644 index 18c9bee5..00000000 --- a/archive_circuits_V2/testvectorgen/auth/testdata/userID_profileID.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"nonce=10. ProfileID == UserID should be true. Ownership true. User state: genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8162166103065016664685834856644195001371303013149727027131225893397958846382","revTreeRoot":"0","rootsTreeRoot":"0","state":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis.json b/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis.json deleted file mode 100644 index cb13013d..00000000 --- a/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","revTreeRoot":"0","rootsTreeRoot":"0","state":"7115004997868594253010848596868364067574661249707337517331323113105592633327","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis_second_auth_claim.json b/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis_second_auth_claim.json deleted file mode 100644 index c473f06c..00000000 --- a/archive_circuits_V2/testvectorgen/auth/testdata/user_state_not_genesis_second_auth_claim.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","18843627616807347027405965102907494712213509184168391784663804560181782095821","21769574296201138406688395494914474950554632404504713590270198507141791084591","17476719578317212277","0","0","0"],"authClaimIncMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"16547485850637761685","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"0","challenge":"12345","challengeSignatureR8x":"17119525341148708510056742833108899809180137847226842265134929121642912372281","challengeSignatureR8y":"14361124785409490066314019246273984594356444175220864488356627192969301706799","challengeSignatureS":"1437929958210592098523189041037049993330511094749287599959220159702091719018","claimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","revTreeRoot":"18174590471735654296853614985726184006995378344929215927298747263240370223984","rootsTreeRoot":"0","state":"11011081180322189554242336567873361504785021441826614473690174477816587629954","gistRoot":"2372526788462776994418746206668460343891099414664260600394307379551521456907","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","gistRoot":"2372526788462776994418746206668460343891099414664260600394307379551521456907","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/generate_json_test.go b/archive_circuits_V2/testvectorgen/contract_data/generate_json_test.go deleted file mode 100644 index 592f8519..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/generate_json_test.go +++ /dev/null @@ -1,702 +0,0 @@ -package contractdata - -import ( - "context" - json2 "encoding/json" - "math/big" - "testing" - - "test/utils" - - "github.com/ethereum/go-ethereum/common" - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-merkletree-sql/v2/db/memory" - "github.com/iden3/go-schema-processor/merklize" - "github.com/stretchr/testify/require" -) - -const ( - UserPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - IssuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" - requestID = "32" -) - -type StateTransitionInputs struct { - AuthClaim *core.Claim `json:"authClaim"` - AuthClaimMtp []string `json:"authClaimMtp"` - AuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - AuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - AuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - AuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - ClaimsTreeRoot string `json:"claimsTreeRoot"` - IsOldStateGenesis string `json:"isOldStateGenesis"` - NewUserState string `json:"newUserState"` - OldUserState string `json:"oldUserState"` - RevTreeRoot string `json:"revTreeRoot"` - RootsTreeRoot string `json:"rootsTreeRoot"` - SignatureR8X string `json:"signatureR8x"` - SignatureR8Y string `json:"signatureR8y"` - SignatureS string `json:"signatureS"` - UserID string `json:"userID"` - NewAuthClaimMtp []string `json:"newAuthClaimMtp"` - NewClaimsTreeRoot string `json:"newClaimsTreeRoot"` - NewRevTreeRoot string `json:"newRevTreeRoot"` - NewRootsTreeRoot string `json:"newRootsTreeRoot"` -} - -type StateTransitionOutputs struct { - ID string `json:"userID"` - NewUserState string `json:"newUserState"` - OldUserState string `json:"oldUserState"` - IsOldStateGenesis string `json:"isOldStateGenesis"` -} - -type CredentialAtomicMTPOnChainV2Inputs struct { - RequestID string `json:"requestID"` - - // begin user data - UserGenesisID string `json:"userGenesisID"` // - ProfileNonce string `json:"profileNonce"` // - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` // - UserAuthClaim *core.Claim `json:"authClaim"` - UserAuthClaimMtp []string `json:"authClaimIncMtp"` - UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - Challenge string `json:"challenge"` - ChallengeSignatureR8X string `json:"challengeSignatureR8x"` - ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` - ChallengeSignatureS string `json:"challengeSignatureS"` - UserClaimsTreeRoot string `json:"userClaimsTreeRoot"` - UserRevTreeRoot string `json:"userRevTreeRoot"` - UserRootsTreeRoot string `json:"userRootsTreeRoot"` - UserState string `json:"userState"` - GistRoot string `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - // end user data - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - // Inclusion - IssuerClaimMtp []string `json:"issuerClaimMtp"` - IssuerClaimClaimsTreeRoot *merkletree.Hash `json:"issuerClaimClaimsTreeRoot"` - IssuerClaimRevTreeRoot *merkletree.Hash `json:"issuerClaimRevTreeRoot"` - IssuerClaimRootsTreeRoot *merkletree.Hash `json:"issuerClaimRootsTreeRoot"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - - IsRevocationChecked int `json:"isRevocationChecked"` - IssuerClaimNonRevClaimsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - - ClaimSchema string `json:"claimSchema"` - - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - Value []string `json:"value"` -} - -type CredentialAtomicMTPOnChainV2Outputs struct { - Merklized string `json:"merklized"` - UserID string `json:"userID"` - CircuitQueryHash string `json:"circuitQueryHash"` - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - Timestamp string `json:"timestamp"` - IsRevocationChecked string `json:"isRevocationChecked"` - GistRoot string `json:"gistRoot"` - Challenge string `json:"challenge"` -} -type TestDataStateTransition struct { - Desc string `json:"desc"` - In StateTransitionInputs `json:"inputs"` - Out StateTransitionOutputs `json:"expOut"` -} - -type TestDataOnChainMTPV2 struct { - Desc string `json:"desc"` - In CredentialAtomicMTPOnChainV2Inputs `json:"inputs"` - Out CredentialAtomicMTPOnChainV2Outputs `json:"expOut"` -} - -type CredentialAtomicSigOnChainV2Inputs struct { - RequestID string `json:"requestID"` - - // user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - - UserAuthClaim *core.Claim `json:"authClaim"` - UserAuthClaimMtp []string `json:"authClaimIncMtp"` - UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - Challenge string `json:"challenge"` - ChallengeSignatureR8X string `json:"challengeSignatureR8x"` - ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` - ChallengeSignatureS string `json:"challengeSignatureS"` - UserClaimsTreeRoot string `json:"userClaimsTreeRoot"` - UserRevTreeRoot string `json:"userRevTreeRoot"` - UserRootsTreeRoot string `json:"userRootsTreeRoot"` - UserState string `json:"userState"` - GistRoot string `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - IssuerClaimNonRevClaimsTreeRoot string `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot string `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot string `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - ClaimSchema string `json:"claimSchema"` - IssuerClaimSignatureR8X string `json:"issuerClaimSignatureR8x"` - IssuerClaimSignatureR8Y string `json:"issuerClaimSignatureR8y"` - IssuerClaimSignatureS string `json:"issuerClaimSignatureS"` - IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` - IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` - IssuerAuthClaimNonRevMtp []string `json:"issuerAuthClaimNonRevMtp"` - IssuerAuthClaimNonRevMtpAuxHi string `json:"issuerAuthClaimNonRevMtpAuxHi"` - IssuerAuthClaimNonRevMtpAuxHv string `json:"issuerAuthClaimNonRevMtpAuxHv"` - IssuerAuthClaimNonRevMtpNoAux string `json:"issuerAuthClaimNonRevMtpNoAux"` - IssuerAuthClaimsTreeRoot string `json:"issuerAuthClaimsTreeRoot"` - IssuerAuthRevTreeRoot string `json:"issuerAuthRevTreeRoot"` - IssuerAuthRootsTreeRoot string `json:"issuerAuthRootsTreeRoot"` - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - IsRevocationChecked int `json:"isRevocationChecked"` - Value []string `json:"value"` -} - -type CredentialAtomicSigOnChainV2Outputs struct { - Merklized string `json:"merklized"` - UserID string `json:"userID"` - CircuitQueryHash string `json:"circuitQueryHash"` - IssuerAuthState string `json:"issuerAuthState"` - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - Timestamp string `json:"timestamp"` - IsRevocationChecked string `json:"isRevocationChecked"` - Challenge string `json:"challenge"` - GistRoot string `json:"gistRoot"` -} -type TestDataSigV2 struct { - Desc string `json:"desc"` - In CredentialAtomicSigOnChainV2Inputs `json:"inputs"` - Out CredentialAtomicSigOnChainV2Outputs `json:"expOut"` -} - -func Test_Generate_Test_Cases(t *testing.T) { - - id, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis state", "issuer_genesis_state") - nextId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "user_state_transition") - - generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer next transition state", "issuer_next_state_transition") - generateStateTransitionData(t, true, UserPK, IssuerPK, "User next transition state", "user_next_state_transition") - - generateMTPData(t, "MTP: Issuer first state", []*gistData{ - {id, issuerFirstState}, - }, false, "valid_mtp_user_genesis", false) - generateMTPData(t, "MTP: User non genesis but latest", []*gistData{ - {id, issuerFirstState}, - {nextId, userFirstState}, - }, true, "valid_mtp_user_non_genesis", false) - generateMTPData(t, "MTP: User sign with address challenge genesis", []*gistData{ - {id, issuerFirstState}, - {nextId, userFirstState}, - }, true, "valid_mtp_user_non_genesis_challenge_address", true) - - generateSigData(t, "Sig: Issuer first state", []*gistData{ - {id, issuerFirstState}, - }, false, "valid_sig_user_genesis", false) - generateSigData(t, "Sig: User non genesis latest", []*gistData{ - {id, issuerFirstState}, - {nextId, userFirstState}, - }, true, "valid_sig_user_non_genesis", false) - generateSigData(t, "Sig: User sign with address challenge genesis", []*gistData{ - {id, issuerFirstState}, - {nextId, userFirstState}, - }, true, "valid_sig_user_non_genesis_challenge_address", true) - -} - -type gistData struct { - id *big.Int - state *big.Int -} - -func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, secondaryPK, desc, fileName string) (*big.Int, *big.Int) { - - primaryEntity := utils.NewIdentity(t, primaryPK) - secondaryEntity := utils.NewIdentity(t, secondaryPK) - - isGenesis := "1" - // user - authMTProof := primaryEntity.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := primaryEntity.ClaimRevMTP(t, primaryEntity.AuthClaim) - - oldState := primaryEntity.State(t) // old state is genesis - oldCltRoot := primaryEntity.Clt.Root().BigInt().String() - oldRevRoot := primaryEntity.Ret.Root().BigInt().String() - oldRotRoot := primaryEntity.Rot.Root().BigInt().String() - - //if genesis == false { - // extract pubKey - - _, secondaryEntityClaim := utils.DefaultJSONUserClaim(t, secondaryEntity.ID) - primaryEntity.AddClaim(t, secondaryEntityClaim) - - if nextState { - isGenesis = "0" - // add claim just to change the state - - oldState = primaryEntity.State(t) // old state is genesis - oldCltRoot = primaryEntity.Clt.Root().BigInt().String() - oldRevRoot = primaryEntity.Ret.Root().BigInt().String() - oldRotRoot = primaryEntity.Rot.Root().BigInt().String() - authMTProof = primaryEntity.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev = primaryEntity.ClaimRevMTP(t, primaryEntity.AuthClaim) - primaryEntityClaim := utils.DefaultUserClaim(t, primaryEntity.ID) - primaryEntity.AddClaim(t, primaryEntityClaim) - } - - hashOldAndNewStates, err := poseidon.Hash( - []*big.Int{oldState, primaryEntity.State(t)}) - require.NoError(t, err) - - sig := primaryEntity.Sign(hashOldAndNewStates) - require.NoError(t, err) - - newAuthMTProof := primaryEntity.AuthMTPStrign(t) - newCltRoot := primaryEntity.Clt.Root().BigInt().String() - newRevRoot := primaryEntity.Ret.Root().BigInt().String() - newRotRoot := primaryEntity.Rot.Root().BigInt().String() - - inputs := StateTransitionInputs{ - AuthClaim: primaryEntity.AuthClaim, - AuthClaimMtp: authMTProof, - AuthClaimNonRevMtp: authNonRevMTProof, - AuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - AuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - AuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - ClaimsTreeRoot: oldCltRoot, - RevTreeRoot: oldRevRoot, - RootsTreeRoot: oldRotRoot, - IsOldStateGenesis: isGenesis, - NewUserState: primaryEntity.State(t).String(), - OldUserState: oldState.String(), - SignatureR8X: sig.R8.X.String(), - SignatureR8Y: sig.R8.Y.String(), - SignatureS: sig.S.String(), - UserID: primaryEntity.ID.BigInt().String(), - NewAuthClaimMtp: newAuthMTProof, - NewClaimsTreeRoot: newCltRoot, - NewRevTreeRoot: newRevRoot, - NewRootsTreeRoot: newRotRoot, - } - - out := StateTransitionOutputs{ - ID: primaryEntity.ID.BigInt().String(), - NewUserState: primaryEntity.State(t).String(), - OldUserState: oldState.String(), - IsOldStateGenesis: isGenesis, - } - - json, err := json2.Marshal(TestDataStateTransition{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) - - return primaryEntity.ID.BigInt(), primaryEntity.State(t) -} - -func generateMTPData(t *testing.T, desc string, gistData []*gistData, nextState bool, fileName string, isAddressChallenge bool) { - - var err error - - user := utils.NewIdentity(t, UserPK) - issuer := utils.NewIdentity(t, IssuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - - subjectID := user.ID - nonceSubject := big.NewInt(0) - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - issuer.AddClaim(t, claim) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - challenge := big.NewInt(12345) - if isAddressChallenge { - addr := common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") - challenge = new(big.Int).SetBytes(merkletree.SwapEndianness(addr.Bytes())) - } - - if nextState { - _, claim1 := utils.DefaultJSONUserClaim(t, issuer.ID) - user.AddClaim(t, claim1) - } - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - - for _, data := range gistData { - idPoseidonHash, _ := poseidon.Hash([]*big.Int{data.id}) - err = gisTree.Add(context.Background(), idPoseidonHash, data.state) - require.Nil(t, err) - } - - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicMTPOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: claimJSONLDProof, - ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, - ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, - ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, - ClaimPathKey: pathKey.String(), - ClaimPathValue: valueKey.String(), - Operator: utils.EQ, - SlotIndex: 0, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{valueKey.String()}, 64), - IsRevocationChecked: 1, - } - 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, - }) - require.NoError(t, err) - - out := CredentialAtomicMTPOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - CircuitQueryHash: circuitQueryHash.String(), - Timestamp: timestamp, - Merklized: "1", - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataOnChainMTPV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateSigData(t *testing.T, desc string, gistData []*gistData, nextState bool, fileName string, isAddressChallenge bool) { - - var err error - - user := utils.NewIdentity(t, UserPK) - issuer := utils.NewIdentity(t, IssuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - - subjectID := user.ID - nonceSubject := big.NewInt(0) - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - challenge := big.NewInt(12345) - if isAddressChallenge { - addr := common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") - challenge = new(big.Int).SetBytes(merkletree.SwapEndianness(addr.Bytes())) - } - - if nextState { - _, claim1 := utils.DefaultJSONUserClaim(t, issuer.ID) - user.AddClaim(t, claim1) - } - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - - for _, data := range gistData { - idPoseidonHash, _ := poseidon.Hash([]*big.Int{data.id}) - err = gisTree.Add(context.Background(), idPoseidonHash, data.state) - require.Nil(t, err) - } - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - - ClaimPathNotExists: "0", // 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: valueKey.String(), // value in this path in merklized json-ld document - // value in this path in merklized json-ld document - - Operator: utils.EQ, - SlotIndex: 0, - Timestamp: timestamp, - IsRevocationChecked: 1, - Value: []string{valueKey.String(), "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, - } - - issuerAuthState := issuer.State(t) - - 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, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - Timestamp: timestamp, - Merklized: "1", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_genesis_state.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_genesis_state.json deleted file mode 100644 index 25832a89..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_genesis_state.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Issuer from genesis state","inputs":{"authClaim":["80551937543569765027552589160822318028","0","18843627616807347027405965102907494712213509184168391784663804560181782095821","21769574296201138406688395494914474950554632404504713590270198507141791084591","17476719578317212277","0","0","0"],"authClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","isOldStateGenesis":"1","newUserState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","oldUserState":"2943483356559152311923412925436024635269538717812859789851139200242297094","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"20167796738505041434113752942798707237582070465269416081101325303079556232773","signatureR8y":"6994035283669575665037135986017048435544770562562058264474902056454202799107","signatureS":"2645171126906857414954317179850069054687915083856300951174311016929238243213","userID":"21933750065545691586450392143787330185992517860945727248803138245838110721","newAuthClaimMtp":["10735385623516517682895122533888272997153449080517244786704177305670810185353","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"21933750065545691586450392143787330185992517860945727248803138245838110721","newUserState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","oldUserState":"2943483356559152311923412925436024635269538717812859789851139200242297094","isOldStateGenesis":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_next_state_transition.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_next_state_transition.json deleted file mode 100644 index 14748691..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/issuer_next_state_transition.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Issuer next transition state","inputs":{"authClaim":["80551937543569765027552589160822318028","0","18843627616807347027405965102907494712213509184168391784663804560181782095821","21769574296201138406688395494914474950554632404504713590270198507141791084591","17476719578317212277","0","0","0"],"authClaimMtp":["10735385623516517682895122533888272997153449080517244786704177305670810185353","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","isOldStateGenesis":"0","newUserState":"21306816147125348268698128919345238438768792440721891850508117209346448952877","oldUserState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"3346713940520525141047333133647502357383712356832951607036892118362998629045","signatureR8y":"19311723249572858976311321121161815234647509404924929165852458494308179143769","signatureS":"1558328888437767120134084427279702412775660305823335768536257228121628343192","userID":"21933750065545691586450392143787330185992517860945727248803138245838110721","newAuthClaimMtp":["10735385623516517682895122533888272997153449080517244786704177305670810185353","5217204782131398249239879629508153308098359990638127121006153561902944261366","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"2897855467627697722673897032007519414216165574495789363673517833958571549833","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"21933750065545691586450392143787330185992517860945727248803138245838110721","newUserState":"21306816147125348268698128919345238438768792440721891850508117209346448952877","oldUserState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","isOldStateGenesis":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/user_next_state_transition.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/user_next_state_transition.json deleted file mode 100644 index fa41824b..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/user_next_state_transition.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User next transition state","inputs":{"authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"17037265493465934746682869748002120766787501276588742860369610466434787550779","isOldStateGenesis":"0","newUserState":"12762287340049584352525153213090774360762035980892092940952129329615052050238","oldUserState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"16864812518887942792010071565525907185946245421810636674059264068589071799596","signatureR8y":"19605122908621458115587929878249004144683338926189897941303110764422913648418","signatureS":"1098770063292183967514704567662854070498388776240699511559115283841980288085","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newAuthClaimMtp":["21144897396476711644243575284009015724868820567251013274563287581923410286971","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"20948820153696573695701996092418155808062743630755896152205516001454929334435","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newUserState":"12762287340049584352525153213090774360762035980892092940952129329615052050238","oldUserState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","isOldStateGenesis":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/user_state_transition.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/user_state_transition.json deleted file mode 100644 index b7868bdb..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/user_state_transition.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User from genesis transition","inputs":{"authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8162166103065016664685834856644195001371303013149727027131225893397958846382","isOldStateGenesis":"1","newUserState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","oldUserState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"5590472494615564554406831770045311704682340952858361260892456530385672603391","signatureR8y":"17033751618155185157400447264531619564767607739593317803134058107541247403926","signatureS":"591776602608543102088379894296964043764035393162394843268618725318763993012","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newAuthClaimMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"17037265493465934746682869748002120766787501276588742860369610466434787550779","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newUserState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","oldUserState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","isOldStateGenesis":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_genesis.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_genesis.json deleted file mode 100644 index e1dbf898..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"MTP: Issuer first state","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"9261952740082697154168142614372093837079863683752625783051369996839209879956","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":"5068714026114262169251099563098251734732205302049357098840688433759755510297","gistMtpAuxHv":"14350982505419309247370121592555562539756979893755695438303858350858014373778","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","timestamp":"1642074362","isRevocationChecked":"1","gistRoot":"9261952740082697154168142614372093837079863683752625783051369996839209879956","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis.json deleted file mode 100644 index 5a09695a..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"MTP: User non genesis but latest","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","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":"17037265493465934746682869748002120766787501276588742860369610466434787550779","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","gistMtp":["0","0","0","9261952740082697154168142614372093837079863683752625783051369996839209879956","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","timestamp":"1642074362","isRevocationChecked":"1","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","challenge":"12345"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis_challenge_address.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis_challenge_address.json deleted file mode 100644 index d2920be8..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_mtp_user_non_genesis_challenge_address.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"MTP: User sign with address challenge genesis","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","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":"583091486781463398742321306787801699791102451699","challengeSignatureR8x":"11668810467316486103683380448531437905872027721345151755962946584758745579558","challengeSignatureR8y":"4187711299270188653280348040015541484590089642909032957691273464895119028000","challengeSignatureS":"1084269377408772223171808841357055550788589582282675384056523849291854854875","userClaimsTreeRoot":"17037265493465934746682869748002120766787501276588742860369610466434787550779","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","gistMtp":["0","0","0","9261952740082697154168142614372093837079863683752625783051369996839209879956","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","timestamp":"1642074362","isRevocationChecked":"1","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","challenge":"583091486781463398742321306787801699791102451699"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_genesis.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_genesis.json deleted file mode 100644 index 61926387..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sig: Issuer first state","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"9261952740082697154168142614372093837079863683752625783051369996839209879956","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":"5068714026114262169251099563098251734732205302049357098840688433759755510297","gistMtpAuxHv":"14350982505419309247370121592555562539756979893755695438303858350858014373778","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","isRevocationChecked":"1","challenge":"12345","gistRoot":"9261952740082697154168142614372093837079863683752625783051369996839209879956"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis.json deleted file mode 100644 index c1d2e4f4..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sig: User non genesis latest","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","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":"17037265493465934746682869748002120766787501276588742860369610466434787550779","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","gistMtp":["0","0","0","9261952740082697154168142614372093837079863683752625783051369996839209879956","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","isRevocationChecked":"1","challenge":"12345","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis_challenge_address.json b/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis_challenge_address.json deleted file mode 100644 index 06aa0d09..00000000 --- a/archive_circuits_V2/testvectorgen/contract_data/testdata/valid_sig_user_non_genesis_challenge_address.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sig: User sign with address challenge genesis","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","21205756903155911299867990799154204893460008369926668392180932841700401266404","0","0","0","0","0","0","0","0","0","0","0","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":"583091486781463398742321306787801699791102451699","challengeSignatureR8x":"11668810467316486103683380448531437905872027721345151755962946584758745579558","challengeSignatureR8y":"4187711299270188653280348040015541484590089642909032957691273464895119028000","challengeSignatureS":"1084269377408772223171808841357055550788589582282675384056523849291854854875","userClaimsTreeRoot":"17037265493465934746682869748002120766787501276588742860369610466434787550779","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"16943514292072615581951225733277375494772075645432829638168938263745642964909","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485","gistMtp":["0","0","0","9261952740082697154168142614372093837079863683752625783051369996839209879956","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","isRevocationChecked":"1","challenge":"583091486781463398742321306787801699791102451699","gistRoot":"2330632222887470777740058486814238715476391492444368442359814550649181604485"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/mtpv2_test.go b/archive_circuits_V2/testvectorgen/credentials/mtpv2/mtpv2_test.go deleted file mode 100644 index 90c55d2e..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/mtpv2_test.go +++ /dev/null @@ -1,492 +0,0 @@ -package mtpv2 - -import ( - "context" - json2 "encoding/json" - "math/big" - "testing" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-schema-processor/merklize" - "github.com/stretchr/testify/require" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" -) - -type CredentialAtomicMTPOffChainV2Inputs struct { - RequestID string `json:"requestID"` - - // user data - UserGenesisID string `json:"userGenesisID"` // - ProfileNonce string `json:"profileNonce"` // - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` // - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - // Inclusion - IssuerClaimMtp []string `json:"issuerClaimMtp"` - IssuerClaimClaimsTreeRoot *merkletree.Hash `json:"issuerClaimClaimsTreeRoot"` - IssuerClaimRevTreeRoot *merkletree.Hash `json:"issuerClaimRevTreeRoot"` - IssuerClaimRootsTreeRoot *merkletree.Hash `json:"issuerClaimRootsTreeRoot"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - - IsRevocationChecked int `json:"isRevocationChecked"` - IssuerClaimNonRevClaimsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - - ClaimSchema string `json:"claimSchema"` - - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - Value []string `json:"value"` -} - -type CredentialAtomicMTPOffChainV2Outputs struct { - RequestID string `json:"requestID"` - UserID string `json:"userID"` - IssuerID string `json:"issuerID"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - ClaimSchema string `json:"claimSchema"` - SlotIndex string `json:"slotIndex"` - Operator int `json:"operator"` - Value []string `json:"value"` - Timestamp string `json:"timestamp"` - Merklized string `json:"merklized"` - ClaimPathKey string `json:"claimPathKey"` - ClaimPathNotExists string `json:"claimPathNotExists"` // 0 for inclusion, 1 for non-inclusion -} - -type TestDataMTPV2 struct { - Desc string `json:"desc"` - In CredentialAtomicMTPOffChainV2Inputs `json:"inputs"` - Out CredentialAtomicMTPOffChainV2Outputs `json:"expOut"` -} - -func Test_ClaimIssuedOnUserID(t *testing.T) { - desc := "User == Subject. Claim issued on UserID" - isUserIDProfile := false - isSubjectIDProfile := false - - generateJSONLDTestData(t, desc, isUserIDProfile, isSubjectIDProfile, "claimIssuedOnUserID") -} - -func Test_ClaimIssuedOnUserProfileID(t *testing.T) { - desc := "User != Subject. Claim issued on ProfileID" - isUserIDProfile := false - isSubjectIDProfile := true - - generateJSONLDTestData(t, desc, isUserIDProfile, isSubjectIDProfile, "claimIssuedOnProfileID") -} - -func Test_ClaimIssuedOnUserProfileID2(t *testing.T) { - desc := "User == Subject. Claim issued on ProfileID" - isUserIDProfile := true - isSubjectIDProfile := true - - generateJSONLDTestData(t, desc, isUserIDProfile, isSubjectIDProfile, "claimIssuedOnProfileID2") -} - -func Test_ClaimNonMerklized(t *testing.T) { - desc := "User == Subject. Claim non merklized claim" - isUserIDProfile := false - isSubjectIDProfile := false - - generateTestData(t, desc, isUserIDProfile, isSubjectIDProfile, "claimNonMerklized") -} - -func Test_RevokedClaimWithRevocationCheck(t *testing.T) { - desc := "User's claim revoked and the circuit checking for revocation status (expected to fail)" - fileName := "revoked_claim_with_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - issuer.AddClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicMTPOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - IsRevocationChecked: 1, - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - } - - out := CredentialAtomicMTPOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: utils.PrepareStrArray([]string{"10"}, 64), - Timestamp: timestamp, - Merklized: "0", - ClaimPathKey: "0", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - } - - json, err := json2.Marshal(TestDataMTPV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_RevokedClaimWithoutRevocationCheck(t *testing.T) { - desc := "User's claim revoked and the circuit not checking for revocation status (expected to fail)" - fileName := "revoked_claim_without_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - issuer.AddClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicMTPOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - IsRevocationChecked: 0, - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - } - - out := CredentialAtomicMTPOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: utils.PrepareStrArray([]string{"10"}, 64), - Timestamp: timestamp, - Merklized: "0", - ClaimPathKey: "0", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - } - - json, err := json2.Marshal(TestDataMTPV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} -func generateJSONLDTestData(t *testing.T, desc string, isUserIDProfile, isSubjectIDProfile bool, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - issuer.AddClaim(t, claim) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicMTPOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IsRevocationChecked: 1, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: claimJSONLDProof, - ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, - ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, - ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, - ClaimPathKey: pathKey.String(), - ClaimPathValue: valueKey.String(), - Operator: utils.EQ, - SlotIndex: 0, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{valueKey.String()}, 64), - } - - out := CredentialAtomicMTPOffChainV2Outputs{ - RequestID: inputs.RequestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "0", - Operator: utils.EQ, - Value: utils.PrepareStrArray([]string{valueKey.String()}, 64), - Timestamp: timestamp, - Merklized: "1", - ClaimPathKey: pathKey.String(), - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - } - - json, err := json2.Marshal(TestDataMTPV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) - -} - -func generateTestData(t *testing.T, desc string, isUserIDProfile, isSubjectIDProfile bool, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - claim := utils.DefaultUserClaim(t, subjectID) - - issuer.AddClaim(t, claim) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - require.NoError(t, err) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicMTPOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - IsRevocationChecked: 1, - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - } - - out := CredentialAtomicMTPOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: utils.PrepareStrArray([]string{"10"}, 64), - Timestamp: timestamp, - Merklized: "0", - ClaimPathKey: "0", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - } - - json, err := json2.Marshal(TestDataMTPV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID.json deleted file mode 100644 index d823ff16..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID.json +++ /dev/null @@ -1,306 +0,0 @@ -{ - "desc": "User != Subject. Claim issued on ProfileID", - "inputs": { - "requestID": "23", - "userGenesisID": "23148936466334350744548790012294489365207440754509988986684797708370051073", - "profileNonce": "0", - "claimSubjectProfileNonce": "999", - "issuerID": "21933750065545691586450392143787330185992517860945727248803138245838110721", - "issuerClaim": [ - "14472269431592746875347367665757389417422", - "24497320812635010775435456013830217801375919178980935564312517783529521153", - "17568057213828477233507447080689055308823020388972334380526849356111335110900", - "0", - "30803922965249841627828060170", - "0", - "0", - "0" - ], - "issuerClaimMtp": [ - "20643387758736831799596675626240785455902781070167728593409367019626753600795", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "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": "6807394214856867182702861581688414112931887520929949769131382186542423406679", - "issuerClaimRevTreeRoot": "0", - "issuerClaimRootsTreeRoot": "0", - "issuerClaimIdenState": "19610686287062380962892375049625048425838961734261320467083164088209350256405", - "isRevocationChecked": 1, - "issuerClaimNonRevClaimsTreeRoot": "6807394214856867182702861581688414112931887520929949769131382186542423406679", - "issuerClaimNonRevRevTreeRoot": "0", - "issuerClaimNonRevRootsTreeRoot": "0", - "issuerClaimNonRevState": "19610686287062380962892375049625048425838961734261320467083164088209350256405", - "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": "180410020913331409885634153623124536270", - "claimPathNotExists": "0", - "claimPathMtp": [ - "5559250731000753554753485016695600829384855452867544273344893815961938985436", - "20222899544143787877985297439625828822272100269106711904511119118819809140477", - "14730426618666280941604039095550905490156541514901979358549599762282042588641", - "20497288520738821800886677250569208588689763166335933087499619993954968899866", - "3295720551404287572425718873751040314503774617833462052445584373469655789999", - "796356776410152646380783209242693344675665178494017735650545708722024766291", - "0", - "0", - "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": "8566939875427719562376598811066985304309117528846759529734201066483458512800", - "claimPathValue": "1420070400000000000", - "operator": 1, - "slotIndex": 0, - "timestamp": "1642074362", - "value": [ - "1420070400000000000", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0" - ] - }, - "expOut": { - "requestID": "23", - "userID": "23148936466334350744548790012294489365207440754509988986684797708370051073", - "issuerID": "21933750065545691586450392143787330185992517860945727248803138245838110721", - "issuerClaimIdenState": "19610686287062380962892375049625048425838961734261320467083164088209350256405", - "issuerClaimNonRevState": "19610686287062380962892375049625048425838961734261320467083164088209350256405", - "claimSchema": "180410020913331409885634153623124536270", - "slotIndex": "0", - "operator": 1, - "value": [ - "1420070400000000000", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0" - ], - "timestamp": "1642074362", - "merklized": "1", - "claimPathKey": "8566939875427719562376598811066985304309117528846759529734201066483458512800", - "claimPathNotExists": "0" - } -} diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID2.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID2.json deleted file mode 100644 index 026a3efb..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnProfileID2.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User == Subject. Claim issued on ProfileID","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","claimSchema":"180410020913331409885634153623124536270","slotIndex":"0","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathKey":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnUserID.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnUserID.json deleted file mode 100644 index 10d72ba4..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimIssuedOnUserID.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User == Subject. Claim issued on UserID","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","claimSchema":"180410020913331409885634153623124536270","slotIndex":"0","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathKey":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimNonMerklized.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimNonMerklized.json deleted file mode 100644 index 711ff8d9..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/claimNonMerklized.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User == Subject. Claim non merklized claim","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathKey":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_with_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_with_revocation_check.json deleted file mode 100644 index f0729334..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_with_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User's claim revoked and the circuit checking for revocation status (expected to fail)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","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":"0","claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathKey":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_without_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_without_revocation_check.json deleted file mode 100644 index 5e193b28..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/mtpv2/testdata/revoked_claim_without_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User's claim revoked and the circuit not checking for revocation status (expected to fail)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","isRevocationChecked":0,"issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","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":"0","claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathKey":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/mtpv2_test.go b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/mtpv2_test.go deleted file mode 100644 index ad89e074..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/mtpv2_test.go +++ /dev/null @@ -1,699 +0,0 @@ -package mtpv2onchain - -import ( - "context" - json2 "encoding/json" - "math/big" - "testing" - - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql/v2/db/memory" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-schema-processor/merklize" - "github.com/stretchr/testify/require" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" - requestID = "32" -) - -type CredentialAtomicMTPOnChainV2Inputs struct { - RequestID string `json:"requestID"` - - // begin user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - UserAuthClaim *core.Claim `json:"authClaim"` - UserAuthClaimMtp []string `json:"authClaimIncMtp"` - UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - Challenge string `json:"challenge"` - ChallengeSignatureR8X string `json:"challengeSignatureR8x"` - ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` - ChallengeSignatureS string `json:"challengeSignatureS"` - UserClaimsTreeRoot string `json:"userClaimsTreeRoot"` - UserRevTreeRoot string `json:"userRevTreeRoot"` - UserRootsTreeRoot string `json:"userRootsTreeRoot"` - UserState string `json:"userState"` - GistRoot string `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - // end user data - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - // Inclusion - IssuerClaimMtp []string `json:"issuerClaimMtp"` - IssuerClaimClaimsTreeRoot *merkletree.Hash `json:"issuerClaimClaimsTreeRoot"` - IssuerClaimRevTreeRoot *merkletree.Hash `json:"issuerClaimRevTreeRoot"` - IssuerClaimRootsTreeRoot *merkletree.Hash `json:"issuerClaimRootsTreeRoot"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - - IssuerClaimNonRevClaimsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot *merkletree.Hash `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - - ClaimSchema string `json:"claimSchema"` - - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - Value []string `json:"value"` - IsRevocationChecked int `json:"isRevocationChecked"` -} - -type CredentialAtomicMTPOnChainV2Outputs struct { - Merklized string `json:"merklized"` - UserID string `json:"userID"` - CircuitQueryHash string `json:"circuitQueryHash"` - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - Timestamp string `json:"timestamp"` - GistRoot string `json:"gistRoot"` - Challenge string `json:"challenge"` - IsRevocationChecked string `json:"isRevocationChecked"` -} - -type TestDataOnChainMTPV2 struct { - Desc string `json:"desc"` - In CredentialAtomicMTPOnChainV2Inputs `json:"inputs"` - Out CredentialAtomicMTPOnChainV2Outputs `json:"expOut"` -} - -func Test_ClaimIssuedOnUserID(t *testing.T) { - desc := "OnChain: User == Subject. Claim issued on UserID" - isUserIDProfile := false - isSubjectIDProfile := false - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "claimIssuedOnUserID") -} - -func Test_ClaimIssuedOnUserProfileID(t *testing.T) { - desc := "OnChain: User != Subject. Claim issued on ProfileID" - isUserIDProfile := false - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "claimIssuedOnProfileID") -} - -func Test_ClaimIssuedOnUserProfileID2(t *testing.T) { - desc := "OnChain: User == Subject. Claim issued on ProfileID" - isUserIDProfile := true - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "claimIssuedOnProfileID2") -} - -func Test_ClaimNonMerklized(t *testing.T) { - desc := "OnChain: User == Subject. Claim non merklized claim" - isUserIDProfile := false - isSubjectIDProfile := false - - generateTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "claimNonMerklized") -} - -func Test_RevokedClaimWithoutRevocationCheck(t *testing.T) { - desc := "OnChain: Checking revoked status when claim is revoked onchain (MTP)" - fileName := "revoked_claim_without_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - issuer.AddClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - err := issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - require.NoError(t, err) - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicMTPOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - IsRevocationChecked: 0, - } - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicMTPOnChainV2Outputs{ - RequestID: requestID, - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - Timestamp: timestamp, - Merklized: "0", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "0", - } - - json, err := json2.Marshal(TestDataOnChainMTPV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_RevokedClaimWithRevocationCheck(t *testing.T) { - desc := "OnChain: User's claim revoked and the circuit checking for revocation status" - fileName := "revoked_claim_with_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - issuer.AddClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - err := issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - require.NoError(t, err) - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), utils.GistLevels) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicMTPOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, utils.GistLevels), - IsRevocationChecked: 1, - } - - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - out := CredentialAtomicMTPOnChainV2Outputs{ - RequestID: requestID, - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - Timestamp: timestamp, - Merklized: "0", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataOnChainMTPV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -// merklized -func generateJSONLDTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - issuer.AddClaim(t, claim) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicMTPOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: claimJSONLDProof, - ClaimPathMtpNoAux: claimJSONLDProofAux.NoAux, - ClaimPathMtpAuxHi: claimJSONLDProofAux.Key, - ClaimPathMtpAuxHv: claimJSONLDProofAux.Value, - ClaimPathKey: pathKey.String(), - ClaimPathValue: valueKey.String(), - Operator: utils.EQ, - SlotIndex: 0, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{valueKey.String()}, 64), - IsRevocationChecked: 1, - } - 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, - }) - require.NoError(t, err) - - out := CredentialAtomicMTPOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - Timestamp: timestamp, - Merklized: "1", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataOnChainMTPV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - claim := utils.DefaultUserClaim(t, subjectID) - - issuer.AddClaim(t, claim) - - issuerClaimMtp, _ := issuer.ClaimMTP(t, claim) - require.NoError(t, err) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicMTPOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimRevTreeRoot: issuer.Ret.Root(), - IssuerClaimRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: utils.PrepareStrArray([]string{}, 32), - ClaimPathMtpNoAux: "0", - ClaimPathMtpAuxHi: "0", - ClaimPathMtpAuxHv: "0", - ClaimPathKey: "0", - ClaimPathValue: "0", - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - IsRevocationChecked: 1, - } - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicMTPOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaimIdenState: issuer.State(t).String(), - IssuerClaimNonRevState: issuer.State(t).String(), - CircuitQueryHash: circuitQueryHash.String(), - Timestamp: timestamp, - Merklized: "0", - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataOnChainMTPV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID.json deleted file mode 100644 index 85e68ed0..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: User != Subject. Claim issued on ProfileID","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"999","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","issuerClaimNonRevClaimsTreeRoot":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID2.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID2.json deleted file mode 100644 index b41d0f3a..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnProfileID2.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: User == Subject. Claim issued on ProfileID","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","issuerClaimNonRevClaimsTreeRoot":"6807394214856867182702861581688414112931887520929949769131382186542423406679","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","issuerClaimNonRevState":"19610686287062380962892375049625048425838961734261320467083164088209350256405","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnUserID.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnUserID.json deleted file mode 100644 index efe78000..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimIssuedOnUserID.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: User == Subject. Claim issued on UserID","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevClaimsTreeRoot":"15931696748584854818716355440944340820148488238203452818912058603664260541937","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":0,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"1496222740463292783938163206931059379817846775593932664024082849882751356658","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","issuerClaimNonRevState":"14350982505419309247370121592555562539756979893755695438303858350858014373778","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimNonMerklized.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimNonMerklized.json deleted file mode 100644 index 441ff245..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/claimNonMerklized.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: User == Subject. Claim non merklized claim","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":1},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_with_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_with_revocation_check.json deleted file mode 100644 index 2a9c6bef..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_with_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: User's claim revoked and the circuit checking for revocation status","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","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":"0","claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":1},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_without_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_without_revocation_check.json deleted file mode 100644 index cf87999c..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/mtpv2/testdata/revoked_claim_without_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"OnChain: Checking revoked status when claim is revoked onchain (MTP)","inputs":{"requestID":"32","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","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":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevClaimsTreeRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","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":"0","claimSchema":"180410020913331409885634153623124536270","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":0},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","requestID":"32","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimIdenState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","issuerClaimNonRevState":"15576309859725957737825999002675353501019651055369992673353778544535511633588","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/sigv2_test.go b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/sigv2_test.go deleted file mode 100644 index 67639176..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/sigv2_test.go +++ /dev/null @@ -1,945 +0,0 @@ -package sigv2onchain - -import ( - "context" - json2 "encoding/json" - "math/big" - "testing" - - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql/v2/db/memory" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-schema-processor/merklize" - "github.com/stretchr/testify/require" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" - requestID = "41" -) - -type CredentialAtomicSigOnChainV2Inputs struct { - RequestID string `json:"requestID"` - - // begin user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - UserAuthClaim *core.Claim `json:"authClaim"` - UserAuthClaimMtp []string `json:"authClaimIncMtp"` - UserAuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - UserAuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - UserAuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - UserAuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - Challenge string `json:"challenge"` - ChallengeSignatureR8X string `json:"challengeSignatureR8x"` - ChallengeSignatureR8Y string `json:"challengeSignatureR8y"` - ChallengeSignatureS string `json:"challengeSignatureS"` - UserClaimsTreeRoot string `json:"userClaimsTreeRoot"` - UserRevTreeRoot string `json:"userRevTreeRoot"` - UserRootsTreeRoot string `json:"userRootsTreeRoot"` - UserState string `json:"userState"` - GistRoot string `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - // end user data - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - IssuerClaimNonRevClaimsTreeRoot string `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot string `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot string `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - ClaimSchema string `json:"claimSchema"` - IssuerClaimSignatureR8X string `json:"issuerClaimSignatureR8x"` - IssuerClaimSignatureR8Y string `json:"issuerClaimSignatureR8y"` - IssuerClaimSignatureS string `json:"issuerClaimSignatureS"` - IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` - IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` - IssuerAuthClaimNonRevMtp []string `json:"issuerAuthClaimNonRevMtp"` - IssuerAuthClaimNonRevMtpAuxHi string `json:"issuerAuthClaimNonRevMtpAuxHi"` - IssuerAuthClaimNonRevMtpAuxHv string `json:"issuerAuthClaimNonRevMtpAuxHv"` - IssuerAuthClaimNonRevMtpNoAux string `json:"issuerAuthClaimNonRevMtpNoAux"` - IssuerAuthClaimsTreeRoot string `json:"issuerAuthClaimsTreeRoot"` - IssuerAuthRevTreeRoot string `json:"issuerAuthRevTreeRoot"` - IssuerAuthRootsTreeRoot string `json:"issuerAuthRootsTreeRoot"` - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - Value []string `json:"value"` - IsRevocationChecked int `json:"isRevocationChecked"` -} - -type CredentialAtomicSigOnChainV2Outputs struct { - Merklized string `json:"merklized"` - UserID string `json:"userID"` - CircuitQueryHash string `json:"circuitQueryHash"` - IssuerAuthState string `json:"issuerAuthState"` - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - Timestamp string `json:"timestamp"` - GistRoot string `json:"gistRoot"` - Challenge string `json:"challenge"` - IsRevocationChecked string `json:"isRevocationChecked"` -} - -type TestDataSigV2 struct { - Desc string `json:"desc"` - In CredentialAtomicSigOnChainV2Inputs `json:"inputs"` - Out CredentialAtomicSigOnChainV2Outputs `json:"expOut"` -} - -func Test_UserID_Subject(t *testing.T) { - desc := "ON Chain: UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)" - isUserIDProfile := true - isSubjectIDProfile := false - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "userID_subject") -} - -func Test_IssueClaimToProfile(t *testing.T) { - desc := "ON Chain: UserID != Subject. UserID out. User nonce = 0. Claim issued on Profile (subject nonce = 999) (Merklized claim)" - isUserIDProfile := false - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject") -} - -func Test_IssueClaimToProfile_2(t *testing.T) { - - desc := "ON Chain: UserID != Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 0) (Merklized claim)" - isUserIDProfile := true - isSubjectIDProfile := false - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject_userid") -} - -func Test_IssueClaimToProfile_3(t *testing.T) { - - desc := "ON Chain: UserID == Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 999) (Merklized claim)" - isUserIDProfile := true - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject_profileID2") -} - -func Test_RegularClaim(t *testing.T) { - - desc := "ON Chain: UserID == Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Claim)" - isUserIDProfile := false - isSubjectIDProfile := false - - generateTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "regular_claim") -} - -func Test_RevokedClaimWithoutRevocationCheck(t *testing.T) { - desc := "ON Chain: User's claim revoked and the circuit not checking for revocation status" - fileName := "revoked_claim_without_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - claimSig := issuer.SignClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - issuerClaimNonRevState := issuer.State(t) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // hash of path in merklized json-ld document - ClaimPathValue: "0", // value in this path in merklized json-ld document - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - IsRevocationChecked: 0, - } - - issuerAuthState := issuer.State(t) - - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - Timestamp: timestamp, - Merklized: "0", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "0", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_RevokedClaimWithRevocationCheck(t *testing.T) { - desc := "ON Chain: User's claim revoked and the circuit checking for revocation status (expected to fail)" - fileName := "revoked_claim_with_revocation_check" - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - claimSig := issuer.SignClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - issuerClaimNonRevState := issuer.State(t) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // hash of path in merklized json-ld document - ClaimPathValue: "0", // value in this path in merklized json-ld document - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, utils.GistLevels), - IsRevocationChecked: 1, - } - - issuerAuthState := issuer.State(t) - - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - Timestamp: timestamp, - Merklized: "0", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_JSON_LD_Proof_non_inclusion(t *testing.T) { - - desc := "ON Chain: JSON-LD proof non inclusion. UserID = Subject. UserID out. User nonce = 0, " + - "Subject nonce = 0 claim issued on userID (" + - "Merklized claim)" - isUserIDProfile := false - isSubjectIDProfile := false - - generateJSONLD_NON_INCLUSION_TestData(t, isUserIDProfile, isSubjectIDProfile, desc, "jsonld_non_inclusion") -} - -// merklized -func generateJSONLDTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 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: valueKey.String(), // value in this path in merklized json-ld document - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{valueKey.String()}, 64), - IsRevocationChecked: 1, - } - - issuerAuthState := issuer.State(t) - - 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, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - Timestamp: timestamp, - Merklized: "1", - CircuitQueryHash: circuitQueryHash.String(), - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - claim := utils.DefaultUserClaim(t, subjectID) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // hash of path in merklized json-ld document - ClaimPathValue: "0", // value in this path in merklized json-ld document - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"10"}, 64), - IsRevocationChecked: 1, - } - - issuerAuthState := issuer.State(t) - - 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)), - big.NewInt(0), - big.NewInt(0), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - CircuitQueryHash: circuitQueryHash.String(), - Timestamp: timestamp, - Merklized: "0", - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, - fileName string) { - - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#testData") - require.NoError(t, err) - - jsonP, _, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - challenge := big.NewInt(12345) - - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.NoError(t, err) - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - sig := user.Sign(challenge) - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - require.NoError(t, err) - - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - inputs := CredentialAtomicSigOnChainV2Inputs{ - RequestID: requestID, - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - UserAuthClaim: user.AuthClaim, - UserAuthClaimMtp: authMTProof, - UserAuthClaimNonRevMtp: authNonRevMTProof, - UserAuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - UserAuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - UserAuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - Challenge: challenge.String(), - ChallengeSignatureR8X: sig.R8.X.String(), - ChallengeSignatureR8Y: sig.R8.Y.String(), - ChallengeSignatureS: sig.S.String(), - UserClaimsTreeRoot: user.Clt.Root().BigInt().String(), - UserRevTreeRoot: user.Ret.Root().BigInt().String(), - UserRootsTreeRoot: user.Rot.Root().BigInt().String(), - UserState: user.State(t).String(), - GistRoot: gistRoot.BigInt().String(), - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().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 - Operator: utils.NOOP, - SlotIndex: 0, - Timestamp: timestamp, - Value: utils.PrepareStrArray([]string{"0"}, 64), - IsRevocationChecked: 1, - } - - issuerAuthState := issuer.State(t) - - 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(1), - valuesHash, - }) - require.NoError(t, err) - - out := CredentialAtomicSigOnChainV2Outputs{ - RequestID: requestID, - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - CircuitQueryHash: circuitQueryHash.String(), - Timestamp: timestamp, - Merklized: "1", - Challenge: challenge.String(), - GistRoot: gistRoot.BigInt().String(), - IsRevocationChecked: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - Desc: desc, - In: inputs, - Out: out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/jsonld_non_inclusion.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/jsonld_non_inclusion.json deleted file mode 100644 index 2bb2fd40..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/jsonld_non_inclusion.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: JSON-LD proof non inclusion. UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"1","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","8572801910485227983539995488533475408768322385604766084351333237918158876183","0","21558280644890495634574226008223308568148491750171125081160458621552477288821","0","0","0","0","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":"15924483770554419123485443865253852621108414928056512791337538323107671760706","claimPathMtpAuxHv":"3649436878755004634629983548864752783389248075618975309339506929996626029578","claimPathKey":"4565618812218816904592638866963205946316329857551756884889133933625594842882","claimPathValue":"0","operator":0,"slotIndex":0,"timestamp":"1642074362","value":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"15647213801176738945778380140062097191238033502629315227513119051399956157850","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject.json deleted file mode 100644 index a6ee1840..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: UserID != Subject. UserID out. User nonce = 0. Claim issued on Profile (subject nonce = 999) (Merklized claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"999","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"20182323053626007196087938606884171693034410400799266202280743366729604996440","issuerClaimSignatureR8y":"20529421457864985372585403202509060910666604521668250902043119365522293707370","issuerClaimSignatureS":"121413623054693703954134599567469283900692572593162039605756532017839005547","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"17055061329686910061711483294099078173641776109555566375260051361977168049259","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_profileID2.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_profileID2.json deleted file mode 100644 index 93634553..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_profileID2.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: UserID == Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 999) (Merklized claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"20182323053626007196087938606884171693034410400799266202280743366729604996440","issuerClaimSignatureR8y":"20529421457864985372585403202509060910666604521668250902043119365522293707370","issuerClaimSignatureS":"121413623054693703954134599567469283900692572593162039605756532017839005547","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","circuitQueryHash":"17055061329686910061711483294099078173641776109555566375260051361977168049259","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_userid.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_userid.json deleted file mode 100644 index 05b2a09c..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/profileID_subject_userid.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: UserID != Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 0) (Merklized claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","circuitQueryHash":"17055061329686910061711483294099078173641776109555566375260051361977168049259","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/regular_claim.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/regular_claim.json deleted file mode 100644 index eca4ab92..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/regular_claim.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: UserID == Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":1},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_with_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_with_revocation_check.json deleted file mode 100644 index 07f7f7ec..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_with_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: User's claim revoked and the circuit checking for revocation status (expected to fail)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","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":"0","claimSchema":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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":"1","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"0","issuerAuthClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerAuthRootsTreeRoot":"0","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":1},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","issuerAuthState":"20420704177203139055971454163395877029462021737850567671726924780413332537","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_without_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_without_revocation_check.json deleted file mode 100644 index ce482c1a..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/revoked_claim_without_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: User's claim revoked and the circuit not checking for revocation status","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","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":"0","claimSchema":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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":"1","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"0","issuerAuthClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerAuthRootsTreeRoot":"0","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","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"],"isRevocationChecked":0},"expOut":{"merklized":"0","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","circuitQueryHash":"13056917131643527202292039715783962226503206267945877878242520938195265335304","issuerAuthState":"20420704177203139055971454163395877029462021737850567671726924780413332537","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/userID_subject.json b/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/userID_subject.json deleted file mode 100644 index f6b664fd..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/onchain/sigv2/testdata/userID_subject.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"ON Chain: UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)","inputs":{"requestID":"41","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"8162166103065016664685834856644195001371303013149727027131225893397958846382","userRevTreeRoot":"0","userRootsTreeRoot":"0","userState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","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":"1","gistMtpAuxHv":"1","gistMtpNoAux":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"isRevocationChecked":1},"expOut":{"merklized":"1","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","circuitQueryHash":"17055061329686910061711483294099078173641776109555566375260051361977168049259","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","requestID":"41","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","timestamp":"1642074362","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","challenge":"12345","isRevocationChecked":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/sigv2_test.go b/archive_circuits_V2/testvectorgen/credentials/sigv2/sigv2_test.go deleted file mode 100644 index 2db18ec0..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/sigv2_test.go +++ /dev/null @@ -1,704 +0,0 @@ -package sigv2 - -import ( - "context" - json2 "encoding/json" - "math/big" - "testing" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-schema-processor/merklize" - "github.com/stretchr/testify/require" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - issuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" -) - -type CredentialAtomicSigOffChainV2Inputs struct { - RequestID string `json:"requestID"` - - // user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - - IssuerID string `json:"issuerID"` - // Claim - IssuerClaim *core.Claim `json:"issuerClaim"` - IssuerClaimNonRevClaimsTreeRoot string `json:"issuerClaimNonRevClaimsTreeRoot"` - IssuerClaimNonRevRevTreeRoot string `json:"issuerClaimNonRevRevTreeRoot"` - IssuerClaimNonRevRootsTreeRoot string `json:"issuerClaimNonRevRootsTreeRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - ClaimSchema string `json:"claimSchema"` - IssuerClaimSignatureR8X string `json:"issuerClaimSignatureR8x"` - IssuerClaimSignatureR8Y string `json:"issuerClaimSignatureR8y"` - IssuerClaimSignatureS string `json:"issuerClaimSignatureS"` - IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` - IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` - IssuerAuthClaimNonRevMtp []string `json:"issuerAuthClaimNonRevMtp"` - IssuerAuthClaimNonRevMtpAuxHi string `json:"issuerAuthClaimNonRevMtpAuxHi"` - IssuerAuthClaimNonRevMtpAuxHv string `json:"issuerAuthClaimNonRevMtpAuxHv"` - IssuerAuthClaimNonRevMtpNoAux string `json:"issuerAuthClaimNonRevMtpNoAux"` - IssuerAuthClaimsTreeRoot string `json:"issuerAuthClaimsTreeRoot"` - IssuerAuthRevTreeRoot string `json:"issuerAuthRevTreeRoot"` - IssuerAuthRootsTreeRoot string `json:"issuerAuthRootsTreeRoot"` - // 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 - - Operator int `json:"operator"` - SlotIndex int `json:"slotIndex"` - Timestamp string `json:"timestamp"` - IsRevocationChecked int `json:"isRevocationChecked"` - Value []string `json:"value"` -} - -type CredentialAtomicSigOffChainV2Outputs struct { - RequestID string `json:"requestID"` - UserID string `json:"userID"` - IssuerID string `json:"issuerID"` - IssuerAuthState string `json:"issuerAuthState"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - ClaimSchema string `json:"claimSchema"` - SlotIndex string `json:"slotIndex"` - Operator int `json:"operator"` - Value []string `json:"value"` - Timestamp string `json:"timestamp"` - Merklized string `json:"merklized"` - ClaimPathNotExists string `json:"claimPathNotExists"` // 0 for inclusion, 1 for non-inclusion -} - -type TestDataSigV2 struct { - Desc string `json:"desc"` - In CredentialAtomicSigOffChainV2Inputs `json:"inputs"` - Out CredentialAtomicSigOffChainV2Outputs `json:"expOut"` -} - -func Test_UserID_Subject(t *testing.T) { - - desc := "UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)" - isUserIDProfile := false - isSubjectIDProfile := false - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "userID_subject") -} - -func Test_IssueClaimToProfile(t *testing.T) { - - desc := "UserID != Subject. UserID out. User nonce = 0. Claim issued on Profile (subject nonce = 999) (Merklized claim)" - isUserIDProfile := false - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject") -} - -func Test_IssueClaimToProfile_2(t *testing.T) { - - desc := "UserID != Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 0) (Merklized claim)" - isUserIDProfile := true - isSubjectIDProfile := false - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject_userid") -} - -func Test_IssueClaimToProfile_3(t *testing.T) { - - desc := "UserID == Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 999) (Merklized claim)" - isUserIDProfile := true - isSubjectIDProfile := true - - generateJSONLDTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "profileID_subject_profileID2") -} - -func Test_RegularClaim(t *testing.T) { - - desc := "UserID == Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Claim)" - isUserIDProfile := false - isSubjectIDProfile := false - - generateTestData(t, isUserIDProfile, isSubjectIDProfile, desc, "regular_claim") -} - -func Test_RevokedClaimWithoutRevocationCheck(t *testing.T) { - desc := "User's claim revoked and the circuit not checking for revocation status" - fileName := "revoked_claim_without_revocation_check" - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - claimSig := issuer.SignClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - issuerClaimNonRevState := issuer.State(t) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicSigOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // 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.EQ, - SlotIndex: 2, - Timestamp: timestamp, - IsRevocationChecked: 0, - Value: []string{"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"}, - } - - issuerAuthState := issuer.State(t) - - out := CredentialAtomicSigOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: []string{"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"}, - Timestamp: timestamp, - Merklized: "0", - ClaimPathNotExists: "0", - } - - json, err := json2.Marshal(TestDataSigV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_RevokedClaimWithRevocationCheck(t *testing.T) { - desc := "User's claim revoked and the circuit checking for revocation status (expected to fail)" - fileName := "revoked_claim_with_revocation_check" - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - nonce := big.NewInt(0) - nonceSubject := big.NewInt(0) - - claim := utils.DefaultUserClaim(t, user.ID) - claimSig := issuer.SignClaim(t, claim) - - revNonce := claim.GetRevocationNonce() - revNonceBigInt := new(big.Int).SetUint64(revNonce) - issuer.Ret.Add(context.Background(), revNonceBigInt, big.NewInt(0)) - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - issuerClaimNonRevState := issuer.State(t) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicSigOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // 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.EQ, - SlotIndex: 2, - Timestamp: timestamp, - IsRevocationChecked: 1, - Value: []string{"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"}, - } - - issuerAuthState := issuer.State(t) - - out := CredentialAtomicSigOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: user.ID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: []string{"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"}, - Timestamp: timestamp, - Merklized: "0", - ClaimPathNotExists: "0", - } - - json, err := json2.Marshal(TestDataSigV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func Test_JSON_LD_Proof_non_inclusion(t *testing.T) { - - desc := "JSON-LD proof non inclusion. UserID = Subject. UserID out. User nonce = 0, " + - "Subject nonce = 0 claim issued on userID (" + - "Merklized claim)" - isUserIDProfile := false - isSubjectIDProfile := false - - generateJSONLD_NON_INCLUSION_TestData(t, isUserIDProfile, isSubjectIDProfile, desc, "jsonld_non_inclusion") -} - -func generateJSONLDTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#residentSince") - require.NoError(t, err) - - jsonP, value, err := mz.Proof(context.Background(), path) - require.NoError(t, err) - - valueKey, err := value.MtEntry() - require.NoError(t, err) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicSigOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - - ClaimPathNotExists: "0", // 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: valueKey.String(), // value in this path in merklized json-ld document - // value in this path in merklized json-ld document - - Operator: utils.EQ, - SlotIndex: 2, - Timestamp: timestamp, - IsRevocationChecked: 1, - Value: []string{valueKey.String(), "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, - } - - issuerAuthState := issuer.State(t) - - out := CredentialAtomicSigOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: []string{"1420070400000000000", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, - Timestamp: timestamp, - Merklized: "1", - ClaimPathNotExists: "0", - } - - json, err := json2.Marshal(TestDataSigV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateTestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, fileName string) { - var err error - - user := utils.NewIdentity(t, userPK) - - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - claim := utils.DefaultUserClaim(t, subjectID) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - emptyPathMtp := utils.PrepareSiblingsStr([]*merkletree.Hash{&merkletree.HashZero}, 32) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicSigOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - ClaimSchema: "180410020913331409885634153623124536270", - - ClaimPathNotExists: "0", // 0 for inclusion, 1 for non-inclusion - ClaimPathMtp: emptyPathMtp, - ClaimPathMtpNoAux: "0", // 1 if aux node is empty, 0 if non-empty or for inclusion proofs - ClaimPathMtpAuxHi: "0", // 0 for inclusion proof - ClaimPathMtpAuxHv: "0", // 0 for inclusion proof - ClaimPathKey: "0", // 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.EQ, - SlotIndex: 2, - Timestamp: timestamp, - IsRevocationChecked: 1, - Value: []string{"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"}, - } - - issuerAuthState := issuer.State(t) - - out := CredentialAtomicSigOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "2", - Operator: utils.EQ, - Value: []string{"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"}, - Timestamp: timestamp, - Merklized: "0", - ClaimPathNotExists: "0", - } - - json, err := json2.Marshal(TestDataSigV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} - -func generateJSONLD_NON_INCLUSION_TestData(t *testing.T, isUserIDProfile, isSubjectIDProfile bool, desc, - fileName string) { - - var err error - - user := utils.NewIdentity(t, userPK) - issuer := utils.NewIdentity(t, issuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - mz, claim := utils.DefaultJSONUserClaim(t, subjectID) - - path, err := merklize.NewPath( - "https://www.w3.org/2018/credentials#credentialSubject", - "https://w3id.org/citizenship#testData") - require.NoError(t, err) - - jsonP, _, err := mz.Proof(context.Background(), path) - - claimJSONLDProof, claimJSONLDProofAux := utils.PrepareProof(jsonP, utils.ClaimLevels) - - pathKey, err := path.MtEntry() - require.NoError(t, err) - - // Sig claim - claimSig := issuer.SignClaim(t, claim) - - issuerClaimNonRevState := issuer.State(t) - - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - requestID := big.NewInt(23) - - inputs := CredentialAtomicSigOffChainV2Inputs{ - RequestID: requestID.String(), - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerClaim: claim, - IssuerClaimNonRevClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsTreeRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsTreeRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevTreeRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsTreeRoot: issuer.Rot.Root().BigInt().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 - // value in this path in merklized json-ld document - - Operator: utils.NOOP, - SlotIndex: 0, - Timestamp: timestamp, - IsRevocationChecked: 1, - Value: []string{"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, - } - - issuerAuthState := issuer.State(t) - - out := CredentialAtomicSigOffChainV2Outputs{ - RequestID: requestID.String(), - UserID: userProfileID.BigInt().String(), - IssuerID: issuer.ID.BigInt().String(), - IssuerAuthState: issuerAuthState.String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - ClaimSchema: "180410020913331409885634153623124536270", - SlotIndex: "0", - Operator: utils.NOOP, - Value: []string{"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, - Timestamp: timestamp, - Merklized: "1", - ClaimPathNotExists: "1", - } - - json, err := json2.Marshal(TestDataSigV2{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/jsonld_non_inclusion.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/jsonld_non_inclusion.json deleted file mode 100644 index be146437..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/jsonld_non_inclusion.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"JSON-LD proof non inclusion. UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"1","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","8572801910485227983539995488533475408768322385604766084351333237918158876183","0","21558280644890495634574226008223308568148491750171125081160458621552477288821","0","0","0","0","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":"15924483770554419123485443865253852621108414928056512791337538323107671760706","claimPathMtpAuxHv":"3649436878755004634629983548864752783389248075618975309339506929996626029578","claimPathKey":"4565618812218816904592638866963205946316329857551756884889133933625594842882","claimPathValue":"0","operator":0,"slotIndex":0,"timestamp":"1642074362","isRevocationChecked":1,"value":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"0","operator":0,"value":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathNotExists":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject.json deleted file mode 100644 index a7c297a7..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"UserID != Subject. UserID out. User nonce = 0. Claim issued on Profile (subject nonce = 999) (Merklized claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"999","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"20182323053626007196087938606884171693034410400799266202280743366729604996440","issuerClaimSignatureR8y":"20529421457864985372585403202509060910666604521668250902043119365522293707370","issuerClaimSignatureS":"121413623054693703954134599567469283900692572593162039605756532017839005547","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_profileID2.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_profileID2.json deleted file mode 100644 index 622f5e49..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_profileID2.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"UserID == Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 999) (Merklized claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","24497320812635010775435456013830217801375919178980935564312517783529521153","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"20182323053626007196087938606884171693034410400799266202280743366729604996440","issuerClaimSignatureR8y":"20529421457864985372585403202509060910666604521668250902043119365522293707370","issuerClaimSignatureS":"121413623054693703954134599567469283900692572593162039605756532017839005547","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_userid.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_userid.json deleted file mode 100644 index 25892232..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/profileID_subject_userid.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"UserID != Subject. UserProfile out. User nonce = 10. Claim issued on Profile (subject nonce = 0) (Merklized claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/regular_claim.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/regular_claim.json deleted file mode 100644 index 74e148a3..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/regular_claim.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"UserID == Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_with_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_with_revocation_check.json deleted file mode 100644 index 86e34287..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_with_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User's claim revoked and the circuit checking for revocation status (expected to fail)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","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":"0","claimSchema":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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":"1","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"0","issuerAuthClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerAuthRootsTreeRoot":"0","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"20420704177203139055971454163395877029462021737850567671726924780413332537","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_without_revocation_check.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_without_revocation_check.json deleted file mode 100644 index f6a76558..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/revoked_claim_without_revocation_check.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"User's claim revoked and the circuit not checking for revocation status","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","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":"0","claimSchema":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","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":"1","issuerAuthClaimNonRevMtpAuxHv":"0","issuerAuthClaimNonRevMtpNoAux":"0","issuerAuthClaimsTreeRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevTreeRoot":"19374975721259875597650302716689543547647001662517455822229477759190533109280","issuerAuthRootsTreeRoot":"0","claimPathNotExists":"0","claimPathMtp":["0","0","0","0","0","0","0","0","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":"0","claimPathValue":"0","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":0,"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"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"20420704177203139055971454163395877029462021737850567671726924780413332537","issuerClaimNonRevState":"20420704177203139055971454163395877029462021737850567671726924780413332537","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"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"],"timestamp":"1642074362","merklized":"0","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/userID_subject.json b/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/userID_subject.json deleted file mode 100644 index 4f9720fb..00000000 --- a/archive_circuits_V2/testvectorgen/credentials/sigv2/testdata/userID_subject.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"UserID = Subject. UserID out. User nonce = 0, Subject nonce = 0 claim issued on userID (Merklized claim)","inputs":{"requestID":"23","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerClaim":["14472269431592746875347367665757389417422","23148936466334350744548790012294489365207440754509988986684797708370051073","17568057213828477233507447080689055308823020388972334380526849356111335110900","0","30803922965249841627828060170","0","0","0"],"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":"180410020913331409885634153623124536270","issuerClaimSignatureR8x":"16040911300643389087133289197280903408637469426127492280866768920345924378805","issuerClaimSignatureR8y":"19031885154371660080142259857483717581648221991555571973619296380694440069623","issuerClaimSignatureS":"1222459322759091234535554313867040847532955367435200603686472935613253652327","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","claimPathNotExists":"0","claimPathMtp":["5559250731000753554753485016695600829384855452867544273344893815961938985436","20222899544143787877985297439625828822272100269106711904511119118819809140477","14730426618666280941604039095550905490156541514901979358549599762282042588641","20497288520738821800886677250569208588689763166335933087499619993954968899866","3295720551404287572425718873751040314503774617833462052445584373469655789999","796356776410152646380783209242693344675665178494017735650545708722024766291","0","0","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":"8566939875427719562376598811066985304309117528846759529734201066483458512800","claimPathValue":"1420070400000000000","operator":1,"slotIndex":2,"timestamp":"1642074362","isRevocationChecked":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},"expOut":{"requestID":"23","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094","issuerClaimNonRevState":"2943483356559152311923412925436024635269538717812859789851139200242297094","claimSchema":"180410020913331409885634153623124536270","slotIndex":"2","operator":1,"value":["1420070400000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"timestamp":"1642074362","merklized":"1","claimPathNotExists":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/go.mod b/archive_circuits_V2/testvectorgen/go.mod deleted file mode 100644 index bd0c2093..00000000 --- a/archive_circuits_V2/testvectorgen/go.mod +++ /dev/null @@ -1,24 +0,0 @@ -module test - -go 1.18 - -require ( - github.com/iden3/go-iden3-core v1.0.1 - github.com/iden3/go-iden3-crypto v0.0.14 - github.com/iden3/go-merkletree-sql/v2 v2.0.2 - github.com/iden3/go-schema-processor v1.1.2 - github.com/stretchr/testify v1.8.2 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dchest/blake512 v1.0.0 // indirect - github.com/ethereum/go-ethereum v1.10.26 - github.com/mr-tron/base58 v1.2.0 // indirect - github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/pquerna/cachecontrol v0.1.0 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/sys v0.6.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/archive_circuits_V2/testvectorgen/go.sum b/archive_circuits_V2/testvectorgen/go.sum deleted file mode 100644 index 14f8b02b..00000000 --- a/archive_circuits_V2/testvectorgen/go.sum +++ /dev/null @@ -1,72 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dchest/blake512 v1.0.0 h1:oDFEQFIqFSeuA34xLtXZ/rWxCXdSjirjzPhey5EUvmA= -github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= -github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= -github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= -github.com/iden3/go-iden3-core v0.1.1-0.20221219072518-403916345ce1 h1:6pSR3C7yjppT0I95TAu3+7yCM+7LbtvqfejEiXdXBeg= -github.com/iden3/go-iden3-core v0.1.1-0.20221219072518-403916345ce1/go.mod h1:wJtcMK/bSazyW/JrQaRrbpUMgSMg79Pke3xgtfPxDnQ= -github.com/iden3/go-iden3-core v1.0.1 h1:Oc/xPI/F7WDoMoZUAUIZrJ1VnYRP0JWkjl9OujDvxRM= -github.com/iden3/go-iden3-core v1.0.1/go.mod h1:g2HGSORT8QJ3u8Sp5i1i+FqEMxAMzYfdMglQt4raxno= -github.com/iden3/go-iden3-crypto v0.0.13 h1:ixWRiaqDULNyIDdOWz2QQJG5t4PpNHkQk2P6GV94cok= -github.com/iden3/go-iden3-crypto v0.0.13/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo= -github.com/iden3/go-iden3-crypto v0.0.14 h1:HQnFchY735JRNQxof6n/Vbyon4owj4+Ku+LNAamWV6c= -github.com/iden3/go-iden3-crypto v0.0.14/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= -github.com/iden3/go-merkletree-sql/v2 v2.0.0 h1:7tMgHCUJCo0jxyM15fjCc7G9Dy0x2rmX+lwa8tqEfho= -github.com/iden3/go-merkletree-sql/v2 v2.0.0/go.mod h1:hQbfImlyOJiI+c8FFuFiEMrjpZN0PylRb0aT8uAa+Sg= -github.com/iden3/go-merkletree-sql/v2 v2.0.2 h1:OylwdQlR0rCxGdUfE3R6HLH6IjlTs13IVB2Fi9Z02Rk= -github.com/iden3/go-merkletree-sql/v2 v2.0.2/go.mod h1:68u+rKk9RU/h4KUm1hnUS9tT3ZfeSAyyrSiWmzZH5gI= -github.com/iden3/go-schema-processor v0.2.1-0.20221108160946-1b71a2d1b644 h1:G9M/uwIFgYcOR2Qo6l3PI3lEX3Thdi+WBxrRdCeH6dM= -github.com/iden3/go-schema-processor v0.2.1-0.20221108160946-1b71a2d1b644/go.mod h1:0r6MLeQRtlyDiUHAOPrN/R6YJj/Jhn1ZI6DPwGCh4hU= -github.com/iden3/go-schema-processor v1.1.2 h1:us+oTbZq+4c2aMjYv80TzOVWCZ0R4N5sSk9R6gp5JiY= -github.com/iden3/go-schema-processor v1.1.2/go.mod h1:Irj/LOiEntZRUqa3Xio0VuHG6v6pP4vo3uxo5lEv4UM= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= -github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/piprate/json-gold v0.4.1 h1:JYbYN36n6YcAYipKy3ttv3X2HDQPeqWqmwta35NPj04= -github.com/piprate/json-gold v0.4.1/go.mod h1:OK1z7UgtBZk06n2cDE2OSq1kffmjFFp5/2yhLLCz9UM= -github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f h1:HlPa7RcxTCrva5izPfTEfvYecO7LTahgmMRD1Qp13xg= -github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAmPf4YLrFg6oQUotqHQeUNWwkvo7jZp1GLU= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc= -github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM= -github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 h1:kACShD3qhmr/3rLmg1yXyt+N4HcwutKyPRB93s54TIU= -golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/archive_circuits_V2/testvectorgen/statetransition/stateTransition_test.go b/archive_circuits_V2/testvectorgen/statetransition/stateTransition_test.go deleted file mode 100644 index 4bbd1fb8..00000000 --- a/archive_circuits_V2/testvectorgen/statetransition/stateTransition_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package main - -import ( - json2 "encoding/json" - "math/big" - "testing" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/stretchr/testify/require" -) - -const ( - userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - userPK2 = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - timestamp = "1642074362" -) - -type StateTransitionInputs struct { - AuthClaim *core.Claim `json:"authClaim"` - AuthClaimMtp []string `json:"authClaimMtp"` - AuthClaimNonRevMtp []string `json:"authClaimNonRevMtp"` - AuthClaimNonRevMtpAuxHi string `json:"authClaimNonRevMtpAuxHi"` - AuthClaimNonRevMtpAuxHv string `json:"authClaimNonRevMtpAuxHv"` - AuthClaimNonRevMtpNoAux string `json:"authClaimNonRevMtpNoAux"` - ClaimsTreeRoot string `json:"claimsTreeRoot"` - IsOldStateGenesis string `json:"isOldStateGenesis"` - NewUserState string `json:"newUserState"` - OldUserState string `json:"oldUserState"` - RevTreeRoot string `json:"revTreeRoot"` - RootsTreeRoot string `json:"rootsTreeRoot"` - SignatureR8X string `json:"signatureR8x"` - SignatureR8Y string `json:"signatureR8y"` - SignatureS string `json:"signatureS"` - UserID string `json:"userID"` - NewAuthClaimMtp []string `json:"newAuthClaimMtp"` - NewClaimsTreeRoot string `json:"newClaimsTreeRoot"` - NewRevTreeRoot string `json:"newRevTreeRoot"` - NewRootsTreeRoot string `json:"newRootsTreeRoot"` -} - -type StateTransitionOutputs struct { - ID string `json:"userID"` - NewUserState string `json:"newUserState"` - OldUserState string `json:"oldUserState"` - IsOldStateGenesis string `json:"isOldStateGenesis"` -} - -type TestDataStateTransition struct { - Desc string `json:"desc"` - In StateTransitionInputs `json:"inputs"` - Out StateTransitionOutputs `json:"expOut"` -} - -func Test_GenesisState(t *testing.T) { - - desc := "Positive: old state is genesis" - isUserStateGenesis := false - - generateAuthTestData(t, isUserStateGenesis, desc, "genesis_state") -} - -func Test_NotGenesis(t *testing.T) { - - desc := "Positive: old state is not genesis" - isUserStateGenesis := true - - generateAuthTestData(t, isUserStateGenesis, desc, "not_genesis_state") -} - -func generateAuthTestData(t *testing.T, genesis bool, desc, fileName string) { - - user := utils.NewIdentity(t, userPK) - - isGenesis := "1" - - // user - authMTProof := user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev := user.ClaimRevMTP(t, user.AuthClaim) - - oldState := user.State(t) // old state is genesis - oldCltRoot := user.Clt.Root().BigInt().String() - oldRevRoot := user.Ret.Root().BigInt().String() - oldRotRoot := user.Rot.Root().BigInt().String() - - //if genesis == false { - // extract pubKey - authClaim2, _ := utils.NewAuthClaim(t, userPK2) - - user.AddClaim(t, authClaim2) - - if genesis { - isGenesis = "0" - - oldState = user.State(t) // old state is genesis - oldCltRoot = user.Clt.Root().BigInt().String() - oldRevRoot = user.Ret.Root().BigInt().String() - oldRotRoot = user.Rot.Root().BigInt().String() - authMTProof = user.AuthMTPStrign(t) - - authNonRevMTProof, nodeAuxNonRev = user.ClaimRevMTP(t, user.AuthClaim) - - claim1 := utils.DefaultUserClaim(t, user.ID) - - user.AddClaim(t, claim1) - } - - newAuthMTProof := user.AuthMTPStrign(t) - newCltRoot := user.Clt.Root().BigInt().String() - newRevRoot := user.Ret.Root().BigInt().String() - newRotRoot := user.Rot.Root().BigInt().String() - - hashOldAndNewStates, err := poseidon.Hash( - []*big.Int{oldState, user.State(t)}) - require.NoError(t, err) - - sig := user.Sign(hashOldAndNewStates) - require.NoError(t, err) - - inputs := StateTransitionInputs{ - AuthClaim: user.AuthClaim, - AuthClaimMtp: authMTProof, - AuthClaimNonRevMtp: authNonRevMTProof, - AuthClaimNonRevMtpAuxHi: nodeAuxNonRev.Key, - AuthClaimNonRevMtpAuxHv: nodeAuxNonRev.Value, - AuthClaimNonRevMtpNoAux: nodeAuxNonRev.NoAux, - ClaimsTreeRoot: oldCltRoot, - RevTreeRoot: oldRevRoot, - RootsTreeRoot: oldRotRoot, - IsOldStateGenesis: isGenesis, - NewUserState: user.State(t).String(), - OldUserState: oldState.String(), - SignatureR8X: sig.R8.X.String(), - SignatureR8Y: sig.R8.Y.String(), - SignatureS: sig.S.String(), - UserID: user.ID.BigInt().String(), - NewAuthClaimMtp: newAuthMTProof, - NewClaimsTreeRoot: newCltRoot, - NewRevTreeRoot: newRevRoot, - NewRootsTreeRoot: newRotRoot, - } - - out := StateTransitionOutputs{ - ID: user.ID.BigInt().String(), - NewUserState: user.State(t).String(), - OldUserState: oldState.String(), - IsOldStateGenesis: isGenesis, - } - - json, err := json2.Marshal(TestDataStateTransition{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(json)) -} diff --git a/archive_circuits_V2/testvectorgen/statetransition/testdata/genesis_state.json b/archive_circuits_V2/testvectorgen/statetransition/testdata/genesis_state.json deleted file mode 100644 index 4c30b19c..00000000 --- a/archive_circuits_V2/testvectorgen/statetransition/testdata/genesis_state.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Positive: old state is genesis","inputs":{"authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8162166103065016664685834856644195001371303013149727027131225893397958846382","isOldStateGenesis":"1","newUserState":"7115004997868594253010848596868364067574661249707337517331323113105592633327","oldUserState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"361334819250135520716365635022122247186670085686564049934525264070020416049","signatureR8y":"12042336291028251258550374788607627666686750111534178228739359925952013099936","signatureS":"645508208020072463318799638644724392823438047603420864503725876203473805941","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newAuthClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newUserState":"7115004997868594253010848596868364067574661249707337517331323113105592633327","oldUserState":"8039964009611210398788855768060749920589777058607598891238307089541758339342","isOldStateGenesis":"1"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/statetransition/testdata/not_genesis_state.json b/archive_circuits_V2/testvectorgen/statetransition/testdata/not_genesis_state.json deleted file mode 100644 index 9fbeb324..00000000 --- a/archive_circuits_V2/testvectorgen/statetransition/testdata/not_genesis_state.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Positive: old state is not genesis","inputs":{"authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","claimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","isOldStateGenesis":"0","newUserState":"4546963942567895423749885008322935416520496550192665955639269179690288593086","oldUserState":"7115004997868594253010848596868364067574661249707337517331323113105592633327","revTreeRoot":"0","rootsTreeRoot":"0","signatureR8x":"19792717827219247588340137942112667964752038741073755597812783308633602002923","signatureR8y":"18334606748072315204305185631923152010223623371080284437052328775686642130235","signatureS":"2721187812724335077262719565987574803056292223585968358948256562899513979328","userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newAuthClaimMtp":["12556597401519486330285452122029558251875639613246233735882741175375581672376","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"newClaimsTreeRoot":"18118219877539765573291833245327124699251574510619312960034151483254231260771","newRevTreeRoot":"0","newRootsTreeRoot":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","newUserState":"4546963942567895423749885008322935416520496550192665955639269179690288593086","oldUserState":"7115004997868594253010848596868364067574661249707337517331323113105592633327","isOldStateGenesis":"0"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/model.go b/archive_circuits_V2/testvectorgen/sybil/model.go deleted file mode 100644 index 17ce5e20..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/model.go +++ /dev/null @@ -1,139 +0,0 @@ -package sybil - -import ( - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-merkletree-sql/v2" -) - -const ( - mtpUserPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - mtpIssuerPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69d" - - timestamp = "1642074362" -) - -type InputsMTP struct { - - // claim of uniqueness - IssuerClaim *core.Claim `json:"issuerClaim"` - IssuerClaimMtp []string `json:"issuerClaimMtp"` - IssuerClaimClaimsRoot *merkletree.Hash `json:"issuerClaimClaimsRoot"` - IssuerClaimRevRoot *merkletree.Hash `json:"issuerClaimRevRoot"` - IssuerClaimRootsRoot *merkletree.Hash `json:"issuerClaimRootsRoot"` - IssuerClaimIdenState string `json:"issuerClaimIdenState"` - - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - - IssuerClaimNonRevClaimsRoot *merkletree.Hash `json:"issuerClaimNonRevClaimsRoot"` - IssuerClaimNonRevRevRoot *merkletree.Hash `json:"issuerClaimNonRevRevRoot"` - IssuerClaimNonRevRootsRoot *merkletree.Hash `json:"issuerClaimNonRevRootsRoot"` - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - - ClaimSchema string `json:"claimSchema"` - - StateCommitmentClaim *core.Claim `json:"stateCommitmentClaim"` - StateCommitmentClaimMtp []string `json:"stateCommitmentClaimMtp"` - StateCommitmentClaimClaimsRoot *merkletree.Hash `json:"stateCommitmentClaimClaimsRoot"` - StateCommitmentClaimRevRoot *merkletree.Hash `json:"stateCommitmentClaimRevRoot"` - StateCommitmentClaimRootsRoot *merkletree.Hash `json:"stateCommitmentClaimRootsRoot"` - StateCommitmentClaimIdenState string `json:"stateCommitmentClaimIdenState"` - - GistRoot *merkletree.Hash `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - - CRS string `json:"crs"` - - // user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - Timestamp string `json:"timestamp"` -} - -type InputsSig struct { - - // claim of uniqueness - IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` - IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` - IssuerAuthClaimsRoot string `json:"issuerAuthClaimsRoot"` - IssuerAuthRevRoot string `json:"issuerAuthRevRoot"` - IssuerAuthRootsRoot string `json:"issuerAuthRootsRoot"` - - IssuerAuthClaimNonRevMtp []string `json:"issuerAuthClaimNonRevMtp"` - IssuerAuthClaimNonRevMtpAuxHi string `json:"issuerAuthClaimNonRevMtpAuxHi"` - IssuerAuthClaimNonRevMtpAuxHv string `json:"issuerAuthClaimNonRevMtpAuxHv"` - IssuerAuthClaimNonRevMtpNoAux string `json:"issuerAuthClaimNonRevMtpNoAux"` - - IssuerClaim *core.Claim `json:"issuerClaim"` - IssuerClaimNonRevClaimsRoot string `json:"issuerClaimNonRevClaimsRoot"` - IssuerClaimNonRevRevRoot string `json:"issuerClaimNonRevRevRoot"` - IssuerClaimNonRevRootsRoot string `json:"issuerClaimNonRevRootsRoot"` - - IssuerClaimNonRevState string `json:"issuerClaimNonRevState"` - IssuerClaimNonRevMtp []string `json:"issuerClaimNonRevMtp"` - IssuerClaimNonRevMtpAuxHi string `json:"issuerClaimNonRevMtpAuxHi"` - IssuerClaimNonRevMtpAuxHv string `json:"issuerClaimNonRevMtpAuxHv"` - IssuerClaimNonRevMtpNoAux string `json:"issuerClaimNonRevMtpNoAux"` - - IssuerClaimSignatureR8X string `json:"issuerClaimSignatureR8x"` - IssuerClaimSignatureR8Y string `json:"issuerClaimSignatureR8y"` - IssuerClaimSignatureS string `json:"issuerClaimSignatureS"` - - ClaimSchema string `json:"claimSchema"` - - StateCommitmentClaim *core.Claim `json:"stateCommitmentClaim"` - StateCommitmentClaimMtp []string `json:"stateCommitmentClaimMtp"` - StateCommitmentClaimClaimsRoot *merkletree.Hash `json:"stateCommitmentClaimClaimsRoot"` - StateCommitmentClaimRevRoot *merkletree.Hash `json:"stateCommitmentClaimRevRoot"` - StateCommitmentClaimRootsRoot *merkletree.Hash `json:"stateCommitmentClaimRootsRoot"` - StateCommitmentClaimIdenState string `json:"stateCommitmentClaimIdenState"` - - GistRoot *merkletree.Hash `json:"gistRoot"` - GistMtp []string `json:"gistMtp"` - GistMtpAuxHi string `json:"gistMtpAuxHi"` - GistMtpAuxHv string `json:"gistMtpAuxHv"` - GistMtpNoAux string `json:"gistMtpNoAux"` - - CRS string `json:"crs"` - - // user data - UserGenesisID string `json:"userGenesisID"` - ProfileNonce string `json:"profileNonce"` - ClaimSubjectProfileNonce string `json:"claimSubjectProfileNonce"` - - RequestID string `json:"requestID"` - IssuerID string `json:"issuerID"` - Timestamp string `json:"timestamp"` -} - -type OutputsMTP struct { - UserID string `json:"userID"` - SybilID string `json:"sybilID"` -} - -type OutputsSig struct { - UserID string `json:"userID"` - SybilID string `json:"sybilID"` - IssuerAuthState string `json:"issuerAuthState"` -} - -type TestDataMTP struct { - Desc string `json:"desc"` - In InputsMTP `json:"inputs"` - Out OutputsMTP `json:"expOut"` -} - -type TestDataSig struct { - Desc string `json:"desc"` - In InputsSig `json:"inputs"` - Out OutputsSig `json:"expOut"` -} diff --git a/archive_circuits_V2/testvectorgen/sybil/sybil.go b/archive_circuits_V2/testvectorgen/sybil/sybil.go deleted file mode 100644 index b6247e13..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/sybil.go +++ /dev/null @@ -1,277 +0,0 @@ -package sybil - -import ( - "context" - "encoding/json" - "fmt" - "math/big" - "testing" - - "test/utils" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-iden3-crypto/babyjub" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-merkletree-sql/v2/db/memory" - "github.com/stretchr/testify/require" -) - -func generateTestDataMTP(t *testing.T, desc, fileName string, invalidGist, invalidIdentity, isUserIDProfile, isSubjectIDProfile bool) { - var err error - - user := utils.NewIdentity(t, mtpUserPK) - issuer := utils.NewIdentity(t, mtpIssuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - expectedSybilID := "10471698337950695878316330095385673516661727327544830961388283775499658220263" - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - // unique claim - uniClaim := utils.DefaultUserClaim(t, subjectID) - issuer.AddClaim(t, uniClaim) - issuerClaimMtp, _ := issuer.ClaimMTP(t, uniClaim) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, uniClaim) - - secret := big.NewInt(10) - scClaim := utils.GenerateNewStateCommitmentClaim(t, secret) - user.AddClaim(t, scClaim) - userClaimMtp, _ := user.ClaimMTP(t, scClaim) - - // gist - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), user.IDHash(t), user.State(t)) - require.Nil(t, err) - - if invalidGist { - gisTree, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(3), big.NewInt(3)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), big.NewInt(4), big.NewInt(4)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), big.NewInt(5), big.NewInt(5)) - require.Nil(t, err) - } - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - if invalidIdentity { - sk := babyjub.NewRandPrivKey() - skB := sk.Scalar().BigInt().Bytes() - user = utils.NewIdentity(t, fmt.Sprintf("%x", skB)) - } - - inputs := InputsMTP{ - IssuerClaim: uniClaim, - IssuerClaimMtp: issuerClaimMtp, - IssuerClaimClaimsRoot: issuer.Clt.Root(), - IssuerClaimRevRoot: issuer.Ret.Root(), - IssuerClaimRootsRoot: issuer.Rot.Root(), - IssuerClaimIdenState: issuer.State(t).String(), - - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - - IssuerClaimNonRevClaimsRoot: issuer.Clt.Root(), - IssuerClaimNonRevRevRoot: issuer.Ret.Root(), - IssuerClaimNonRevRootsRoot: issuer.Rot.Root(), - IssuerClaimNonRevState: issuer.State(t).String(), - - ClaimSchema: "180410020913331409885634153623124536270", - - StateCommitmentClaim: scClaim, - StateCommitmentClaimMtp: userClaimMtp, - StateCommitmentClaimClaimsRoot: user.Clt.Root(), - StateCommitmentClaimRevRoot: user.Ret.Root(), - StateCommitmentClaimRootsRoot: user.Rot.Root(), - StateCommitmentClaimIdenState: user.State(t).String(), - - GistRoot: gistRoot, - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - - CRS: big.NewInt(123456789).String(), - - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - ClaimSubjectProfileNonce: nonceSubject.String(), - - IssuerID: issuer.ID.BigInt().String(), - RequestID: "321", - Timestamp: timestamp, - } - - out := OutputsMTP{ - UserID: userProfileID.BigInt().String(), - SybilID: expectedSybilID, - } - - jsonTestData, err := json.Marshal(TestDataMTP{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(jsonTestData)) -} - -func generateTestDataSig(t *testing.T, desc, fileName string, invalidGist, invalidIdentity, isUserIDProfile, isSubjectIDProfile bool) { - user := utils.NewIdentity(t, mtpUserPK) - issuer := utils.NewIdentity(t, mtpIssuerPK) - - userProfileID := user.ID - nonce := big.NewInt(0) - var err error - if isUserIDProfile { - nonce = big.NewInt(10) - userProfileID, err = core.ProfileID(user.ID, nonce) - require.NoError(t, err) - } - - expectedSybilID := "10471698337950695878316330095385673516661727327544830961388283775499658220263" - expectedIssuerAuthState := "2943483356559152311923412925436024635269538717812859789851139200242297094" - - subjectID := user.ID - nonceSubject := big.NewInt(0) - if isSubjectIDProfile { - nonceSubject = big.NewInt(999) - subjectID, err = core.ProfileID(user.ID, nonceSubject) - require.NoError(t, err) - } - - // Sig claim - claim := utils.DefaultUserClaim(t, subjectID) - - claimSig := issuer.SignClaim(t, claim) - issuerClaimNonRevState := issuer.State(t) - issuerClaimNonRevMtp, issuerClaimNonRevAux := issuer.ClaimRevMTP(t, claim) - issuerAuthClaimMtp, issuerAuthClaimNodeAux := issuer.ClaimRevMTP(t, issuer.AuthClaim) - - secret := big.NewInt(10) - scClaim := utils.GenerateNewStateCommitmentClaim(t, secret) - user.AddClaim(t, scClaim) - userClaimMtp, _ := user.ClaimMTP(t, scClaim) - - // gist - gisTree, err := merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(1), big.NewInt(1)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), user.IDHash(t), user.State(t)) - require.Nil(t, err) - - if invalidGist { - gisTree, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), 64) - require.Nil(t, err) - err = gisTree.Add(context.Background(), big.NewInt(3), big.NewInt(3)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), big.NewInt(4), big.NewInt(4)) - require.Nil(t, err) - - err = gisTree.Add(context.Background(), big.NewInt(5), big.NewInt(5)) - require.Nil(t, err) - } - - gistProofRaw, _, err := gisTree.GenerateProof(context.Background(), user.IDHash(t), nil) - gistRoot := gisTree.Root() - gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - - if invalidIdentity { - sk := babyjub.NewRandPrivKey() - skB := sk.Scalar().BigInt().Bytes() - user = utils.NewIdentity(t, fmt.Sprintf("%x", skB)) - } - - inputs := InputsSig{ - IssuerClaim: claim, - IssuerClaimNonRevClaimsRoot: issuer.Clt.Root().BigInt().String(), - IssuerClaimNonRevRevRoot: issuer.Ret.Root().BigInt().String(), - IssuerClaimNonRevRootsRoot: issuer.Rot.Root().BigInt().String(), - IssuerClaimNonRevState: issuerClaimNonRevState.String(), - IssuerClaimNonRevMtp: issuerClaimNonRevMtp, - IssuerClaimNonRevMtpAuxHi: issuerClaimNonRevAux.Key, - IssuerClaimNonRevMtpAuxHv: issuerClaimNonRevAux.Value, - IssuerClaimNonRevMtpNoAux: issuerClaimNonRevAux.NoAux, - IssuerClaimSignatureR8X: claimSig.R8.X.String(), - IssuerClaimSignatureR8Y: claimSig.R8.Y.String(), - IssuerClaimSignatureS: claimSig.S.String(), - IssuerAuthClaim: issuer.AuthClaim, - IssuerAuthClaimMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtp: issuerAuthClaimMtp, - IssuerAuthClaimNonRevMtpAuxHi: issuerAuthClaimNodeAux.Key, - IssuerAuthClaimNonRevMtpAuxHv: issuerAuthClaimNodeAux.Value, - IssuerAuthClaimNonRevMtpNoAux: issuerAuthClaimNodeAux.NoAux, - IssuerAuthClaimsRoot: issuer.Clt.Root().BigInt().String(), - IssuerAuthRevRoot: issuer.Ret.Root().BigInt().String(), - IssuerAuthRootsRoot: issuer.Rot.Root().BigInt().String(), - - ClaimSchema: "180410020913331409885634153623124536270", - - StateCommitmentClaim: scClaim, - StateCommitmentClaimMtp: userClaimMtp, - StateCommitmentClaimClaimsRoot: user.Clt.Root(), - StateCommitmentClaimRevRoot: user.Ret.Root(), - StateCommitmentClaimRootsRoot: user.Rot.Root(), - StateCommitmentClaimIdenState: user.State(t).String(), - - GistRoot: gistRoot, - GistMtp: gistProof, - GistMtpAuxHi: gistNodAux.Key, - GistMtpAuxHv: gistNodAux.Value, - GistMtpNoAux: gistNodAux.NoAux, - - CRS: big.NewInt(123456789).String(), - - UserGenesisID: user.ID.BigInt().String(), - ProfileNonce: nonce.String(), - - ClaimSubjectProfileNonce: nonceSubject.String(), - - IssuerID: issuer.ID.BigInt().String(), - RequestID: "321", - Timestamp: timestamp, - } - - out := OutputsSig{ - UserID: userProfileID.BigInt().String(), - SybilID: expectedSybilID, - IssuerAuthState: expectedIssuerAuthState, - } - - jsonTestData, err := json.Marshal(TestDataSig{ - desc, - inputs, - out, - }) - require.NoError(t, err) - - utils.SaveTestVector(t, fileName, string(jsonTestData)) -} diff --git a/archive_circuits_V2/testvectorgen/sybil/sybil_test.go b/archive_circuits_V2/testvectorgen/sybil/sybil_test.go deleted file mode 100644 index 22746c2b..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/sybil_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package sybil - -import "testing" - -func TestHappyFlowMTP(t *testing.T) { - desc := "Sybil resistance - Happy flow - MTP" - generateTestDataMTP(t, desc, "happyflow - MTP", false, false, false, false) -} - -func TestHappyFlowSig(t *testing.T) { - desc := "Sybil resistance - Happy flow - Sig" - generateTestDataSig(t, desc, "happyflow - Sig", false, false, false, false) -} - -func TestInvalidGistRootMTP(t *testing.T) { - desc := "Sybil resistance - Invalid GIST Root - MTP" - generateTestDataMTP(t, desc, "invalid gist - MTP", true, false, false, false) -} - -func TestInvalidGistRootSig(t *testing.T) { - desc := "Sybil resistance - Invalid GIST Root - Sig" - generateTestDataSig(t, desc, "invalid gist - Sig", true, false, false, false) -} - -func TestInvalidIdentitySig(t *testing.T) { - desc := "Sybil resistance - Invalid Identity - Sig" - generateTestDataSig(t, desc, "invalid identity - Sig", false, true, false, false) -} - -func TestInvalidIdentityMTP(t *testing.T) { - desc := "Sybil resistance - Invalid Identity - MTP" - generateTestDataMTP(t, desc, "invalid identity - MTP", false, true, false, false) -} - -func TestHappyFlowWithProfileMTP(t *testing.T) { - desc := "Sybil resistance - Happy flow with Profile - MTP" - generateTestDataMTP(t, desc, "happyflow with profile - MTP", false, false, true, false) -} - -func TestHappyFlowWithProfileSig(t *testing.T) { - desc := "Sybil resistance - Happy flow with Profile - Sig" - generateTestDataSig(t, desc, "happyflow with profile - Sig", false, false, true, false) -} - -func TestHappyFlowWithProfileAndSubjectMTP(t *testing.T) { - desc := "Sybil resistance - Happy flow with Profile and Subject - MTP" - generateTestDataMTP(t, desc, "happyflow with profile and subject - MTP", false, false, true, true) -} - -func TestHappyFlowWithProfileAndSubjectSig(t *testing.T) { - desc := "Sybil resistance - Happy flow with Profile and Subject - Sig" - generateTestDataSig(t, desc, "happyflow with profile and subject - Sig", false, false, true, true) -} diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - MTP.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - MTP.json deleted file mode 100644 index ce02a35e..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - MTP.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - Sig.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - Sig.json deleted file mode 100644 index f6a6d7f2..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow - Sig.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - MTP.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - MTP.json deleted file mode 100644 index 40018653..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - MTP.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow with Profile - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - Sig.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - Sig.json deleted file mode 100644 index 1c2c801e..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile - Sig.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow with Profile - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - MTP.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - MTP.json deleted file mode 100644 index efccc3f6..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - MTP.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow with Profile and Subject - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","24497320812635010775435456013830217801375919178980935564312517783529521153","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"7548989542047724266078821565632990941857981951889314326285276071945019646899","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"5506222531691139844295896785526877493099929256302137379679372984046649128508","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"7548989542047724266078821565632990941857981951889314326285276071945019646899","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"5506222531691139844295896785526877493099929256302137379679372984046649128508","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - Sig.json b/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - Sig.json deleted file mode 100644 index 9b2d4836..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/happyflow with profile and subject - Sig.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Happy flow with Profile and Subject - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","24497320812635010775435456013830217801375919178980935564312517783529521153","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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","issuerClaimSignatureR8x":"5062489673270143139851128901418434272852532085699303350493305260614640477937","issuerClaimSignatureR8y":"8809727142363129669248157438827701160102550085774460055216619833243024377146","issuerClaimSignatureS":"319962668067660034966032225712389365026815048082152194780874537233943145769","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"10","claimSubjectProfileNonce":"999","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"19816097857299506276751016592539988756969255304244082727801276212869922817","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - MTP.json b/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - MTP.json deleted file mode 100644 index f96a2d3a..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - MTP.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Invalid GIST Root - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"9031636983330134044879452748194793133599690422740028335553282168244414780237","gistMtp":["9054077202653694725190129562729426419405710792276939073869944863201489138082","14218827602097913497782608311388761513660285528499590827800641410537362569671","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"5","gistMtpAuxHv":"5","gistMtpNoAux":"0","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - Sig.json b/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - Sig.json deleted file mode 100644 index 102aca6f..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid gist - Sig.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Invalid GIST Root - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"3461385328650380016743116112609833611346981568419520334721277164748096698844","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"19154270784101589893911330956057280387309546389720604898289367552674181948497","gistRoot":"9031636983330134044879452748194793133599690422740028335553282168244414780237","gistMtp":["9054077202653694725190129562729426419405710792276939073869944863201489138082","14218827602097913497782608311388761513660285528499590827800641410537362569671","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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":"5","gistMtpAuxHv":"5","gistMtpNoAux":"0","crs":"123456789","userGenesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - MTP.json b/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - MTP.json deleted file mode 100644 index f9ce9fb7..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - MTP.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Invalid Identity - MTP","inputs":{"issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["0","0","0","20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimRevRoot":"0","issuerClaimRootsRoot":"0","issuerClaimIdenState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","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"],"issuerClaimNonRevMtpNoAux":"1","issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevClaimsRoot":"5181482836916141156416342038332162656372113141706502558354777241159764399436","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"0","issuerClaimNonRevState":"3339503409184382089877035147936476106276990951173542963633720034821185132093","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"2152157619727152949217484347427696558259128078237803777010632640458288243936","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"6687556230006256976415795163509710967472544960832503552539208792142499100984","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"22845179017290271109878800879354505819397635566486781804213353531061633025","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - Sig.json b/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - Sig.json deleted file mode 100644 index b150eeaf..00000000 --- a/archive_circuits_V2/testvectorgen/sybil/testdata/invalid identity - Sig.json +++ /dev/null @@ -1 +0,0 @@ -{"desc":"Sybil resistance - Invalid Identity - Sig","inputs":{"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"],"issuerAuthClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerAuthRevRoot":"0","issuerAuthRootsRoot":"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","issuerClaim":["3583233690122716044519380227940806650830","23148936466334350744548790012294489365207440754509988986684797708370051073","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimNonRevClaimsRoot":"20643387758736831799596675626240785455902781070167728593409367019626753600795","issuerClaimNonRevRevRoot":"0","issuerClaimNonRevRootsRoot":"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","issuerClaimSignatureR8x":"6009541096871527792243386384096231340067474190101091530507148551135935669869","issuerClaimSignatureR8y":"21407298901003665469054234025891175478757417093942142815529365365949388290718","issuerClaimSignatureS":"1061441685873832236639155829779552898548912415538872104865210006348646647963","claimSchema":"180410020913331409885634153623124536270","stateCommitmentClaim":["7082351036644153942426544930816155573","0","0","0","0","0","10","0"],"stateCommitmentClaimMtp":["8162166103065016664685834856644195001371303013149727027131225893397958846382","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"stateCommitmentClaimClaimsRoot":"13486307223518722177756581733198081748175481348223425936120479194108154193332","stateCommitmentClaimRevRoot":"0","stateCommitmentClaimRootsRoot":"0","stateCommitmentClaimIdenState":"12843500554523042381268402375996411599380512190004461788389734045745426460901","gistRoot":"18165817176741382151999696314717937335448038484956953130037737217192218725983","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","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","crs":"123456789","userGenesisID":"19567216425439473215830624753356350372768627824740469665148892426280894465","profileNonce":"0","claimSubjectProfileNonce":"0","requestID":"321","issuerID":"21933750065545691586450392143787330185992517860945727248803138245838110721","timestamp":"1642074362"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","sybilID":"10471698337950695878316330095385673516661727327544830961388283775499658220263","issuerAuthState":"2943483356559152311923412925436024635269538717812859789851139200242297094"}} \ No newline at end of file diff --git a/archive_circuits_V2/testvectorgen/utils/constants.go b/archive_circuits_V2/testvectorgen/utils/constants.go deleted file mode 100644 index 81650a1d..00000000 --- a/archive_circuits_V2/testvectorgen/utils/constants.go +++ /dev/null @@ -1,53 +0,0 @@ -package utils - -// List of available operators. -const ( - NOOP int = iota // No operation, skip query verification in circuit - EQ - LT - GT - IN - NIN - NE - LTE - GTE - BETWEEN - SD = 16 - NULLIFY = 17 -) - -const TestClaimDocument = `{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/citizenship/v1", - "https://w3id.org/security/bbs/v1" - ], - "id": "https://issuer.oidp.uscis.gov/credentials/83627465", - "type": ["VerifiableCredential", "PermanentResidentCard"], - "issuer": "did:example:489398593", - "identifier": 83627465, - "name": "Permanent Resident Card", - "description": "Government of Example Permanent Resident Card.", - "issuanceDate": "2019-12-03T12:19:52Z", - "expirationDate": "2029-12-03T12:19:52Z", - "credentialSubject": { - "id": "did:example:b34ca6cd37bbf23", - "type": ["PermanentResident", "Person"], - "givenName": "JOHN", - "familyName": "SMITH", - "gender": "Male", - "image": "data:image/png;base64,iVBORw0KGgokJggg==", - "residentSince": "2015-01-01", - "lprCategory": "C09", - "lprNumber": "999-999-999", - "commuterClassification": "C1", - "birthCountry": "Bahamas", - "birthDate": "1958-07-17" - } - }` - -const ( - IdentityTreeLevels = 40 - GistLevels = 64 - ClaimLevels = 32 -) diff --git a/archive_circuits_V2/testvectorgen/utils/identity.go b/archive_circuits_V2/testvectorgen/utils/identity.go deleted file mode 100644 index cdb5c08a..00000000 --- a/archive_circuits_V2/testvectorgen/utils/identity.go +++ /dev/null @@ -1,205 +0,0 @@ -package utils - -import ( - "context" - "math/big" - "testing" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-iden3-crypto/babyjub" - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-merkletree-sql/v2/db/memory" -) - -type IdentityTest struct { - ID core.ID - Clt *merkletree.MerkleTree - Ret *merkletree.MerkleTree - Rot *merkletree.MerkleTree - AuthClaim *core.Claim - PK *babyjub.PrivateKey -} - -func (it *IdentityTest) Sign(challenge *big.Int) *babyjub.Signature { - return it.PK.SignPoseidon(challenge) -} - -func (it *IdentityTest) State(t testing.TB) *big.Int { - state, err := core.IdenState(it.Clt.Root().BigInt(), it.Ret.Root().BigInt(), it.Rot.Root().BigInt()) - if err != nil { - t.Fatalf("Error calculating state: %v", err) - } - return state -} - -func (it *IdentityTest) AuthMTPStrign(t testing.TB) []string { - p, _ := it.ClaimMTPRaw(t, it.AuthClaim) - return PrepareSiblingsStr(p.AllSiblings(), IdentityTreeLevels) -} - -func (it *IdentityTest) SignClaim(t testing.TB, claim *core.Claim) *babyjub.Signature { - hashIndex, hashValue, err := claim.HiHv() - if err != nil { - t.Fatalf("can't get hash index/value from claim %v", err) - } - - commonHash, err := poseidon.Hash([]*big.Int{hashIndex, hashValue}) - if err != nil { - t.Fatalf("can't hash index and value") - } - - return it.PK.SignPoseidon(commonHash) -} - -func (it *IdentityTest) ClaimMTPRaw(t testing.TB, claim *core.Claim) (*merkletree.Proof, *big.Int) { - // add auth claim to claimsMT - hi, _, err := claim.HiHv() - if err != nil { - t.Fatalf("can't get claim hash index %v", err) - } - - proof, value, err := it.Clt.GenerateProof(context.Background(), hi, nil) - if err != nil { - t.Fatalf("can't generate proof %v", err) - } - return proof, value -} - -func (it *IdentityTest) ClaimMTP(t testing.TB, claim *core.Claim) (sibling []string, nodeAux NodeAuxValue) { - // add auth claim to claimsMT - hi, _, err := claim.HiHv() - if err != nil { - t.Fatalf("can't get claim index hash %v", err) - } - - proof, _, err := it.Clt.GenerateProof(context.Background(), hi, nil) - if err != nil { - t.Fatalf("can't generate proof %v", err) - } - - return PrepareProof(proof, IdentityTreeLevels) -} - -func (it *IdentityTest) ClaimRevMTPRaw(t testing.TB, claim *core.Claim) (*merkletree.Proof, *big.Int) { - // add auth claim to claimsMT - revNonce := claim.GetRevocationNonce() - - proof, value, err := it.Ret.GenerateProof(context.Background(), new(big.Int).SetUint64(revNonce), nil) - if err != nil { - t.Fatalf("can't generate proof %v", err) - } - return proof, value -} - -func (it *IdentityTest) ClaimRevMTP(t testing.TB, claim *core.Claim) (sibling []string, nodeAux NodeAuxValue) { - // add auth claim to claimsMT - revNonce := claim.GetRevocationNonce() - - proof, _, err := it.Ret.GenerateProof(context.Background(), new(big.Int).SetUint64(revNonce), nil) - if err != nil { - t.Fatalf("can't generate proof %v", err) - } - - return PrepareProof(proof, IdentityTreeLevels) - -} - -func (it *IdentityTest) IDHash(t testing.TB) *big.Int { - idHash, err := poseidon.Hash([]*big.Int{it.ID.BigInt()}) - if err != nil { - t.Fatalf("can't hash id %v", err) - } - return idHash -} - -func (it *IdentityTest) AddClaim(t *testing.T, claim *core.Claim) { - // add auth claim to claimsMT - hi, hv, err := claim.HiHv() - if err != nil { - t.Fatalf("Error calculating hi and hv: %v", err) - } - - err = it.Clt.Add(context.Background(), hi, hv) - if err != nil { - t.Fatalf("Error adding claim to claimsMT: %v", err) - } -} - -func NewIdentity(t testing.TB, privKHex string) *IdentityTest { - - it := IdentityTest{} - var err error - - // init claims tree - - it.Clt, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) - if err != nil { - t.Fatalf("Error creating Claims merkle tree: %v", err) - } - it.Ret, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) - if err != nil { - t.Fatalf("Error creating Revocation merkle tree: %v", err) - } - it.Rot, err = merkletree.NewMerkleTree(context.Background(), memory.NewMemoryStorage(), IdentityTreeLevels) - if err != nil { - t.Fatalf("Error creating Roots merkle tree: %v", err) - } - - authClaim, key := NewAuthClaim(t, privKHex) - - it.AuthClaim = authClaim - it.PK = key - - // add auth claim to claimsMT - hi, hv, err := authClaim.HiHv() - - err = it.Clt.Add(context.Background(), hi, hv) - if err != nil { - t.Fatalf("Error adding Auth claim to Claims merkle tree: %v", err) - } - - state := it.State(t) - - identifier, err := IDFromState(state) - if err != nil { - t.Fatalf("Error generating id from state: %v", err) - } - - it.ID = *identifier - - return &it -} - -type NodeAuxValue struct { - Key string - Value string - NoAux string -} - -func getNodeAuxValue(p *merkletree.Proof) NodeAuxValue { - - // proof of inclusion - if p.Existence { - return NodeAuxValue{ - Key: merkletree.HashZero.BigInt().String(), - Value: merkletree.HashZero.BigInt().String(), - NoAux: "0", - } - } - - // proof of non-inclusion (NodeAux exists) - if p.NodeAux != nil && p.NodeAux.Value != nil && p.NodeAux.Key != nil { - return NodeAuxValue{ - Key: p.NodeAux.Key.BigInt().String(), - Value: p.NodeAux.Value.BigInt().String(), - NoAux: "0", - } - } - // proof of non-inclusion (NodeAux does not exist) - return NodeAuxValue{ - Key: merkletree.HashZero.BigInt().String(), - Value: merkletree.HashZero.BigInt().String(), - NoAux: "1", - } -} diff --git a/archive_circuits_V2/testvectorgen/utils/identity_test.go b/archive_circuits_V2/testvectorgen/utils/identity_test.go deleted file mode 100644 index 3e4dcc40..00000000 --- a/archive_circuits_V2/testvectorgen/utils/identity_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package utils - -import ( - json2 "encoding/json" - "math/big" - "testing" - - core "github.com/iden3/go-iden3-core" - "github.com/stretchr/testify/require" -) - -const userPK = "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e" - -func Test_IdentityData(t *testing.T) { - - id := NewIdentity(t, userPK) - - r := struct { - IssuerID *big.Int `json:"issuerID"` - IssuerAuthClaim *core.Claim `json:"issuerAuthClaim"` - IssuerAuthClaimMtp []string `json:"issuerAuthClaimMtp"` - IssuerAuthClaimsTreeRoot *big.Int `json:"issuerAuthClaimsTreeRoot"` - IssuerAuthRevTreeRoot *big.Int `json:"issuerAuthRevTreeRoot"` - IssuerAuthRootsTreeRoot *big.Int `json:"issuerAuthRootsTreeRoot"` - IssuerAuthState *big.Int `json:"issuerAuthState"` - }{ - IssuerID: id.ID.BigInt(), - IssuerAuthClaim: id.AuthClaim, - IssuerAuthClaimMtp: id.AuthMTPStrign(t), - IssuerAuthClaimsTreeRoot: id.Clt.Root().BigInt(), - IssuerAuthRevTreeRoot: id.Ret.Root().BigInt(), - IssuerAuthRootsTreeRoot: id.Rot.Root().BigInt(), - IssuerAuthState: id.State(t), - } - - json, err := json2.Marshal(r) - t.Log(string(json)) - - t.Log("ID:", id.ID.String()) - t.Log("ID int:", id.ID.BigInt().String()) - did, err := core.ParseDIDFromID(id.ID) - require.NoError(t, err) - - t.Log("DID:", did.String()) -} diff --git a/archive_circuits_V2/testvectorgen/utils/utils.go b/archive_circuits_V2/testvectorgen/utils/utils.go deleted file mode 100644 index 247bb3e4..00000000 --- a/archive_circuits_V2/testvectorgen/utils/utils.go +++ /dev/null @@ -1,305 +0,0 @@ -package utils - -import ( - "context" - "encoding/hex" - "fmt" - "math/big" - "os" - "strings" - "testing" - "time" - - core "github.com/iden3/go-iden3-core" - "github.com/iden3/go-iden3-crypto/babyjub" - "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql/v2" - "github.com/iden3/go-schema-processor/merklize" -) - -func DefaultJSONUserClaim(t testing.TB, subject core.ID) (*merklize.Merklizer, *core.Claim) { - mz, err := merklize.MerklizeJSONLD(context.Background(), strings.NewReader(TestClaimDocument)) - if err != nil { - t.Fatalf("failed marklize claim: %v", err) - } - - var schemaHash core.SchemaHash - schemaBytes, err := hex.DecodeString("ce6bb12c96bfd1544c02c289c6b4b987") - if err != nil { - t.Fatalf("failed decode schema hash string %v", err) - } - copy(schemaHash[:], schemaBytes) - - nonce := 10 - - claim, err := core.NewClaim( - schemaHash, - core.WithIndexID(subject), - core.WithExpirationDate(time.Unix(1669884010, 0)), //Thu Dec 01 2022 08:40:10 GMT+0000 - core.WithRevocationNonce(uint64(nonce)), - core.WithIndexMerklizedRoot(mz.Root().BigInt())) - - if err != nil { - t.Fatalf("failed generate core claim %v", err) - } - - return mz, claim -} - -func DefaultUserClaim(t testing.TB, subject core.ID) *core.Claim { - dataSlotA, err := core.NewElemBytesFromInt(big.NewInt(10)) - if err != nil { - t.Fatalf("failed get NewElemBytesFromInt %v", err) - } - - nonce := 1 - var schemaHash core.SchemaHash - schemaBytes, err := hex.DecodeString("ce6bb12c96bfd1544c02c289c6b4b987") - if err != nil { - t.Fatalf("failed decode schema hash %v", err) - } - copy(schemaHash[:], schemaBytes) - - claim, err := core.NewClaim( - schemaHash, - core.WithIndexID(subject), - core.WithIndexData(dataSlotA, core.ElemBytes{}), - core.WithExpirationDate(time.Unix(1669884010, 0)), //Thu Dec 01 2022 08:40:10 GMT+0000 - core.WithRevocationNonce(uint64(nonce))) - if err != nil { - t.Fatalf("failed create new claim %v", err) - } - - return claim - -} - -func GenerateNewStateCommitmentClaim(t testing.TB, secret *big.Int) *core.Claim { - dataSlotA, err := core.NewElemBytesFromInt(secret) - if err != nil { - t.Fatalf("failed get NewElemBytesFromInt %v", err) - } - - var schemaHash core.SchemaHash - schemaBytes, err := hex.DecodeString("b55fa22ddacd3459bee10699dd025405") - if err != nil { - t.Fatalf("failed decode schema hash %v", err) - } - copy(schemaHash[:], schemaBytes) - - claim, err := core.NewClaim(schemaHash, core.WithValueData(dataSlotA, core.ElemBytes{})) - if err != nil { - t.Fatalf("failed create new claim %v", err) - } - - return claim -} - -func PrepareProof(proof *merkletree.Proof, levels int) ([]string, NodeAuxValue) { - return PrepareSiblingsStr(proof.AllSiblings(), levels), getNodeAuxValue(proof) -} - -func ExtractPubXY(privKHex string) (key *babyjub.PrivateKey, x, y *big.Int) { - // Extract pubKey - var k babyjub.PrivateKey - if _, err := hex.Decode(k[:], []byte(privKHex)); err != nil { - panic(err) - } - pk := k.Public() - return &k, pk.X, pk.Y -} - -func HashToStr(siblings []*merkletree.Hash) []string { - siblingsStr := make([]string, len(siblings)) - for i, sibling := range siblings { - siblingsStr[i] = sibling.BigInt().String() - } - return siblingsStr -} - -func PrepareStrArray(siblings []string, levels int) []string { - // Add the rest of empty levels to the array - for i := len(siblings); i < levels; i++ { - siblings = append(siblings, "0") - } - return siblings -} - -func IDFromState(state *big.Int) (*core.ID, error) { - typ, err := core.BuildDIDType(core.DIDMethodIden3, core.NoChain, core.NoNetwork) - if err != nil { - return nil, err - } - // create new identity - return core.IdGenesisFromIdenState(typ, state) -} - -func PrepareSiblingsStr(siblings []*merkletree.Hash, levels int) []string { - // siblings := mtproof.AllSiblings() - // Add the rest of empty levels to the siblings - for i := len(siblings); i < levels; i++ { - siblings = append(siblings, &merkletree.HashZero) - } - return HashToStr(siblings) -} - -func NewAuthClaim(t testing.TB, privKHex string) (auth *core.Claim, key *babyjub.PrivateKey) { - // extract pubKey - key, X, Y := ExtractPubXY(privKHex) - - // create auth claim - authClaim, err := AuthClaimFromPubKey(X, Y) - if err != nil { - t.Fatalf("can't create auth claim from pub key %v", err) - } - return authClaim, key -} - -func AuthClaimFromPubKey(X, Y *big.Int) (*core.Claim, error) { - - // NOTE: We take nonce as hash of public key to make it random - // We don't use random number here because this test vectors will be used for tests - // and have randomization inside tests is usually a bad idea - revNonce, err := poseidon.Hash([]*big.Int{X}) - if err != nil { - return nil, err - } - - return core.NewClaim(core.AuthSchemaHash, - core.WithIndexDataInts(X, Y), - core.WithRevocationNonce(revNonce.Uint64())) -} - -func SaveTestVector(t *testing.T, fileName string, data string) { - t.Helper() - path := "testdata/" + fileName + ".json" - - f, err := os.Create(path) - defer f.Close() - if err != nil { - t.Fatalf("Error writing to file %s: %s", path, err) - } - - _, err = f.WriteString(data) - if err != nil { - t.Fatalf("Error writing to file %s: %s", path, err) - } -} - -// BatchSize defined by poseidon hash implementation in Solidity -const BatchSize = 5 - -func FromStringArrayToBigIntArray(values []string) []*big.Int { - bigInts := make([]*big.Int, len(values)) - for i, s := range values { - bigInts[i], _ = new(big.Int).SetString(s, 10) - } - return bigInts -} - -// PoseidonHashValue returns the solidity and circom implementation of poseidon hash -func PoseidonHashValue(values []*big.Int) (*big.Int, error) { - - if values == nil { - return nil, fmt.Errorf("values not provided") - } - - if len(values) == 0 { - return nil, fmt.Errorf("empty values") - } - - iterationCount := 0 - var err error - getValueByIndex := func(arr []*big.Int, idx, length int) *big.Int { - if idx < length { - return arr[idx] - } - return big.NewInt(0) - } - l := len(values) - hashFnBatchSize := 6 - // first iteration to get the first hash (6 elements) - fullHash, err := poseidon.Hash([]*big.Int{ - getValueByIndex(values, 0, l), - getValueByIndex(values, 1, l), - getValueByIndex(values, 2, l), - getValueByIndex(values, 3, l), - getValueByIndex(values, 4, l), - getValueByIndex(values, 5, l), - }) - - restLength := l - hashFnBatchSize - if restLength > BatchSize { - r := restLength % BatchSize - diff := BatchSize - r - iterationCount = (restLength + diff) / BatchSize - } - - if err != nil { - return nil, err - } - - for i := 0; i < iterationCount; i++ { - elemIdx := i*BatchSize + hashFnBatchSize - fullHash, err = poseidon.Hash([]*big.Int{ - fullHash, - getValueByIndex(values, elemIdx, l), - getValueByIndex(values, elemIdx+1, l), - getValueByIndex(values, elemIdx+2, l), - getValueByIndex(values, elemIdx+3, l), - getValueByIndex(values, elemIdx+4, l), - }) - if err != nil { - return nil, err - } - } - - return fullHash, nil -} - -// CalculateLinkID returns linkID calculated from linkNonce and claim -func CalculateLinkID(linkNonce string, claim *core.Claim) (string, error) { - if linkNonce == "0" { - return "0", nil - } - - nonceInt, ok := big.NewInt(0).SetString(linkNonce, 10) - - if !ok { - return "", fmt.Errorf("invalid linkNonce value: '%s'", linkNonce) - } - - hi, hv, err := claim.HiHv() - if err != nil { - return "", err - } - - claimHash, err := poseidon.Hash([]*big.Int{hi, hv}) - if err != nil { - return "", err - } - - linkID, err := poseidon.Hash([]*big.Int{claimHash, nonceInt}) - if err != nil { - return "", err - } - - return linkID.String(), nil -} - -// CalculateNullify returns nullify operator -func CalculateNullify(genesisID, claimSubjectProfileNonce, claimSchema, fieldValue, verifierID, crs *big.Int) (string, error) { - if claimSubjectProfileNonce == big.NewInt(0) { - return "0", nil - } - if verifierID == big.NewInt(0) { - return "0", nil - } - - nullifier, err := poseidon.Hash([]*big.Int{genesisID, claimSubjectProfileNonce, claimSchema, fieldValue, verifierID, crs}) - if err != nil { - return "", err - } - - return nullifier.String(), nil -} From d0d2073cebf041f92f354c00c1d58ee6b2ddef62 Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Wed, 17 Apr 2024 20:05:24 +0200 Subject: [PATCH 09/10] Rename authV2 circuit to authV3 (#133) --- circuits/auth/{authV2.circom => authV3.circom} | 6 +++--- circuits/{authV2.circom => authV3.circom} | 4 ++-- .../credentialAtomicQueryV3OffChain.circom | 2 +- .../credentialAtomicQueryV3OnChain.circom | 6 +++--- test/auth/{authV2.test.ts => authV3.test.ts} | 6 +++--- test/circuits/authV2Test.circom | 5 ----- test/circuits/authV3Test.circom | 5 +++++ .../auth/{authV2_test.go => authV3_test.go} | 16 ++++++++-------- 8 files changed, 25 insertions(+), 25 deletions(-) rename circuits/auth/{authV2.circom => authV3.circom} (96%) rename circuits/{authV2.circom => authV3.circom} (81%) rename test/auth/{authV2.test.ts => authV3.test.ts} (98%) delete mode 100644 test/circuits/authV2Test.circom create mode 100644 test/circuits/authV3Test.circom rename testvectorgen/auth/{authV2_test.go => authV3_test.go} (97%) diff --git a/circuits/auth/authV2.circom b/circuits/auth/authV3.circom similarity index 96% rename from circuits/auth/authV2.circom rename to circuits/auth/authV3.circom index d55bb851..cbcfa96b 100644 --- a/circuits/auth/authV2.circom +++ b/circuits/auth/authV3.circom @@ -7,7 +7,7 @@ include "../lib/idOwnership.circom"; include "../lib/utils/idUtils.circom"; include "../lib/utils/safeOne.circom"; -template AuthV2(IdOwnershipLevels, onChainLevels) { +template AuthV3(IdOwnershipLevels, onChainLevels) { signal input genesisID; // random number, which should be stored by user if there is a need to // generate the same userID (ProfileID) output for different proofs @@ -52,7 +52,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { // get safe zero and one values to be used in ForceEqualIfEnabled signal {binary} one <== SafeOne()(genesisID); - checkAuthV2(IdOwnershipLevels, onChainLevels)( + checkAuthV3(IdOwnershipLevels, onChainLevels)( one, genesisID, state, @@ -80,7 +80,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { userID <== SelectProfile()(genesisID, profileNonce); } -template checkAuthV2(IdOwnershipLevels, onChainLevels) { +template checkAuthV3(IdOwnershipLevels, onChainLevels) { signal input {binary} enabled; signal input genesisID; diff --git a/circuits/authV2.circom b/circuits/authV3.circom similarity index 81% rename from circuits/authV2.circom rename to circuits/authV3.circom index 2ba241f5..7306d271 100644 --- a/circuits/authV2.circom +++ b/circuits/authV3.circom @@ -1,6 +1,6 @@ pragma circom 2.1.1; -include "auth/authV2.circom"; +include "auth/authV3.circom"; /* * The identity authorization circuit. @@ -13,4 +13,4 @@ include "auth/authV2.circom"; - challenge - gistRoot */ -component main {public [challenge, gistRoot]} = AuthV2(40, 64); +component main {public [challenge, gistRoot]} = AuthV3(40, 64); diff --git a/circuits/offchain/credentialAtomicQueryV3OffChain.circom b/circuits/offchain/credentialAtomicQueryV3OffChain.circom index 8406f7d5..123bf5aa 100644 --- a/circuits/offchain/credentialAtomicQueryV3OffChain.circom +++ b/circuits/offchain/credentialAtomicQueryV3OffChain.circom @@ -5,7 +5,7 @@ include "../../node_modules/circomlib/circuits/mux1.circom"; include "../../node_modules/circomlib/circuits/mux4.circom"; include "../../node_modules/circomlib/circuits/bitify.circom"; include "../../node_modules/circomlib/circuits/comparators.circom"; -include "../auth/authV2.circom"; +include "../auth/authV3.circom"; include "../lib/linked/linkId.circom"; include "../lib/query/processQueryWithModifiers.circom"; include "../lib/utils/nullify.circom"; diff --git a/circuits/onchain/credentialAtomicQueryV3OnChain.circom b/circuits/onchain/credentialAtomicQueryV3OnChain.circom index a008d563..7d688fbe 100644 --- a/circuits/onchain/credentialAtomicQueryV3OnChain.circom +++ b/circuits/onchain/credentialAtomicQueryV3OnChain.circom @@ -4,7 +4,7 @@ include "../../node_modules/circomlib/circuits/bitify.circom"; include "../../node_modules/circomlib/circuits/comparators.circom"; include "../../node_modules/circomlib/circuits/poseidon.circom"; include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; +include "../auth/authV3.circom"; include "../lib/query/query.circom"; include "../lib/utils/idUtils.circom"; include "../lib/utils/spongeHash.circom"; @@ -160,7 +160,7 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArray // Modifier/Computation Operator output ($sd, $nullify) signal output operatorOutput; - // Enabled/disable checkAuthV2 verification + // Enabled/disable checkAuthV3 verification signal input isBJJAuthEnabled; // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that @@ -178,7 +178,7 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArray ForceEqualIfEnabled()(NOT()(safeIsBJJAuthEnabled), [profileNonce, 0]); - checkAuthV2(idOwnershipLevels, onChainLevels)( + checkAuthV3(idOwnershipLevels, onChainLevels)( safeIsBJJAuthEnabled, // enabled userGenesisID, userState, // user state diff --git a/test/auth/authV2.test.ts b/test/auth/authV3.test.ts similarity index 98% rename from test/auth/authV2.test.ts rename to test/auth/authV3.test.ts index 8b12e456..ff3646d4 100644 --- a/test/auth/authV2.test.ts +++ b/test/auth/authV3.test.ts @@ -4,7 +4,7 @@ const path = require("path"); const wasm_tester = require("circom_tester").wasm; // inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("authV2Test.circom:", async function() { +describe("authV3Test.circom:", async function() { const tests = [ {"desc":"Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","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"],"authClaimNonRevMtpAuxHi":"0","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"1","challenge":"12345","challengeSignatureR8x":"15829360093371098546177008474519342171461782120259125067189481965541223738777","challengeSignatureR8y":"10840522802382821290541462398953040493080116495308402635486440290351677745960","challengeSignatureS":"1196477404779941775725836688033485533497812196897664950083199167075327114562","claimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","revTreeRoot":"0","rootsTreeRoot":"0","state":"7115004997868594253010848596868364067574661249707337517331323113105592633327","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","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"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","challenge":"12345"}}, @@ -18,9 +18,9 @@ describe("authV2Test.circom:", async function() { before(async () => { circuit = await wasm_tester( - path.join(__dirname, "../circuits", "authV2Test.circom"), + path.join(__dirname, "../circuits", "authV3Test.circom"), { - output: path.join(__dirname, "../circuits", "build/authV2"), + output: path.join(__dirname, "../circuits", "build/authV3"), recompile: true, }, ); diff --git a/test/circuits/authV2Test.circom b/test/circuits/authV2Test.circom deleted file mode 100644 index 3351d423..00000000 --- a/test/circuits/authV2Test.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/auth/authV2.circom"; - -component main {public [challenge, gistRoot]} = AuthV2(32,32); diff --git a/test/circuits/authV3Test.circom b/test/circuits/authV3Test.circom new file mode 100644 index 00000000..b8feb216 --- /dev/null +++ b/test/circuits/authV3Test.circom @@ -0,0 +1,5 @@ +pragma circom 2.1.1; + +include "../../circuits/auth/authV3.circom"; + +component main {public [challenge, gistRoot]} = AuthV3(32,32); diff --git a/testvectorgen/auth/authV2_test.go b/testvectorgen/auth/authV3_test.go similarity index 97% rename from testvectorgen/auth/authV2_test.go rename to testvectorgen/auth/authV3_test.go index 0d1c1b22..5585068a 100644 --- a/testvectorgen/auth/authV2_test.go +++ b/testvectorgen/auth/authV3_test.go @@ -22,7 +22,7 @@ const ( timestamp = "1642074362" ) -type AuthV2Inputs struct { +type AuthV3Inputs struct { UserGenesisID string `json:"genesisID"` Nonce string `json:"profileNonce"` UserAuthClaim *core.Claim `json:"authClaim"` @@ -46,16 +46,16 @@ type AuthV2Inputs struct { GistMtpNoAux string `json:"gistMtpNoAux"` } -type AuthV2Outputs struct { +type AuthV3Outputs struct { ID string `json:"userID"` GistRoot string `json:"gistRoot"` Challenge string `json:"challenge"` } -type TestDataAuthV2 struct { +type TestDataAuthV3 struct { Desc string `json:"desc"` - In AuthV2Inputs `json:"inputs"` - Out AuthV2Outputs `json:"expOut"` + In AuthV3Inputs `json:"inputs"` + Out AuthV3Outputs `json:"expOut"` } func Test_UserID_Subject(t *testing.T) { @@ -156,7 +156,7 @@ func generateAuthTestData(t *testing.T, profile, genesis, isSecondAuthClaim bool gistRoot := gisTree.Root() gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - inputs := AuthV2Inputs{ + inputs := AuthV3Inputs{ UserGenesisID: user.ID.BigInt().String(), Nonce: nonce.String(), UserAuthClaim: user.AuthClaim, @@ -180,13 +180,13 @@ func generateAuthTestData(t *testing.T, profile, genesis, isSecondAuthClaim bool GistMtpNoAux: gistNodAux.NoAux, } - out := AuthV2Outputs{ + out := AuthV3Outputs{ ID: userProfile.BigInt().String(), Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), } - json, err := json2.Marshal(TestDataAuthV2{ + json, err := json2.Marshal(TestDataAuthV3{ desc, inputs, out, From 6840f6288b56888d5deb8070178fc12d46baa792 Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Wed, 17 Apr 2024 19:19:00 +0100 Subject: [PATCH 10/10] Update deps --- testvectorgen/go.mod | 45 +++++--------------- testvectorgen/go.sum | 97 ++++++++++---------------------------------- 2 files changed, 32 insertions(+), 110 deletions(-) diff --git a/testvectorgen/go.mod b/testvectorgen/go.mod index 1d7e8dca..d05b87a2 100644 --- a/testvectorgen/go.mod +++ b/testvectorgen/go.mod @@ -3,49 +3,24 @@ module test go 1.18 require ( - github.com/iden3/go-iden3-core v1.0.2 - github.com/iden3/go-iden3-core/v2 v2.0.0 - github.com/iden3/go-iden3-crypto v0.0.15 + github.com/iden3/go-iden3-core/v2 v2.1.0 + github.com/iden3/go-iden3-crypto v0.0.16 github.com/iden3/go-merkletree-sql/v2 v2.0.6 - github.com/iden3/go-schema-processor/v2 v2.1.0 - github.com/stretchr/testify v1.8.4 + github.com/iden3/go-schema-processor/v2 v2.3.3 + github.com/stretchr/testify v1.9.0 ) -require github.com/pkg/errors v0.9.1 // indirect - require ( - github.com/benbjohnson/clock v1.3.5 // indirect - github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dchest/blake512 v1.0.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/ethereum/go-ethereum v1.13.5 - github.com/ipfs/boxo v0.8.0 // indirect - github.com/ipfs/go-cid v0.4.1 // indirect - github.com/ipfs/go-ipfs-api v0.6.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-flow-metrics v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.28.1 // indirect - github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/ethereum/go-ethereum v1.13.15 + github.com/holiman/uint256 v1.2.4 // indirect github.com/mr-tron/base58 v1.2.0 // indirect - github.com/multiformats/go-base32 v0.1.0 // indirect - github.com/multiformats/go-base36 v0.2.0 // indirect - github.com/multiformats/go-multiaddr v0.9.0 // indirect - github.com/multiformats/go-multibase v0.2.0 // indirect - github.com/multiformats/go-multicodec v0.9.0 // indirect - github.com/multiformats/go-multihash v0.2.2 // indirect - github.com/multiformats/go-multistream v0.4.1 // indirect - github.com/multiformats/go-varint v0.0.7 // indirect github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/pquerna/cachecontrol v0.1.0 // indirect - github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/sys v0.13.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + github.com/pquerna/cachecontrol v0.2.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/sys v0.19.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/testvectorgen/go.sum b/testvectorgen/go.sum index 1fe891b0..35447bcd 100644 --- a/testvectorgen/go.sum +++ b/testvectorgen/go.sum @@ -1,97 +1,44 @@ -github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= -github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= -github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= -github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake512 v1.0.0 h1:oDFEQFIqFSeuA34xLtXZ/rWxCXdSjirjzPhey5EUvmA= github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= -github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/ethereum/go-ethereum v1.13.5 h1:U6TCRciCqZRe4FPXmy1sMGxTfuk8P7u2UoinF3VbaFk= -github.com/ethereum/go-ethereum v1.13.5/go.mod h1:yMTu38GSuyxaYzQMViqNmQ1s3cE84abZexQmTgenWk0= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLxGP0Y= -github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo= -github.com/iden3/go-iden3-core/v2 v2.0.0 h1:sQEuuq3RLfyYSY8qPiqxQ6YBpGbiAwepHJD/vjf1adA= -github.com/iden3/go-iden3-core/v2 v2.0.0/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= -github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= -github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= +github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo= +github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/iden3/go-iden3-core/v2 v2.1.0 h1:R1s7Tj3tIx5lDy8S7OJrSNuxXIFeRzWRmTBaQoQHJps= +github.com/iden3/go-iden3-core/v2 v2.1.0/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= +github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk= +github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/iden3/go-merkletree-sql/v2 v2.0.6 h1:vsVDImnvnHf7Ggr45ptFOXJyWNA/8IwVQO1jzRLUlY8= github.com/iden3/go-merkletree-sql/v2 v2.0.6/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk= -github.com/iden3/go-schema-processor/v2 v2.1.0 h1:8/fA7IVkyVmpbJij9Ar0X2zWPQJMlCaaPP4hfTZqbqU= -github.com/iden3/go-schema-processor/v2 v2.1.0/go.mod h1:EogHwnFnxQKOGRVme6upCcisoAQeEIl+HuRAGa7w3+w= -github.com/ipfs/boxo v0.8.0 h1:UdjAJmHzQHo/j3g3b1bAcAXCj/GM6iTwvSlBDvPBNBs= -github.com/ipfs/boxo v0.8.0/go.mod h1:RIsi4CnTyQ7AUsNn5gXljJYZlQrHBMnJp94p73liFiA= -github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= -github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= -github.com/ipfs/go-ipfs-api v0.6.0 h1:JARgG0VTbjyVhO5ZfesnbXv9wTcMvoKRBLF1SzJqzmg= -github.com/ipfs/go-ipfs-api v0.6.0/go.mod h1:iDC2VMwN9LUpQV/GzEeZ2zNqd8NUdRmWcFM+K/6odf0= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/iden3/go-schema-processor/v2 v2.3.3 h1:GfChxMZHG4miA3p/5rLIrM7TGmKu/oAAXgLloYTBHSI= +github.com/iden3/go-schema-processor/v2 v2.3.3/go.mod h1:8y/R0iQpYhyhRQ3sL4F5Aja3+1T68M6uwGQdC4pQ4X0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= -github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.28.1 h1:YurK+ZAI6cKfASLJBVFkpVBdl3wGhFi6fusOt725ii8= -github.com/libp2p/go-libp2p v0.28.1/go.mod h1:s3Xabc9LSwOcnv9UD4nORnXKTsWkPMkIMB/JIGXVnzk= -github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= -github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= -github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= -github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= -github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= -github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= -github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= -github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= -github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= -github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= -github.com/multiformats/go-multihash v0.2.2 h1:Uu7LWs/PmWby1gkj1S1DXx3zyd3aVabA4FiMKn/2tAc= -github.com/multiformats/go-multihash v0.2.2/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= -github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= -github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= -github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= -github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f h1:HlPa7RcxTCrva5izPfTEfvYecO7LTahgmMRD1Qp13xg= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc= -github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/pquerna/cachecontrol v0.2.0 h1:vBXSNuE5MYP9IJ5kjsdo8uq+w41jSPgvba2DEnkRx9k= +github.com/pquerna/cachecontrol v0.2.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b h1:wA3QeTsaAXybLL2kb2cKhCAQTHgYTMwuI8lBlJSv5V8= -github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b/go.mod h1:xT1Y5p2JR2PfSZihE0s4mjdJaRGp1waCTf5JzhQLBck= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=