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

Unify/simplify pickles variable names #16376

Draft
wants to merge 3 commits into
base: compatible
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module Wrap = struct
{ plonk : 'plonk
; combined_inner_product : 'fp
; b : 'fp
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
; bulletproof_challenges : 'bulletproof_challenges
; branch_data : 'branch_data
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module Wrap : sig
{ plonk : 'plonk
; combined_inner_product : 'fp
; b : 'fp
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
; bulletproof_challenges : 'bulletproof_challenges
; branch_data : 'branch_data
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib/pickles/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,18 @@ let ft_comm ~add:( + ) ~scale ~negate

let combined_evaluation (type f)
(module Impl : Snarky_backendless.Snark_intf.Run with type field = f)
~(xi : Impl.Field.t) (without_degree_bound : _ list) =
~(polyscale : Impl.Field.t) (without_degree_bound : _ list) =
let open Impl in
let open Field in
let mul_and_add ~(acc : Field.t) ~(xi : Field.t)
let mul_and_add ~(acc : Field.t) ~(polyscale : Field.t)
(fx : (Field.t, Boolean.var) Opt.t) : Field.t =
match fx with
| Nothing ->
acc
| Just fx ->
fx + (xi * acc)
fx + (polyscale * acc)
| Maybe (b, fx) ->
Field.if_ b ~then_:(fx + (xi * acc)) ~else_:acc
Field.if_ b ~then_:(fx + (polyscale * acc)) ~else_:acc
in
with_label __LOC__ (fun () ->
Pcs_batch.combine_split_evaluations ~mul_and_add
Expand All @@ -274,4 +274,4 @@ let combined_evaluation (type f)
Field.zero
| Maybe (b, x) ->
(b :> Field.t) * x )
~xi without_degree_bound )
~polyscale without_degree_bound )
2 changes: 1 addition & 1 deletion src/lib/pickles/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ val dlog_pcs_batch :

val combined_evaluation :
(module Snarky_backendless.Snark_intf.Run with type field = 'f)
-> xi:'f Snarky_backendless.Cvar.t
-> polyscale:'f Snarky_backendless.Cvar.t
-> ( 'f Snarky_backendless.Cvar.t
, 'f Snarky_backendless.Cvar.t Snarky_backendless.Snark_intf.Boolean0.t )
Pickles_types.Opt.t
Expand Down
39 changes: 20 additions & 19 deletions src/lib/pickles/composition_types/composition_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ module Wrap = struct
.t =
{ plonk : 'plonk
; combined_inner_product : 'fp
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} r^i xi^j f_j(pt_i) *)
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} evalscale^i polyscale^j f_j(pt_i) *)
; b : 'fp
(** b = challenge_poly plonk.zeta + r * challenge_poly (domain_generrator * plonk.zeta)
(** b = challenge_poly plonk.zeta + evalscale * challenge_poly (domain_generator * plonk.zeta)
where challenge_poly(x) = \prod_i (1 + bulletproof_challenges.(i) * x^{2^{k - 1 - i}})
*)
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
(** The challenge used for combining polynomials *)
; bulletproof_challenges : 'bulletproof_challenges
(** The challenges from the inner-product argument that was partially verified. *)
Expand Down Expand Up @@ -232,7 +232,7 @@ module Wrap = struct
{ plonk : 'plonk
; combined_inner_product : 'fp
; b : 'fp
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
; bulletproof_challenges : 'bulletproof_challenges
; branch_data : 'branch_data
}
Expand Down Expand Up @@ -284,11 +284,11 @@ module Wrap = struct
{ plonk
; combined_inner_product
; b : 'fp
; xi
; polyscale
; bulletproof_challenges
; branch_data
} ~f:_ ~scalar =
{ xi = scalar xi
{ polyscale = scalar polyscale
; combined_inner_product
; b
; plonk
Expand Down Expand Up @@ -343,7 +343,7 @@ module Wrap = struct
({ plonk
; combined_inner_product = _
; b = _
; xi = _
; polyscale = _
; bulletproof_challenges
; branch_data
} :
Expand Down Expand Up @@ -776,7 +776,7 @@ module Wrap = struct
let[@warning "-45"] to_data
({ proof_state =
{ deferred_values =
{ xi
{ polyscale
; combined_inner_product
; b
; branch_data
Expand Down Expand Up @@ -811,7 +811,7 @@ module Wrap = struct
]
in
let challenge = [ beta; gamma ] in
let scalar_challenge = [ alpha; zeta; xi ] in
let scalar_challenge = [ alpha; zeta; polyscale ] in
let digest =
[ sponge_digest_before_evaluations
; messages_for_next_wrap_proof
Expand Down Expand Up @@ -852,7 +852,7 @@ module Wrap = struct
fp
in
let [ beta; gamma ] = challenge in
let [ alpha; zeta; xi ] = scalar_challenge in
let [ alpha; zeta; polyscale ] = scalar_challenge in
let [ sponge_digest_before_evaluations
; messages_for_next_wrap_proof
; messages_for_next_step_proof
Expand All @@ -863,7 +863,7 @@ module Wrap = struct
let feature_flags = Plonk_types.Features.of_data feature_flags in
{ proof_state =
{ deferred_values =
{ xi
{ polyscale
; combined_inner_product
; b
; branch_data
Expand Down Expand Up @@ -911,7 +911,8 @@ module Step = struct
*)
type 'fq t =
{ b : 'fq
; combined_inner_product : 'fq (* sum_i r^i sum_j xi^j f_j(pt_i) *)
; combined_inner_product : 'fq
(* sum_i evalscale^i sum_j polyscale^j f_j(pt_i) *)
}
[@@deriving hlist]
end
Expand Down Expand Up @@ -1086,13 +1087,13 @@ module Step = struct
type ('plonk, 'scalar_challenge, 'fq, 'bulletproof_challenges) t_ =
{ plonk : 'plonk
; combined_inner_product : 'fq
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} r^i xi^j f_j(pt_i) *)
; xi : 'scalar_challenge
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} evalscale^i polyscale^j f_j(pt_i) *)
; polyscale : 'scalar_challenge
(** The challenge used for combining polynomials *)
; bulletproof_challenges : 'bulletproof_challenges
(** The challenges from the inner-product argument that was partially verified. *)
; b : 'fq
(** b = challenge_poly plonk.zeta + r * challenge_poly (domain_generrator * plonk.zeta)
(** b = challenge_poly plonk.zeta + evalscale * challenge_poly (domain_generator * plonk.zeta)
where challenge_poly(x) = \prod_i (1 + bulletproof_challenges.(i) * x^{2^{k - 1 - i}})
*)
}
Expand Down Expand Up @@ -1211,7 +1212,7 @@ module Step = struct

let[@warning "-45"] to_data
({ deferred_values =
{ xi
{ polyscale
; bulletproof_challenges
; b
; combined_inner_product
Expand Down Expand Up @@ -1239,7 +1240,7 @@ module Step = struct
]
in
let challenge = [ beta; gamma ] in
let scalar_challenge = [ alpha; zeta; xi ] in
let scalar_challenge = [ alpha; zeta; polyscale ] in
let digest = [ sponge_digest_before_evaluations ] in
let bool = [ should_finalize ] in
let open Hlist.HlistId in
Expand All @@ -1262,12 +1263,12 @@ module Step = struct
]
; Vector.[ sponge_digest_before_evaluations ]
; Vector.[ beta; gamma ]
; Vector.[ alpha; zeta; xi ]
; Vector.[ alpha; zeta; polyscale ]
; bulletproof_challenges
; Vector.[ should_finalize ]
] : _ t =
{ deferred_values =
{ xi
{ polyscale
; bulletproof_challenges
; b
; combined_inner_product
Expand Down
14 changes: 7 additions & 7 deletions src/lib/pickles/composition_types/composition_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ module Wrap : sig
.t =
{ plonk : 'plonk
; combined_inner_product : 'fp
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} r^i xi^j f_j(pt_i) *)
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} evalscale^i polyscale^j f_j(pt_i) *)
; b : 'fp
(** b = challenge_poly plonk.zeta + r * challenge_poly (domain_generrator * plonk.zeta)
(** b = challenge_poly plonk.zeta + evalscale * challenge_poly (domain_generator * plonk.zeta)
where challenge_poly(x) = \prod_i (1 + bulletproof_challenges.(i) * x^{2^{k - 1 - i}})
*)
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
(** The challenge used for combining polynomials *)
; bulletproof_challenges : 'bulletproof_challenges
(** The challenges from the inner-product argument that was partially verified. *)
Expand Down Expand Up @@ -208,7 +208,7 @@ module Wrap : sig
{ plonk : 'plonk
; combined_inner_product : 'fp
; b : 'fp
; xi : 'scalar_challenge
; polyscale : 'scalar_challenge
; bulletproof_challenges : 'bulletproof_challenges
; branch_data : 'branch_data
}
Expand Down Expand Up @@ -1010,13 +1010,13 @@ module Step : sig
type ('plonk, 'scalar_challenge, 'fq, 'bulletproof_challenges) t_ =
{ plonk : 'plonk
; combined_inner_product : 'fq
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} r^i xi^j f_j(pt_i) *)
; xi : 'scalar_challenge
(** combined_inner_product = sum_{i < num_evaluation_points} sum_{j < num_polys} evalscale^i polyscale^j f_j(pt_i) *)
; polyscale : 'scalar_challenge
(** The challenge used for combining polynomials *)
; bulletproof_challenges : 'bulletproof_challenges
(** The challenges from the inner-product argument that was partially verified. *)
; b : 'fq
(** b = challenge_poly plonk.zeta + r * challenge_poly (domain_generrator * plonk.zeta)
(** b = challenge_poly plonk.zeta + evalscale * challenge_poly (domain_generator * plonk.zeta)
where challenge_poly(x) = \prod_i (1 + bulletproof_challenges.(i) * x^{2^{k - 1 - i}})
*)
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib/pickles/pickles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1486,17 +1486,17 @@ module Make_str (_ : Wire_types.Concrete) = struct
; feature_flags = Plonk_types.Features.none_bool
}
in
let r = scalar_chal O.u in
let xi = scalar_chal O.v in
let evalscale = scalar_chal O.u in
let polyscale = scalar_chal O.v in
let to_field =
SC.to_field_constant
(module Tick.Field)
~endo:Endo.Wrap_inner_curve.scalar
in
let module As_field = struct
let r = to_field r
let evalscale = to_field evalscale

let xi = to_field xi
let polyscale = to_field polyscale

let zeta = to_field plonk0.zeta

Expand Down Expand Up @@ -1584,7 +1584,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
(let x1, x2 = x_hat in
([| x1 |], [| x2 |]) )
}
~r ~xi ~zeta ~zetaw
~evalscale ~polyscale ~zeta ~zetaw
~old_bulletproof_challenges:prev_challenges
~env:tick_env ~domain:tick_domain
~ft_eval1:proof.proof.openings.ft_eval1
Expand All @@ -1611,7 +1611,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
let b =
let open Tick.Field in
challenge_polynomial zeta
+ (r * challenge_polynomial zetaw)
+ (evalscale * challenge_polynomial zetaw)
in
let overwritten_prechals =
Array.map prechals
Expand Down Expand Up @@ -1687,7 +1687,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
in
{ proof_state =
{ deferred_values =
{ xi
{ polyscale
; b = shift_value b
; bulletproof_challenges =
Vector.of_array_and_length_exn
Expand Down
21 changes: 11 additions & 10 deletions src/lib/pickles/step.ml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ struct
; combined_inner_product =
deferred_values.combined_inner_product
; b = deferred_values.b
; xi = deferred_values.xi
; polyscale = deferred_values.polyscale
; bulletproof_challenges =
statement.proof_state.deferred_values
.bulletproof_challenges
Expand Down Expand Up @@ -333,18 +333,18 @@ struct
; feature_flags = Plonk_types.Features.none_bool
}
in
let xi = scalar_chal O.v in
let r = scalar_chal O.u in
let polyscale = scalar_chal O.v in
let evalscale = scalar_chal O.u in
let sponge_digest_before_evaluations = O.digest_before_evaluations o in
let to_field =
SC.to_field_constant
(module Tock.Field)
~endo:Endo.Step_inner_curve.scalar
in
let module As_field = struct
let r = to_field r
let evalscale = to_field evalscale

let xi = to_field xi
let polyscale = to_field polyscale

let zeta = to_field plonk0.zeta

Expand All @@ -368,7 +368,7 @@ struct
let open As_field in
let b =
let open Tock.Field in
challenge_polynomial zeta + (r * challenge_polynomial zetaw)
challenge_polynomial zeta + (evalscale * challenge_polynomial zetaw)
in
let prechals =
Vector.of_list_and_length_exn
Expand Down Expand Up @@ -480,8 +480,8 @@ struct
([| f x_hat |] :: [| ft_eval |] :: a)
in
let open Tock.Field in
Pcs_batch.combine_split_evaluations ~xi ~init:Fn.id
~mul_and_add:(fun ~acc ~xi fx -> fx + (xi * acc))
Pcs_batch.combine_split_evaluations ~polyscale ~init:Fn.id
~mul_and_add:(fun ~acc ~polyscale fx -> fx + (polyscale * acc))
v
in
let ft_eval0 =
Expand All @@ -492,7 +492,8 @@ struct
in
let open Tock.Field in
combine ~which_eval:`Fst ~ft_eval:ft_eval0 As_field.zeta
+ (r * combine ~which_eval:`Snd ~ft_eval:proof.openings.ft_eval1 zetaw)
+ evalscale
* combine ~which_eval:`Snd ~ft_eval:proof.openings.ft_eval1 zetaw
in
let chal = Challenge.Constant.of_tock_field in
let plonk =
Expand Down Expand Up @@ -522,7 +523,7 @@ struct
; gamma = chal plonk0.gamma
}
; combined_inner_product = shifted_value combined_inner_product
; xi
; polyscale
; bulletproof_challenges = new_bulletproof_challenges
; b = shifted_value b
}
Expand Down
Loading