Fix the pedantic lints (2)
MODIFY
kimchi/src/proof.rs
kimchi/src/proof.rs
@@ -101,6 +101,7 @@ pub struct ProverCommitments<G: AffineCurve> {
#[serde_as]
#[derive(Clone, Serialize, Deserialize)]
#[serde(bound = "G: ark_serialize::CanonicalDeserialize + ark_serialize::CanonicalSerialize")]
+#[allow(clippy::module_name_repetitions)]
pub struct ProverProof<G: AffineCurve> {
/// All the polynomial commitments required in the proof
pub commitments: ProverCommitments<G>,

MODIFY
kimchi/src/prover.rs
kimchi/src/prover.rs
@@ -114,7 +114,7 @@ impl<G: KimchiCurve> ProverProof<G>
where
G::BaseField: PrimeField,
{
- /// This function constructs prover's zk-proof from the witness & the ProverIndex against SRS instance
+ /// This function constructs prover's zk-proof from the witness & the `ProverIndex` against SRS instance
pub fn create<
EFqSponge: Clone + FqSponge<G::BaseField, G, G::ScalarField>,
EFrSponge: FrSponge<G::ScalarField>,
@@ -134,7 +134,8 @@ where
)
}
- /// This function constructs prover's recursive zk-proof from the witness & the ProverIndex against SRS instance
+ /// This function constructs prover's recursive zk-proof from the witness & the `ProverIndex` against SRS instance
+ #[allow(clippy::needless_pass_by_value, clippy::too_many_lines)]
pub fn create_recursive<
EFqSponge: Clone + FqSponge<G::BaseField, G, G::ScalarField>,
EFrSponge: FrSponge<G::ScalarField>,
@@ -583,7 +584,10 @@ where
let lagrange = index.cs.evaluate(&witness_poly, &z_poly);
let env = {
let mut index_evals = HashMap::new();
- use GateType::*;
+ use GateType::{
+ ChaCha0, ChaCha1, ChaCha2, ChaChaFinal, CompleteAdd, EndoMul, EndoMulScalar,
+ Poseidon, VarBaseMul,
+ };
index_evals.insert(Poseidon, &index.cs.ps8);
index_evals.insert(CompleteAdd, &index.cs.complete_addl4);
index_evals.insert(VarBaseMul, &index.cs.mull8);

MODIFY
kimchi/src/prover_index.rs
kimchi/src/prover_index.rs
-//! This module implements the prover index as [ProverIndex].
+//! This module implements the prover index as [`ProverIndex`].
use crate::{
alphas::Alphas,
circuits::{
constraints::ConstraintSystem,
expr::{Linearization, PolishToken},
- wires::*,
+ wires::PERMUTS,
},
curve::KimchiCurve,
linearization::expr_linearization,
@@ -137,7 +137,7 @@ impl<G: KimchiCurve> ProverIndex<G> {
}
pub mod testing {
- use super::*;
+ use super::{Arc, ConstraintSystem, EvaluationDomain, FqSponge, ProverIndex, SRS};
use crate::circuits::{
gate::CircuitGate,
lookup::{runtime_tables::RuntimeTableCfg, tables::LookupTable},
@@ -145,6 +145,7 @@ pub mod testing {
use commitment_dlog::srs::endos;
use mina_curves::pasta::{pallas::Pallas, vesta::Vesta, Fp};
+ #[must_use]
pub fn new_index_for_test_with_lookups(
gates: Vec<CircuitGate<Fp>>,
public: usize,
@@ -167,6 +168,7 @@ pub mod testing {
let (endo_q, _endo_r) = endos::<Pallas>();
ProverIndex::<Vesta>::create(cs, endo_q, srs)
}
+ #[must_use]
pub fn new_index_for_test(gates: Vec<CircuitGate<Fp>>, public: usize) -> ProverIndex<Vesta> {
new_index_for_test_with_lookups(gates, public, 0, vec![], None)
}

MODIFY
kimchi/src/snarky/constraint_system.rs
kimchi/src/snarky/constraint_system.rs
@@ -88,7 +88,7 @@ impl<Field: PrimeField> GateSpec<usize, Field> {
let wires: Vec<_> = wired_to
.into_iter()
.take(PERMUTS)
- .map(|x| x.to_rust_wire())
+ .map(Position::to_rust_wire)
.collect();
CircuitGate {
typ: kind,
@@ -147,9 +147,9 @@ pub enum BasicSnarkyConstraint<Var> {
R1CS(Var, Var, Var),
}
-/** A PLONK constraint (or gate) can be [Basic](KimchiConstraint::Basic), [Poseidon](KimchiConstraint::Poseidon),
- * [EcAddComplete](KimchiConstraint::EcAddComplete), [EcScale](KimchiConstraint::EcScale),
- * [EcEndoscale](KimchiConstraint::EcEndoscale), or [EcEndoscalar](KimchiConstraint::EcEndoscalar). */
+/** A PLONK constraint (or gate) can be [`Basic`](KimchiConstraint::Basic), [`Poseidon`](KimchiConstraint::Poseidon),
+ * [`EcAddComplete`](KimchiConstraint::EcAddComplete), [`EcScale`](KimchiConstraint::EcScale),
+ * [`EcEndoscale`](KimchiConstraint::EcEndoscale), or [`EcEndoscalar`](KimchiConstraint::EcEndoscalar). */
pub enum KimchiConstraint<Var, Field> {
Basic {
l: (Field, Var),
@@ -212,6 +212,7 @@ enum Circuit<Field, RustGates> {
}
/** The constraint system. */
+#[allow(clippy::module_name_repetitions)]
pub struct SnarkyConstraintSystem<Field, RustGates>
where
Field: ark_ff::Field,
@@ -257,7 +258,7 @@ where
}
impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field, Gates> {
- /** Converts the set of permutations (equivalence_classes) to
+ /** Converts the set of permutations (`equivalence_classes`) to
a hash table that maps each position to the next one.
For example, if one of the equivalence class is [pos1, pos3, pos7],
the function will return a hashtable that maps pos1 to pos3,
@@ -287,6 +288,9 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
/** Compute the witness, given the constraint system `sys`
and a function that converts the indexed secret inputs to their concrete values.
*/
+ /// # Panics
+ ///
+ /// Will panic if some inputs like `public_input_size` are unknown(None value).
pub fn compute_witness<F: Fn(usize) -> Field>(&self, external_values: F) -> Vec<Vec<Field>> {
let mut internal_values = HashMap::new();
let public_input_size = self.public_input_size.unwrap();
@@ -330,7 +334,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
}
fn union_find(&mut self, value: V) {
- self.union_finds.make_set(value)
+ self.union_finds.make_set(value);
}
fn create_internal(&mut self, constant: Option<Field>, lc: Vec<(Field, V)>) -> V {
@@ -365,18 +369,21 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
}
/** Returns the number of public inputs. */
+ /// # Panics
+ ///
+ /// Will panic if `public_input_size` is None.
pub fn get_primary_input_size(&self) -> usize {
self.public_input_size.unwrap()
}
/** Non-public part of the witness. */
pub fn set_auxiliary_input_size(&mut self, x: usize) {
- self.auxiliary_input_size = x
+ self.auxiliary_input_size = x;
}
/** Sets the number of public-input. It should only be called once. */
pub fn set_public_input_size(&mut self, x: usize) {
- self.public_input_size = Some(x)
+ self.public_input_size = Some(x);
}
/** Adds {row; col} to the system's wiring under a specific key.
@@ -388,12 +395,12 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
self.equivalence_classes
.entry(key)
.or_insert_with(Vec::new)
- .push(Position { row, col })
+ .push(Position { row, col });
}
/** Same as wire', except that the row must be given relatively to the end of the public-input rows. */
fn wire(&mut self, key: V, row: usize, col: usize) {
- self.wire_(key, Row::AfterPublicInput(row), col)
+ self.wire_(key, Row::AfterPublicInput(row), col);
}
/** Adds a row/gate/constraint to a constraint system `sys`. */
@@ -423,6 +430,11 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
self.rows.push(vars);
}
+ /// Fill the `gate` values(input and output), and finalize the `circuit`.
+ ///
+ /// # Panics
+ ///
+ /// Will panic if `circuit` is completed.
pub fn finalize(&mut self) {
// if it's already finalized, return early
if matches!(self.gates, Circuit::Compiled(..)) {
@@ -439,7 +451,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
// get gates without holding on an immutable reference
let gates = match std::mem::replace(&mut self.gates, Circuit::Unfinalized(vec![])) {
Circuit::Unfinalized(gates) => gates,
- _ => panic!("we expect the gates to be unfinalized"),
+ Circuit::Compiled(_, _) => panic!("we expect the gates to be unfinalized"),
};
/* Create rows for public input. */
@@ -503,7 +515,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
/* convert all the gates into our Gates.t Rust vector type */
let mut rust_gates = Gates::create();
let mut add_gates = |gates: Vec<_>| {
- for gate in gates.into_iter() {
+ for gate in gates {
let g = to_absolute_row(gate);
rust_gates.add(g.to_rust_gate());
}
@@ -518,7 +530,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
self.finalize();
match &mut self.gates {
Circuit::Compiled(_, gates) => gates,
- _ => unreachable!(),
+ Circuit::Unfinalized(_) => unreachable!(),
}
}
}
@@ -534,7 +546,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
*/
fn accumulate_terms<Field: PrimeField>(terms: Vec<(Field, usize)>) -> HashMap<usize, Field> {
let mut acc = HashMap::new();
- for (x, i) in terms.into_iter() {
+ for (x, i) in terms {
match acc.entry(i) {
std::collections::hash_map::Entry::Occupied(mut entry) => {
let res = x + entry.get();
@@ -560,6 +572,7 @@ pub trait SnarkyCvar: Clone {
fn to_constant_and_terms(&self) -> (Option<Self::Field>, Vec<(Self::Field, usize)>);
}
+#[allow(clippy::needless_pass_by_value)]
pub fn canonicalize<Cvar>(x: Cvar) -> Option<(Vec<(Cvar::Field, usize)>, usize, bool)>
where
Cvar: SnarkyCvar,
@@ -606,7 +619,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
}
}
- /** Converts a number of scaled additions \sum s_i * x_i
+ /** Converts a number of scaled additions \sum `s_i` * `x_i`
to as many constraints as needed,
creating temporary variables for each new row/constraint,
and returning the output variable.
@@ -654,6 +667,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
It returns the output variable as (1, `Var res),
unless the output is a constant, in which case it returns (c, `Constant).
*/
+ #[allow(clippy::needless_pass_by_value)]
fn reduce_lincom<Cvar>(&mut self, x: Cvar) -> (Field, ConstantOrVar)
where
Cvar: SnarkyCvar<Field = Field>,
@@ -758,6 +772,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
}
}
+ #[allow(clippy::too_many_lines)]
pub fn add_basic_snarky_constraint<Cvar>(&mut self, constraint: BasicSnarkyConstraint<Cvar>)
where
Cvar: SnarkyCvar<Field = Field>,
@@ -775,7 +790,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
Some(xl),
Some(xo),
vec![Field::zero(), Field::zero(), -so, sl * sl, Field::zero()],
- )
+ );
}
((sl, ConstantOrVar::Var(xl)), (so, ConstantOrVar::Constant)) =>
/* TODO: it's hard to read the array of selector values, name them! */
@@ -785,7 +800,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
Some(xl),
None,
vec![Field::zero(), Field::zero(), Field::zero(), sl * sl, -so],
- )
+ );
}
((sl, ConstantOrVar::Constant), (so, ConstantOrVar::Var(xo))) =>
/* sl^2 = so * xo */
@@ -795,10 +810,10 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
None,
Some(xo),
vec![Field::zero(), Field::zero(), so, Field::zero(), -(sl * sl)],
- )
+ );
}
((sl, ConstantOrVar::Constant), (so, ConstantOrVar::Constant)) => {
- assert_eq!(sl * sl, so)
+ assert_eq!(sl * sl, so);
}
}
}
@@ -821,7 +836,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
Some(x2),
Some(x3),
vec![Field::zero(), Field::zero(), s3, (-s1) * s2, Field::zero()],
- )
+ );
}
(
(s1, ConstantOrVar::Var(x1)),
@@ -845,7 +860,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
None,
Some(x3),
vec![(s1 * s2), Field::zero(), -s3, Field::zero(), Field::zero()],
- )
+ );
}
(
(s1, ConstantOrVar::Constant),
@@ -910,7 +925,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
Field::one(),
Field::zero(),
],
- )
+ );
}
ConstantOrVar::Constant => assert_eq!(s, (s * s)),
}
@@ -925,7 +940,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
self.union_find(x1);
self.union_find(x2);
assert!(self.union_finds.union(x1, x2).is_ok());
- }
+ };
} else if
/* s1 x1 - s2 x2 = 0 */
s1 != s2 {
@@ -934,14 +949,14 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
Some(x2),
None,
vec![s1, -s2, Field::zero(), Field::zero(), Field::zero()],
- )
+ );
} else {
self.add_generic_constraint(
Some(x1),
Some(x2),
None,
vec![s1, -s2, Field::zero(), Field::zero(), Field::zero()],
- )
+ );
}
}
(ConstantOrVar::Var(x1), ConstantOrVar::Constant) => {
@@ -996,6 +1011,12 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
}
}
+ ///
+ ///
+ /// # Panics
+ ///
+ /// Will panic if `witness` fields are empty.
+ #[allow(clippy::too_many_lines)]
pub fn add_constraint<Cvar>(&mut self, constraint: KimchiConstraint<Cvar, Field>)
where
Cvar: SnarkyCvar<Field = Field>,
@@ -1058,7 +1079,7 @@ impl<Field: PrimeField, Gates: GateVector<Field>> SnarkyConstraintSystem<Field,
var(r),
var(o),
vec![coeff(l), coeff(r), coeff(o), m, c],
- )
+ );
}
// TODO: the code in circuit-writer was better
// TODO: also `rounds` would be a better name than `state`

MODIFY
kimchi/src/verifier.rs
kimchi/src/verifier.rs
@@ -9,7 +9,7 @@ use crate::{
lookup::{lookups::LookupsUsed, tables::combine_table},
polynomials::{generic, permutation},
scalars::RandomOracles,
- wires::*,
+ wires::{COLUMNS, PERMUTS},
},
curve::KimchiCurve,
error::VerifyError,
@@ -35,6 +35,7 @@ where
G::BaseField: PrimeField,
{
/// This function runs the random oracle argument
+ #[allow(clippy::too_many_lines)]
pub fn oracles<
EFqSponge: Clone + FqSponge<G::BaseField, G, G::ScalarField>,
EFrSponge: FrSponge<G::ScalarField>,
@@ -210,7 +211,9 @@ where
//~ 1. Evaluate the negated public polynomial (if present) at $\zeta$ and $\zeta\omega$.
//~
//~ NOTE: this works only in the case when the poly segment size is not smaller than that of the domain.
- let public_evals = if !self.public.is_empty() {
+ let public_evals = if self.public.is_empty() {
+ [vec![G::ScalarField::zero()], vec![G::ScalarField::zero()]]
+ } else {
[
vec![
(self
@@ -235,8 +238,6 @@ where
* (zetaw.pow(&[n as u64]) - G::ScalarField::one()),
],
]
- } else {
- [vec![G::ScalarField::zero()], vec![G::ScalarField::zero()]]
};
println!("verifier public eval: {:?}", public_evals);
@@ -299,10 +300,10 @@ where
.map(|(w, s)| (beta * s) + w + gamma)
.fold(init, |x, y| x * y);
- ft_eval0 -= if !public_evals[0].is_empty() {
- public_evals[0][0]
- } else {
+ ft_eval0 -= if public_evals[0].is_empty() {
G::ScalarField::zero()
+ } else {
+ public_evals[0][0]
};
ft_eval0 -= evals[0]
@@ -399,6 +400,7 @@ where
};
let oracles = RandomOracles {
+ joint_combiner,
beta,
gamma,
alpha_chal,
@@ -409,7 +411,6 @@ where
zeta_chal,
v_chal,
u_chal,
- joint_combiner,
};
Ok(OraclesResult {
@@ -427,6 +428,7 @@ where
}
}
+#[allow(clippy::too_many_lines)]
fn to_batch<'a, G, EFqSponge, EFrSponge>(
index: &VerifierIndex<G>,
proof: &'a ProverProof<G>,
@@ -553,15 +555,18 @@ where
PolishToken::evaluate(tokens, index.domain, oracles.zeta, &evals, &constants)
.expect("should evaluate");
- use Column::*;
+ use Column::{
+ Coefficient, Index, LookupAggreg, LookupKindIndex, LookupRuntimeSelector,
+ LookupRuntimeTable, LookupSorted, LookupTable, Witness, Z,
+ };
match col {
Witness(i) => {
scalars.push(scalar);
- commitments.push(&proof.commitments.w_comm[*i])
+ commitments.push(&proof.commitments.w_comm[*i]);
}
Coefficient(i) => {
scalars.push(scalar);
- commitments.push(&index.coefficients_comm[*i])
+ commitments.push(&index.coefficients_comm[*i]);
}
Z => {
scalars.push(scalar);
@@ -574,7 +579,7 @@ where
.as_ref()
.ok_or(VerifyError::LookupCommitmentMissing)?;
scalars.push(scalar);
- commitments.push(&lookup_coms.sorted[*i])
+ commitments.push(&lookup_coms.sorted[*i]);
}
LookupAggreg => {
let lookup_coms = proof
@@ -583,7 +588,7 @@ where
.as_ref()
.ok_or(VerifyError::LookupCommitmentMissing)?;
scalars.push(scalar);
- commitments.push(&lookup_coms.aggreg)
+ commitments.push(&lookup_coms.aggreg);
}
LookupKindIndex(i) => match index.lookup_index.as_ref() {
None => {
@@ -616,7 +621,11 @@ where
panic!("runtime lookup table is unused in the linearization")
}
Index(t) => {
- use GateType::*;
+ use GateType::{
+ CairoClaim, CairoFlags, CairoInstruction, CairoTransition, ChaCha0,
+ ChaCha1, ChaCha2, ChaChaFinal, CompleteAdd, EndoMul, EndoMulScalar,
+ Generic, Lookup, Poseidon, RangeCheck0, RangeCheck1, VarBaseMul, Zero,
+ };
let c = match t {
Zero | Generic | Lookup => {
panic!("Selector for {:?} not defined", t)
@@ -802,7 +811,7 @@ where
let joint_combiner = oracles
.joint_combiner
.expect("joint_combiner should be present if lookups are used");
- let table_id_combiner = joint_combiner.1.pow([li.max_joint_size as u64]);
+ let table_id_combiner = joint_combiner.1.pow([u64::from(li.max_joint_size)]);
let lookup_table: Vec<_> = li.lookup_table.iter().collect();
let runtime = lookup_comms.runtime.as_ref();
@@ -859,7 +868,7 @@ where
})
}
-/// Verify a proof [ProverProof] using a [VerifierIndex] and a `group_map`.
+/// Verify a proof [`ProverProof`] using a [`VerifierIndex`] and a `group_map`.
pub fn verify<G, EFqSponge, EFrSponge>(
group_map: &G::Map,
verifier_index: &VerifierIndex<G>,
@@ -877,7 +886,7 @@ where
/// This function verifies the batch of zk-proofs
/// proofs: vector of Plonk proofs
-/// index: VerifierIndex
+/// index: `VerifierIndex`
/// RETURN: verification status
pub fn batch_verify<G, EFqSponge, EFrSponge>(
group_map: &G::Map,
@@ -922,8 +931,9 @@ where
}
//~ 1. Use the [`PolyCom.verify`](#polynomial-commitments) to verify the partially evaluated proofs.
- match srs.verify::<EFqSponge, _>(group_map, &mut batch, &mut thread_rng()) {
- false => Err(VerifyError::OpenProof),
- true => Ok(()),
+ if srs.verify::<EFqSponge, _>(group_map, &mut batch, &mut thread_rng()) {
+ Ok(())
+ } else {
+ Err(VerifyError::OpenProof)
}
}

MODIFY
kimchi/src/verifier_index.rs
kimchi/src/verifier_index.rs
-//! This module implements the verifier index as [VerifierIndex].
-//! You can derive this struct from the [ProverIndex] struct.
+//! This module implements the verifier index as [`VerifierIndex`].
+//! You can derive this struct from the [`ProverIndex`] struct.
use crate::{
alphas::Alphas,
@@ -10,7 +10,7 @@ use crate::{
permutation::{zk_polynomial, zk_w3},
range_check,
},
- wires::*,
+ wires::{COLUMNS, PERMUTS},
},
curve::KimchiCurve,
error::VerifierIndexError,
@@ -37,6 +37,7 @@ use std::{
//~spec:startcode
#[serde_as]
#[derive(Serialize, Deserialize, Debug, Clone)]
+#[allow(clippy::module_name_repetitions)]
pub struct LookupVerifierIndex<G: CommitmentCurve> {
pub lookup_used: LookupsUsed,
#[serde(bound = "PolyComm<G>: Serialize + DeserializeOwned")]
@@ -139,7 +140,11 @@ pub struct VerifierIndex<G: KimchiCurve> {
//~spec:endcode
impl<G: KimchiCurve> ProverIndex<G> {
- /// Produces the [VerifierIndex] from the prover's [ProverIndex].
+ /// Produces the [`VerifierIndex`] from the prover's [`ProverIndex`].
+ ///
+ /// # Panics
+ ///
+ /// Will panic if `srs` cannot be in `cell`.
pub fn verifier_index(&self) -> VerifierIndex<G> {
if let Some(verifier_index) = &self.verifier_index {
return verifier_index.clone();
@@ -244,7 +249,7 @@ impl<G: KimchiCurve> ProverIndex<G> {
}
impl<G: KimchiCurve> VerifierIndex<G> {
- /// Gets srs from [VerifierIndex] lazily
+ /// Gets srs from [`VerifierIndex`] lazily
pub fn srs(&self) -> &Arc<SRS<G>>
where
G::BaseField: PrimeField,
@@ -256,17 +261,21 @@ impl<G: KimchiCurve> VerifierIndex<G> {
})
}
- /// Gets zkpm from [VerifierIndex] lazily
+ /// Gets zkpm from [`VerifierIndex`] lazily
pub fn zkpm(&self) -> &DensePolynomial<G::ScalarField> {
self.zkpm.get_or_init(|| zk_polynomial(self.domain))
}
- /// Gets w from [VerifierIndex] lazily
+ /// Gets w from [`VerifierIndex`] lazily
pub fn w(&self) -> &G::ScalarField {
self.w.get_or_init(|| zk_w3(self.domain))
}
- /// Deserializes a [VerifierIndex] from a file, given a pointer to an SRS and an optional offset in the file.
+ /// Deserializes a [`VerifierIndex`] from a file, given a pointer to an SRS and an optional offset in the file.
+ ///
+ /// # Errors
+ ///
+ /// Will give error if it fails to deserialize from file or unable to set `srs` in `verifier_index`.
pub fn from_file(
srs: Option<Arc<SRS<G>>>,
path: &Path,
@@ -288,10 +297,10 @@ impl<G: KimchiCurve> VerifierIndex<G> {
.map_err(|e| e.to_string())?;
// fill in the rest
- if srs.is_some() {
+ if let Some(srs) = srs {
verifier_index
.srs
- .set(srs.unwrap())
+ .set(srs)
.map_err(|_| VerifierIndexError::SRSHasBeenSet.to_string())?;
};

Fix the pedantic lints (2)