Skip to content

Commit 9f55ef7

Browse files
authored
Merge pull request #915 from o1-labs/add-get-auxiliary-input-size
snarky: add get_aux_input_size
2 parents 0d59b62 + 858c581 commit 9f55ef7

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/base/constraint_system.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module type S = sig
2323

2424
val get_public_input_size : t -> int Core_kernel.Set_once.t
2525

26+
val get_auxiliary_input_size : t -> int Core_kernel.Set_once.t
27+
2628
val get_rows_len : t -> int
2729
end
2830

src/base/snark_intf.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ module type Basic = sig
555555
(** Get the number of public input *)
556556
val get_public_input_size : t -> int Core_kernel.Set_once.t
557557

558+
(** Get the number of auxiliary/private input *)
559+
val get_auxiliary_input_size : t -> int Core_kernel.Set_once.t
560+
558561
(** Get the number of rows/circuit size *)
559562
val get_rows_len : t -> int
560563
end

src/tests/backend.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ end) : Snarky.Backend_intf.S = struct
215215

216216
let get_public_input_size t = t.public_input_size
217217

218+
let get_auxiliary_input_size t = t.auxiliary_input_size
219+
218220
let get_rows_len t = Deque.length t.constraints
219221
end
220222

src/tests/fermat.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ let test_get_public_input_size () =
120120
(* The Fermat circuit takes 1 public input (z) *)
121121
check int "Fermat circuit public input size" 1 public_input_size
122122

123+
(* Regression test for get_auxiliary_input_size *)
124+
let test_get_auxiliary_input_size () =
125+
let cs = get_constraint_system () in
126+
let auxiliary_input_size_set_once =
127+
Fermat_snark.S.R1CS_constraint_system.get_auxiliary_input_size cs
128+
in
129+
let auxiliary_input_size =
130+
Core_kernel.Set_once.get_exn auxiliary_input_size_set_once [%here]
131+
in
132+
(* The Fermat circuit has:
133+
- 2 witness variables (x, y)
134+
- 6 intermediate variables from cube computations (2 per cube_var for x, y, z)
135+
Total: 8 auxiliary inputs *)
136+
check int "Fermat circuit auxiliary input size" 8 auxiliary_input_size
137+
123138
let cube_test () =
124139
let a = Fermat_snark.Backend.Field.random () in
125140
let a_cubed = Fermat_snark.Circuit.cube a in
@@ -131,4 +146,6 @@ let test_cases =
131146
; test_case "Fermat circuit" `Quick fermat_test
132147
; test_case "regtest get_rows_len" `Quick test_get_rows_len
133148
; test_case "regtest get_public_input_size" `Quick test_get_public_input_size
149+
; test_case "regtest get_auxiliary_input_size" `Quick
150+
test_get_auxiliary_input_size
134151
]

0 commit comments

Comments
 (0)