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 -}