Get the sui address that signed a message off-chain, on chain with sui move code

This is a question from the Suinami Riders group (Telegram)

Hi guys I’m looking for an example to get the sui address which sign the message in an off chain client and get address on chain with move code. I have tried the “ecrecover” from the “ecdsa_k1" Sui module, but not able to get a valid public key.

7 Likes

what hash function are you using when signing? also which sui version you are using?

on the latest release, the method is called ecdsa_k1::secp256k1_ecrecover

note that you need to pass in the raw message (not after its hashed) and the same hash function you used when signing the message.

here is an example sui/ecdsa_k1_tests.move at main · MystenLabs/sui · GitHub

2 Likes