Skip to content

Commit

Permalink
Integration tests worked
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Sep 19, 2024
1 parent d87e284 commit de7779c
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 307 deletions.
35 changes: 1 addition & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[workspace]
members = [
"packages/relayer",
"packages/scripts",
"packages/circuits/node_modules/@zk-email/relayer-utils",
]
exclude = ["node_modules/*"]
members = ["packages/relayer", "packages/scripts"]
exclude = ["node_modules/*", "packages/circuits/node_modules/*"]
resolver = "2"
44 changes: 41 additions & 3 deletions packages/circuits/helpers/email_sender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs";
import { promisify } from "util";
const emailWalletUtils = require("@zk-email/relayer-utils");
const relayerUtils = require("@zk-email/relayer-utils");

export async function genEmailSenderInput(
emailFilePath: string,
Expand All @@ -19,6 +19,44 @@ export async function genEmailSenderInput(
recipient_email_idx: number;
}> {
const emailRaw = await promisify(fs.readFile)(emailFilePath, "utf8");
const jsonStr = await emailWalletUtils.genEmailSenderInput(emailRaw, accountCode);
return JSON.parse(jsonStr);
const options = {
maxHeaderLength: 1024,
ignoreBodyHashCheck: true,
}
const jsonStr = await relayerUtils.genEmailCircuitInput(emailRaw, accountCode, options);
const {
body_hash_idx,
precomputed_sha,
padded_body,
padded_body_len,
command_idx,
padded_cleaned_body,
account_code,
...circuitInputsRelevant
} = JSON.parse(jsonStr);
const parsedEmail = await relayerUtils.parseEmail(emailRaw);
const subjectEmailIdxes = relayerUtils.extractSubjectAllIdxes(
parsedEmail.canonicalizedHeader
)[0];
const subject = parsedEmail.canonicalizedHeader.slice(
subjectEmailIdxes[0],
subjectEmailIdxes[1]
);
let recipientEmailIdx = 0;
try {
recipientEmailIdx = relayerUtils.extractEmailAddrIdxes(subject)[0][0];
} catch (e) {
console.log("No email address in subject");
recipientEmailIdx = 0;
}
console.log({
sender_account_code: account_code,
recipient_email_idx: recipientEmailIdx,
...circuitInputsRelevant,
});
return {
sender_account_code: account_code,
recipient_email_idx: recipientEmailIdx,
...circuitInputsRelevant,
};
}
9 changes: 4 additions & 5 deletions packages/circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
"test": "NODE_OPTIONS=--max_old_space_size=8192 jest"
},
"dependencies": {
"@zk-email/circuits": "^6.1.1",
"@zk-email/ether-email-auth-circom": "/Users/suegamisora/codes/ether-email-auth/packages/circuits",
"@zk-email/helpers": "^6.1.1",
"@zk-email/relayer-utils": "/Users/suegamisora/codes/relayer-utils-1",
"@zk-email/zk-regex-circom": "^2.1.0",
"@zk-email/circuits": "=6.1.5",
"@zk-email/relayer-utils": "=0.3.7",
"@zk-email/zk-regex-circom": "=2.1.1",
"@zk-email/ether-email-auth-circom": "0.0.2-preview",
"circom-grumpkin": "https://github.com/zkemail/circom-grumpkin.git",
"commander": "^11.0.0",
"snarkjs": "^0.7.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/src/verifier/AnnouncementVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ contract AnnouncementVerifier {
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
uint256 constant deltax1 = 1872897201398364180136956405563456104769319815771777288636804792542500861861;
uint256 constant deltax2 = 15391418996219944407418340234390811728876304592461267334892882130552315264899;
uint256 constant deltay1 = 17973712144921020951412561872955756958528341259743359366735386171189583753395;
uint256 constant deltay2 = 6881872257559889803336051693780525349669321781936932860914089569112569575201;
uint256 constant deltax1 = 6021058327459909781296854683640015150852517373793601651011140929674766593136;
uint256 constant deltax2 = 8958852967621983740770913787164063956463021526641835048412435927500818740247;
uint256 constant deltay1 = 21227816902095712972418730271551354564584570940788668915643522438204753038965;
uint256 constant deltay2 = 21500811721458517869211895746343832071179360587913717033923962799912551264201;

uint256 constant IC0x = 11541328982697831985122779204525341819172299548155197733745512760010296786584;
uint256 constant IC0y = 4912600014728947449271015462008279900846525879333470015129856497234688681860;
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/src/verifier/ClaimVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ contract ClaimVerifier {
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
uint256 constant deltax1 = 15924359623938328656241672740211919750111378425602275303418107506172377636070;
uint256 constant deltax2 = 8136007875489307109416580223432959998369623673560516903198102117198957272924;
uint256 constant deltay1 = 6244689059474160506316410162442436336545386950888018841181082859587039406248;
uint256 constant deltay2 = 10334564390409539270946177121675114471256501812620081677372067351218158232174;
uint256 constant deltax1 = 18785511401846744025211691333617330808976571357383710434259597062006739076758;
uint256 constant deltax2 = 4290494539015554883025013992780383796583855720289266056855177159155807869405;
uint256 constant deltay1 = 18180341976861136503307057720165742999654562321387202755390774917362552016043;
uint256 constant deltay2 = 4960733180692751225282574731775689784108356389366547908285351408104513074082;

uint256 constant IC0x = 12162592475836939001090539993209264472926898859801840211443541901466257396874;
uint256 constant IC0y = 13868908035282123831022702818759871530925026705655094556541666705359159145982;
Expand Down
Loading

0 comments on commit de7779c

Please sign in to comment.