Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

restore verify_eth_signature #783

Merged
merged 1 commit into from
Apr 19, 2024
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
13 changes: 12 additions & 1 deletion crates/contracts/src/cairo1_helpers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub trait IHelpers<T> {
self: @T, words: Array<u64>, last_input_word: u64, last_input_num_bytes: usize
) -> u256;

fn verify_eth_signature(
self: @T, msg_hash: u256, signature: Signature, eth_address: EthAddress
);

/// Recovers the Ethereum address from a message hash and a signature.
///
/// # Arguments
Expand All @@ -76,7 +80,7 @@ mod embeddable_impls {
use evm::precompiles::modexp::ModExp;
use evm::precompiles::sha256::Sha256;
use starknet::EthAddress;
use starknet::eth_signature::{Signature, public_key_point_to_eth_address};
use starknet::eth_signature::{Signature, verify_eth_signature, public_key_point_to_eth_address};
use starknet::secp256_trait::{recover_public_key};
use starknet::secp256k1::Secp256k1Point;
use utils::helpers::U256Trait;
Expand Down Expand Up @@ -117,6 +121,13 @@ mod embeddable_impls {
cairo_keccak(ref words, last_input_word, last_input_num_bytes).reverse_endianness()
}


fn verify_eth_signature(
self: @TContractState, msg_hash: u256, signature: Signature, eth_address: EthAddress
) {
verify_eth_signature(msg_hash, signature, eth_address);
}

fn recover_eth_address(
self: @TContractState, msg_hash: u256, signature: Signature
) -> EthAddress {
Expand Down
Loading