A deterministic finite automaton (DFA) chip verifies that state transitions of DFA are valid for a given input string. In ZK-Email, it will be used to confirm that the given email string matches with the regular expression corresponding to the DFA.
The DFA chip consists of the following tables and constraints, where denotes a state of DFA, represent the number of states and input patterns, respectively, and is the number of state transitions to be proved. Notably, the following tables are combined and a selector column is also defined in the actual implementation.
Witness table:
cur_state |
next_state |
input |
---|---|---|
Lookup table:
valid_cur_state |
valid_next_state |
valid_input |
---|---|---|
Constraints:
In a nutshell, the valid patterns of the state transitions are fixed in the lookup table, and the actual state transitions to be proved are written in the witness table. The third constraint requires that each state transition in the witness table is included in the valid patterns. The second constraint confirms that the next state is used as the current state in the next state transition. The first and the fourth constraints correspond to the initial and final conditions, respectively.