Skip to content

Commit

Permalink
passes all reencryption tests
Browse files Browse the repository at this point in the history
  • Loading branch information
poppyseedDev committed Dec 14, 2024
1 parent 821c15d commit 9000025
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
27 changes: 8 additions & 19 deletions hardhat/test/decIdentity/diploma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ describe("Diploma", function () {
);
}

// /**
// * Helper function to setup reencryption
// */
// async function setupReencryption(instance: FhevmInstance, signer: HardhatEthersSigner, contractAddress: string) {
// const { publicKey, privateKey } = instance.generateKeypair();
// const eip712 = instance.createEIP712(publicKey, contractAddress);
// const signature = await signer.signTypedData(eip712.domain, { Reencrypt: eip712.types.Reencrypt }, eip712.message);

// return { publicKey, privateKey, signature: signature.replace("0x", "") };
// }

/**
* Helper function to register identity
*/
Expand Down Expand Up @@ -184,10 +173,10 @@ describe("Diploma", function () {
this.signers.alice,
this.instances,
degreeClaim,
this.diplomaAddress,
this.employerClaimAddress,
);

expect(reencryptedDegreeClaim).to.equal(0);
expect(reencryptedDegreeClaim).to.equal(false);
});

it("should generate both degree and adult claims", async function () {
Expand Down Expand Up @@ -228,18 +217,18 @@ describe("Diploma", function () {
this.signers.alice,
this.instances,
degreeClaim,
this.diplomaAddress,
this.employerClaimAddress,
);

const reencryptedAdultClaim = await reencryptEbool(
this.signers.alice,
this.instances,
adultClaim,
this.diplomaAddress,
this.employerClaimAddress,
);

expect(reencryptedDegreeClaim).to.equal(1);
expect(reencryptedAdultClaim).to.equal(1);
expect(reencryptedDegreeClaim).to.equal(true);
expect(reencryptedAdultClaim).to.equal(true);

await employerClaim.verifyClaims(userId, latestAdultClaimUserId, latestDegreeClaimUserId);
const verifyResult = await employerClaim.getVerifyClaim(userId);
Expand All @@ -248,10 +237,10 @@ describe("Diploma", function () {
this.signers.alice,
this.instances,
verifyResult,
this.diplomaAddress,
this.employerClaimAddress,
);

expect(reencryptedVerifyResult).to.equal(1);
expect(reencryptedVerifyResult).to.equal(true);
});

it("should not allow generating claims without a registered ID", async function () {
Expand Down
13 changes: 9 additions & 4 deletions hardhat/test/decIdentity/passportID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("PassportID", function () {
});

// Test case: Retrieve the registered identity
it.only("should retrieve the registered identity", async function () {
it("should retrieve the registered identity", async function () {
await idMapping.connect(this.signers.alice).generateId();
const userId = await idMapping.getId(this.signers.alice);

Expand All @@ -110,7 +110,7 @@ describe("PassportID", function () {
this.signers.alice,
this.instances,
firstnameHandleAlice,
this.diplomaAddress,
this.passportIDAddress,
);

expect(reencryptedFirstname).to.equal(8);
Expand All @@ -131,9 +131,14 @@ describe("PassportID", function () {

const latestClaimUserId = await employerClaim.lastClaimId();
const adultsClaim = await employerClaim.getAdultClaim(latestClaimUserId);
const reencrypted = await reencryptEbool(this.signers.bob, this.instances, adultsClaim, this.diplomaAddress);
const reencrypted = await reencryptEbool(
this.signers.alice,
this.instances,
adultsClaim,
this.employerClaimAddress,
);

expect(reencrypted).to.equal(1);
expect(reencrypted).to.equal(true);
});

// Test case: Should fail verification with invalid claim IDs
Expand Down

0 comments on commit 9000025

Please sign in to comment.