Skip to content

Commit

Permalink
Merge branch 'develop' into feature/mina-caqti-internal-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
psteckler authored Oct 16, 2023
2 parents 70c088c + 4b2e023 commit 50778d2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
11 changes: 4 additions & 7 deletions src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate};
use kimchi::{linearization::expr_linearization, prover_index::ProverIndex};
use mina_curves::pasta::{Fp, Pallas, Vesta, VestaParameters};
use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge};
use poly_commitment::evaluation_proof::OpeningProof;
use poly_commitment::{evaluation_proof::OpeningProof, SRS as _};
use serde::{Deserialize, Serialize};
use std::{
fs::{File, OpenOptions},
Expand Down Expand Up @@ -70,6 +70,7 @@ pub fn caml_pasta_fp_plonk_index_create(
let cs = match ConstraintSystem::<Fp>::create(gates)
.public(public as usize)
.prev_challenges(prev_challenges as usize)
.max_poly_size(Some(srs.0.max_poly_size()))
.lookup(lookup_tables)
.runtime(if runtime_tables.is_empty() {
None
Expand All @@ -78,12 +79,8 @@ pub fn caml_pasta_fp_plonk_index_create(
})
.build()
{
Err(_) => {
return Err(ocaml::Error::failwith(
"caml_pasta_fp_plonk_index_create: could not create constraint system",
)
.err()
.unwrap())
Err(e) => {
return Err(e.into())
}
Ok(cs) => cs,
};
Expand Down
10 changes: 3 additions & 7 deletions src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate};
use kimchi::{linearization::expr_linearization, prover_index::ProverIndex};
use mina_curves::pasta::{Fq, Pallas, PallasParameters, Vesta};
use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge};
use poly_commitment::evaluation_proof::OpeningProof;
use poly_commitment::{evaluation_proof::OpeningProof};
use serde::{Deserialize, Serialize};
use std::{
fs::{File, OpenOptions},
Expand Down Expand Up @@ -78,12 +78,8 @@ pub fn caml_pasta_fq_plonk_index_create(
})
.build()
{
Err(_) => {
return Err(ocaml::Error::failwith(
"caml_pasta_fq_plonk_index_create: could not create constraint system",
)
.err()
.unwrap())
Err(e) => {
return Err(e.into())
}
Ok(cs) => cs,
};
Expand Down
14 changes: 8 additions & 6 deletions src/lib/pickles/pickles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
V.f Max_local_max_proofs_verifieds.length
(M.f prev_messages_for_next_wrap_proof)
in
O.create pairing_vk
O.create_with_public_evals pairing_vk
Vector.(
map2 (Vector.trim_front sgs lte) prev_challenges
~f:(fun commitment cs ->
Expand Down Expand Up @@ -1520,7 +1520,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
let tick_combined_evals =
Plonk_checks.evals_of_split_evals
(module Tick.Field)
proof.openings.evals
proof.proof.openings.evals
~rounds:(Nat.to_int Tick.Rounds.n) ~zeta:As_field.zeta
~zetaw
in
Expand Down Expand Up @@ -1573,11 +1573,13 @@ module Make_str (_ : Wire_types.Concrete) = struct
(* Note: We do not pad here. *)
~actual_proofs_verified:
(Nat.Add.create actual_proofs_verified)
{ evals = proof.openings.evals; public_input = x_hat }
{ evals = proof.proof.openings.evals
; public_input = x_hat
}
~r ~xi ~zeta ~zetaw
~old_bulletproof_challenges:prev_challenges
~env:tick_env ~domain:tick_domain
~ft_eval1:proof.openings.ft_eval1
~ft_eval1:proof.proof.openings.ft_eval1
~plonk:tick_plonk_minimal
in
let chal = Challenge.Constant.of_tick_field in
Expand Down Expand Up @@ -1769,9 +1771,9 @@ module Make_str (_ : Wire_types.Concrete) = struct
; prev_evals =
{ Plonk_types.All_evals.evals =
{ public_input = x_hat
; evals = proof.openings.evals
; evals = proof.proof.openings.evals
}
; ft_eval1 = proof.openings.ft_eval1
; ft_eval1 = proof.proof.openings.ft_eval1
}
}
: _ P.Base.Wrap.t )
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pickles/proof.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Base = struct
Types.Step.Statement.t
; index : int
; prev_evals : 'prev_evals
; proof : Tick.Proof.t
; proof : Tick.Proof.with_public_evals
}
end

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pickles/proof.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Base : sig
Import.Types.Step.Statement.t
; index : int
; prev_evals : 'prev_evals
; proof : Backend.Tick.Proof.t
; proof : Backend.Tick.Proof.with_public_evals
}
end

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pickles/step.ml
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ struct
}
in
[%log internal] "Pickles_step_proof_done" ;
( { Proof.Base.Step.proof = next_proof.proof
( { Proof.Base.Step.proof = next_proof
; statement = next_statement
; index = branch_data.index
; prev_evals =
Expand Down
32 changes: 18 additions & 14 deletions src/lib/pickles/wrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ let deferred_values (type n) ~(sgs : (Backend.Tick.Curve.Affine.t, n) Vector.t)
~actual_feature_flags
~(prev_challenges : ((Backend.Tick.Field.t, _) Vector.t, n) Vector.t)
~(step_vk : Kimchi_bindings.Protocol.VerifierIndex.Fp.t)
~(public_input : Backend.Tick.Field.t list) ~(proof : Backend.Tick.Proof.t)
~(public_input : Backend.Tick.Field.t list)
~(proof : Backend.Tick.Proof.with_public_evals)
~(actual_proofs_verified : n Nat.t) : deferred_values_and_hints =
let module O = Tick.Oracles in
let o =
O.create step_vk
O.create_with_public_evals step_vk
Vector.(
map2 sgs prev_challenges ~f:(fun commitment cs ->
{ Tick.Proof.Challenge_polynomial.commitment
Expand Down Expand Up @@ -159,7 +160,7 @@ let deferred_values (type n) ~(sgs : (Backend.Tick.Curve.Affine.t, n) Vector.t)
let tick_combined_evals =
Plonk_checks.evals_of_split_evals
(module Tick.Field)
proof.openings.evals ~rounds:(Nat.to_int Tick.Rounds.n)
proof.proof.openings.evals ~rounds:(Nat.to_int Tick.Rounds.n)
~zeta:As_field.zeta ~zetaw
|> Plonk_types.Evals.to_in_circuit
in
Expand Down Expand Up @@ -236,10 +237,11 @@ let deferred_values (type n) ~(sgs : (Backend.Tick.Curve.Affine.t, n) Vector.t)
As_field.(
combined_inner_product (* Note: We do not pad here. *)
~actual_proofs_verified:(Nat.Add.create actual_proofs_verified)
{ evals = proof.openings.evals; public_input = x_hat }
{ evals = proof.proof.openings.evals; public_input = x_hat }
~r ~xi ~zeta ~zetaw ~old_bulletproof_challenges:prev_challenges
~env:tick_env ~domain:tick_domain
~ft_eval1:proof.openings.ft_eval1 ~plonk:tick_plonk_minimal)
~ft_eval1:proof.proof.openings.ft_eval1
~plonk:tick_plonk_minimal)
; branch_data =
{ proofs_verified =
( match actual_proofs_verified with
Expand Down Expand Up @@ -332,7 +334,8 @@ let%test_module "gate finalization" =
(feature_flags : Plonk_types.Features.options)
(public_input : Pasta_bindings.Fp.t list)
(vk : Kimchi_bindings.Protocol.VerifierIndex.Fp.t)
(proof : Backend.Tick.Proof.t) : Impls.Step.Boolean.value =
(proof : Backend.Tick.Proof.with_public_evals) :
Impls.Step.Boolean.value =
(* Constants helper - takes an OCaml value and converts it to a snarky value, where
all values here are constant literals. N.b. this should be
encapsulated as Snarky internals, but it never got merged. *)
Expand Down Expand Up @@ -418,8 +421,9 @@ let%test_module "gate finalization" =
and evals =
constant
(Plonk_types.All_evals.typ (module Impls.Step) full_features)
{ evals = { public_input = x_hat_evals; evals = proof.openings.evals }
; ft_eval1 = proof.openings.ft_eval1
{ evals =
{ public_input = x_hat_evals; evals = proof.proof.openings.evals }
; ft_eval1 = proof.proof.openings.ft_eval1
}
in

Expand Down Expand Up @@ -499,7 +503,7 @@ let%test_module "gate finalization" =

let runtest feature_flags =
run_recursive_proof_test S.actual_feature_flags feature_flags
public_input vk proof.proof
public_input vk proof

let%test "true -> yes" = runtest test_feature_flags_configs.true_is_yes

Expand Down Expand Up @@ -734,9 +738,9 @@ let wrap
in
k (M.f messages_for_next_wrap_proof)
| Messages ->
k proof.messages
k proof.proof.messages
| Openings_proof ->
k proof.openings.proof
k proof.proof.openings.proof
| Proof_state ->
k prev_statement_with_hashes.proof_state
| Which_branch ->
Expand Down Expand Up @@ -802,7 +806,7 @@ let wrap
let messages_for_next_wrap_proof :
_ P.Base.Messages_for_next_proof_over_same_field.Wrap.t =
{ challenge_polynomial_commitment =
proof.openings.proof.challenge_polynomial_commitment
proof.proof.openings.proof.challenge_polynomial_commitment
; old_bulletproof_challenges =
Vector.map prev_statement.proof_state.unfinalized_proofs ~f:(fun t ->
t.deferred_values.bulletproof_challenges )
Expand Down Expand Up @@ -913,8 +917,8 @@ let wrap
~to_option:Opt.to_option_unsafe
; prev_evals =
{ Plonk_types.All_evals.evals =
{ public_input = x_hat_evals; evals = proof.openings.evals }
; ft_eval1 = proof.openings.ft_eval1
{ public_input = x_hat_evals; evals = proof.proof.openings.evals }
; ft_eval1 = proof.proof.openings.ft_eval1
}
}
: _ P.Base.Wrap.t )

0 comments on commit 50778d2

Please sign in to comment.