Skip to content

Commit 4ff9ac0

Browse files
authored
chore: precompile bn128 copy (#1071)
1 parent 52c517c commit 4ff9ac0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/precompile/src/bn128.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ fn read_point(input: &[u8], pos: usize) -> Result<bn::G1, Error> {
118118
fn run_add(input: &[u8]) -> Result<Vec<u8>, Error> {
119119
use bn::AffineG1;
120120

121-
let mut input = input.to_vec();
122-
input.resize(ADD_INPUT_LEN, 0);
121+
let input = if input.len() < ADD_INPUT_LEN {
122+
let mut input = input.to_vec();
123+
input.resize(ADD_INPUT_LEN, 0);
124+
input
125+
} else {
126+
input[..ADD_INPUT_LEN].to_vec()
127+
};
123128

124129
let p1 = read_point(&input, 0)?;
125130
let p2 = read_point(&input, 64)?;

0 commit comments

Comments
 (0)