Skip to content

Commit

Permalink
Rename authV2 circuit to authV3
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrezhniev committed Apr 17, 2024
1 parent 4999228 commit 71a093b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions circuits/auth/authV2.circom → circuits/auth/authV3.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions circuits/authV2.circom → circuits/authV3.circom
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma circom 2.1.1;

include "auth/authV2.circom";
include "auth/authV3.circom";

/*
* The identity authorization circuit.
Expand All @@ -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);
2 changes: 1 addition & 1 deletion circuits/offchain/credentialAtomicQueryV3OffChain.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 3 additions & 3 deletions circuits/onchain/credentialAtomicQueryV3OnChain.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/auth/authV2.test.ts → test/auth/authV3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"}},
Expand All @@ -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,
},
);
Expand Down
5 changes: 0 additions & 5 deletions test/circuits/authV2Test.circom

This file was deleted.

5 changes: 5 additions & 0 deletions test/circuits/authV3Test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.1;

include "../../circuits/auth/authV3.circom";

component main {public [challenge, gistRoot]} = AuthV3(32,32);
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 71a093b

Please sign in to comment.