Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add finalize_keccak to is_valid_eth_signature #542

Merged
merged 1 commit into from Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
add finalize_keccak
  • Loading branch information
andrew-fleming committed Jan 16, 2023
commit 6d4cb750478fca2fd916f73297632f899aca9299
10 changes: 8 additions & 2 deletions src/openzeppelin/account/library.cairo
Expand Up @@ -18,7 +18,10 @@ from starkware.starknet.common.syscalls import (
get_contract_address,
get_tx_info
)
from starkware.cairo.common.cairo_secp.signature import verify_eth_signature_uint256
from starkware.cairo.common.cairo_secp.signature import (
finalize_keccak,
verify_eth_signature_uint256
)
from openzeppelin.utils.constants.library import (
IACCOUNT_ID,
IERC165_ID,
Expand Down Expand Up @@ -157,13 +160,16 @@ namespace Account {
let (high, low) = split_felt(hash);
let msg_hash: Uint256 = Uint256(low=low, high=high);

let (local keccak_ptr: felt*) = alloc();
let (keccak_ptr: felt*) = alloc();
local keccak_ptr_start: felt* = keccak_ptr;

with keccak_ptr {
verify_eth_signature_uint256(
msg_hash=msg_hash, r=sig_r, s=sig_s, v=sig_v, eth_address=_public_key
);
}
// Required to ensure sequencers cannot spoof validation check.
finalize_keccak(keccak_ptr_start=keccak_ptr_start, keccak_ptr_end=keccak_ptr);

return (is_valid=TRUE);
}
Expand Down