13     Finds the index corresponding to `annotation` 
   14     in the annotation set (which has the structure below) 
   16     "variables_annotations": 
   18             { "index": INDEX, "annotation": ANNOTATION }, 
   22             { "index": INDEX, "annotation": ANNOTATION } 
   26     for i 
in range(len(annotation_set)):
 
   27         if annotation_set[i][
"annotation"] == annotation:
 
   28             return annotation_set[i][
"index"]
 
   33     Returns the set of constraints in which a given wire figures 
   34     (wire = index of a variable annotation) 
   35     The set of constraints has the structure below: 
   42                 "constraint_annotation": ANNOTATION 
   43                 "linear_combination": { 
   44                     # `index:` Index of the wire/variable 
   45                     # `value:` Scalar by which the wire value is multiplied 
   46                     # by in the linear combination A 
   48                             { "index": "0", "value": "0x1" } 
   51                             { "index": "530", "scalar": "0x1" }, 
   52                             { "index": "531", "scalar": "0x2" }, 
   53                             { "index": "532", "scalar": "0x4" } 
   56                             { "index": "2", "scalar": "0x1" } 
   65     for i 
in range(len(constraints_set)):
 
   66         lin_com_a = constraints_set[i][
"linear_combination"][
"A"]
 
   67         lin_com_b = constraints_set[i][
"linear_combination"][
"B"]
 
   68         lin_com_c = constraints_set[i][
"linear_combination"][
"C"]
 
   72         if found_in_a 
or found_in_b 
or found_in_c:
 
   73             constraints_id.append(constraints_set[i][
"constraint_id"])
 
   74             print(
"Constraint: ", 
str(constraints_set[i]))
 
   79     Returns a set of constraints which annotation matches the given pattern. 
   80     The regex is given by the user (which can be quite dangerous but 
   81     the goal of this script is not to be robust anyway) 
   86     for i 
in range(len(constraints_set)):
 
   87         constraint_annotation = constraints_set[i][
"constraint_annotation"]
 
   88         x = re.search(annotation_pattern, constraint_annotation)
 
   91             constraints_id.append(constraints_set[i][
"constraint_id"])
 
   92             print(
"Constraint: ", 
str(constraints_set[i]))
 
   98     Inspects all the elements of the linear combination and returns 
   99     true is the variable corresponding to the annotation_index 
  100     is used in the linear combination 
  104     for i 
in range(len(linear_combination)):
 
  105         if linear_combination[i][
"index"] == annotation_index:
 
  109 if __name__ == 
"__main__":
 
  110     path_zeth = os.environ[
"ZETH_DEBUG_DIR"]
 
  111     filename = 
"r1cs.json" 
  114     file_path = os.path.join(path_zeth, filename)
 
  115     with open(file_path, 
'r') 
as r1cs_file:
 
  116         data=r1cs_file.read()
 
  119     r1cs_obj = json.loads(data)
 
  120     r1cs_variables_nb = r1cs_obj[
"num_variables"]
 
  121     r1cs_constraints_nb = r1cs_obj[
"num_constraints"]
 
  123     print(
"R1CS successfully loaded, vars: {}, constraints: {}" 
  124             .format(r1cs_variables_nb, r1cs_variables_nb))
 
  126     variables_annotations_set = r1cs_obj[
"variables_annotations"]
 
  127     constraints_set = r1cs_obj[
"constraints"]
 
  133     annotation_to_check = 
"joinsplit_gadget phi bits_31" 
  134     annotation_index = 
get_index(variables_annotations_set, annotation_to_check)
 
  135     print(
"Index of the annotation to check: {}".format(annotation_index))
 
  137     print(
"Fetching constraints using annotation: {} of index: {}..." 
  138             .format(annotation_to_check, annotation_index))
 
  140     print(
"Result: {}".format(constraints_using_annotation))
 
  143     print(
"Testing the regex matching. Query: {}".format(regex))