From 5b669f7efea6802f88fff90720879ad6741ed508 Mon Sep 17 00:00:00 2001 From: javiersuweijie Date: Fri, 8 Nov 2024 10:50:27 +0800 Subject: [PATCH] fix: accept when sender email is different --- packages/app/package.json | 2 +- packages/app/src/app/submit/email/action.ts | 2 +- .../templates/zkemail_example/lib/generate_inputs.js.ejs | 3 +++ .../lib/code-gen/templates/zkemail_example/package.json | 2 +- .../templates/zkemail_masking/lib/generate_inputs.js.ejs | 3 +++ .../lib/code-gen/templates/zkemail_masking/package.json | 4 ++-- packages/app/yarn.lock | 8 ++++---- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index 9f3924a..3ecb92b 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -25,7 +25,7 @@ "@rainbow-me/rainbowkit": "^2.1.3", "@tanstack/react-query": "^5.51.15", "@zk-email/circuits": "6.1.1", - "@zk-email/helpers": "6.1.1", + "@zk-email/helpers": "6.2.0", "@zk-email/zk-email-sdk": "^1.0.6", "@zk-email/relayer-utils": "^0.4.2", "archiver": "^7.0.1", diff --git a/packages/app/src/app/submit/email/action.ts b/packages/app/src/app/submit/email/action.ts index 4d7cdf4..48b7767 100644 --- a/packages/app/src/app/submit/email/action.ts +++ b/packages/app/src/app/submit/email/action.ts @@ -27,7 +27,7 @@ export async function processEmail(values: z.infer, email: st let headerString; try { - result = await verifyDKIMSignature(email) + result = await verifyDKIMSignature(email, values.parameters.senderDomain) } catch (e: any) { return { error: true, diff --git a/packages/app/src/lib/code-gen/templates/zkemail_example/lib/generate_inputs.js.ejs b/packages/app/src/lib/code-gen/templates/zkemail_example/lib/generate_inputs.js.ejs index 7d7a8e7..e14f9e0 100644 --- a/packages/app/src/lib/code-gen/templates/zkemail_example/lib/generate_inputs.js.ejs +++ b/packages/app/src/lib/code-gen/templates/zkemail_example/lib/generate_inputs.js.ejs @@ -6,6 +6,9 @@ export async function generateCircuitInputs(rawEmail, inputs) { maxBodyLength: <%- ignoreBodyHashCheck ? 0 : emailBodyMaxLength %>, maxHeadersLength: <%- emailHeaderMaxLength || 1024 %>, shaPrecomputeSelector: "<%- shaPrecomputeSelector.replaceAll('"', '\\\"') %>", + }, + { + domain: "<%- senderDomain %>", }); const emailBodyString = circuitInputs.emailBody ? Buffer.from(circuitInputs.emailBody.map(Number)).toString('ascii') : null; diff --git a/packages/app/src/lib/code-gen/templates/zkemail_example/package.json b/packages/app/src/lib/code-gen/templates/zkemail_example/package.json index 4b3005b..20a7334 100644 --- a/packages/app/src/lib/code-gen/templates/zkemail_example/package.json +++ b/packages/app/src/lib/code-gen/templates/zkemail_example/package.json @@ -9,7 +9,7 @@ "dependencies": { "@types/node-forge": "^1.3.11", "@zk-email/circuits": "6.1.1", - "@zk-email/helpers": "6.1.1", + "@zk-email/helpers": "6.2.0", "node-forge": "^1.3.1", "snarkjs": "^0.7.4" }, diff --git a/packages/app/src/lib/code-gen/templates/zkemail_masking/lib/generate_inputs.js.ejs b/packages/app/src/lib/code-gen/templates/zkemail_masking/lib/generate_inputs.js.ejs index b24cd4e..26bc27a 100644 --- a/packages/app/src/lib/code-gen/templates/zkemail_masking/lib/generate_inputs.js.ejs +++ b/packages/app/src/lib/code-gen/templates/zkemail_masking/lib/generate_inputs.js.ejs @@ -8,6 +8,9 @@ export async function generateCircuitInputs(rawEmail, inputs) { shaPrecomputeSelector: "<%- shaPrecomputeSelector %>", enableBodyMasking: true, mask: JSON.parse(inputs["mask"]) || Array.apply(null, {length: <%- emailBodyMaxLength %> }).map(() => 0) + }, + { + domain: "<%- senderDomain %>", }); const emailBodyString = circuitInputs.emailBody ? Buffer.from(circuitInputs.emailBody.map(Number)).toString('ascii') : null; diff --git a/packages/app/src/lib/code-gen/templates/zkemail_masking/package.json b/packages/app/src/lib/code-gen/templates/zkemail_masking/package.json index 55bf9fd..4d3b356 100644 --- a/packages/app/src/lib/code-gen/templates/zkemail_masking/package.json +++ b/packages/app/src/lib/code-gen/templates/zkemail_masking/package.json @@ -8,8 +8,8 @@ }, "dependencies": { "@types/node-forge": "^1.3.11", - "@zk-email/circuits": "6.1.5", - "@zk-email/helpers": "6.1.5", + "@zk-email/circuits": "6.2.0", + "@zk-email/helpers": "6.2.0", "node-forge": "^1.3.1", "snarkjs": "^0.7.4" }, diff --git a/packages/app/yarn.lock b/packages/app/yarn.lock index c035822..2ba6ce9 100644 --- a/packages/app/yarn.lock +++ b/packages/app/yarn.lock @@ -2516,10 +2516,10 @@ "@zk-email/zk-regex-circom" "^2.1.0" circomlib "^2.0.5" -"@zk-email/helpers@6.1.1": - version "6.1.1" - resolved "https://registry.yarnpkg.com/@zk-email/helpers/-/helpers-6.1.1.tgz#3172d07c7fd1ce56a2957dc9ff32b0bc7d1592a3" - integrity sha512-u3LYa8rLdLCvy4FpgXOfQNJPOIrj26CwxLDEYOwyDwYpdSdvEgqE/FL1h2Rwkr1TdbneWaCeSVQC4jhtQaXswg== +"@zk-email/helpers@6.2.0": + version "6.2.0" + resolved "https://registry.yarnpkg.com/@zk-email/helpers/-/helpers-6.2.0.tgz#be0fd0f4626b3b8d1f8e16cafa4936bd6e138bb0" + integrity sha512-BRrVjRKxfcz8waPIVYLn3D2y9dCBafdBCEtjgzbz9Jh8WyJZJNKMJ3MVjm28V5He+H6YyOcatSItO+VIuQ1Nrw== dependencies: addressparser "^1.0.1" atob "^2.1.2"