Skip to content

Commit

Permalink
fix: rip-7212 implementation incorrect return value (#790)
Browse files Browse the repository at this point in the history
* fix: rip-7212 implementation incorrect return value

* fix type

---------

Co-authored-by: enitrat <msaug@protonmail.com>
  • Loading branch information
ulerdogan and enitrat authored May 6, 2024
1 parent af1a8db commit d7ea4af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/evm/src/precompiles/p256verify.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl P256Verify of Precompile {
let gas: u128 = P256VERIFY_PRECOMPILE_GAS_COST;

if input.len() != 160 {
return Result::Ok((gas, array![0].span()));
return Result::Ok((gas, array![].span()));
}

let message_hash = input.slice(0, 32);
Expand Down Expand Up @@ -59,7 +59,7 @@ impl P256Verify of Precompile {
};

if !is_valid_signature(message_hash, r, s, public_key) {
return Result::Ok((gas, array![0].span()));
return Result::Ok((gas, array![].span()));
}

return Result::Ok((gas, array![1].span()));
Expand Down
5 changes: 2 additions & 3 deletions crates/evm/src/tests/test_precompiles/test_p256verify.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ fn test_p256verify_precompile_input_too_short() {

let (gas, result) = P256Verify::exec(calldata.span()).unwrap();

let result: u256 = result.from_be_bytes().unwrap();
assert_eq!(result, 0x00);
assert_eq!(result, array![].span());
assert_eq!(gas, 3450);
}

Expand Down Expand Up @@ -117,5 +116,5 @@ fn test_p256verify_precompile_input_too_short_static_call() {
let mut result = Default::default();
vm.memory.load_n(0x1, ref result, 0x80);

assert_eq!(result, array![0x00]);
assert_eq!(result, array![0]);
}

0 comments on commit d7ea4af

Please sign in to comment.