Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose internal state to o1js #834

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/base/snark0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,25 @@ module Run = struct
Run_state.set_as_prover !state true ;
res )

module Low_level = struct
type state = field Run_state.t

let state = state

let make_state ~num_inputs ~input ~next_auxiliary ~aux ?system
?eval_constraints ~with_witness ?log_constraint () =
Runner.State.make ~num_inputs ~input:(pack_field_vec input)
~next_auxiliary ~aux:(pack_field_vec aux) ?system ?eval_constraints
~with_witness ?log_constraint ()

let push_active_counter () =
let counters = !active_counters in
active_counters := this_functor_id :: counters ;
counters

let reset_active_counter counters = active_counters := counters
end

module Run_and_check_deferred (M : sig
type _ t

Expand Down
28 changes: 28 additions & 0 deletions src/base/snark_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,34 @@ module type Run_basic = sig

val run_and_check_exn : (unit -> (unit -> 'a) As_prover.t) -> 'a

module Low_level : sig
type state = field Run_state.t

val state : state ref

val make_state :
num_inputs:int
-> input:Field.Constant.Vector.t
-> next_auxiliary:int ref
-> aux:Field.Constant.Vector.t
-> ?system:R1CS_constraint_system.t
-> ?eval_constraints:bool
-> with_witness:bool
-> ?log_constraint:
( ?at_label_boundary:[ `End | `Start ] * string
-> ( field Cvar.t
, field )
Checked_runner.Constraint0.basic_with_annotation
option
-> unit )
-> unit
-> state

val push_active_counter : unit -> int list

val reset_active_counter : int list -> unit
end

module Run_and_check_deferred (M : sig
type _ t

Expand Down
Loading