Skip to content

Commit 81b65dd

Browse files
authored
nit: remove unnecessary call to into_u256() for bn128 add (bluealloy#1239)
* nit: remove unnecessary call to into_u256() for bn128 add * Rename out to output
1 parent 020c6ff commit 81b65dd

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

crates/precompile/src/bn128.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,9 @@ pub fn run_add(input: &[u8]) -> Result<Bytes, Error> {
145145

146146
let mut output = [0u8; 64];
147147
if let Some(sum) = AffineG1::from_jacobian(p1 + p2) {
148-
sum.x()
149-
.into_u256()
150-
.to_big_endian(&mut output[..32])
151-
.unwrap();
152-
sum.y()
153-
.into_u256()
154-
.to_big_endian(&mut output[32..])
155-
.unwrap();
148+
sum.x().to_big_endian(&mut output[..32]).unwrap();
149+
sum.y().to_big_endian(&mut output[32..]).unwrap();
156150
}
157-
158151
Ok(output.into())
159152
}
160153

@@ -166,12 +159,12 @@ pub fn run_mul(input: &[u8]) -> Result<Bytes, Error> {
166159
// `Fr::from_slice` can only fail when the length is not 32.
167160
let fr = bn::Fr::from_slice(&input[64..96]).unwrap();
168161

169-
let mut out = [0u8; 64];
162+
let mut output = [0u8; 64];
170163
if let Some(mul) = AffineG1::from_jacobian(p * fr) {
171-
mul.x().to_big_endian(&mut out[..32]).unwrap();
172-
mul.y().to_big_endian(&mut out[32..]).unwrap();
164+
mul.x().to_big_endian(&mut output[..32]).unwrap();
165+
mul.y().to_big_endian(&mut output[32..]).unwrap();
173166
}
174-
Ok(out.into())
167+
Ok(output.into())
175168
}
176169

177170
pub fn run_pair(

0 commit comments

Comments
 (0)