Skip to content

Commit c6ec473

Browse files
authored
chore: fix clippy (#109)
* make rust infer the types * fix clippy
1 parent 51a4bec commit c6ec473

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

bindings/java/rust_code/src/errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rust_eth_kzg::Error as DASError;
1+
use rust_eth_kzg::Error as KZGError;
22

33
#[derive(Debug)]
44
pub enum Error {
@@ -8,7 +8,7 @@ pub enum Error {
88
got: usize,
99
name: &'static str,
1010
},
11-
DASError(DASError),
11+
Cryptography(KZGError),
1212
}
1313

1414
impl From<jni::errors::Error> for Error {
@@ -17,8 +17,8 @@ impl From<jni::errors::Error> for Error {
1717
}
1818
}
1919

20-
impl From<DASError> for Error {
21-
fn from(err: DASError) -> Self {
22-
Error::DASError(err)
20+
impl From<KZGError> for Error {
21+
fn from(err: KZGError) -> Self {
22+
Error::Cryptography(err)
2323
}
2424
}

bindings/java/rust_code/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn verify_cell_kzg_proof_batch<'local>(
149149
) {
150150
Ok(_) => Ok(jboolean::from(true)),
151151
Err(x) if x.invalid_proof() => Ok(jboolean::from(false)),
152-
Err(err) => Err(Error::DASError(err)),
152+
Err(err) => Err(Error::Cryptography(err)),
153153
}
154154
}
155155

@@ -291,7 +291,7 @@ fn throw_on_error(env: &mut JNIEnv, err: Error, func_name: &'static str) {
291291
got,
292292
name,
293293
} => format!("{name} is not the correct size. expected: {expected}\ngot: {got}"),
294-
Error::DASError(err) => format!("{:?}", err),
294+
Error::Cryptography(err) => format!("{:?}", err),
295295
};
296296
let msg = format!(
297297
"function {} has thrown an exception, with reason: {}",

cryptography/kzg_multi_open/src/fk20/verifier.rs

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl FK20Verifier {
192192
/// Efficiently refers to being able to verify these proofs faster than verifying each proof individually.
193193
///
194194
/// The matching function in the spec is: https://github.com/ethereum/consensus-specs/blob/b9e7b031b5f2c18d76143007ea779a32b5505155/specs/_features/eip7594/polynomial-commitments-sampling.md#compute_verify_cell_kzg_proof_batch_challenge
195+
#[allow(clippy::manual_slice_size_calculation)]
195196
fn compute_fiat_shamir_challenge(
196197
opening_key: &OpeningKey,
197198
row_commitments: &[G1Point],

eip7594/src/serialization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ pub(crate) fn deserialize_cell_to_scalars(
4545
}
4646

4747
pub(crate) fn deserialize_scalar(scalar_bytes: &[u8]) -> Result<Scalar, SerializationError> {
48-
let bytes32 : [u8;BYTES_PER_FIELD_ELEMENT]= scalar_bytes.try_into().expect("infallible: expected blob chunks to be exactly {SCALAR_SERIALIZED_SIZE} bytes, since blob was a multiple of {SCALAR_SERIALIZED_SIZE");
48+
let bytes32 = scalar_bytes.try_into().expect("infallible: expected blob chunks to be exactly {SCALAR_SERIALIZED_SIZE} bytes, since blob was a multiple of {SCALAR_SERIALIZED_SIZE");
4949

5050
// Convert the CtOption into Option
51-
let option_scalar: Option<Scalar> = Scalar::from_bytes_be(&bytes32).into();
51+
let option_scalar: Option<Scalar> = Scalar::from_bytes_be(bytes32).into();
5252
match option_scalar {
5353
Some(scalar) => Ok(scalar),
5454
None => Err(SerializationError::CouldNotDeserializeScalar {
@@ -58,7 +58,7 @@ pub(crate) fn deserialize_scalar(scalar_bytes: &[u8]) -> Result<Scalar, Serializ
5858
}
5959

6060
pub(crate) fn deserialize_compressed_g1(point_bytes: &[u8]) -> Result<G1Point, SerializationError> {
61-
let point_bytes: [u8; BYTES_PER_G1_POINT] = match point_bytes.try_into() {
61+
let point_bytes = match point_bytes.try_into() {
6262
Ok(bytes) => bytes,
6363
Err(_) => {
6464
return Err(SerializationError::G1PointHasInvalidLength {
@@ -68,7 +68,7 @@ pub(crate) fn deserialize_compressed_g1(point_bytes: &[u8]) -> Result<G1Point, S
6868
}
6969
};
7070

71-
let opt_g1: Option<G1Point> = Option::from(G1Point::from_compressed(&point_bytes));
71+
let opt_g1: Option<G1Point> = Option::from(G1Point::from_compressed(point_bytes));
7272
opt_g1.ok_or(SerializationError::CouldNotDeserializeG1Point {
7373
bytes: point_bytes.to_vec(),
7474
})

0 commit comments

Comments
 (0)