From 845ab87ece2c34b4edf84d1bbe4761b74aa84e6b Mon Sep 17 00:00:00 2001 From: Dimitri Date: Fri, 13 Dec 2024 15:08:25 +0700 Subject: [PATCH 1/2] chore: bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb7f124..163d1e9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "wasm:postbuild": "node build.js", "build": "npm run wasm:build && npm run wasm:postbuild" }, - "version": "0.4.55", + "version": "0.4.58", "devDependencies": { "@types/bun": "latest", "prettier": "^3.3.3" From cda92bf5d8f768402aaec1a51b3887c22add40f6 Mon Sep 17 00:00:00 2001 From: Aditya Bisht Date: Fri, 13 Dec 2024 23:35:09 +0530 Subject: [PATCH 2/2] feat: support multiple reveal inputs for circuit --- src/circuit.rs | 5 + src/cryptos.rs | 4 +- src/parse_email.rs | 12 - tests/fixtures/x.eml | 405 ++++++++++++++++++ .../{circuit_intput.ts => circuit_input.ts} | 0 5 files changed, 412 insertions(+), 14 deletions(-) create mode 100644 tests/fixtures/x.eml rename ts_tests/{circuit_intput.ts => circuit_input.ts} (100%) diff --git a/src/circuit.rs b/src/circuit.rs index 156c3c3..77b4597 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -594,6 +594,11 @@ pub async fn generate_circuit_inputs_with_decomposed_regexes_and_external_inputs // Add the first index to the circuit inputs circuit_inputs[format!("{}RegexIdx", decomposed_regex.name)] = idxes[0].0.into(); + + for (i, idx) in idxes.iter().enumerate().skip(1) { + // Add the remaining indices to the circuit inputs + circuit_inputs[format!("{}RegexIdx{}", decomposed_regex.name, i)] = idx.0.into(); + } } // Process each external input and add it to the circuit inputs diff --git a/src/cryptos.rs b/src/cryptos.rs index b1dc45b..cf17742 100644 --- a/src/cryptos.rs +++ b/src/cryptos.rs @@ -2,8 +2,8 @@ #[cfg(target_arch = "wasm32")] use crate::EmailHeaders; -use crate::{field_to_hex, find_index_in_body, hex_to_field, remove_quoted_printable_soft_breaks}; -use anyhow::{anyhow, Result}; +use crate::{field_to_hex, hex_to_field}; +use anyhow::Result; use ethers::types::Bytes; use halo2curves::ff::Field; use poseidon_rs::{poseidon_bytes, poseidon_fields, Fr, PoseidonError}; diff --git a/src/parse_email.rs b/src/parse_email.rs index c3ff085..93d7a0d 100644 --- a/src/parse_email.rs +++ b/src/parse_email.rs @@ -290,18 +290,6 @@ impl ParsedEmail { /// - `Vec`: A mapping from cleaned indices to original indices. For cleaned indices that /// correspond to actual content, `index_map[i]` gives the original position of /// that byte in `body`. For padded bytes, the value is `usize::MAX`. -/// -/// # Example -/// -/// ``` -/// let body = b"Hello=\r\nWorld".to_vec(); -/// // body: [72,101,108,108,111,61,13,10,87,111,114,108,100] -/// let (clean_content, index_map) = remove_quoted_printable_soft_breaks(body); -/// -/// // clean_content might look like [72,101,108,108,111,87,111,114,108,100,0,0,0] -/// // index_map might map: -/// // 0->0, 1->1, 2->2, 3->3, 4->4, 5->8, 6->9, 7->10, 8->11, 9->12, and the rest are usize::MAX. -/// ``` pub fn remove_quoted_printable_soft_breaks(body: Vec) -> (Vec, Vec) { let original_len = body.len(); let mut cleaned = Vec::with_capacity(original_len); diff --git a/tests/fixtures/x.eml b/tests/fixtures/x.eml new file mode 100644 index 0000000..bcd6e0c --- /dev/null +++ b/tests/fixtures/x.eml @@ -0,0 +1,405 @@ +Delivered-To: prakharsingh0908@gmail.com +Received: by 2002:a05:6a21:e85:b0:1a1:4898:1cbb with SMTP id ma5csp770067pzb; + Sun, 3 Mar 2024 11:22:12 -0800 (PST) +X-Google-Smtp-Source: AGHT+IEYrEIJ2J42/EIdte/tMr9cjmRYvmb2akT91bJfuj1DPqwO5X/KDJjJr5M8BCd6KFRL1PDL +X-Received: by 2002:a25:8d83:0:b0:dcc:744d:b486 with SMTP id o3-20020a258d83000000b00dcc744db486mr4467271ybl.39.1709493732057; + Sun, 03 Mar 2024 11:22:12 -0800 (PST) +ARC-Seal: i=1; a=rsa-sha256; t=1709493732; cv=none; + d=google.com; s=arc-20160816; + b=ry64Al11brb6kQgAzh6xRMlDJjQH2v5znjpL7BgMdtPNDfc8f1h6pzmur+cBAmwoSG + t0279yyYCSji4efImuLnJC4i66W3uv39y9ULdpw0kublngPnohISfEpO2+R/oyuTKxyg + xkiGazCm+C5sWlvXL4HMnVB0U58GH8Xq4AWvQI3q6JQY8wiR/+mEMWyQkEaPTzOJkDC3 + 3cS6qYRTdu7HeVrCo6RQLFOSbrcKFwxFnxK5tn/Z3ai2hw8GLcdtqeTL3DrZOUqd4cgn + Go9wpKtdBCtZuSLybu59VIEEF1/nwIaQn1odmz9S1PMz6rmMbUTOSEArO+4KCBSc89p0 + TpeQ== +ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; + h=feedback-id:message-id:mime-version:subject:to:from:date + :dkim-signature; + bh=FdTZJBML6IFSokG+xIENDPymtEDbBXnfghtNTrbziwY=; + fh=zanVBDvxvGaQYFrJgBgPf/HU+vTVdQ89/iEB38rTxvM=; + b=TvDL86BkvFaxGB86d4VhvS2rSPMp4Eq4sjWoNTRO1Ycg322LuiZxHBvQVzENRlewCE + TPfxavZlOrcRpFq7Z/cYjkWoZdLgcvRi20YMBLScn26PzLPlHOn/sY343s8tymUOL1Kh + +gqxxAz3lLEOMqM2UjAenFL5Xnc5VBXIdGva2PXlHdUiYUhhXeOknD5BmC9YpC/Q63gZ + LO2yBa+A5l8LLf0hYBAfWD2Rd/UUiCJ7Kz+dNFRJ3mzu6EvRV56uRWftGjASOK4G+U10 + L0P7J6ynXoO7AfDyfhp36Er/xKz8px/nSTV8FCFU02U7OR5QrtRrNfDAxxKYRty71mRu + FBxQ==; + dara=google.com +ARC-Authentication-Results: i=1; mx.google.com; + dkim=pass header.i=@x.com header.s=dkim-202308 header.b=dR+AllhX; + spf=pass (google.com: domain of n07855b1d60-bece66ae1cf44474-prakharsingh0908===gmail.com@bounce.x.com designates 199.16.156.173 as permitted sender) smtp.mailfrom="n07855b1d60-bece66ae1cf44474-prakharsingh0908===gmail.com@bounce.x.com"; + dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=x.com +Return-Path: +Received: from spring-chicken-bh.x.com (spring-chicken-bh.twitter.com. [199.16.156.173]) + by mx.google.com with ESMTPS id f84-20020a256a57000000b00dcf095b571dsi3310870ybc.177.2024.03.03.11.22.11 + for + (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); + Sun, 03 Mar 2024 11:22:12 -0800 (PST) +Received-SPF: pass (google.com: domain of n07855b1d60-bece66ae1cf44474-prakharsingh0908===gmail.com@bounce.x.com designates 199.16.156.173 as permitted sender) client-ip=199.16.156.173; +Authentication-Results: mx.google.com; + dkim=pass header.i=@x.com header.s=dkim-202308 header.b=dR+AllhX; + spf=pass (google.com: domain of n07855b1d60-bece66ae1cf44474-prakharsingh0908===gmail.com@bounce.x.com designates 199.16.156.173 as permitted sender) smtp.mailfrom="n07855b1d60-bece66ae1cf44474-prakharsingh0908===gmail.com@bounce.x.com"; + dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=x.com +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=x.com; + s=dkim-202308; t=1709493731; + bh=FdTZJBML6IFSokG+xIENDPymtEDbBXnfghtNTrbziwY=; + h=Date:From:To:Subject:MIME-Version:Content-Type:Message-ID; + b=dR+AllhXCbvPRRqE964H0WSqSPVmWuukkYFM9ZTMzLeDVSkKzskitQl5XtDJuNCnM + 6oCzJk5uqV0NYlC+CBscBY1CkRg7enTbnMUUNv+8U3koCrfTrm14XsFn567jwwkX6P + Mfhx2FB05C8yKCjV0w8uqGozYizABHartJ76plNLxC/1Bf+sQ52ov5p8x9ZbSI8Vjs + exi67biSgOWRDspEHopyydUaa3Oay+sFqN/afKfDfph9H3DFTp/ByEXnv7qFr/INdY + nFp7VAzMQhh3prQ42IxsAjzLOcJeUGEE3qRgsO84f1vQWYhI7vwGuDaBuS1bwLHrYq + uDu2isdPoOBJw== +X-MSFBL: D6A8ONDc3O1sUq4sf2z9RfAjFaWL6AsXTMMN+RU2C+8=|eyJ1IjoicHJha2hhcnN + pbmdoMDkwOEBnbWFpbC5jb21AaWlkIyNiZWNlNjZhZTFjZjQ0NDc0OTZmZDM4MTV + hZmNmNzNlZkB1c2IjIzI0QDI5NkAxNTIzMzk5NjYxMzc3MjY1NjczQDBAMzg1ZTc + 1YmIwZTIxMTk5OGRjYWJmNTdmMGMzZjIyNzEyZTZmYzkxYSIsImciOiJCdWxrIiw + iciI6InByYWtoYXJzaW5naDA5MDhAZ21haWwuY29tIiwiYiI6ImF0bGEtYmJtLTI + 2LXNyMS1CdWxrLjE5MyJ9 +Date: Sun, 03 Mar 2024 19:22:11 +0000 +From: Twitter +To: Prakhar Singh +Subject: Password reset request +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_27434810_822635987.1709493731862" +X-Twitter-CID: ibis2-password_reset_pin_based_email +Message-ID: +Feedback-ID: atla.c5bbd1c7e491b5023ff4b22a03711997:X + +------=_Part_27434810_822635987.1709493731862 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Twitter + +Reset your password? + +If you requested a password reset for prakharxsingh, use the confirmation code below to complete the process. If you didn't make this request, ignore this email. + +> cqvrfqbt + + +Getting a lot of password reset emails? +You can change your account settings to require personal information to reset your password. + +account settings +> https://twitter.com/settings/security + +------------------------ +Help +> https://support.twitter.com/articles/14663 + +Not my account +> https://twitter.com/account/not_my_account/1523399661377265673/4GBE3-F8C2F-170949?ut=1&cn=cGFzc3dvcmRfcmVzZXRfcGluX2Jhc2VkX2VtYWls + +Email security tips +> https://support.twitter.com/articles/204820-fake-twitter-emails + +X Corp. 1355 Market Street, Suite 900 San Francisco, CA 94103 + +------=_Part_27434810_822635987.1709493731862 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + +
 
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Reset your password?
If you requested a password reset for @prakharxsingh, use the co= +nfirmation code below to complete the process. If you didn't make this requ= +est, ignore this email.
cqvrfqbt
Getting a lot of password reset emails?
You can change your account settings to require personal information to = +reset your password.
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Help  |  Not my account  |  Em= +ail security tips
This email was meant for @prakharxsingh
X Corp. 1355 Market Street, Suite 900= + San Francisco, CA 94103
+
+ + +------=_Part_27434810_822635987.1709493731862-- diff --git a/ts_tests/circuit_intput.ts b/ts_tests/circuit_input.ts similarity index 100% rename from ts_tests/circuit_intput.ts rename to ts_tests/circuit_input.ts