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

Remove R1CS_constraint_system from snarky #12130

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/lib/blockchain_snark/dune
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
random_oracle
kimchi_backend.pasta
kimchi_backend.pasta.basic
kimchi_backend.pasta.constraint_system
data_hash_lib
ppx_version.runtime
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ module Make

val create : unit -> t

val get_public_input_size : t -> int Set_once.t

val get_primary_input_size : t -> int

val set_primary_input_size : t -> int -> unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module type With_accessors = sig

val create : unit -> t

val get_public_input_size : t -> int Set_once.t

val get_primary_input_size : t -> int

val set_primary_input_size : t -> int -> unit
Expand Down
4 changes: 2 additions & 2 deletions src/lib/crypto/kimchi_backend/tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let%test_module "pallas" =

let%test_unit "test snarky instance" =
Kimchi_pasta.Pallas_based_plonk.Keypair.set_urs_info [] ;
let (_ : Impl.R1CS_constraint_system.t) =
let (_ : Impl.constraint_system) =
Impl.constraint_system ~input_typ:Field.typ ~return_typ:Typ.unit main
in
let (_ : Impl.Proof_inputs.t) =
Expand All @@ -65,7 +65,7 @@ let%test_module "vesta" =

let%test_unit "test snarky instance" =
Kimchi_pasta.Vesta_based_plonk.Keypair.set_urs_info [] ;
let (_ : Impl.R1CS_constraint_system.t) =
let (_ : Impl.constraint_system) =
Impl.constraint_system ~input_typ:Field.typ ~return_typ:Typ.unit main
in
let (_ : Impl.Proof_inputs.t) =
Expand Down
2 changes: 2 additions & 0 deletions src/lib/crypto_params/crypto_params.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let () = Pickles.Backend.Tock.Keypair.set_urs_info Cache_dir.cache
let () = Pickles.Backend.Tick.Keypair.set_urs_info Cache_dir.cache

module Tock = struct
module R1CS_constraint_system = Pickles.Backend.Tock.R1CS_constraint_system
module Full = Pickles.Impls.Wrap
module Run = Pickles.Impls.Wrap

Expand All @@ -15,6 +16,7 @@ module Tock = struct
end

module Tick = struct
module R1CS_constraint_system = Pickles.Backend.Tick.R1CS_constraint_system
module Full = Pickles.Impls.Step
module Run = Pickles.Impls.Step

Expand Down
19 changes: 8 additions & 11 deletions src/lib/pickles/fix_domains.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ let rough_domains : Domains.t =
let d = Domain.Pow_2_roots_of_unity 20 in
{ h = d }

let domains (type field)
(module Impl : Snarky_backendless.Snark_intf.Run with type field = field)
(Spec.ETyp.T (typ, conv, _conv_inv))
let domains (type field cs)
(module CS : Kimchi_pasta_constraint_system.Intf.With_accessors
with type t = cs )
(module Impl : Snarky_backendless.Snark_intf.Run
with type field = field
and type constraint_system = cs ) (Spec.ETyp.T (typ, conv, _conv_inv))
(Spec.ETyp.T (return_typ, _ret_conv, ret_conv_inv)) main =
let main x () = ret_conv_inv (main (conv x)) in

let domains2 sys : Domains.t =
let open Domain in
let public_input_size =
Set_once.get_exn
(Impl.R1CS_constraint_system.get_public_input_size sys)
[%here]
in
let rows =
zk_rows + public_input_size + Impl.R1CS_constraint_system.get_rows_len sys
in
let public_input_size = CS.get_primary_input_size sys in
let rows = zk_rows + public_input_size + CS.get_rows_len sys in
{ h = Pow_2_roots_of_unity Int.(ceil_log2 rows) }
in
domains2 (Impl.constraint_system ~input_typ:typ ~return_typ main)
2 changes: 2 additions & 0 deletions src/lib/pickles/impls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let forbidden_shifted_values ~modulus:r ~size_in_bits =
module Step = struct
module Impl = Snarky_backendless.Snark.Run.Make (Tick)
include Impl
module R1CS_constraint_system = Tick.R1CS_constraint_system
module Verification_key = Tick.Verification_key
module Proving_key = Tick.Proving_key

Expand Down Expand Up @@ -180,6 +181,7 @@ module Wrap = struct
module Digest = Digest.Make (Impl)
module Wrap_field = Tock.Field
module Step_field = Tick.Field
module R1CS_constraint_system = Tock.R1CS_constraint_system
module Verification_key = Tock.Verification_key
module Proving_key = Tock.Proving_key

Expand Down
1 change: 1 addition & 0 deletions src/lib/pickles/step_branch_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ let create
(* TODO *)
in
Fix_domains.domains
(module Impls.Step.R1CS_constraint_system)
(module Impls.Step)
(T (Snarky_backendless.Typ.unit (), Fn.id, Fn.id))
etyp main
Expand Down
1 change: 1 addition & 0 deletions src/lib/pickles/wrap_domains.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct
Timer.clock __LOC__ ;
let t =
Fix_domains.domains
(module Impls.Wrap.R1CS_constraint_system)
(module Impls.Wrap)
(Impls.Wrap.input ())
(T (Snarky_backendless.Typ.unit (), Fn.id, Fn.id))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snarky
1 change: 1 addition & 0 deletions src/lib/transaction_snark/dune
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
mina_ledger
kimchi_backend.pasta
kimchi_backend.pasta.basic
kimchi_backend.pasta.constraint_system
merkle_ledger
mina_base.util
ppx_version.runtime
Expand Down