@@ -251,6 +251,7 @@ def compile(self, regex: str) -> None:
251251 """
252252 Compile the regex.
253253 """
254+ logger .debug (f"Compiling regex starts" )
254255 # Create JSON for the regex for zk-regex
255256 base_json = {
256257 "parts" : []
@@ -269,25 +270,31 @@ def compile(self, regex: str) -> None:
269270 circom_file_path = tempfile .NamedTemporaryFile (suffix = ".circom" , delete = False ).name
270271
271272 # Call zk-regex to generate the circom code
273+ logger .debug (f"Generating circom code starts" )
272274 ZkRegexSubprocess .compile (json_file_path , circom_file_path , self ._template_name )
275+ logger .debug (f"Generating circom code ends" )
273276
274277 # Append the circom file to include the main function
275278 with open (circom_file_path , 'a' ) as f :
276279 f .write ("\n \n " )
277280 f .write ("component main {public [msg]} = " + f"{ self ._template_name } ({ self ._circom_max_input_size } );" )
278281
279282 # Compile the circom code to wasm
283+ logger .debug (f"Compiling circom code starts" )
280284 self ._wasm_path , self ._r1cs_path = CircomSubprocess .compile (circom_file_path , self ._link_path )
285+ logger .debug (f"Compiling circom code ends" )
281286
282287 # Also setup the proving and verification key if the flag is set
283288 if self ._run_the_prover :
284289 self ._zkey_path = SnarkjsSubprocess .setup_zkey (self ._r1cs_path , self ._ptau_path )
285290 self ._vkey_path = SnarkjsSubprocess .export_verification_key (self ._zkey_path )
291+ logger .debug (f"Compiling regex ends" )
286292
287293 def match (self , input : str ) -> tuple [bool , str ]:
288294 """
289295 Match the regex on an input.
290296 """
297+ logger .debug (f"Matching regex starts" )
291298 # Convert input to list of decimal ASCII values and pad input with zeroes
292299 numeric_input = [ord (c ) for c in input ] + [0 ] * (self ._circom_max_input_size - len (input ))
293300
@@ -298,10 +305,12 @@ def match(self, input: str) -> tuple[bool, str]:
298305
299306 # Skip if input is larger than circuit max input size
300307 if len (numeric_input ) > self ._circom_max_input_size :
301- raise RegexRunError (f"Input too large for input: { input } " )
308+ raise RegexRunError (f"Input too large for input: { len ( numeric_input ) } " )
302309
303310 # Generate the witness
311+ logger .debug (f"Generating witness starts" )
304312 witness_path = SnarkjsSubprocess .witness_gen (self ._wasm_path , input_path )
313+ logger .debug (f"Generating witness ends" )
305314 # Remove input file
306315 Path (input_path ).unlink ()
307316
@@ -320,6 +329,7 @@ def match(self, input: str) -> tuple[bool, str]:
320329
321330 # Return the output of the match
322331 output = int (result [1 ])
332+ logger .debug (f"Matching regex ends" )
323333 return output == 1 , ""
324334
325335 def clean (self ):
0 commit comments