-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added test for qp-encoded sha-precompute selector
- Loading branch information
1 parent
d43398c
commit 2537c1f
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/circuits/tests/email-verifier-with-qp-encoded-sha-precompute-selector.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import fs from "fs"; | ||
import { wasm as wasm_tester } from "circom_tester"; | ||
import path from "path"; | ||
import { DKIMVerificationResult } from "@zk-email/helpers/src/dkim"; | ||
import { generateEmailVerifierInputsFromDKIMResult } from "@zk-email/helpers/src/input-generators"; | ||
import { verifyDKIMSignature } from "@zk-email/helpers/src/dkim"; | ||
|
||
describe("EmailVerifier : With soft line breaks", () => { | ||
jest.setTimeout(30 * 60 * 1000); // 30 minutes | ||
|
||
let dkimResult: DKIMVerificationResult; | ||
let circuit: any; | ||
|
||
beforeAll(async () => { | ||
const rawEmail = fs.readFileSync( | ||
path.join(__dirname, "./test-emails/lorem_ipsum.eml"), | ||
"utf8" | ||
); | ||
dkimResult = await verifyDKIMSignature(rawEmail); | ||
|
||
circuit = await wasm_tester( | ||
path.join( | ||
__dirname, | ||
"./test-circuits/email-verifier-with-soft-line-breaks-test.circom" | ||
), | ||
{ | ||
recompile: true, | ||
include: path.join(__dirname, "../../../node_modules"), | ||
output: path.join(__dirname, "./compiled-test-circuits"), | ||
} | ||
); | ||
}); | ||
|
||
it("should verify email with soft line break in sha precompute selector", async function () { | ||
const emailVerifierInputs = generateEmailVerifierInputsFromDKIMResult( | ||
dkimResult, | ||
{ | ||
maxHeadersLength: 640, | ||
maxBodyLength: 1408, | ||
ignoreBodyHashCheck: false, | ||
removeSoftLineBreaks: true, | ||
shaPrecomputeSelector: "imperdiet neque.", | ||
} | ||
); | ||
|
||
const witness = await circuit.calculateWitness(emailVerifierInputs); | ||
await circuit.checkConstraints(witness); | ||
}); | ||
}); |