Skip to content

Commit

Permalink
unify type
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 committed Aug 23, 2024
1 parent f5e53e5 commit 6b9b321
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 91 deletions.
2 changes: 1 addition & 1 deletion MINA_COMMIT
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The mina commit used to generate the backends for node and web is
994cf49db79355993347bf594fbdfb6db40c2ffa
750e609aae082ff56caa07cacef34b7b40c460dc
105 changes: 52 additions & 53 deletions compiled/node_bindings/o1js_node.bc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -431540,60 +431540,59 @@
[0,x]);
caml_call3(Ops[8],g,[0,x],5);
caml_call3(Scalar_challenge[5],_guv_,g,[0,x]);
function _gAz_(js_result)
{var
public_output=js_result.publicOutput,
auxiliary_output=js_result.auxiliaryOutput,
should_verifys_js=js_result.shouldVerify,
previous_proofs_should_verify=
_guw_(0,prevs$0,should_verifys_js),
statements=js_result.previousStatements,
previous_public_inputs=
_gux_
(public_input_size,
public_output_size,
self,
0,
prevs$0,
statements);
function go(i,public_inputs,should_verifys,tags)
{if(public_inputs)
{var
tags$0=tags[2],
should_verifys$0=should_verifys[2],
proof_must_verify=should_verifys[1],
public_inputs$0=public_inputs[2],
public_input=public_inputs[1],
_gAA_=caml_call1(Typ$0[12][2],0),
_gAB_=0,
proof=
caml_call3
(exists$8,
[0,function(param){return [0,Get_prev_proof,i]}],
_gAB_,
_gAA_);
return [0,
[0,public_input,proof,proof_must_verify],
go(i + 1 | 0,public_inputs$0,should_verifys$0,tags$0)]}
return 0}
var
previous_proof_statements=
go
(0,
previous_public_inputs,
previous_proofs_should_verify,
prevs$0);
return [0,
previous_proof_statements,
public_output,
auxiliary_output]}
var
res=
caml_call2
(map$49,
deferred_of_promise(caml_call1(rule.main,public_input)),
_gAz_);
return res}
_gAz_=
deferred_of_promise(caml_call1(rule.main,public_input));
return caml_call2
(map$49,
_gAz_,
function(js_result)
{var
public_output=js_result.publicOutput,
auxiliary_output=js_result.auxiliaryOutput,
should_verifys_js=js_result.shouldVerify,
previous_proofs_should_verify=
_guw_(0,prevs$0,should_verifys_js),
statements=js_result.previousStatements,
previous_public_inputs=
_gux_
(public_input_size,
public_output_size,
self,
0,
prevs$0,
statements);
function go(i,public_inputs,should_verifys,tags)
{if(public_inputs)
{var
tags$0=tags[2],
should_verifys$0=should_verifys[2],
proof_must_verify=should_verifys[1],
public_inputs$0=public_inputs[2],
public_input=public_inputs[1],
_gAA_=caml_call1(Typ$0[12][2],0),
_gAB_=0,
proof=
caml_call3
(exists$8,
[0,function(param){return [0,Get_prev_proof,i]}],
_gAB_,
_gAA_);
return [0,
[0,public_input,proof,proof_must_verify],
go(i + 1 | 0,public_inputs$0,should_verifys$0,tags$0)]}
return 0}
var
previous_proof_statements=
go
(0,
previous_public_inputs,
previous_proofs_should_verify,
prevs$0);
return [0,
previous_proof_statements,
public_output,
auxiliary_output]})}
function _gAv_(param)
{if(param && param[1])return 1;return 0}
var _gAw_=map$38(rule.featureFlags,_gAv_);
Expand Down
2 changes: 1 addition & 1 deletion compiled/node_bindings/o1js_node.bc.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled/web_bindings/o1js_web.bc.js

Large diffs are not rendered by default.

57 changes: 27 additions & 30 deletions ocaml/lib/pickles_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Boolean = Impl.Boolean
module Typ = Impl.Typ
module Backend = Pickles.Backend

module Public_input = struct
module Field_input_array = struct
type t = Field.t array

module Constant = struct
Expand All @@ -30,9 +30,9 @@ let statement_typ (input_size : int) (output_size : int) =
Typ.(array ~length:input_size Field.typ * array ~length:output_size Field.typ)

type ('prev_proof, 'proof) js_prover =
Public_input.Constant.t
Field_input_array.Constant.t
-> 'prev_proof array
-> (Public_input.Constant.t * Impl.field array * 'proof)
-> (Field_input_array.Constant.t * Impl.field array * 'proof)
Promise_js_helpers.js_promise

let dummy_constraints =
Expand Down Expand Up @@ -64,9 +64,9 @@ let dummy_constraints =
type pickles_rule_js =
< identifier : Js.js_string Js.t Js.prop
; main :
( Public_input.t
-> < publicOutput : Public_input.t Js.prop
; auxiliaryOutput : Public_input.t Js.prop
( Field_input_array.t
-> < publicOutput : Field_input_array.t Js.prop
; auxiliaryOutput : Field_input_array.t Js.prop
; previousStatements : Statement.t array Js.prop
; shouldVerify : Boolean.var array Js.prop >
Js.t
Expand Down Expand Up @@ -194,8 +194,8 @@ module Choices = struct
let get_typ ~public_input_size ~public_output_size
(type a1 a2 a3 a4 width height) (tag : (a1, a2, a3, a4) Pickles.Tag.t)
(self :
( Public_input.t * Public_input.t
, Public_input.Constant.t * Public_input.Constant.t
( Field_input_array.t * Field_input_array.t
, Field_input_array.Constant.t * Field_input_array.Constant.t
, width
, height )
Pickles.Tag.t ) =
Expand All @@ -210,8 +210,8 @@ module Choices = struct
public_input_size:int
-> public_output_size:int
-> self:
( Public_input.t * Public_input.t
, Public_input.Constant.t * Public_input.Constant.t
( Field_input_array.t * Field_input_array.t
, Field_input_array.Constant.t * Field_input_array.Constant.t
, width
, height )
Pickles.Tag.t
Expand Down Expand Up @@ -248,10 +248,10 @@ module Choices = struct
, _
, _
, _
, Public_input.t
, Public_input.Constant.t
, Public_input.t
, Public_input.Constant.t
, Field_input_array.t
, Field_input_array.Constant.t
, Field_input_array.t
, Field_input_array.Constant.t
, 'aux_var
, 'aux_value )
t =
Expand Down Expand Up @@ -308,12 +308,9 @@ module Choices = struct
dummy_constraints () ;

(* circuit from js *)
let res =
Promise.map
~f:(finish_circuit prevs self)
(Promise_js_helpers.of_js (rule##.main public_input))
in
res
rule##.main public_input
|> Promise_js_helpers.of_js
|> Promise.map ~f:(finish_circuit prevs self)
in

{ identifier = Js.to_string rule##.identifier
Expand Down Expand Up @@ -374,12 +371,12 @@ module Choices = struct
, _
, _
, _
, Public_input.t
, Public_input.Constant.t
, Public_input.t
, Public_input.Constant.t
, Public_input.t
, 'aux )
, Field_input_array.t
, Field_input_array.Constant.t
, Field_input_array.t
, Field_input_array.Constant.t
, 'aux_var
, 'aux_value )
t =
if index < 0 then Choices rules
else
Expand Down Expand Up @@ -634,7 +631,6 @@ let pickles_compile (choices : pickles_rule_js array)
( public_input_typ public_input_size
, public_input_typ public_output_size ) )
~auxiliary_typ:(Typ.array ~length:auxiliary_output_size Typ.field)
(* TODO: actually fix *)
~branches:(module Branches)
~max_proofs_verified:(module Max_proofs_verified)
~name ?storables ?cache
Expand All @@ -643,7 +639,7 @@ let pickles_compile (choices : pickles_rule_js array)
(* translate returned prover and verify functions to JS *)
let module Proof = (val p) in
let to_js_prover prover : ('prev_proof, Proof.t) js_prover =
let prove (public_input : Public_input.Constant.t)
let prove (public_input : Field_input_array.Constant.t)
(prevs : 'prev_proof array) =
let handler (Snarky_backendless.Request.With { request; respond }) =
match request with
Expand All @@ -665,8 +661,9 @@ let pickles_compile (choices : pickles_rule_js array)
( a
, b
, c
, Public_input.Constant.t
, (Public_input.Constant.t * Impl.field array * Proof.t) Promise.t )
, Field_input_array.Constant.t
, (Field_input_array.Constant.t * Impl.field array * Proof.t) Promise.t
)
Pickles.Provers.t
-> ('prev_proof, Proof.t) js_prover list = function
| [] ->
Expand Down
8 changes: 4 additions & 4 deletions ocaml/lib/pickles_bindings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Impl = Pickles.Impls.Step
module Field = Impl.Field
module Boolean = Impl.Boolean

module Public_input : sig
module Field_input_array : sig
type t = Field.t array

module Constant : sig
Expand All @@ -24,9 +24,9 @@ end
type pickles_rule_js =
< identifier : Js.js_string Js.t Js.prop
; main :
( Public_input.t
-> < publicOutput : Public_input.t Js.prop
; auxiliaryOutput : Public_input.t Js.prop
( Field_input_array.t
-> < publicOutput : Field_input_array.t Js.prop
; auxiliaryOutput : Field_input_array.t Js.prop
; previousStatements : Statement.t array Js.prop
; shouldVerify : Boolean.var array Js.prop >
Js.t
Expand Down

0 comments on commit 6b9b321

Please sign in to comment.