How can I derive BigInt3/EcPoints from an ethereum public key and signature?

Recently @liorgold published a cairo-examples/secp at master · starkware-libs/cairo-examples · GitHub which introduces support to the ECDSA signature verification over the secp256k1 elliptic curve. I am trying to use the code but I am still strugling with what should be the way to transform the public key into an EcPoint and r, s into BigInt3

Can someone give me an example of how to transform this?


    message: 'Some data',
    messageHash: '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655',
    v: '0x1c',
    r: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd',
    s: '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029',
    signature: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c'
    public_key: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23'
43 Likes

Hey I am sorry, I have been busy lately but I saw your message. Will update asap. Did you manage to move forward?
Thanks!

19 Likes

Thanks for your reply @henri.lieutaud ! No not yet. we are still working on it! It would be great if you could provide any insights/examples!

16 Likes

The repo actually contains two examples -

Cairo example
StarkNet example

Let me know if you have any more questions after looking at them

18 Likes

@bbrandtom My question is not on how to use the code but rather on how to prepare the data and transform the public key into an EcPoint and the r,s into BigInt3.

16 Likes

I think I found the answer! I was casually reading some of Cairo source code and I stumbled upon this :smiley: I will test it out and write my findings cairo-lang/secp_utils.py at master · starkware-libs/cairo-lang · GitHub

13 Likes

Hey, great to read! Do post your comments later on, thanks!

13 Likes

Hey @0xwalid Did you manage to test that out?
Could you share your findings here?
I appreciate it in advance.

10 Likes

You just need to partition a felt into 3 parts containing 86 bits.
Here’s a method that transforms Uint256 into BigInt3, it should show you how to do it using bit masks web3-account/recover.cairo at 57e563f3664cdb16fdf5fcf129590c483d272328 · software-mansion-labs/web3-account · GitHub

13 Likes