# Is it possible to use verify\_ecdsa\_signature in cairo to verify a web3.js/wallet ecdsa signature?

**URL:** <https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338>\
**Category:** Support\
**Tags:** cryptography, cairo\
**Created:** [January 13, 2022, 10:55pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338 "2022-01-13T22:55:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xwalid](https://avatars.discourse-cdn.com/v4/letter/0/e19adc/32.png) [@0xwalid](https://community.starknet.io/u/0xwalid)\
**Post date:** [January 13, 2022, 10:55pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/1 "2022-01-13T22:55:55Z")

</div>

I am pretty new to Cairo and I am thinking of building a dApp that takes web3 wallet signatures and validate it in Cairo-based contract on Starknet.

When using web3.js, I can sign a message like this:

```auto
web3.eth.accounts.sign('Some data', '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318');
> {
    message: 'Some data',
    messageHash: '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655',
    v: '0x1c',
    r: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd',
    s: '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029',
    signature: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c'
}
// note public key is "0x2c7536E3605D9C16a7a3D7b1898e529396a65c23"

```

when I tried to use Cairo’s builtin `verify_ecdsa_signature`, It did not work (maybe I’m doing something wrong). It was failing at the line `assert ecdsa_ptr.pub_key = public_key`.

The way I tried to use `verify_ecdsa_signature` is by first converting all the hex values in the msg\_hash,r,s and public key to decimals. then call

```auto
    let (msg_hash) = hash2{hash_ptr=pedersen_ptr}(1539108943018361713761, 0)
    
    verify_ecdsa_signature(
        message=msg_hash,
        public_key=253809562540106565134163611412781682525957676067,
        signature_r=83713930994764734002432606962255364472443135907807238282514898577139886061053,
        signature_s=43435997768575461196683613590576722655951133545204789519877940758262837256233)

```

I have two questions here:  
1- Does it even make sense to do this in the first place? in another word is `verify_ecdsa_signature` secp256k1n compatible? if not (according to [Support Web3 wallets in StarkNet](https://community.starknet.io/t/support-web3-wallets-in-starknet/192)) then when is Starkware planning on releasing the ability to do this?  
2- If it does, then what’s going wrong here? and what am i supposed to do with the `v` value? as it’s part of the signature.

UPDATE: have you tried this? I found this example and might be what I’m looking for [cairo-examples/secp at master · starkware-libs/cairo-examples · GitHub](https://github.com/starkware-libs/cairo-examples/tree/master/secp) correct me if I am wrong  
Thanks!

---

<div class="post-metadata">

**Author:** ![martriay](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/martriay/32/25_2.png) [@martriay](https://community.starknet.io/u/martriay)\
**Post date:** [January 14, 2022, 2:39pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/2 "2022-01-14T14:39:01Z")

</div>

It’s not, that’s the StarkKey’s signing algorithm. Check [Support Web3 wallets in StarkNet](https://community.starknet.io/t/support-web3-wallets-in-starknet/192)

---

<div class="post-metadata">

**Author:** ![0xwalid](https://avatars.discourse-cdn.com/v4/letter/0/e19adc/32.png) [@0xwalid](https://community.starknet.io/u/0xwalid)\
**Post date:** [January 14, 2022, 7:41pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/4 "2022-01-14T19:41:38Z")

</div>

have you tried this? @martriay[cairo-examples/secp at master · starkware-libs/cairo-examples · GitHub](https://github.com/starkware-libs/cairo-examples/tree/master/secp)

---

<div class="post-metadata">

**Author:** ![martriay](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/martriay/32/25_2.png) [@martriay](https://community.starknet.io/u/martriay)\
**Post date:** [January 17, 2022, 3:48pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/5 "2022-01-17T15:48:21Z")

</div>

I haven’t, I didn’t know that was released!

---

<div class="post-metadata">

**Author:** ![martriay](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/martriay/32/25_2.png) [@martriay](https://community.starknet.io/u/martriay)\
**Post date:** [July 11, 2022, 3:55pm UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/6 "2022-07-11T15:55:49Z")

</div>

Note that [OpenZeppelin Contracts for Cairo v0.2.0](https://github.com/OpenZeppelin/cairo-contracts/releases/tag/v0.2.0) comes with an EthAccount contract!

---

<div class="post-metadata">

**Author:** ![intelliDean](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/intellidean/32/85686_2.png) [@intelliDean](https://community.starknet.io/u/intelliDean)\
**Post date:** [June 6, 2025, 10:16am UTC](https://community.starknet.io/t/is-it-possible-to-use-verify-ecdsa-signature-in-cairo-to-verify-a-web3-js-wallet-ecdsa-signature/338/7 "2025-06-06T10:16:54Z")

</div>

Hi @0xwalid, this is 2025 and I am having the same issue as you. How did you solve this problem eventually? If you did, do you have a better way to do it now. I need to verify a signature on my smar contract. thanks
