Skip to content

Commit

Permalink
Clippy: be friendly with
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Mar 8, 2024
1 parent 2e14bd2 commit 5acc2a2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion kimchi/src/circuits/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<
}

// for public gates, only the left wire is toggled
if row < self.cs.public && gate.coeffs.get(0) != Some(&F::one()) {
if row < self.cs.public && gate.coeffs.first() != Some(&F::one()) {
return Err(GateError::IncorrectPublic(row));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn compute_ffadd_values<F: PrimeField>(
/// opcode: true for addition, false for subtraction
/// modulus: modulus of the foreign field
pub fn create_chain<F: PrimeField>(
inputs: &Vec<BigUint>,
inputs: &[BigUint],
opcodes: &[FFOps],
modulus: BigUint,
) -> [Vec<F>; COLUMNS] {
Expand Down
12 changes: 6 additions & 6 deletions kimchi/src/tests/foreign_field_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn full_circuit<F: PrimeField + SquareRootField>(

// Creates the witness with the public input for FFAdd containing the 1 value
fn short_witness<F: PrimeField>(
inputs: &Vec<BigUint>,
inputs: &[BigUint],
opcodes: &[FFOps],
modulus: BigUint,
) -> [Vec<F>; COLUMNS] {
Expand All @@ -278,7 +278,7 @@ fn short_witness<F: PrimeField>(
// opcode: true for addition, false for subtraction
// modulus: modulus of the foreign field
fn long_witness<F: PrimeField>(
inputs: &Vec<BigUint>,
inputs: &[BigUint],
opcodes: &[FFOps],
modulus: BigUint,
) -> [Vec<F>; COLUMNS] {
Expand Down Expand Up @@ -1401,7 +1401,7 @@ where

// Compute addition witness
let witness = short_witness(
&vec![left_input, right_input],
&[left_input, right_input],
&[FFOps::Add],
foreign_field_modulus.clone(),
);
Expand Down Expand Up @@ -1476,7 +1476,7 @@ fn test_ffadd_finalization() {
let left = modulus.clone() - BigUint::one();
let right = modulus.clone() - BigUint::one();
// create a chain of 1 addition
let add_witness = witness::create_chain::<Fp>(&vec![left, right], operation, modulus);
let add_witness = witness::create_chain::<Fp>(&[left, right], operation, modulus);
for col in 0..COLUMNS {
witness[col].extend(add_witness[col].iter());
}
Expand Down Expand Up @@ -1548,7 +1548,7 @@ fn test_gate_invalid_foreign_field_modulus() {
#[test]
fn test_witness_max_foreign_field_modulus() {
short_witness::<PallasField>(
&vec![BigUint::zero(), BigUint::zero()],
&[BigUint::zero(), BigUint::zero()],
&[FFOps::Add],
BigUint::max_foreign_field_modulus::<PallasField>(),
);
Expand All @@ -1558,7 +1558,7 @@ fn test_witness_max_foreign_field_modulus() {
#[should_panic]
fn test_witness_invalid_foreign_field_modulus() {
short_witness::<PallasField>(
&vec![BigUint::zero(), BigUint::zero()],
&[BigUint::zero(), BigUint::zero()],
&[FFOps::Add],
BigUint::max_foreign_field_modulus::<PallasField>() + BigUint::one(),
);
Expand Down
4 changes: 2 additions & 2 deletions msm/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn prove<
>(
domain: EvaluationDomains<G::ScalarField>,
srs: &OpeningProof::SRS,
constraints: &Vec<MSMExpr<G::ScalarField>>,
constraints: &[MSMExpr<G::ScalarField>],
inputs: ProofInputs<N, G, ID>,
rng: &mut RNG,
) -> Result<Proof<N, G, OpeningProof>, ProverError>
Expand Down Expand Up @@ -205,7 +205,7 @@ where
}

let combined_expr =
Expr::combine_constraints(0..(constraints.len() as u32), constraints.clone());
Expr::combine_constraints(0..(constraints.len() as u32), constraints.to_owned());

// An evaluation of our expression E(vec X) on witness columns
// Every witness column w_i(X) is evaluated first at D1, so we get E(vec w_i(X)) = 0?
Expand Down
8 changes: 5 additions & 3 deletions msm/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn verify<
>(
domain: EvaluationDomains<G::ScalarField>,
srs: &OpeningProof::SRS,
constraint_exprs: &Vec<MSMExpr<G::ScalarField>>,
constraint_exprs: &[MSMExpr<G::ScalarField>],
proof: &Proof<N, G, OpeningProof>,
) -> bool {
let Proof {
Expand Down Expand Up @@ -155,8 +155,10 @@ pub fn verify<
zk_rows: 0,
};

let combined_expr =
Expr::combine_constraints(0..(constraint_exprs.len() as u32), constraint_exprs.clone());
let combined_expr = Expr::combine_constraints(
0..(constraint_exprs.len() as u32),
constraint_exprs.to_owned(),
);
let ft_eval0 = -PolishToken::evaluate(
combined_expr.to_polish().as_slice(),
domain.d1,
Expand Down
58 changes: 29 additions & 29 deletions optimism/src/cannon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,35 @@ impl Meta {
}
}

pub const HINT_CLIENT_READ_FD: i32 = 3;
pub const HINT_CLIENT_WRITE_FD: i32 = 4;
pub const PREIMAGE_CLIENT_READ_FD: i32 = 5;
pub const PREIMAGE_CLIENT_WRITE_FD: i32 = 6;

pub struct Preimage(Vec<u8>);

impl Preimage {
pub fn create(v: Vec<u8>) -> Self {
Preimage(v)
}

pub fn get(self) -> Vec<u8> {
self.0
}
}

pub struct Hint(Vec<u8>);

impl Hint {
pub fn create(v: Vec<u8>) -> Self {
Hint(v)
}

pub fn get(self) -> Vec<u8> {
self.0
}
}

#[cfg(test)]
mod tests {

Expand Down Expand Up @@ -456,32 +485,3 @@ mod tests {
assert!(PreimageKey::from_str("0x01").is_err());
}
}

pub const HINT_CLIENT_READ_FD: i32 = 3;
pub const HINT_CLIENT_WRITE_FD: i32 = 4;
pub const PREIMAGE_CLIENT_READ_FD: i32 = 5;
pub const PREIMAGE_CLIENT_WRITE_FD: i32 = 6;

pub struct Preimage(Vec<u8>);

impl Preimage {
pub fn create(v: Vec<u8>) -> Self {
Preimage(v)
}

pub fn get(self) -> Vec<u8> {
self.0
}
}

pub struct Hint(Vec<u8>);

impl Hint {
pub fn create(v: Vec<u8>) -> Self {
Hint(v)
}

pub fn get(self) -> Vec<u8> {
self.0
}
}
2 changes: 1 addition & 1 deletion poly-commitment/src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ pub fn combine_commitments<G: CommitmentCurve>(
}

pub fn combine_evaluations<G: CommitmentCurve>(
evaluations: &Vec<Evaluation<G>>,
evaluations: &[Evaluation<G>],
polyscale: G::ScalarField,
) -> Vec<G::ScalarField> {
let mut xi_i = G::ScalarField::one();
Expand Down
8 changes: 4 additions & 4 deletions poly-commitment/src/pairing_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ impl<
}
pub fn verify(
&self,
srs: &PairingSRS<Pair>, // SRS
evaluations: &Vec<Evaluation<G>>, // commitments to the polynomials
polyscale: F, // scaling factor for polynoms
elm: &[F], // vector of evaluation points
srs: &PairingSRS<Pair>, // SRS
evaluations: &[Evaluation<G>], // commitments to the polynomials
polyscale: F, // scaling factor for polynoms
elm: &[F], // vector of evaluation points
) -> bool {
let poly_commitment = {
let mut scalars: Vec<F> = Vec::new();
Expand Down
4 changes: 1 addition & 3 deletions utils/src/field_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ pub trait FieldHelpers<F> {
where
F: PrimeField,
{
big.clone()
.into()
.map_err(|_| FieldHelpersError::DeserializeBytes)
F::from_biguint(big).map_err(|_| FieldHelpersError::DeserializeBytes)
}

/// Serialize to bytes
Expand Down

0 comments on commit 5acc2a2

Please sign in to comment.