Skip to content

Commit a2ed9dd

Browse files
committed
Review fixes
1 parent 31055f4 commit a2ed9dd

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
lines changed

ledger/src/proofs/caching.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ impl<T> From<&GroupAffineCached> for ark_ec::models::short_weierstrass::Affine<T
125125
where
126126
T: ark_ec::short_weierstrass::SWCurveConfig,
127127
<T as CurveConfig>::BaseField: From<ark_ff::BigInteger256>,
128-
<T as CurveConfig>::BaseField: From<ark_ff::BigInt<4>>,
129128
{
130129
// This is copy of old `GroupAffine::new` function
131130
fn from(pallas: &GroupAffineCached) -> Self {

ledger/src/proofs/public_input/plonk_checks.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,37 @@ mod scalars {
751751
let x = sub_eval(x, ctx);
752752
field::mul(x, y, ctx.w)
753753
}
754-
Operations::Sub(_, _) => todo!(),
755-
Operations::Double(_) => todo!(),
756-
Operations::Square(_) => todo!(),
757-
Operations::Cache(_, _) => todo!(),
758-
Operations::IfFeature(_, _, _) => todo!(),
754+
Operations::Sub(x, y) => {
755+
let x = sub_eval(x, ctx);
756+
let y = sub_eval(y, ctx);
757+
x - y
758+
}
759+
Operations::Double(x) => {
760+
let x = sub_eval(x, ctx);
761+
x.double()
762+
}
763+
Operations::Square(x) => {
764+
let x = sub_eval(x, ctx);
765+
field::mul(x, x, ctx.w)
766+
}
767+
Operations::Cache(id, _e) => ctx.cache.get(id).copied().unwrap(),
768+
Operations::IfFeature(feature, e1, e2) => match ctx.env.feature_flags.as_ref() {
769+
None => sub_eval(e2, ctx),
770+
Some(feature_flags) => {
771+
let is_feature_enabled = match get_feature_flag(feature_flags, feature, ctx.w) {
772+
None => return sub_eval(e2, ctx),
773+
Some(enabled) => enabled,
774+
};
775+
776+
let on_false = sub_eval(e2, ctx);
777+
let on_true = sub_eval(e1, ctx);
778+
779+
ctx.w.exists_no_check(match is_feature_enabled {
780+
Boolean::True => on_true,
781+
Boolean::False => on_false,
782+
})
783+
}
784+
},
759785
}
760786
}
761787

ledger/src/proofs/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ impl<F: FieldWitness> InnerCurve<F> {
13101310
}
13111311
}
13121312

1313+
use poly_commitment::SRS;
13131314
use std::cell::RefCell;
13141315

13151316
thread_local! {
@@ -3902,8 +3903,7 @@ pub fn make_prover_index<C: ProofConstants, F: FieldWitness>(
39023903
let srs: poly_commitment::ipa::SRS<F::OtherCurve> = {
39033904
let srs = get_srs_mut::<F>();
39043905
let srs = srs.lock().unwrap().clone();
3905-
// srs.add_lagrange_basis(cs.domain.d1);
3906-
// srs.with_lagrange_basis(cs.domain.d1);
3906+
srs.get_lagrange_basis(cs.domain.d1);
39073907
srs
39083908
};
39093909

ledger/src/proofs/verifiers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use kimchi::{
2222
mina_curves::pasta::Pallas,
2323
};
2424
use mina_curves::pasta::{Fp, Fq};
25-
use poly_commitment::{ipa::SRS, lagrange_basis::WithLagrangeBasis, SRS as _};
25+
use poly_commitment::{ipa::SRS, SRS as _};
2626

2727
use crate::{proofs::BACKEND_TOCK_ROUNDS_N, VerificationKey};
2828

@@ -338,7 +338,7 @@ fn make_verifier_index(index: VerifierIndex<Fq>) -> VerifierIndex<Fq> {
338338
// <https://github.com/o1-labs/proof-systems/blob/2702b09063c7a48131173d78b6cf9408674fd67e/kimchi/src/verifier_index.rs#L310-L314>
339339
let srs = {
340340
let srs = SRS::create(max_poly_size);
341-
srs.with_lagrange_basis(domain);
341+
srs.get_lagrange_basis(domain);
342342
Arc::new(srs)
343343
};
344344

@@ -397,7 +397,7 @@ pub fn make_zkapp_verifier_index(vk: &VerificationKey) -> VerifierIndex<Fq> {
397397
let srs = {
398398
let degree = 1 << BACKEND_TOCK_ROUNDS_N;
399399
let srs = SRS::<Pallas>::create(degree);
400-
srs.with_lagrange_basis(domain);
400+
srs.get_lagrange_basis(domain);
401401
srs
402402
};
403403

ledger/src/proofs/wrap.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ fn make_lagrange<F: FieldWitness>(
266266

267267
let x_domain = EvaluationDomain::<F>::new(domain_size).expect("invalid argument");
268268

269-
// srs.with_lagrange_basis(x_domain);
270-
271269
let lagrange_bases = srs.get_lagrange_basis(x_domain)[..domain_size].to_vec();
272270
// lagrange_bases[..domain_size].to_vec()
273271
lagrange_bases.clone()
@@ -1453,7 +1451,7 @@ pub mod pcs_batch {
14531451
pub mod wrap_verifier {
14541452
use std::sync::Arc;
14551453

1456-
use ark_ec::short_weierstrass::Affine;
1454+
use ark_ec::short_weierstrass::{Affine, Projective};
14571455
use itertools::Itertools;
14581456
use poly_commitment::{ipa::SRS, SRS as _};
14591457

@@ -1826,8 +1824,6 @@ pub mod wrap_verifier {
18261824
EvaluationDomain::<<F as crate::proofs::field::FieldWitness>::Scalar>::new(d)
18271825
.expect("invalid argument");
18281826

1829-
// srs.with_lagrange_basis(x_domain);
1830-
18311827
let lagrange_bases = &srs.get_lagrange_basis(x_domain);
18321828
lagrange_bases[i].clone()
18331829
}
@@ -1910,17 +1906,22 @@ pub mod wrap_verifier {
19101906
};
19111907
(x, y)
19121908
})
1913-
.reduce(|mut acc, v| {
1914-
acc.0 = Affine::from(acc.0 + v.0);
1915-
acc.1 = Affine::from(acc.1 + v.1);
1916-
acc
1917-
})
1918-
.unwrap();
1909+
.fold(
1910+
(Projective::default(), Projective::default()),
1911+
|mut acc, v| {
1912+
acc.0 += v.0;
1913+
acc.1 += v.1;
1914+
acc
1915+
},
1916+
);
19191917

19201918
w.exists([y.y, y.x]);
19211919
w.exists([x.y, x.x]);
19221920

1923-
(InnerCurve::of_affine(x), InnerCurve::of_affine(y))
1921+
(
1922+
InnerCurve::of_affine(Affine::from(x)),
1923+
InnerCurve::of_affine(Affine::from(y)),
1924+
)
19241925
};
19251926

19261927
// TODO: Hack until we have proper cvar :(

0 commit comments

Comments
 (0)