-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! BLS12-381 precompile with input size limits for Optimism. | ||
use precompile::{ | ||
bls12_381, {PrecompileError, PrecompileResult, PrecompileWithAddress}, | ||
}; | ||
use primitives::Bytes; | ||
|
||
pub mod pair { | ||
use super::*; | ||
|
||
pub const ISTHMUS_MAX_INPUT_SIZE: usize = 235008; | ||
pub const ISTHMUS: PrecompileWithAddress = | ||
PrecompileWithAddress(precompile::u64_to_address(bls12_381::pairing::ADDRESS), |input, gas_limit| { | ||
run_pair(input, gas_limit) | ||
}); | ||
|
||
pub fn run_pair(input: &[u8], gas_limit: u64) -> PrecompileResult { | ||
if input.len() > ISTHMUS_MAX_INPUT_SIZE { | ||
return Err(PrecompileError::Other( | ||
"BLS12-381 pairing input is too large".into(), | ||
).into()); | ||
} | ||
let input = Bytes::copy_from_slice(input); | ||
bls12_381::pairing::pairing( | ||
&input, | ||
gas_limit, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters