From 71a093b0df19e65a756431273ce53496efe9301a Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Wed, 17 Apr 2024 17:28:38 +0100 Subject: [PATCH] Rename authV2 circuit to authV3 --- circuits/auth/{authV2.circom => authV3.circom} | 6 +++--- circuits/{authV2.circom => authV3.circom} | 4 ++-- .../credentialAtomicQueryV3OffChain.circom | 2 +- .../credentialAtomicQueryV3OnChain.circom | 6 +++--- test/auth/{authV2.test.ts => authV3.test.ts} | 6 +++--- test/circuits/authV2Test.circom | 5 ----- test/circuits/authV3Test.circom | 5 +++++ .../auth/{authV2_test.go => authV3_test.go} | 16 ++++++++-------- 8 files changed, 25 insertions(+), 25 deletions(-) rename circuits/auth/{authV2.circom => authV3.circom} (96%) rename circuits/{authV2.circom => authV3.circom} (81%) rename test/auth/{authV2.test.ts => authV3.test.ts} (98%) delete mode 100644 test/circuits/authV2Test.circom create mode 100644 test/circuits/authV3Test.circom rename testvectorgen/auth/{authV2_test.go => authV3_test.go} (97%) diff --git a/circuits/auth/authV2.circom b/circuits/auth/authV3.circom similarity index 96% rename from circuits/auth/authV2.circom rename to circuits/auth/authV3.circom index d55bb851..cbcfa96b 100644 --- a/circuits/auth/authV2.circom +++ b/circuits/auth/authV3.circom @@ -7,7 +7,7 @@ include "../lib/idOwnership.circom"; include "../lib/utils/idUtils.circom"; include "../lib/utils/safeOne.circom"; -template AuthV2(IdOwnershipLevels, onChainLevels) { +template AuthV3(IdOwnershipLevels, onChainLevels) { signal input genesisID; // random number, which should be stored by user if there is a need to // generate the same userID (ProfileID) output for different proofs @@ -52,7 +52,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { // get safe zero and one values to be used in ForceEqualIfEnabled signal {binary} one <== SafeOne()(genesisID); - checkAuthV2(IdOwnershipLevels, onChainLevels)( + checkAuthV3(IdOwnershipLevels, onChainLevels)( one, genesisID, state, @@ -80,7 +80,7 @@ template AuthV2(IdOwnershipLevels, onChainLevels) { userID <== SelectProfile()(genesisID, profileNonce); } -template checkAuthV2(IdOwnershipLevels, onChainLevels) { +template checkAuthV3(IdOwnershipLevels, onChainLevels) { signal input {binary} enabled; signal input genesisID; diff --git a/circuits/authV2.circom b/circuits/authV3.circom similarity index 81% rename from circuits/authV2.circom rename to circuits/authV3.circom index 2ba241f5..7306d271 100644 --- a/circuits/authV2.circom +++ b/circuits/authV3.circom @@ -1,6 +1,6 @@ pragma circom 2.1.1; -include "auth/authV2.circom"; +include "auth/authV3.circom"; /* * The identity authorization circuit. @@ -13,4 +13,4 @@ include "auth/authV2.circom"; - challenge - gistRoot */ -component main {public [challenge, gistRoot]} = AuthV2(40, 64); +component main {public [challenge, gistRoot]} = AuthV3(40, 64); diff --git a/circuits/offchain/credentialAtomicQueryV3OffChain.circom b/circuits/offchain/credentialAtomicQueryV3OffChain.circom index 8406f7d5..123bf5aa 100644 --- a/circuits/offchain/credentialAtomicQueryV3OffChain.circom +++ b/circuits/offchain/credentialAtomicQueryV3OffChain.circom @@ -5,7 +5,7 @@ include "../../node_modules/circomlib/circuits/mux1.circom"; include "../../node_modules/circomlib/circuits/mux4.circom"; include "../../node_modules/circomlib/circuits/bitify.circom"; include "../../node_modules/circomlib/circuits/comparators.circom"; -include "../auth/authV2.circom"; +include "../auth/authV3.circom"; include "../lib/linked/linkId.circom"; include "../lib/query/processQueryWithModifiers.circom"; include "../lib/utils/nullify.circom"; diff --git a/circuits/onchain/credentialAtomicQueryV3OnChain.circom b/circuits/onchain/credentialAtomicQueryV3OnChain.circom index a008d563..7d688fbe 100644 --- a/circuits/onchain/credentialAtomicQueryV3OnChain.circom +++ b/circuits/onchain/credentialAtomicQueryV3OnChain.circom @@ -4,7 +4,7 @@ include "../../node_modules/circomlib/circuits/bitify.circom"; include "../../node_modules/circomlib/circuits/comparators.circom"; include "../../node_modules/circomlib/circuits/poseidon.circom"; include "../lib/query/comparators.circom"; -include "../auth/authV2.circom"; +include "../auth/authV3.circom"; include "../lib/query/query.circom"; include "../lib/utils/idUtils.circom"; include "../lib/utils/spongeHash.circom"; @@ -160,7 +160,7 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArray // Modifier/Computation Operator output ($sd, $nullify) signal output operatorOutput; - // Enabled/disable checkAuthV2 verification + // Enabled/disable checkAuthV3 verification signal input isBJJAuthEnabled; // flag indicates if merklized flag set in issuer claim (if set MTP is used to verify that @@ -178,7 +178,7 @@ template credentialAtomicQueryV3OnChain(issuerLevels, claimLevels, maxValueArray ForceEqualIfEnabled()(NOT()(safeIsBJJAuthEnabled), [profileNonce, 0]); - checkAuthV2(idOwnershipLevels, onChainLevels)( + checkAuthV3(idOwnershipLevels, onChainLevels)( safeIsBJJAuthEnabled, // enabled userGenesisID, userState, // user state diff --git a/test/auth/authV2.test.ts b/test/auth/authV3.test.ts similarity index 98% rename from test/auth/authV2.test.ts rename to test/auth/authV3.test.ts index 8b12e456..ff3646d4 100644 --- a/test/auth/authV2.test.ts +++ b/test/auth/authV3.test.ts @@ -4,7 +4,7 @@ const path = require("path"); const wasm_tester = require("circom_tester").wasm; // inputs MUST be generated by GO-CIRCUITS library https://github.com/iden3/go-circuits (using corresponding test) -describe("authV2Test.circom:", async function() { +describe("authV3Test.circom:", async function() { const tests = [ {"desc":"Ownership true. User state: not-genesis. Auth claims total/signedWith/revoked: 1/1/none","inputs":{"genesisID":"23148936466334350744548790012294489365207440754509988986684797708370051073","profileNonce":"0","authClaim":["80551937543569765027552589160822318028","0","4720763745722683616702324599137259461509439547324750011830105416383780791263","4844030361230692908091131578688419341633213823133966379083981236400104720538","16547485850637761685","0","0","0"],"authClaimIncMtp":["20643387758736831799596675626240785455902781070167728593409367019626753600795","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"authClaimNonRevMtpAuxHi":"0","authClaimNonRevMtpAuxHv":"0","authClaimNonRevMtpNoAux":"1","challenge":"12345","challengeSignatureR8x":"15829360093371098546177008474519342171461782120259125067189481965541223738777","challengeSignatureR8y":"10840522802382821290541462398953040493080116495308402635486440290351677745960","challengeSignatureS":"1196477404779941775725836688033485533497812196897664950083199167075327114562","claimsTreeRoot":"8794724428328826645726823821449086761079599815895679828313419678997386356573","revTreeRoot":"0","rootsTreeRoot":"0","state":"7115004997868594253010848596868364067574661249707337517331323113105592633327","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","gistMtp":["0","0","0","0","1243904711429961858774220647610724273798918457991486031567244100767259239747","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"gistMtpAuxHi":"0","gistMtpAuxHv":"0","gistMtpNoAux":"0"},"expOut":{"userID":"23148936466334350744548790012294489365207440754509988986684797708370051073","gistRoot":"12426001693315048096465296555250933925657269666213597651273856698420831593981","challenge":"12345"}}, @@ -18,9 +18,9 @@ describe("authV2Test.circom:", async function() { before(async () => { circuit = await wasm_tester( - path.join(__dirname, "../circuits", "authV2Test.circom"), + path.join(__dirname, "../circuits", "authV3Test.circom"), { - output: path.join(__dirname, "../circuits", "build/authV2"), + output: path.join(__dirname, "../circuits", "build/authV3"), recompile: true, }, ); diff --git a/test/circuits/authV2Test.circom b/test/circuits/authV2Test.circom deleted file mode 100644 index 3351d423..00000000 --- a/test/circuits/authV2Test.circom +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.1.1; - -include "../../circuits/auth/authV2.circom"; - -component main {public [challenge, gistRoot]} = AuthV2(32,32); diff --git a/test/circuits/authV3Test.circom b/test/circuits/authV3Test.circom new file mode 100644 index 00000000..b8feb216 --- /dev/null +++ b/test/circuits/authV3Test.circom @@ -0,0 +1,5 @@ +pragma circom 2.1.1; + +include "../../circuits/auth/authV3.circom"; + +component main {public [challenge, gistRoot]} = AuthV3(32,32); diff --git a/testvectorgen/auth/authV2_test.go b/testvectorgen/auth/authV3_test.go similarity index 97% rename from testvectorgen/auth/authV2_test.go rename to testvectorgen/auth/authV3_test.go index 0d1c1b22..5585068a 100644 --- a/testvectorgen/auth/authV2_test.go +++ b/testvectorgen/auth/authV3_test.go @@ -22,7 +22,7 @@ const ( timestamp = "1642074362" ) -type AuthV2Inputs struct { +type AuthV3Inputs struct { UserGenesisID string `json:"genesisID"` Nonce string `json:"profileNonce"` UserAuthClaim *core.Claim `json:"authClaim"` @@ -46,16 +46,16 @@ type AuthV2Inputs struct { GistMtpNoAux string `json:"gistMtpNoAux"` } -type AuthV2Outputs struct { +type AuthV3Outputs struct { ID string `json:"userID"` GistRoot string `json:"gistRoot"` Challenge string `json:"challenge"` } -type TestDataAuthV2 struct { +type TestDataAuthV3 struct { Desc string `json:"desc"` - In AuthV2Inputs `json:"inputs"` - Out AuthV2Outputs `json:"expOut"` + In AuthV3Inputs `json:"inputs"` + Out AuthV3Outputs `json:"expOut"` } func Test_UserID_Subject(t *testing.T) { @@ -156,7 +156,7 @@ func generateAuthTestData(t *testing.T, profile, genesis, isSecondAuthClaim bool gistRoot := gisTree.Root() gistProof, gistNodAux := utils.PrepareProof(gistProofRaw, utils.GistLevels) - inputs := AuthV2Inputs{ + inputs := AuthV3Inputs{ UserGenesisID: user.ID.BigInt().String(), Nonce: nonce.String(), UserAuthClaim: user.AuthClaim, @@ -180,13 +180,13 @@ func generateAuthTestData(t *testing.T, profile, genesis, isSecondAuthClaim bool GistMtpNoAux: gistNodAux.NoAux, } - out := AuthV2Outputs{ + out := AuthV3Outputs{ ID: userProfile.BigInt().String(), Challenge: challenge.String(), GistRoot: gistRoot.BigInt().String(), } - json, err := json2.Marshal(TestDataAuthV2{ + json, err := json2.Marshal(TestDataAuthV3{ desc, inputs, out,