Skip to content
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
12 changes: 6 additions & 6 deletions crates/precompile/src/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ pub fn run(input: &Bytes, gas_limit: u64) -> PrecompileResult {
return Err(Error::Blake2WrongLength.into());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this check also would go below gas check, and then gas check would have to handle empty input...


let f = match input[212] {
1 => true,
0 => false,
_ => return Err(Error::Blake2WrongFinalIndicatorFlag.into()),
};

// rounds 4 bytes
let rounds = u32::from_be_bytes(input[..4].try_into().unwrap()) as usize;
let gas_used = rounds as u64 * F_ROUND;
if gas_used > gas_limit {
return Err(Error::OutOfGas.into());
}

let f = match input[212] {
1 => true,
0 => false,
_ => return Err(Error::Blake2WrongFinalIndicatorFlag.into()),
};

let mut h = [0u64; 8];
let mut m = [0u64; 16];

Expand Down