Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nit: remove unnecessary call to into_u256() for bn128 add #1239

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions crates/precompile/src/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,9 @@ pub fn run_add(input: &[u8]) -> Result<Bytes, Error> {

let mut output = [0u8; 64];
if let Some(sum) = AffineG1::from_jacobian(p1 + p2) {
sum.x()
.into_u256()
.to_big_endian(&mut output[..32])
.unwrap();
sum.y()
.into_u256()
.to_big_endian(&mut output[32..])
.unwrap();
sum.x().to_big_endian(&mut output[..32]).unwrap();
sum.y().to_big_endian(&mut output[32..]).unwrap();
}

Ok(output.into())
}

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

let mut out = [0u8; 64];
let mut output = [0u8; 64];
if let Some(mul) = AffineG1::from_jacobian(p * fr) {
mul.x().to_big_endian(&mut out[..32]).unwrap();
mul.y().to_big_endian(&mut out[32..]).unwrap();
mul.x().to_big_endian(&mut output[..32]).unwrap();
mul.y().to_big_endian(&mut output[32..]).unwrap();
}
Ok(out.into())
Ok(output.into())
}

pub fn run_pair(
Expand Down
Loading