-
Notifications
You must be signed in to change notification settings - Fork 542
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
Fast zkapp proofs with max_proofs_verified=0 #11053
Conversation
a879d80
to
460c394
Compare
This reverts commit abb4bdf.
@@ -51,30 +51,56 @@ module As_field = struct | |||
|
|||
let of_field_obj (x : field_class Js.t) : t = Obj.magic x | |||
|
|||
let of_number_exn (value : t) : Impl.Field.t = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are unrelated. Please open a separate PR for them in future.
@@ -228,6 +254,11 @@ let optdef_arg_method (type a) class_ (name : string) | |||
in | |||
Js.Unsafe.set prototype (Js.string name) meth | |||
|
|||
let to_js_bigint = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
@@ -278,6 +309,7 @@ let () = | |||
method_ "sizeInFields" (fun _this : int -> 1) ; | |||
method_ "toFields" (fun this : field_class Js.t Js.js_array Js.t -> | |||
singleton_array this ) ; | |||
method_ "toBigInt" (fun this -> to_string this##.value |> to_js_bigint) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
@@ -358,6 +390,10 @@ let () = | |||
in | |||
field_class##.one := mk Field.one ; | |||
field_class##.zero := mk Field.zero ; | |||
field_class##.minusOne := mk @@ Field.negate Field.one ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
@@ -494,7 +530,11 @@ let () = | |||
else Field.Constant.of_string s ) ) | |||
with Failure _ -> Js.Opt.empty ) | |||
| _ -> | |||
Js.Opt.empty ) | |||
Js.Opt.empty ) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
@@ -1731,15 +1764,19 @@ let pickles_compile (choices : pickles_rule_js Js.js_array Js.t) = | |||
(* TODO: get rid of Obj.magic, this should be an empty "H3.T" *) | |||
let prevs = Obj.magic [] in | |||
let statement = Zkapp_statement.(statement_js |> of_js |> to_constant) in | |||
prover ?handler:None prevs statement |> Promise_js_helpers.to_js | |||
let proof_promise = prover ?handler:None prevs statement in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: unnecessary let ... = ... in
method_ "toField" (fun this : field_class Js.t -> | ||
new%js field_constr (As_field.of_field (this##.value :> Field.t)) ) ; | ||
add_op1 "not" Boolean.not ; | ||
add_op2 "and" Boolean.( &&& ) ; | ||
add_op2 "or" Boolean.( ||| ) ; | ||
method_ "assertEquals" (fun this (y : As_bool.t) : unit -> | ||
Boolean.Assert.( = ) this##.value (As_bool.value y) ) ; | ||
method_ "assertTrue" (fun this : unit -> Boolean.Assert.is_true this##.value) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
@@ -5,8 +5,8 @@ let () = | |||
let js_layout = | |||
`Assoc | |||
[ ("Parties", layout Parties.deriver) | |||
; ("BalanceChange", layout Fields_derivers_zkapps.Derivers.balance_change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated
let ok = await Ledger.verifyPartyProof(statement, proof, verificationKey.data); | ||
toc(); | ||
console.log("did proof verify?", ok); | ||
if (!ok) console.log("proof didn't verify"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is this not redundant with the log immediately above?
@@ -90,6 +91,16 @@ partiesJsonInitialize = signFeePayer(partiesJsonInitialize, senderKey, { | |||
}); | |||
toc(); | |||
|
|||
// verify the proof | |||
tic("verify transaction proof"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: tic
and tock
would be better served by self-documenting names. Consider e.g. startTiming
and endTiming
.
(Not to change in this PR, it's already a grab-bag, lets not make it worse.)
This adds the snarkyjs changes required to take advantage of #11097 / #11185
To get an idea of the impact, here are snark performance timings taken from the snarkyjs unit test in CI:
This also includes some smaller snarkyjs bindings changes, whose JS counterparts are mostly merged with o1-labs/o1js#171
Field(number)
in snarkyjs #10960Field(10n)
,Field('-10')
(bigints, strings with a minus sign)TODO: