Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
simplify result return
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Mar 7, 2024
1 parent 2ba34e6 commit b99172f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions crates/precompile/src/secp256r1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use reth::revm::precompile::{utilities::right_pad, Precompile, PrecompileWithAddress};
use revm_primitives::{Bytes, PrecompileError, PrecompileResult, StandardPrecompileFn};
use revm_primitives::{Bytes, PrecompileError, PrecompileResult, StandardPrecompileFn, B256};

/// EIP-7212 secp256r1 precompile.
pub const P256VERIFY: PrecompileWithAddress = PrecompileWithAddress(
Expand Down Expand Up @@ -31,15 +31,8 @@ fn p256_verify(i: &Bytes, target_gas: u64) -> PrecompileResult {
let signature: Signature = Signature::from_slice(sig).unwrap();
let public_key: VerifyingKey = VerifyingKey::from_sec1_bytes(&uncompressed_pk).unwrap();

let mut result = [0u8; 32];

// verify
if public_key.verify_prehash(msg, &signature).is_ok() {
result[31] = 0x01;
Ok((P256VERIFY_BASE, result.into()))
} else {
Ok((P256VERIFY_BASE, result.into()))
}
let result = public_key.verify_prehash(msg, &signature).is_ok();
Ok((P256VERIFY_BASE, B256::with_last_byte(result as u8).into()))
}

#[cfg(test)]
Expand Down

0 comments on commit b99172f

Please sign in to comment.