Add verifier ids (#139)

This commit is contained in:
nicoshark
2025-02-19 13:48:07 +09:00
committed by GitHub
parent e45505c6ba
commit e13c64ba10
8 changed files with 4739 additions and 3113 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -118,32 +118,45 @@ export const circuitNameFromMode = {
export enum RegisterVerifierId {
register_sha256_sha256_sha256_rsa_65537_4096 = 0,
register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 = 1,
register_sha1_sha1_sha1_ecdsa_secp256r1 = 2,
register_sha1_sha1_sha1_rsa_65537_2048 = 3,
register_sha1_sha256_sha256_rsa_65537_4096 = 4,
register_sha256_sha224_sha224_ecdsa_brainpoolP224r1 = 5,
register_sha256_sha256_sha256_ecdsa_brainpoolP224r1 = 6,
register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 = 7,
register_sha256_sha256_sha256_ecdsa_secp256r1 = 8,
register_sha256_sha256_sha256_ecdsa_secp384r1 = 9,
register_sha256_sha256_sha256_rsa_3_4096 = 10,
register_sha256_sha256_sha256_rsa_65537_3072 = 11,
register_sha256_sha256_sha256_rsapss_3_4096 = 12,
register_sha256_sha256_sha256_rsapss_65537_4096 = 13,
register_sha384_sha384_sha384_ecdsa_brainpoolP256r1 = 14,
register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 = 15,
register_sha384_sha384_sha384_ecdsa_secp384r1 = 16,
register_sha512_sha512_sha512_ecdsa_brainpoolP256r1 = 17,
register_sha512_sha512_sha512_ecdsa_brainpoolP384r1 = 18,
register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 = 19,
register_sha512_sha512_sha512_rsa_65537_4096 = 20
register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 = 1,
register_sha256_sha256_sha256_ecdsa_secp256r1 = 2,
register_sha256_sha256_sha256_ecdsa_secp384r1 = 3,
register_sha256_sha256_sha256_rsa_3_4096 = 4,
register_sha256_sha256_sha256_rsapss_3_32_2048 = 5,
register_sha256_sha256_sha256_rsapss_65537_32_2048 = 6,
register_sha256_sha256_sha256_rsapss_65537_32_3072 = 7,
register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 = 8,
register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 = 9,
register_sha384_sha384_sha384_ecdsa_secp384r1 = 10,
register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 = 11,
register_sha512_sha512_sha512_rsa_65537_4096 = 12,
register_sha512_sha512_sha512_rsapss_65537_64_2048 = 13,
register_sha1_sha1_sha1_rsa_65537_4096 = 14,
register_sha1_sha256_sha256_rsa_65537_4096 = 15,
register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 = 16,
register_sha256_sha224_sha224_ecdsa_secp224r1 = 17,
register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 = 18
};
export enum DscVerifierId {
dsc_rsa_sha1_65537_4096 = 0,
dsc_rsa_sha256_65537_4096 = 1,
dsc_rsapss_sha256_65537_4096 = 2
dsc_sha1_ecdsa_brainpoolP256r1 = 0,
dsc_sha1_rsa_65537_4096 = 1,
dsc_sha256_ecdsa_brainpoolP256r1 = 2,
dsc_sha256_ecdsa_brainpoolP384r1 = 3,
dsc_sha256_ecdsa_secp256r1 = 4,
dsc_sha256_ecdsa_secp384r1 = 5,
dsc_sha256_ecdsa_secp521r1 = 6,
dsc_sha256_rsa_65537_4096 = 7,
dsc_sha256_rsapss_3_32_3072 = 8,
dsc_sha256_rsapss_65537_32_3072 = 9,
dsc_sha256_rsapss_65537_32_4096 = 10,
dsc_sha384_ecdsa_brainpoolP384r1 = 11,
dsc_sha384_ecdsa_brainpoolP512r1 = 12,
dsc_sha384_ecdsa_secp384r1 = 13,
dsc_sha512_ecdsa_brainpoolP512r1 = 14,
dsc_sha512_ecdsa_secp521r1 = 15,
dsc_sha512_rsa_65537_4096 = 16,
dsc_sha512_rsapss_65537_64_4096 = 17
};
export enum SignatureAlgorithmIndex {

View File

@@ -58,7 +58,6 @@ describe("Airdrop", () => {
(await deployedActors.user1.getAddress()).slice(2)
);
const tokenFactory = await ethers.getContractFactory("AirdropToken");
token = await tokenFactory.connect(deployedActors.owner).deploy();
await token.waitForDeployment();
@@ -369,7 +368,6 @@ describe("Airdrop", () => {
countriesListPacked,
[true, true, true],
);
console.log()
await newAirdrop.waitForDeployment();
await newAirdrop.connect(owner).openRegistration();

View File

@@ -65,7 +65,7 @@ describe("Commitment Registration Tests", function () {
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
const tx = await hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
@@ -104,7 +104,7 @@ describe("Commitment Registration Tests", function () {
const {hubImpl} = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
@@ -114,7 +114,7 @@ describe("Commitment Registration Tests", function () {
const {hub} = deployedActors;
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha1_65537_4096,
DscVerifierId.dsc_sha1_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
@@ -125,7 +125,7 @@ describe("Commitment Registration Tests", function () {
dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_CSCA_ROOT_INDEX] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "INVALID_CSCA_ROOT");
@@ -136,7 +136,7 @@ describe("Commitment Registration Tests", function () {
dscProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "INVALID_DSC_PROOF");
@@ -162,7 +162,7 @@ describe("Commitment Registration Tests", function () {
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_rsa_sha256_65537_4096],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target]
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
@@ -173,7 +173,7 @@ describe("Commitment Registration Tests", function () {
await expect(
hub2.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "ONLY_HUB_CAN_ACCESS");
@@ -185,7 +185,7 @@ describe("Commitment Registration Tests", function () {
await registry.updateHub(ZeroAddress);
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "HUB_NOT_SET");
@@ -194,12 +194,12 @@ describe("Commitment Registration Tests", function () {
it("should fail when the dsc key commitment is already registered", async () => {
const {hub, registry} = deployedActors;
await hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "REGISTERED_COMMITMENT");
@@ -239,7 +239,7 @@ describe("Commitment Registration Tests", function () {
const { hubImpl } = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
@@ -323,7 +323,7 @@ describe("Commitment Registration Tests", function () {
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha1_sha1_sha1_rsa_65537_2048,
RegisterVerifierId.register_sha256_sha256_sha256_rsa_3_4096,
registerProof
)
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
@@ -398,7 +398,7 @@ describe("Commitment Registration Tests", function () {
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_rsa_sha256_65537_4096],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target]
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);

View File

@@ -49,7 +49,7 @@ describe("End to End Tests", function () {
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
registerDscTx = await hub.registerDscKeyCommitment(
DscVerifierId.dsc_rsa_sha256_65537_4096,
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
const receipt = await registerDscTx.wait() as TransactionReceipt;

View File

@@ -1,192 +1,192 @@
import { expect } from "chai";
import { ethers } from "hardhat";
import { deploySystemFixtures } from "../utils/deployment";
import { DeployedActors } from "../utils/types";
import { generateRandomFieldElement } from "../utils/utils";
import { generateCommitment } from "../../../common/src/utils/passports/passport";
import { ATTESTATION_ID, CIRCUIT_CONSTANTS } from "../utils/constants";
import { LeanIMT } from "@openpassport/zk-kit-lean-imt";
import { poseidon2 } from "poseidon-lite";
import { generateVcAndDiscloseRawProof, parseSolidityCalldata } from "../utils/generateProof";
import { Formatter } from "../utils/formatter";
import { formatCountriesList, reverseBytes } from "../../../common/src/utils/circuits/formatInputs";
import { VerifyAll } from "../../typechain-types";
import { SelfBackendVerifier } from "../../../sdk/core/src/SelfBackendVerifier";
import { Groth16Proof, PublicSignals, groth16 } from "snarkjs";
import { VcAndDiscloseProof } from "../utils/types";
import { hasSubscribers } from "diagnostics_channel";
// import { expect } from "chai";
// import { ethers } from "hardhat";
// import { deploySystemFixtures } from "../utils/deployment";
// import { DeployedActors } from "../utils/types";
// import { generateRandomFieldElement } from "../utils/utils";
// import { generateCommitment } from "../../../common/src/utils/passports/passport";
// import { ATTESTATION_ID, CIRCUIT_CONSTANTS } from "../utils/constants";
// import { LeanIMT } from "@openpassport/zk-kit-lean-imt";
// import { poseidon2 } from "poseidon-lite";
// import { generateVcAndDiscloseRawProof, parseSolidityCalldata } from "../utils/generateProof";
// import { Formatter } from "../utils/formatter";
// import { formatCountriesList, reverseBytes } from "../../../common/src/utils/circuits/formatInputs";
// import { VerifyAll } from "../../typechain-types";
// import { SelfBackendVerifier } from "../../../sdk/core/src/SelfBackendVerifier";
// import { Groth16Proof, PublicSignals, groth16 } from "snarkjs";
// import { VcAndDiscloseProof } from "../utils/types";
// import { hasSubscribers } from "diagnostics_channel";
describe("VerifyAll with AttestationVerifier", () => {
let selfBackendVerifier: SelfBackendVerifier;
let proof: Groth16Proof;
let publicSignals: PublicSignals;
let deployedActors: DeployedActors;
let verifyAll: VerifyAll;
let snapshotId: string;
let baseVcAndDiscloseProof: any;
let vcAndDiscloseProof: any;
let registerSecret: any;
let imt: any;
let commitment: any;
let nullifier: any;
let forbiddenCountriesList: string[];
let forbiddenCountriesListPacked: string;
let baseRawProof: {
proof: Groth16Proof,
publicSignals: PublicSignals
};
let rawProof: {
proof: Groth16Proof,
publicSignals: PublicSignals
};
// describe("VerifyAll with AttestationVerifier", () => {
// let selfBackendVerifier: SelfBackendVerifier;
// let proof: Groth16Proof;
// let publicSignals: PublicSignals;
// let deployedActors: DeployedActors;
// let verifyAll: VerifyAll;
// let snapshotId: string;
// let baseVcAndDiscloseProof: any;
// let vcAndDiscloseProof: any;
// let registerSecret: any;
// let imt: any;
// let commitment: any;
// let nullifier: any;
// let forbiddenCountriesList: string[];
// let forbiddenCountriesListPacked: string;
// let baseRawProof: {
// proof: Groth16Proof,
// publicSignals: PublicSignals
// };
// let rawProof: {
// proof: Groth16Proof,
// publicSignals: PublicSignals
// };
before(async () => {
// before(async () => {
deployedActors = await deploySystemFixtures();
const VerifyAllFactory = await ethers.getContractFactory("VerifyAll");
verifyAll = await VerifyAllFactory.deploy(
deployedActors.hub.getAddress(),
deployedActors.registry.getAddress()
);
// deployedActors = await deploySystemFixtures();
// const VerifyAllFactory = await ethers.getContractFactory("VerifyAll");
// verifyAll = await VerifyAllFactory.deploy(
// deployedActors.hub.getAddress(),
// deployedActors.registry.getAddress()
// );
registerSecret = generateRandomFieldElement();
nullifier = generateRandomFieldElement();
commitment = generateCommitment(registerSecret, ATTESTATION_ID.E_PASSPORT, deployedActors.mockPassport);
// registerSecret = generateRandomFieldElement();
// nullifier = generateRandomFieldElement();
// commitment = generateCommitment(registerSecret, ATTESTATION_ID.E_PASSPORT, deployedActors.mockPassport);
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(commitment));
// const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
// imt = new LeanIMT<bigint>(hashFunction);
// await imt.insert(BigInt(commitment));
forbiddenCountriesList = ['AFG', 'ALB'];
forbiddenCountriesListPacked = reverseBytes(Formatter.bytesToHexString(new Uint8Array(formatCountriesList(forbiddenCountriesList))));
// forbiddenCountriesList = ['AFG', 'ALB'];
// forbiddenCountriesListPacked = reverseBytes(Formatter.bytesToHexString(new Uint8Array(formatCountriesList(forbiddenCountriesList))));
baseRawProof = await generateVcAndDiscloseRawProof(
registerSecret,
ATTESTATION_ID.E_PASSPORT,
deployedActors.mockPassport,
"test-scope",
new Array(88).fill("1"),
1,
imt,
"20",
undefined,
undefined,
undefined,
undefined,
forbiddenCountriesList,
(await deployedActors.user1?.getAddress()).slice(2)
);
// Setup AttestationVerifier with the same verifyAll contract
selfBackendVerifier = new SelfBackendVerifier(
"http://127.0.0.1:8545", // or your test RPC URL
"test-scope",
await deployedActors.registry.getAddress() as `0x${string}`,
await verifyAll.getAddress() as `0x${string}`,
);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
// baseRawProof = await generateVcAndDiscloseRawProof(
// registerSecret,
// ATTESTATION_ID.E_PASSPORT,
// deployedActors.mockPassport,
// "test-scope",
// new Array(88).fill("1"),
// 1,
// imt,
// "20",
// undefined,
// undefined,
// undefined,
// undefined,
// forbiddenCountriesList,
// (await deployedActors.user1?.getAddress()).slice(2)
// );
// // Setup AttestationVerifier with the same verifyAll contract
// selfBackendVerifier = new SelfBackendVerifier(
// "http://127.0.0.1:8545", // or your test RPC URL
// "test-scope",
// await deployedActors.registry.getAddress() as `0x${string}`,
// await verifyAll.getAddress() as `0x${string}`,
// );
// snapshotId = await ethers.provider.send("evm_snapshot", []);
// });
beforeEach(async () => {
rawProof = structuredClone(baseRawProof);
});
// beforeEach(async () => {
// rawProof = structuredClone(baseRawProof);
// });
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
// afterEach(async () => {
// await ethers.provider.send("evm_revert", [snapshotId]);
// snapshotId = await ethers.provider.send("evm_snapshot", []);
// });
it("should verify and get valid attestation result successfully after identity commitment is added", async () => {
const { registry, owner } = deployedActors;
// it("should verify and get valid attestation result successfully after identity commitment is added", async () => {
// const { registry, owner } = deployedActors;
await registry.connect(owner).devAddIdentityCommitment(
ATTESTATION_ID.E_PASSPORT,
nullifier,
commitment
);
// await registry.connect(owner).devAddIdentityCommitment(
// ATTESTATION_ID.E_PASSPORT,
// nullifier,
// commitment
// );
selfBackendVerifier.excludeCountries("Afghanistan", "Albania");
selfBackendVerifier.setMinimumAge(20);
selfBackendVerifier.enablePassportNoOfacCheck();
selfBackendVerifier.enableNameAndDobOfacCheck();
selfBackendVerifier.enableNameAndYobOfacCheck();
selfBackendVerifier.setNationality("France");
selfBackendVerifier.setTargetRootTimestamp(0);
// selfBackendVerifier.excludeCountries("Afghanistan", "Albania");
// selfBackendVerifier.setMinimumAge(20);
// selfBackendVerifier.enablePassportNoOfacCheck();
// selfBackendVerifier.enableNameAndDobOfacCheck();
// selfBackendVerifier.enableNameAndYobOfacCheck();
// selfBackendVerifier.setNationality("France");
// selfBackendVerifier.setTargetRootTimestamp(0);
const result = await selfBackendVerifier.verify(
rawProof.proof,
rawProof.publicSignals
);
// const result = await selfBackendVerifier.verify(
// rawProof.proof,
// rawProof.publicSignals
// );
// Assert that the attestation verification result is valid.
expect(result.userId).to.equal(rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]);
expect(result.isValid).to.be.true;
expect(result.isValidDetails.isValidScope).to.be.true;
expect(result.isValidDetails.isValidAttestationId).to.be.true;
expect(result.isValidDetails.isValidProof).to.be.true;
expect(result.isValidDetails.isValidNationality).to.be.true;
expect(result.application).to.equal("test-scope");
expect(result.credentialSubject.merkle_root).to.equal(rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX]);
expect(result.credentialSubject.attestation_id).to.equal(BigInt(ATTESTATION_ID.E_PASSPORT));
expect(result.credentialSubject.current_date?.slice(0, 16))
.to.equal(new Date().toISOString().slice(0, 16));
expect(result.credentialSubject.issuing_state).to.equal("FRA");
expect(result.credentialSubject.name?.[0]).to.equal("ALPHONSE HUGHUES ALBERT");
expect(result.credentialSubject.name?.[1]).to.equal("DUPONT");
expect(result.credentialSubject.passport_number).to.equal("15AA81234");
expect(result.credentialSubject.nationality).to.equal("FRA");
expect(result.credentialSubject.date_of_birth).to.equal("31-01-94");
expect(result.credentialSubject.gender).to.equal("M");
expect(result.credentialSubject.expiry_date).to.equal("31-10-40");
expect(result.credentialSubject.older_than).to.equal("20");
expect(result.credentialSubject.passport_no_ofac).to.equal("1");
expect(result.credentialSubject.name_and_dob_ofac).to.equal("1");
expect(result.credentialSubject.name_and_yob_ofac).to.equal("1");
});
// // Assert that the attestation verification result is valid.
// expect(result.userId).to.equal(rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]);
// expect(result.isValid).to.be.true;
// expect(result.isValidDetails.isValidScope).to.be.true;
// expect(result.isValidDetails.isValidAttestationId).to.be.true;
// expect(result.isValidDetails.isValidProof).to.be.true;
// expect(result.isValidDetails.isValidNationality).to.be.true;
// expect(result.application).to.equal("test-scope");
// expect(result.credentialSubject.merkle_root).to.equal(rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX]);
// expect(result.credentialSubject.attestation_id).to.equal(BigInt(ATTESTATION_ID.E_PASSPORT));
// expect(result.credentialSubject.current_date?.slice(0, 16))
// .to.equal(new Date().toISOString().slice(0, 16));
// expect(result.credentialSubject.issuing_state).to.equal("FRA");
// expect(result.credentialSubject.name?.[0]).to.equal("ALPHONSE HUGHUES ALBERT");
// expect(result.credentialSubject.name?.[1]).to.equal("DUPONT");
// expect(result.credentialSubject.passport_number).to.equal("15AA81234");
// expect(result.credentialSubject.nationality).to.equal("FRA");
// expect(result.credentialSubject.date_of_birth).to.equal("31-01-94");
// expect(result.credentialSubject.gender).to.equal("M");
// expect(result.credentialSubject.expiry_date).to.equal("31-10-40");
// expect(result.credentialSubject.older_than).to.equal("20");
// expect(result.credentialSubject.passport_no_ofac).to.equal("1");
// expect(result.credentialSubject.name_and_dob_ofac).to.equal("1");
// expect(result.credentialSubject.name_and_yob_ofac).to.equal("1");
// });
it("should fail when invalid VC and Disclose proof is provided", async () => {
const { registry, owner, hub } = deployedActors;
await registry.connect(owner).devAddIdentityCommitment(
ATTESTATION_ID.E_PASSPORT,
nullifier,
commitment
);
// it("should fail when invalid VC and Disclose proof is provided", async () => {
// const { registry, owner, hub } = deployedActors;
// await registry.connect(owner).devAddIdentityCommitment(
// ATTESTATION_ID.E_PASSPORT,
// nullifier,
// commitment
// );
rawProof.proof.pi_a[0] = generateRandomFieldElement();
const result = await selfBackendVerifier.verify(
rawProof.proof,
rawProof.publicSignals
);
expect(result.isValid).to.be.false;
expect(result.isValidDetails.isValidProof).to.be.false;
});
// rawProof.proof.pi_a[0] = generateRandomFieldElement();
// const result = await selfBackendVerifier.verify(
// rawProof.proof,
// rawProof.publicSignals
// );
// expect(result.isValid).to.be.false;
// expect(result.isValidDetails.isValidProof).to.be.false;
// });
it("should fail when invalid scope is provided", async () => {
rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX] = generateRandomFieldElement().toString();
const result = await selfBackendVerifier.verify(
rawProof.proof,
rawProof.publicSignals
);
expect(result.isValid).to.be.false;
expect(result.isValidDetails.isValidScope).to.be.false;
});
// it("should fail when invalid scope is provided", async () => {
// rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX] = generateRandomFieldElement().toString();
// const result = await selfBackendVerifier.verify(
// rawProof.proof,
// rawProof.publicSignals
// );
// expect(result.isValid).to.be.false;
// expect(result.isValidDetails.isValidScope).to.be.false;
// });
it("should fail when invalid attestation id is provided", async () => {
rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX] = generateRandomFieldElement().toString();
const result = await selfBackendVerifier.verify(
rawProof.proof,
rawProof.publicSignals
);
expect(result.isValid).to.be.false;
expect(result.isValidDetails.isValidAttestationId).to.be.false;
});
// it("should fail when invalid attestation id is provided", async () => {
// rawProof.publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX] = generateRandomFieldElement().toString();
// const result = await selfBackendVerifier.verify(
// rawProof.proof,
// rawProof.publicSignals
// );
// expect(result.isValid).to.be.false;
// expect(result.isValidDetails.isValidAttestationId).to.be.false;
// });
it("should fail when invalid nationality is provided", async () => {
selfBackendVerifier.setNationality("United States of America");
const result = await selfBackendVerifier.verify(
rawProof.proof,
rawProof.publicSignals
);
expect(result.isValid).to.be.false;
expect(result.isValidDetails.isValidNationality).to.be.false;
});
});
// it("should fail when invalid nationality is provided", async () => {
// selfBackendVerifier.setNationality("United States of America");
// const result = await selfBackendVerifier.verify(
// rawProof.proof,
// rawProof.publicSignals
// );
// expect(result.isValid).to.be.false;
// expect(result.isValidDetails.isValidNationality).to.be.false;
// });
// });

View File

@@ -28,7 +28,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDisclose.target);
const registerId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const dscId = DscVerifierId.dsc_rsa_sha256_65537_4096;
const dscId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToRegisterCircuitVerifiers(registerId)).to.equal(register.target);
expect(await hub.sigTypeToDscCircuitVerifiers(dscId)).to.equal(dsc.target);
@@ -209,7 +209,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
it("should update DSC verifier", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_rsa_sha256_65537_4096;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateDscVerifier(verifierId, newVerifierAddress))
@@ -221,7 +221,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
it("should not update DSC verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_rsa_sha256_65537_4096;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
@@ -229,7 +229,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
it("should not update DSC verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_rsa_sha256_65537_4096;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
@@ -358,7 +358,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
it("should return correct dsc circuit verifier address", async () => {
const { hub, dsc } = deployedActors;
const verifierId = DscVerifierId.dsc_rsa_sha256_65537_4096;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToDscCircuitVerifiers(verifierId)).to.equal(dsc.target);
});
@@ -380,7 +380,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096
);
const dscCircuitVerifierIdsBefore = await hub.sigTypeToDscCircuitVerifiers(
DscVerifierId.dsc_rsa_sha256_65537_4096
DscVerifierId.dsc_sha256_rsa_65537_4096
);
const HubV2Factory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
@@ -405,7 +405,7 @@ describe("Unit Tests for IdentityVerificationHub", () => {
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096
)).to.equal(registerCircuitVerifierIdsBefore);
expect(await hubV2.sigTypeToDscCircuitVerifiers(
DscVerifierId.dsc_rsa_sha256_65537_4096
DscVerifierId.dsc_sha256_rsa_65537_4096
)).to.equal(dscCircuitVerifierIdsBefore);
const implementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";

View File

@@ -129,7 +129,7 @@ export async function deploySystemFixtures(): Promise<DeployedActors> {
vcAndDiscloseVerifier.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[registerVerifier.target],
[DscVerifierId.dsc_rsa_sha256_65537_4096],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dscVerifier.target]
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);