Skip to content

Commit

Permalink
Merge pull request #113 from iden3/feature/pid-1062
Browse files Browse the repository at this point in the history
Feature/pid 1062 - Combine Auth and Non-auth circuits into one for Onchain
  • Loading branch information
vmidyllic authored Nov 14, 2023
2 parents 5c0a800 + 00260c3 commit 2dd87d8
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 50 deletions.
3 changes: 2 additions & 1 deletion circuits/credentialAtomicQueryV3OnChain.circom
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ component main{public [requestID,
gistRoot,
proofType,
verifierID,
verifierSessionID
verifierSessionID,
authEnabled
]} = credentialAtomicQueryV3OnChain(40, 32, 64, 40, 64);
13 changes: 3 additions & 10 deletions circuits/onchain/credentialAtomicQueryV3OnChain.circom
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,15 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, valueArraySiz
// Modifier/Computation Operator output ($sd, $nullify)
signal output operatorOutput;

/////////////////////////////////////////////////////////////////
// FIXME: `===` without multiplications gives 0 constraints!!!
// because compiler removes all linear constraints during optimization pass
// ForceEqualIfEnabled(1, [x, y]) gives 0 too, so we need to do a workaround:
// calculate signal with value 1 and pass it to ForceEqualIfEnabled as an enabled signal
/////////////////////////////////////////////////////////////////
signal zero <== IsZero()(userGenesisID); // comparing to zero something that can't be zero to get zero as an output
signal one <== 1 - zero;
zero * one === 0;
// Enabled/disable checkAuthV2 verification
signal input authEnabled;

/////////////////////////////////////////////////////////////////
// Auth check
/////////////////////////////////////////////////////////////////

checkAuthV2(idOwnershipLevels, onChainLevels)(
one, // enabled
authEnabled, // enabled
userGenesisID,
userState, // user state
userClaimsTreeRoot,
Expand Down
2 changes: 2 additions & 0 deletions test/onchain/credentialAtomicQueryV3OnChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("Test credentialAtomicQueryV3OnChain.circom", function () {
require(`${sigBasePath}/nullify.json`),
require(`${sigBasePath}/revoked_claim_without_revocation_check.json`),
require(`${sigBasePath}/jsonld_non_inclusion.json`),
require(`${sigBasePath}/auth_check_disabled.json`),

// mtp
require(`${mtpBasePath}/claimIssuedOnProfileID.json`),
Expand All @@ -55,6 +56,7 @@ describe("Test credentialAtomicQueryV3OnChain.circom", function () {
require(`${mtpBasePath}/selective_disclosure.json`),
require(`${mtpBasePath}/nullify.json`),
require(`${mtpBasePath}/revoked_claim_without_revocation_check.json`),
require(`${mtpBasePath}/auth_check_disabled.json`),
];

tests.forEach(({ desc, inputs, expOut }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"desc":"Skip Auth V2 check","inputs":{"requestID":"41","userGenesisID":"23273167900576580892722615617815475823351560716009055944677723144398443009","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":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaim":["3583233690122716044519380227940806650830","23273167900576580892722615617815475823351560716009055944677723144398443009","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["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","0","0"],"issuerClaimClaimsTreeRoot":"822392840143531676250086160084530040476172248252065459222610568880934884086","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"595634593597118989354040083735120083650459900146875299094425656479483321655","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"822392840143531676250086160084530040476172248252065459222610568880934884086","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"595634593597118989354040083735120083650459900146875299094425656479483321655","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":9,"slotIndex":2,"timestamp":"1642074362","value":["8","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"],"issuerClaimSignatureR8x":"0","issuerClaimSignatureR8y":"0","issuerClaimSignatureS":"0","issuerAuthClaim":["0","0","0","0","0","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":"0","issuerAuthClaimsTreeRoot":"0","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","issuerAuthState":"0","proofType":"2","linkNonce":"0","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","verifierSessionID":"0","authEnabled":0},"expOut":{"requestID":"41","userID":"23273167900576580892722615617815475823351560716009055944677723144398443009","issuerID":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaimNonRevState":"595634593597118989354040083735120083650459900146875299094425656479483321655","circuitQueryHash":"1200197573263720781403876012067624377690459697223785410935360278236612478754","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","timestamp":"1642074362","merklized":"0","proofType":"2","isRevocationChecked":"1","challenge":"12345","issuerState":"595634593597118989354040083735120083650459900146875299094425656479483321655","linkID":"0","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","verifierSessionID":"0","operatorOutput":"0","nullifier":"0","authEnabled":"0"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"desc":"Skip Auth V2 check","inputs":{"requestID":"41","userGenesisID":"23273167900576580892722615617815475823351560716009055944677723144398443009","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":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaim":["3583233690122716044519380227940806650830","23273167900576580892722615617815475823351560716009055944677723144398443009","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimMtp":["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","0","0"],"issuerClaimClaimsTreeRoot":"822392840143531676250086160084530040476172248252065459222610568880934884086","issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimIdenState":"595634593597118989354040083735120083650459900146875299094425656479483321655","isRevocationChecked":1,"issuerClaimNonRevClaimsTreeRoot":"822392840143531676250086160084530040476172248252065459222610568880934884086","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"595634593597118989354040083735120083650459900146875299094425656479483321655","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":9,"slotIndex":2,"timestamp":"1642074362","value":["8","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"],"issuerClaimSignatureR8x":"0","issuerClaimSignatureR8y":"0","issuerClaimSignatureS":"0","issuerAuthClaim":["0","0","0","0","0","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":"0","issuerAuthClaimsTreeRoot":"0","issuerAuthRevTreeRoot":"0","issuerAuthRootsTreeRoot":"0","issuerAuthState":"0","proofType":"2","linkNonce":"0","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","verifierSessionID":"0","authEnabled":0},"expOut":{"requestID":"41","userID":"23273167900576580892722615617815475823351560716009055944677723144398443009","issuerID":"22057981499787921734624217749308316644136637822444794206796063681866502657","issuerClaimNonRevState":"595634593597118989354040083735120083650459900146875299094425656479483321655","circuitQueryHash":"1200197573263720781403876012067624377690459697223785410935360278236612478754","gistRoot":"1243904711429961858774220647610724273798918457991486031567244100767259239747","timestamp":"1642074362","merklized":"0","proofType":"2","isRevocationChecked":"1","challenge":"12345","issuerState":"595634593597118989354040083735120083650459900146875299094425656479483321655","linkID":"0","verifierID":"21929109382993718606847853573861987353620810345503358891473103689157378049","verifierSessionID":"0","operatorOutput":"0","nullifier":"0","authEnabled":"0"}}
Loading

0 comments on commit 2dd87d8

Please sign in to comment.