Skip to content

Commit

Permalink
ran cargo fix --bin zk-regex --tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bert0RM committed Dec 13, 2023
1 parent 57f569a commit d093d3a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/apis/src/extract_substrs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use compiler::DecomposedRegexConfig;
use fancy_regex::Regex;
use itertools::Itertools;

use neon::prelude::*;
use serde_json;
use thiserror::Error;
Expand Down
2 changes: 2 additions & 0 deletions packages/circom/tests/circuits/simple_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma circom 2.1.5;

include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";

// regex: 1=(a|b) (2=(b|c)+ )+d
template SimpleRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
Expand Down Expand Up @@ -128,6 +129,7 @@ template SimpleRegex(msg_bytes) {
is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][9] * (1 - is_consecutive[msg_bytes-i][1]) + is_consecutive[msg_bytes-i][1];
is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0];
}
// substrings calculated: [{(2, 3)}, {(6, 7), (7, 7)}, {(8, 9)}]
signal is_substr0[msg_bytes][2];
signal is_reveal0[msg_bytes];
signal output reveal0[msg_bytes];
Expand Down
7 changes: 2 additions & 5 deletions packages/compiler/src/bin/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use std::{
fs::File,
path::{Path, PathBuf},
};


use clap::{Parser, Subcommand};
use itertools::Itertools;

use zk_regex_compiler::*;

#[derive(Parser, Debug, Clone)]
Expand Down
16 changes: 8 additions & 8 deletions packages/compiler/src/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use crate::get_accepted_state;
use crate::js_caller::*;
use crate::RegexAndDFA;
// use crate::{AllstrRegexDef, SubstrRegexDef};
use fancy_regex::Regex;
use itertools::Itertools;
use petgraph::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::io::BufWriter;

Check warning on line 6 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `fancy_regex::Regex`

Check warning on line 7 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `itertools::Itertools`

Check warning on line 8 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `petgraph::prelude::*`

Check warning on line 9 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused imports: `Deserialize`, `Serialize`

Check warning on line 10 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `std::collections::HashSet`

Check warning on line 11 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `std::io::BufWriter`
use std::io::Write;
use std::path::PathBuf;
use std::{collections::HashMap, fs::File};
use thiserror::Error;
use std::{fs::File};

Check warning on line 14 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `collections::HashMap`

Check warning on line 15 in packages/compiler/src/circom.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `thiserror::Error`

impl RegexAndDFA {
pub fn gen_circom(
Expand Down
16 changes: 8 additions & 8 deletions packages/compiler/src/halo2.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use crate::js_caller::*;
use crate::*;
use fancy_regex::Regex;

Check warning on line 3 in packages/compiler/src/halo2.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `fancy_regex::Regex`
use itertools::Itertools;
use petgraph::prelude::*;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashSet;

Check warning on line 5 in packages/compiler/src/halo2.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `petgraph::prelude::*`



use std::io::BufWriter;
use std::io::Write;
use std::iter::FromIterator;

use std::path::PathBuf;
use std::{collections::HashMap, fs::File};
use thiserror::Error;
use std::{fs::File};


impl RegexAndDFA {
pub fn gen_halo2_tables(
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler/src/js_caller.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use js_sandbox::{AnyError, JsError, Script};
use petgraph::prelude::*;

use js_sandbox::{JsError, Script};

use serde_json::Value;
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub(crate) fn get_accepted_state(dfa_val: &[Value]) -> Option<usize> {

pub(crate) fn get_max_state(dfa_val: &[Value]) -> Result<usize, JsCallerError> {
let mut max_state = 0;
for (i, val) in dfa_val.iter().enumerate() {
for (_i, val) in dfa_val.iter().enumerate() {
for (_, next_node_val) in val["edges"]
.as_object()
.ok_or(JsCallerError::InvalidEdges(val["edges"].clone()))?
Expand Down

0 comments on commit d093d3a

Please sign in to comment.