Skip to content

Commit

Permalink
Replace circuit constant to constant from js sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhniuk committed Oct 30, 2024
1 parent f92918d commit 2f553f1
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 51 deletions.
5 changes: 0 additions & 5 deletions helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export const networks = Object.freeze({
export const STATE_ADDRESS_POLYGON_AMOY = "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124";
export const STATE_ADDRESS_POLYGON_MAINNET = "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D";

export const CIRCUIT_ID_MTP_V2 = "credentialAtomicQueryMTPV2OnChain";
export const CIRCUIT_ID_SIG_V2 = "credentialAtomicQuerySigV2OnChain";
export const CIRCUIT_ID_V3 = "credentialAtomicQueryV3OnChain-beta.1";
export const CIRCUIT_ID_AUTH_V2 = "authV2";

export const VALIDATOR_TYPES = Object.freeze({
MTP_V2: "mtpV2",
SIG_V2: "sigV2",
Expand Down
17 changes: 8 additions & 9 deletions scripts/deploy/deployCrossChainVerifierWithRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { Hex } from "@iden3/js-crypto";
import { Merklizer } from "@iden3/js-jsonld-merklization";
import path from "path";
import fs from "fs";
import { Operators } from "@0xpolygonid/js-sdk";
import { CIRCUIT_ID_MTP_V2, CIRCUIT_ID_SIG_V2, CIRCUIT_ID_V3 } from "../../helpers/constants";
import { CircuitId, Operators } from "@0xpolygonid/js-sdk";

const removePreviousIgnitionFiles = true;

Expand Down Expand Up @@ -110,7 +109,7 @@ async function main() {
value: [await Merklizer.hashValue("http://www.w3.org/2001/XMLSchema#boolean", true)],
slotIndex: 0,
queryHash: "",
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
allowedIssuers: [],
skipClaimRevocationCheck: false,
verifierID: verifierId.bigInt(),
Expand Down Expand Up @@ -195,7 +194,7 @@ async function main() {
value: [],
slotIndex: 0,
queryHash: "",
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
allowedIssuers: [],
skipClaimRevocationCheck: false,
verifierID: verifierId.bigInt(),
Expand Down Expand Up @@ -280,7 +279,7 @@ async function main() {
operator: Operators.LT,
slotIndex: 0,
value: [20020101, ...new Array(63).fill(0)], // for operators 1-3 only first value matters
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
skipClaimRevocationCheck: false,
claimPathNotExists: 0,
};
Expand Down Expand Up @@ -310,7 +309,7 @@ async function main() {
},
scope: [
{
circuitId: CIRCUIT_ID_SIG_V2,
circuitId: CircuitId.AtomicQuerySigV2OnChain,
id: requestId_Sig,
query: {
allowedIssuers: ["*"],
Expand Down Expand Up @@ -348,7 +347,7 @@ async function main() {

console.log("================= setZKPRequest MTP V2 ===================");

query.circuitIds = [CIRCUIT_ID_MTP_V2];
query.circuitIds = [CircuitId.AtomicQueryMTPV2OnChain];
data = packValidatorParams(query);
const requestId_Mtp = 2;

Expand All @@ -368,7 +367,7 @@ async function main() {
},
scope: [
{
circuitId: CIRCUIT_ID_SIG_V2,
circuitId: CircuitId.AtomicQueryMTPV2OnChain,
id: requestId_Mtp,
query: {
allowedIssuers: ["*"],
Expand Down Expand Up @@ -416,7 +415,7 @@ async function main() {
value: [20020101, ...new Array(63).fill(0)], // for operators 1-3 only first value matters
slotIndex: 0,
queryHash: "",
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
allowedIssuers: [],
skipClaimRevocationCheck: false,
verifierID: verifierId.bigInt(),
Expand Down
26 changes: 13 additions & 13 deletions scripts/upgrade/validators/verifier-validators-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ import {
removeLocalhostNetworkIgnitionFiles,
verifyContract,
} from "../../../helpers/helperUtils";
import {
contractsInfo,
CIRCUIT_ID_MTP_V2,
CIRCUIT_ID_SIG_V2,
CIRCUIT_ID_V3,
VALIDATOR_TYPES,
} from "../../../helpers/constants";
import { contractsInfo, VALIDATOR_TYPES } from "../../../helpers/constants";
import fs from "fs";
import path from "path";
import { CircuitId } from "@0xpolygonid/js-sdk";

// In real upgrade, you should use THE NAME and THE ADDRESS
// of your custom verifier contract
Expand Down Expand Up @@ -78,21 +73,26 @@ async function main() {

const circuitId = (await validator.getSupportedCircuitIds())[0];
switch (circuitId) {
case CIRCUIT_ID_SIG_V2:
case CircuitId.AtomicQuerySigV2OnChain:
validatorVerification = contractsInfo.VALIDATOR_SIG.verificationOpts;
validatorContractName = "CredentialAtomicQuerySigV2Validator";
validatorContractName = contractsInfo.VALIDATOR_SIG.name;
validatorType = VALIDATOR_TYPES.SIG_V2;
break;
case CIRCUIT_ID_MTP_V2:
case CircuitId.AtomicQueryMTPV2OnChain:
validatorVerification = contractsInfo.VALIDATOR_MTP.verificationOpts;
validatorContractName = "CredentialAtomicQueryMTPV2Validator";
validatorContractName = contractsInfo.VALIDATOR_MTP.name;
validatorType = VALIDATOR_TYPES.MTP_V2;
break;
case CIRCUIT_ID_V3:
case CircuitId.AtomicQueryV3OnChain:
validatorVerification = contractsInfo.VALIDATOR_V3.verificationOpts;
validatorContractName = "CredentialAtomicQueryV3Validator";
validatorContractName = contractsInfo.VALIDATOR_V3.name;
validatorType = VALIDATOR_TYPES.V3;
break;
case CircuitId.AuthV2:
validatorVerification = contractsInfo.VALIDATOR_AUTH_V2.verificationOpts;
validatorContractName = contractsInfo.VALIDATOR_AUTH_V2.name;
validatorType = VALIDATOR_TYPES.AUTH_V2;
break;
}
validators.push({
circuitId,
Expand Down
15 changes: 9 additions & 6 deletions scripts/upgrade/verifiers/helpers/testVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from "@0xpolygonid/js-sdk";
import { ProofData } from "@iden3/js-jwz";
import { packCrossChainProofs, packZKProof } from "../../../../test/utils/packData";
import { CIRCUIT_ID_MTP_V2, CIRCUIT_ID_SIG_V2, CIRCUIT_ID_V3 } from "../../../../helpers/constants";
import { VerifierType } from "../../../../helpers/DeployHelper";

const rhsUrl = "https://rhs-staging.polygonid.me";

Expand Down Expand Up @@ -488,7 +488,7 @@ export async function setZKPRequest_KYCAgeCredential(
requestId: number,
verifier: Contract,
validatorAddress: string,
verifierType: "mtpV2" | "sigV2" | "v3",
verifierType: VerifierType,
provider?: JsonRpcProvider,
) {
console.log(
Expand Down Expand Up @@ -528,13 +528,16 @@ export async function setZKPRequest_KYCAgeCredential(
let circuitId: string;
switch (verifierType) {
case "mtpV2":
circuitId = CIRCUIT_ID_MTP_V2;
circuitId = CircuitId.AtomicQueryMTPV2OnChain;
break;
case "sigV2":
circuitId = CIRCUIT_ID_SIG_V2;
circuitId = CircuitId.AtomicQuerySigV2OnChain;
break;
case "v3":
circuitId = CIRCUIT_ID_V3;
circuitId = CircuitId.AtomicQueryV3OnChain;
break;
case "authV2":
circuitId = CircuitId.AuthV2;
break;
}

Expand Down Expand Up @@ -562,7 +565,7 @@ export async function setZKPRequest_KYCAgeCredential(
value: [20020101, ...new Array(63).fill(0)], // for operators 1-3 only first value matters
slotIndex: 0,
queryHash: "",
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
allowedIssuers: [],
skipClaimRevocationCheck: false,
verifierID: verifierId.bigInt(),
Expand Down
4 changes: 2 additions & 2 deletions test/validators/mtp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { prepareInputs, publishState } from "../../utils/state-utils";
import { DeployHelper } from "../../../helpers/DeployHelper";
import { packValidatorParams } from "../../utils/validator-pack-utils";
import { CIRCUIT_ID_MTP_V2 } from "../../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

const tenYears = 315360000;
const testCases: any[] = [
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("Atomic MTP Validator", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_MTP_V2],
circuitIds: [CircuitId.AtomicQueryMTPV2OnChain],
skipClaimRevocationCheck: false,
claimPathNotExists: 0,
};
Expand Down
4 changes: 2 additions & 2 deletions test/validators/sig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { prepareInputs, publishState } from "../../utils/state-utils";
import { DeployHelper } from "../../../helpers/DeployHelper";
import { packValidatorParams } from "../../utils/validator-pack-utils";
import { CIRCUIT_ID_SIG_V2 } from "../../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

const tenYears = 315360000;
const testCases: any[] = [
Expand Down Expand Up @@ -132,7 +132,7 @@ describe("Atomic Sig Validator", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
skipClaimRevocationCheck: false,
claimPathNotExists: 0,
};
Expand Down
4 changes: 2 additions & 2 deletions test/validators/v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { prepareInputs, publishState } from "../../utils/state-utils";
import { DeployHelper } from "../../../helpers/DeployHelper";
import { packV3ValidatorParams } from "../../utils/validator-pack-utils";
import { calculateQueryHashV3 } from "../../utils/query-hash-utils";
import { CIRCUIT_ID_V3 } from "../../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

const tenYears = 315360000;
const testCases: any[] = [
Expand Down Expand Up @@ -386,7 +386,7 @@ describe("Atomic V3 Validator", function () {
operator,
slotIndex,
value,
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
skipClaimRevocationCheck: false,
queryHash: test.queryHash == undefined ? queryHash : test.queryHash,
groupID: test.groupID == undefined ? 1 : test.groupID,
Expand Down
4 changes: 2 additions & 2 deletions test/verifier/embedded-zkp-verifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { prepareInputs } from "../utils/state-utils";
import { Block, Signer } from "ethers";
import { buildCrossChainProofs, packCrossChainProofs, packZKProof } from "../utils/packData";
import proofJson from "../validators/sig/data/valid_sig_user_genesis.json";
import { CIRCUIT_ID_SIG_V2 } from "../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

describe("Embedded ZKP Verifier", function () {
let verifier: any, sig: any;
Expand All @@ -23,7 +23,7 @@ describe("Embedded ZKP Verifier", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
claimPathNotExists: 0,
};

Expand Down
4 changes: 2 additions & 2 deletions test/verifier/universal-verifier-submit-V2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { prepareInputs } from "../utils/state-utils";
import { Block, Contract } from "ethers";
import proofJson from "../validators/sig/data/valid_sig_user_genesis.json";
import { buildCrossChainProofs, packCrossChainProofs, packZKProof } from "../utils/packData";
import { CIRCUIT_ID_SIG_V2 } from "../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

describe("Universal Verifier V2 MTP & SIG validators", function () {
let verifier: any, sig: any;
Expand Down Expand Up @@ -47,7 +47,7 @@ describe("Universal Verifier V2 MTP & SIG validators", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
claimPathNotExists: 0,
};

Expand Down
8 changes: 4 additions & 4 deletions test/verifier/universal-verifier.events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeployHelper } from "../../helpers/DeployHelper";
import { ethers } from "hardhat";
import { packValidatorParams } from "../utils/validator-pack-utils";
import { AbiCoder } from "ethers";
import { CIRCUIT_ID_SIG_V2 } from "../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

describe("Universal Verifier events", function () {
let verifier: any, sig: any;
Expand All @@ -19,7 +19,7 @@ describe("Universal Verifier events", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
skipClaimRevocationCheck: false,
claimPathNotExists: 0n,
},
Expand All @@ -34,7 +34,7 @@ describe("Universal Verifier events", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
skipClaimRevocationCheck: true,
claimPathNotExists: 0n,
},
Expand All @@ -49,7 +49,7 @@ describe("Universal Verifier events", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
skipClaimRevocationCheck: false,
claimPathNotExists: 0n,
},
Expand Down
4 changes: 2 additions & 2 deletions test/verifier/universal-verifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { packValidatorParams } from "../utils/validator-pack-utils";
import { prepareInputs } from "../utils/state-utils";
import { Block } from "ethers";
import proofJson from "../validators/mtp/data/valid_mtp_user_genesis.json";
import { CIRCUIT_ID_SIG_V2 } from "../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

describe("Universal Verifier MTP & SIG validators", function () {
let verifier: any, sig: any, state: any;
Expand All @@ -24,7 +24,7 @@ describe("Universal Verifier MTP & SIG validators", function () {
queryHash: BigInt(
"1496222740463292783938163206931059379817846775593932664024082849882751356658",
),
circuitIds: [CIRCUIT_ID_SIG_V2],
circuitIds: [CircuitId.AtomicQuerySigV2OnChain],
claimPathNotExists: 0,
};

Expand Down
4 changes: 2 additions & 2 deletions test/verifier/universal-verifier.v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { packV3ValidatorParams } from "../utils/validator-pack-utils";
import { prepareInputs, publishState } from "../utils/state-utils";
import { calculateQueryHashV3 } from "../utils/query-hash-utils";
import { expect } from "chai";
import { CIRCUIT_ID_V3 } from "../../helpers/constants";
import { CircuitId } from "@0xpolygonid/js-sdk";

describe("Universal Verifier V3 validator", function () {
let verifier: any, v3: any, state: any;
Expand Down Expand Up @@ -40,7 +40,7 @@ describe("Universal Verifier V3 validator", function () {
operator,
slotIndex,
value,
circuitIds: [CIRCUIT_ID_V3],
circuitIds: [CircuitId.AtomicQueryV3OnChain],
skipClaimRevocationCheck: false,
queryHash,
groupID: 1,
Expand Down

0 comments on commit 2f553f1

Please sign in to comment.