cryptonerdcn / wasm-cairo

A suite of development tools and a WASM-Runtime environment for Cairo. All based on WebAssembly. By Caironautes, for Caironautes.
https://wasm-cairo-landing.vercel.app/
Apache License 2.0
53 stars 13 forks source link

Unable to find eth_signature from starknet #13

Open Bisht13 opened 10 months ago

Bisht13 commented 10 months ago

On trying to compile the code below,

use core::traits::Into;
use core::array::ArrayTrait;
use core::keccak;
use core::option::OptionTrait;
use core::starknet::SyscallResultTrait;
use starknet::{EthAddress,secp256k1::{secp256k1_new_syscall},eth_signature::public_key_point_to_eth_address};

fn proof(txn_hash: u256, final_hash: u256) {
    let public_key = secp256k1_new_syscall(0x643285cb1513659e8a634ea5d74c2180b2549edce3083e2906aa1c88c918ae4c, 0x6e0086f3d9ff7e443a9d275e0c5e14e3904dd5d4937bad9d7a8e03d6e38b9ef9).unwrap_syscall().unwrap();
    let address = public_key_point_to_eth_address(public_key);
    let mut hash_arr = ArrayTrait::<u256>::new();
    hash_arr.append(address.address.into());
    hash_arr.append(txn_hash);
    let cal_final_hash = keccak::keccak_u256s_be_inputs(hash_arr.span());
    assert(cal_final_hash == final_hash, 'Invalid final hash');
}

fn main() {
    let txn_hash = 0x1;
    let final_hash: u256 = 0xf52437fd0c9b08a5c208b7bfd82ad37120702db8e69608b03242d9d61e3cf2f1;
    proof(txn_hash, final_hash);
}

The following error is showing,

error: Identifier not found.
 --> astro.cairo:6:62
use starknet::{EthAddress,secp256k1::{secp256k1_new_syscall},eth_signature::public_key_point_to_eth_address};
                                                             ^***********^
cryptonerdcn commented 9 months ago

Confirmed. I can reproduce this on https://astro-editor.netlify.app/ Very strange. I will check it.