diff --git a/src/app/zkapps_examples/tokens/zkapps_tokens.ml b/src/app/zkapps_examples/tokens/zkapps_tokens.ml index b51ec8af77d..23ddb7382d2 100644 --- a/src/app/zkapps_examples/tokens/zkapps_tokens.ml +++ b/src/app/zkapps_examples/tokens/zkapps_tokens.ml @@ -482,7 +482,7 @@ module Rules = struct *) Boolean.Assert.any [ proof_must_verify; zero_total ] ; let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> let proof_must_verify = As_prover.read Boolean.typ proof_must_verify in @@ -494,7 +494,7 @@ module Rules = struct ; (* dummy to avoid pickles bug *) { public_input = recursive_input ; proof = - exists (Typ.Internal.ref ()) ~compute:(fun () -> + exists (Typ.prover_value ()) ~compute:(fun () -> Lazy.force dummy_proof ) ; proof_must_verify = Boolean.false_ } @@ -567,7 +567,7 @@ module Rules = struct *) Boolean.Assert.any [ proof_must_verify; zero_total ] ; let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> let proof_must_verify = As_prover.read Boolean.typ proof_must_verify in @@ -581,7 +581,7 @@ module Rules = struct ; (* dummy to avoid pickles bug *) { public_input = recursive_input ; proof = - exists (Typ.Internal.ref ()) ~compute:(fun () -> + exists (Typ.prover_value ()) ~compute:(fun () -> Lazy.force dummy_proof ) ; proof_must_verify = Boolean.false_ } diff --git a/src/app/zkapps_examples/zkapps_examples.ml b/src/app/zkapps_examples/zkapps_examples.ml index 89a528c9ac9..cd4feb71479 100644 --- a/src/app/zkapps_examples/zkapps_examples.ml +++ b/src/app/zkapps_examples/zkapps_examples.ml @@ -454,20 +454,22 @@ let exists_deferred ?request:req ?compute typ = (* Set up a full Ivar, in case we are generating the constraint system. *) let deferred = ref (Ivar.create_full ()) in (* Request or compute the [Deferred.t] value. *) - let requested = exists ?request:req ?compute (Typ.Internal.ref ()) in + let requested = exists ?request:req ?compute (Typ.prover_value ()) in as_prover (fun () -> (* If we are generating the witness, create a new Ivar.. *) deferred := Ivar.create () ; (* ..and fill it when the value we want to read resolves. *) - Deferred.upon (As_prover.Ref.get requested) (fun _ -> - Ivar.fill !deferred () ) ) ; + Deferred.upon + (As_prover.read (Typ.prover_value ()) requested) + (fun _ -> Ivar.fill !deferred ()) ) ; (* Await the [Deferred.t] if we're generating the witness, otherwise we immediately bind over the filled Ivar and continue. *) Deferred.map (Ivar.read !deferred) ~f:(fun () -> (* Retrieve the value by peeking in the known-resolved deferred. *) exists typ ~compute:(fun () -> - Option.value_exn @@ Deferred.peek @@ As_prover.Ref.get requested ) ) + Option.value_exn @@ Deferred.peek + @@ As_prover.read (Typ.prover_value ()) requested ) ) type return_type = { account_update : Account_update.Body.t diff --git a/src/dune-project b/src/dune-project index 5d704b1e96a..00cf502607a 100644 --- a/src/dune-project +++ b/src/dune-project @@ -59,7 +59,6 @@ (package (name heap_usage)) (package (name hex)) (package (name immutable_array)) -(package (name inline_test_quiet_logs)) (package (name integers_stubs_js)) (package (name integration_test_local_engine)) (package (name integration_test_lib)) diff --git a/src/lib/blockchain_snark/blockchain_snark_state.ml b/src/lib/blockchain_snark/blockchain_snark_state.ml index 35a9bd44a09..b8e6fd6f621 100644 --- a/src/lib/blockchain_snark/blockchain_snark_state.ml +++ b/src/lib/blockchain_snark/blockchain_snark_state.ml @@ -160,13 +160,13 @@ let%snarkydef_ step ~(logger : Logger.t) , previous_state_body_hash ) = let%bind prev_state_ref = with_label __LOC__ (fun () -> - exists (Typ.Internal.ref ()) ~request:(As_prover.return Prev_state) ) + exists (Typ.prover_value ()) ~request:(As_prover.return Prev_state) ) in let%bind t = with_label __LOC__ (fun () -> exists (Protocol_state.typ ~constraint_constants) - ~compute:(As_prover.Ref.get prev_state_ref) ) + ~compute:(As_prover.read (Typ.prover_value ()) prev_state_ref) ) in let%map previous_state_hash, body = Protocol_state.hash_checked t in let previous_blockchain_proof_input = @@ -366,10 +366,10 @@ let%snarkydef_ step ~(logger : Logger.t) with_label __LOC__ (fun () -> Boolean.Assert.any [ is_base_case; success ]) in let%bind previous_blockchain_proof = - exists (Typ.Internal.ref ()) ~request:(As_prover.return Prev_state_proof) + exists (Typ.prover_value ()) ~request:(As_prover.return Prev_state_proof) in let%map txn_snark_proof = - exists (Typ.Internal.ref ()) ~request:(As_prover.return Txn_snark_proof) + exists (Typ.prover_value ()) ~request:(As_prover.return Txn_snark_proof) in ( { Pickles.Inductive_rule.Previous_proof_statement.public_input = previous_blockchain_proof_input diff --git a/src/lib/mina_base/account.ml b/src/lib/mina_base/account.ml index da459ca0881..0ec0d31b109 100644 --- a/src/lib/mina_base/account.ml +++ b/src/lib/mina_base/account.ml @@ -433,7 +433,7 @@ type var = , Timing.var , Permissions.Checked.t (* TODO: This is a hack that lets us avoid unhashing zkApp accounts when we don't need to *) - , Field.Var.t * Zkapp_account.t option As_prover.Ref.t ) + , Field.Var.t * Zkapp_account.t option Typ.prover_value ) Poly.t let identifier_of_var ({ public_key; token_id; _ } : var) = @@ -461,12 +461,13 @@ let typ' zkapp = let typ : (var, value) Typ.t = let zkapp : - ( Field.Var.t * Zkapp_account.t option As_prover.Ref.t + ( Field.Var.t * Zkapp_account.t option Typ.prover_value , Zkapp_account.t option ) Typ.t = let account : - (Zkapp_account.t option As_prover.Ref.t, Zkapp_account.t option) Typ.t = - Typ.Internal.ref () + (Zkapp_account.t option Typ.prover_value, Zkapp_account.t option) Typ.t + = + Typ.prover_value () in Typ.(Field.typ * account) |> Typ.transport ~there:(fun x -> (hash_zkapp_account_opt x, x)) ~back:snd diff --git a/src/lib/mina_base/account_update.ml b/src/lib/mina_base/account_update.ml index f019acf9f5d..cbe7d37e50d 100644 --- a/src/lib/mina_base/account_update.ml +++ b/src/lib/mina_base/account_update.ml @@ -1050,10 +1050,6 @@ module Preconditions = struct type t = V.var end - module Int_as_prover_ref = struct - type t = int As_prover.Ref.t - end - type t = { network : Zkapp_precondition.Protocol_state.Checked.t ; account : Account_precondition.Checked.t @@ -1440,10 +1436,6 @@ module Body = struct type t = V.var end - module Int_as_prover_ref = struct - type t = int As_prover.Ref.t - end - type t = { public_key : Public_key.Compressed.var ; token_id : Token_id.Checked.t diff --git a/src/lib/mina_base/data_as_hash.ml b/src/lib/mina_base/data_as_hash.ml index e0d956857c2..c6787122ff6 100644 --- a/src/lib/mina_base/data_as_hash.ml +++ b/src/lib/mina_base/data_as_hash.ml @@ -1,28 +1,28 @@ open Snark_params open Tick -type 'a t = Field.Var.t * 'a As_prover.Ref.t +type 'a t = Field.Var.t * 'a Typ.prover_value let hash (x, _) = x -let ref (_, x) = x +let prover_value (_, x) = x let typ ~hash = Typ.transport - Typ.(Field.typ * Internal.ref ()) + Typ.(Field.typ * prover_value ()) ~there:(fun s -> (hash s, s)) ~back:(fun (_, s) -> s) let optional_typ ~hash ~non_preimage ~dummy_value = Typ.transport - Typ.(Field.typ * Internal.ref ()) + Typ.(Field.typ * prover_value ()) ~there:(function | None -> (non_preimage, dummy_value) | Some s -> (hash s, s) ) ~back:(fun (_, s) -> Some s) let lazy_optional_typ ~hash ~non_preimage ~dummy_value = Typ.transport - Typ.(Field.typ * Internal.ref ()) + Typ.(Field.typ * prover_value ()) ~there:(function | None -> (Lazy.force non_preimage, dummy_value) | Some s -> (hash s, s) ) @@ -33,16 +33,19 @@ let to_input (x, _) = Random_oracle_input.Chunked.field x let if_ b ~then_ ~else_ = let open Run in let hash = Field.if_ b ~then_:(fst then_) ~else_:(fst else_) in - let ref = - As_prover.Ref.create - As_prover.( - fun () -> - let ref = if read Boolean.typ b then snd then_ else snd else_ in - As_prover.Ref.get ref) + let prover_value = + exists (Typ.prover_value ()) + ~compute: + As_prover.( + fun () -> + let prover_value = + if read Boolean.typ b then snd then_ else snd else_ + in + read (Typ.prover_value ()) prover_value) in - (hash, ref) + (hash, prover_value) -let make_unsafe hash ref : 'a t = (hash, ref) +let make_unsafe hash prover_value : 'a t = (hash, prover_value) module As_record = struct (* it's OK that hash is a Field.t (not a var), bc this is just annotation for the deriver *) diff --git a/src/lib/mina_base/data_as_hash.mli b/src/lib/mina_base/data_as_hash.mli index 90f15db1ccb..f77727218a1 100644 --- a/src/lib/mina_base/data_as_hash.mli +++ b/src/lib/mina_base/data_as_hash.mli @@ -15,7 +15,7 @@ open Snark_params.Tick (* Use the hash representing x *) ... let%bind () = as_prover As_prover.( - let%map x = As_prover.Ref.get (Data_as_hash.ref x) in + let%map x = As_prover.read (Typ.prover_value ()) (Data_as_hash.prover_value x) in printf "%s\n" (Foo.to_string x) ) in @@ -26,7 +26,7 @@ type 'value t val hash : _ t -> Field.Var.t -val ref : 'value t -> 'value As_prover.Ref.t +val prover_value : 'value t -> 'value Typ.prover_value val typ : hash:('value -> Field.t) -> ('value t, 'value) Typ.t @@ -46,7 +46,7 @@ val to_input : _ t -> Field.Var.t Random_oracle_input.Chunked.t val if_ : Boolean.var -> then_:'value t -> else_:'value t -> 'value t -val make_unsafe : Field.Var.t -> 'value As_prover.Ref.t -> 'value t +val make_unsafe : Field.Var.t -> 'value Typ.prover_value -> 'value t module As_record : sig type 'a t = { data : 'a; hash : Field.t } [@@deriving annot, fields] diff --git a/src/lib/mina_base/prover_value.ml b/src/lib/mina_base/prover_value.ml index d5085da35db..860d820a0dd 100644 --- a/src/lib/mina_base/prover_value.ml +++ b/src/lib/mina_base/prover_value.ml @@ -1,10 +1,10 @@ open Snark_params.Tick.Run -type 'a t = 'a As_prover.Ref.t +type 'a t = 'a Typ.prover_value -let get = As_prover.Ref.get +let get x = As_prover.read (Typ.prover_value ()) x -let create = As_prover.Ref.create +let create compute = exists (Typ.prover_value ()) ~compute let if_ b ~then_ ~else_ = create (fun () -> @@ -12,4 +12,4 @@ let if_ b ~then_ ~else_ = let map t ~f = create (fun () -> f (get t)) -let typ = Typ.Internal.ref +let typ = Typ.prover_value diff --git a/src/lib/pickles/compile.ml b/src/lib/pickles/compile.ml index b353b28a1f4..a3bd5adb669 100644 --- a/src/lib/pickles/compile.ml +++ b/src/lib/pickles/compile.ml @@ -1319,7 +1319,7 @@ struct ; main = (fun { public_input = () } -> let dummy_proof = - As_prover.Ref.create (fun () -> + exists (Typ.prover_value ()) ~compute:(fun () -> Proof.dummy Nat.N2.n Nat.N2.n Nat.N2.n ~domain_log2:15 ) in Promise.return @@ -1396,7 +1396,7 @@ struct ; main = (fun { public_input = () } -> let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> Proof) + exists (Typ.prover_value ()) ~request:(fun () -> Proof) in Promise.return { Inductive_rule.previous_proof_statements = diff --git a/src/lib/pickles/inductive_rule.ml b/src/lib/pickles/inductive_rule.ml index fca731f68e1..71a2dc14cdd 100644 --- a/src/lib/pickles/inductive_rule.ml +++ b/src/lib/pickles/inductive_rule.ml @@ -8,7 +8,7 @@ end module Previous_proof_statement = struct type ('prev_var, 'width) t = { public_input : 'prev_var - ; proof : ('width, 'width) Proof.t Impls.Step.As_prover.Ref.t + ; proof : ('width, 'width) Proof.t Impls.Step.Typ.prover_value ; proof_must_verify : B.t } diff --git a/src/lib/pickles/inductive_rule.mli b/src/lib/pickles/inductive_rule.mli index 711c3f00129..45c2bc19cf5 100644 --- a/src/lib/pickles/inductive_rule.mli +++ b/src/lib/pickles/inductive_rule.mli @@ -5,7 +5,7 @@ end module Previous_proof_statement : sig type ('prev_var, 'width) t = { public_input : 'prev_var - ; proof : ('width, 'width) Proof.t Impls.Step.As_prover.Ref.t + ; proof : ('width, 'width) Proof.t Impls.Step.Typ.prover_value ; proof_must_verify : B.t } diff --git a/src/lib/pickles/pickles.ml b/src/lib/pickles/pickles.ml index 6b463123c67..1f795c3d2d4 100644 --- a/src/lib/pickles/pickles.ml +++ b/src/lib/pickles/pickles.ml @@ -560,7 +560,7 @@ module Make_str (_ : Wire_types.Concrete) = struct exists Field.typ ~request:(fun () -> Prev_input) in let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Proof ) in let is_base_case = Field.equal Field.zero self in @@ -657,7 +657,7 @@ module Make_str (_ : Wire_types.Concrete) = struct No_recursion_input ) in let no_recursive_proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> No_recursion_proof ) in let prev = @@ -665,7 +665,7 @@ module Make_str (_ : Wire_types.Concrete) = struct Recursive_input ) in let prev_proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Recursive_proof ) in let is_base_case = Field.equal Field.zero self in @@ -777,7 +777,7 @@ module Make_str (_ : Wire_types.Concrete) = struct No_recursion_input ) in let no_recursive_proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> No_recursion_proof ) in let prev = @@ -785,7 +785,7 @@ module Make_str (_ : Wire_types.Concrete) = struct Recursive_input ) in let prev_proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Recursive_proof ) in let is_base_case = @@ -1001,7 +1001,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; main = (fun { public_input = () } -> let dummy_proof = - As_prover.Ref.create (fun () -> + exists (Typ.prover_value ()) ~compute:(fun () -> Proof0.dummy Nat.N2.n Nat.N2.n Nat.N2.n ~domain_log2:15 ) in Promise.return @@ -1902,7 +1902,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; main = (fun { public_input = () } -> let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Proof ) in Promise.return @@ -2177,19 +2177,22 @@ module Make_str (_ : Wire_types.Concrete) = struct exists Field.typ ~request:(fun () -> Prev_input) in let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Proof ) in let vk = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Verifier_index ) in as_prover (fun () -> - let vk = As_prover.Ref.get vk in + let vk = + As_prover.read (Typ.prover_value ()) vk + in Side_loaded.in_prover side_loaded_tag vk ) ; let vk = exists Side_loaded_verification_key.typ - ~compute:(fun () -> As_prover.Ref.get vk) + ~compute:(fun () -> + As_prover.read (Typ.prover_value ()) vk ) in Side_loaded.in_circuit side_loaded_tag vk ; let is_base_case = Field.equal Field.zero self in @@ -2489,19 +2492,22 @@ module Make_str (_ : Wire_types.Concrete) = struct exists Field.typ ~request:(fun () -> Prev_input) in let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Proof ) in let vk = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Verifier_index ) in as_prover (fun () -> - let vk = As_prover.Ref.get vk in + let vk = + As_prover.read (Typ.prover_value ()) vk + in Side_loaded.in_prover side_loaded_tag vk ) ; let vk = exists Side_loaded_verification_key.typ - ~compute:(fun () -> As_prover.Ref.get vk) + ~compute:(fun () -> + As_prover.read (Typ.prover_value ()) vk ) in Side_loaded.in_circuit side_loaded_tag vk ; let is_base_case = Field.equal Field.zero self in diff --git a/src/lib/pickles/pickles_intf.mli b/src/lib/pickles/pickles_intf.mli index c9948c9dd56..83f40f4163c 100644 --- a/src/lib/pickles/pickles_intf.mli +++ b/src/lib/pickles/pickles_intf.mli @@ -118,7 +118,7 @@ module type S = sig module Previous_proof_statement : sig type ('prev_var, 'width) t = { public_input : 'prev_var - ; proof : ('width, 'width) Proof.t Impls.Step.As_prover.Ref.t + ; proof : ('width, 'width) Proof.t Impls.Step.Typ.prover_value ; proof_must_verify : B.t } diff --git a/src/lib/pickles/scalar_challenge.ml b/src/lib/pickles/scalar_challenge.ml index 20bae3d9247..54abb768cfe 100644 --- a/src/lib/pickles/scalar_challenge.ml +++ b/src/lib/pickles/scalar_challenge.ml @@ -43,9 +43,7 @@ let to_field_checked' (type f) ?(num_bits = num_bits) let bits_msb = lazy (let open Field.Constant in - unpack !!scalar |> Fn.flip List.take num_bits |> Array.of_list_rev - (* - |> Array.of_list_rev_map ~f:(fun b -> if b then one else zero) *)) + unpack !!scalar |> Fn.flip List.take num_bits |> Array.of_list_rev) in let nybbles_per_row = 8 in let bits_per_row = 2 * nybbles_per_row in diff --git a/src/lib/pickles/scalar_challenge.mli b/src/lib/pickles/scalar_challenge.mli index f5a8a74c896..fb3d539e400 100644 --- a/src/lib/pickles/scalar_challenge.mli +++ b/src/lib/pickles/scalar_challenge.mli @@ -8,6 +8,12 @@ val to_field_constant : -> Import.Challenge.Constant.t Import.Scalar_challenge.t -> 'f +(** [to_field_checked' ?num_bits backend chal] builds a circuit using the gate + [Kimchi_backend_common.Plonk_constraint_system.Plonk_constraint.(T + EC_endoscalar)] to decompose into [num_bits] bits a scalar challenge [chal]. + + The default value of [num_bits] is 128, and the gadget requires 8 rows. +*) val to_field_checked' : ?num_bits:int -> (module Snarky_backendless.Snark_intf.Run with type field = 'f) diff --git a/src/lib/pickles/step_main.ml b/src/lib/pickles/step_main.ml index b096a6c2ca8..bfa03b59d8f 100644 --- a/src/lib/pickles/step_main.ml +++ b/src/lib/pickles/step_main.ml @@ -339,7 +339,7 @@ let step_main : tag public_input in { public_input - ; proof = As_prover.Ref.get proof + ; proof = As_prover.read (Typ.prover_value ()) proof ; proof_must_verify = As_prover.read Boolean.typ proof_must_verify } @@ -371,7 +371,7 @@ let step_main : ~request:(fun () -> Req.Messages_for_next_wrap_proof) and actual_wrap_domains = exists - (Vector.typ (Typ.Internal.ref ()) (Length.to_nat proofs_verified)) + (Vector.typ (Typ.prover_value ()) (Length.to_nat proofs_verified)) ~request:(fun () -> Req.Wrap_domain_indices) in let proof_witnesses = @@ -403,7 +403,7 @@ let step_main : -> (vars, ns1) H2.T(Inductive_rule.Previous_proof_statement).t -> (vars, n) Length.t -> actual_wrap_domains: - ( Pickles_base.Proofs_verified.t As_prover.Ref.t + ( Pickles_base.Proofs_verified.t Typ.prover_value , n ) Vector.t -> (_, n) Vector.t * B.t list = @@ -436,7 +436,8 @@ let step_main : | `Known wrap_domain -> as_prover (fun () -> let actual_wrap_domain = - As_prover.Ref.get actual_wrap_domain + As_prover.read (Typ.prover_value ()) + actual_wrap_domain |> Pickles_base.Proofs_verified.to_int in let actual_wrap_domain = diff --git a/src/lib/pickles/test/chunked_circuits/chunks2.ml b/src/lib/pickles/test/chunked_circuits/chunks2.ml index 0ee6f2214aa..748fc34dccd 100644 --- a/src/lib/pickles/test/chunked_circuits/chunks2.ml +++ b/src/lib/pickles/test/chunked_circuits/chunks2.ml @@ -108,7 +108,7 @@ let test () = ; main = (fun _ -> let proof = - exists (Typ.Internal.ref ()) ~request:(fun () -> + exists (Typ.prover_value ()) ~request:(fun () -> Requests.Proof ) in { previous_proof_statements = diff --git a/src/lib/snarky b/src/lib/snarky index 9d5eb9ee983..98805117bcc 160000 --- a/src/lib/snarky +++ b/src/lib/snarky @@ -1 +1 @@ -Subproject commit 9d5eb9ee983ac955092fcc908647b443abdf16aa +Subproject commit 98805117bcce13e09a6e7de0da24ed2e50e9b267 diff --git a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml index 4ccbfee0796..01dbbb0fb11 100644 --- a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml +++ b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml @@ -245,7 +245,7 @@ let%test_module "multisig_account" = assert false ) in let proof = - Run.exists (Typ.Internal.ref ()) + Run.exists (Typ.prover_value ()) ~compute:(fun () -> assert false) in Impl.run_checked diff --git a/src/lib/transaction_snark/test/util.ml b/src/lib/transaction_snark/test/util.ml index f4711161da8..c06604b6716 100644 --- a/src/lib/transaction_snark/test/util.ml +++ b/src/lib/transaction_snark/test/util.ml @@ -347,7 +347,7 @@ let dummy_rule self : _ Pickles.Inductive_rule.t = Run.exists Zkapp_statement.typ ~compute:(fun () -> assert false) in let proof = - Run.exists (Typ.Internal.ref ()) ~compute:(fun () -> assert false) + Run.exists (Typ.prover_value ()) ~compute:(fun () -> assert false) in Impl.run_checked (Transaction_snark.dummy_constraints ()) ; (* Unsatisfiable. *) diff --git a/src/lib/transaction_snark/transaction_snark.ml b/src/lib/transaction_snark/transaction_snark.ml index 00deee101f0..3e002973a53 100644 --- a/src/lib/transaction_snark/transaction_snark.ml +++ b/src/lib/transaction_snark/transaction_snark.ml @@ -450,7 +450,7 @@ module Make_str (A : Wire_types.Concrete) = struct let%snarkydef_ compute_as_prover ~constraint_constants ~txn_global_slot (txn : Transaction_union.var) = let%bind data = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~compute: As_prover.( let%map txn = read Transaction_union.typ txn in @@ -468,54 +468,54 @@ module Make_str (A : Wire_types.Concrete) = struct (txn, fee_payer, source, receiver)) in let%bind fee_payer_idx = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( let%map _txn, fee_payer, _source, _receiver = - read (Typ.Internal.ref ()) data + read (Typ.prover_value ()) data in Ledger_hash.Find_index fee_payer) in let%bind fee_payer_account = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( let%map fee_payer_idx = - read (Typ.Internal.ref ()) fee_payer_idx + read (Typ.prover_value ()) fee_payer_idx in Ledger_hash.Get_element fee_payer_idx) in let%bind source_idx = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( let%map _txn, _fee_payer, source, _receiver = - read (Typ.Internal.ref ()) data + read (Typ.prover_value ()) data in Ledger_hash.Find_index source) in let%bind source_account = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( - let%map source_idx = read (Typ.Internal.ref ()) source_idx in + let%map source_idx = read (Typ.prover_value ()) source_idx in Ledger_hash.Get_element source_idx) in let%bind receiver_idx = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( let%map _txn, _fee_payer, _source, receiver = - read (Typ.Internal.ref ()) data + read (Typ.prover_value ()) data in Ledger_hash.Find_index receiver) in let%bind receiver_account = - exists (Typ.Internal.ref ()) + exists (Typ.prover_value ()) ~request: As_prover.( let%map receiver_idx = - read (Typ.Internal.ref ()) receiver_idx + read (Typ.prover_value ()) receiver_idx in Ledger_hash.Get_element receiver_idx) in @@ -523,16 +523,16 @@ module Make_str (A : Wire_types.Concrete) = struct ~compute: As_prover.( let%bind txn, _fee_payer, _source, _receiver = - read (Typ.Internal.ref ()) data + read (Typ.prover_value ()) data in let%bind fee_payer_account, _path = - read (Typ.Internal.ref ()) fee_payer_account + read (Typ.prover_value ()) fee_payer_account in let%bind source_account, _path = - read (Typ.Internal.ref ()) source_account + read (Typ.prover_value ()) source_account in let%bind receiver_account, _path = - read (Typ.Internal.ref ()) receiver_account + read (Typ.prover_value ()) receiver_account in let%map txn_global_slot = read Mina_numbers.Global_slot_since_genesis.typ txn_global_slot @@ -939,7 +939,8 @@ module Make_str (A : Wire_types.Concrete) = struct { a with zkapp = ( Zkapp_account.Checked.digest a.zkapp - , As_prover.Ref.create (fun () -> None) ) + , exists (Typ.prover_value ()) ~compute:(fun () -> + None ) ) } in run_checked (Account.Checked.digest a) ) ) @@ -1430,8 +1431,9 @@ module Make_str (A : Wire_types.Concrete) = struct let vk = exists Side_loaded_verification_key.typ ~compute:(fun () -> Option.value_exn - (As_prover.Ref.get - (Data_as_hash.ref a.zkapp.verification_key.data) ) + (As_prover.read (Typ.prover_value ()) + (Data_as_hash.prover_value + a.zkapp.verification_key.data ) ) .data ) in let expected_hash = @@ -1924,7 +1926,8 @@ module Make_str (A : Wire_types.Concrete) = struct (g, l) in let start_zkapp_command = - As_prover.Ref.create (fun () -> !witness.start_zkapp_command) + exists (Typ.prover_value ()) ~compute:(fun () -> + ref !witness.start_zkapp_command ) in let zkapp_input = ref None in let must_verify = ref Boolean.true_ in @@ -1999,7 +2002,11 @@ module Make_str (A : Wire_types.Concrete) = struct (global_state, local_state) | `Compute_in_circuit -> V.create (fun () -> - match As_prover.Ref.get start_zkapp_command with + let start_zkapp_command = + As_prover.read (Typ.prover_value ()) + start_zkapp_command + in + match Stdlib.( ! ) start_zkapp_command with | [] -> `Skip | p :: ps -> @@ -2008,7 +2015,7 @@ module Make_str (A : Wire_types.Concrete) = struct (V.get local.stack_frame.data.calls.data) in if should_pop then ( - As_prover.Ref.set start_zkapp_command ps ; + start_zkapp_command := ps ; `Start p ) else `Skip ) |> finish @@ -2018,11 +2025,15 @@ module Make_str (A : Wire_types.Concrete) = struct Mina_base.Zkapp_command.Call_forest.is_empty (V.get local.stack_frame.data.calls.data) ) ) ; V.create (fun () -> - match As_prover.Ref.get start_zkapp_command with + let start_zkapp_command = + As_prover.read (Typ.prover_value ()) + start_zkapp_command + in + match Stdlib.( ! ) start_zkapp_command with | [] -> assert false | p :: ps -> - As_prover.Ref.set start_zkapp_command ps ; + start_zkapp_command := ps ; `Start p ) |> finish in @@ -2116,7 +2127,7 @@ module Make_str (A : Wire_types.Concrete) = struct main ?witness:!witness s ~constraint_constants stmt in let proof = - Run.exists (Typ.Internal.ref ()) ~request:(fun () -> + Run.exists (Typ.prover_value ()) ~request:(fun () -> Zkapp_proof ) in { previous_proof_statements = @@ -3285,7 +3296,7 @@ module Make_str (A : Wire_types.Concrete) = struct let s1, s2 = Run.run_checked (main x) in let p1, p2 = Run.exists - Typ.(Internal.ref () * Internal.ref ()) + Typ.(prover_value () * prover_value ()) ~request:(fun () -> Proofs_to_merge) in { previous_proof_statements = diff --git a/src/lib/transaction_snark/transaction_snark.mli b/src/lib/transaction_snark/transaction_snark.mli index 203368128a6..99a3d1cf147 100644 --- a/src/lib/transaction_snark/transaction_snark.mli +++ b/src/lib/transaction_snark/transaction_snark.mli @@ -1,17 +1,3 @@ include Transaction_snark_intf.Full with type Stable.V2.t = Mina_wire_types.Transaction_snark.V2.t -(*and type ( 'ledger_hash - , 'amount - , 'pending_coinbase - , 'fee_excess - , 'sok_digest - , 'local_state ) - Statement.Poly.Stable.V2.t = - ( 'ledger_hash - , 'amount - , 'pending_coinbase - , 'fee_excess - , 'sok_digest - , 'local_state ) - Mina_wire_types.Mina_state.Snarked_ledger_state.Poly.V2.t*)