Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

In contract, how to verify signature which is created by eosjs-ecc sign('xx', wif) method? #4520

Closed
86chenjie opened this issue Jul 6, 2018 · 3 comments

Comments

@86chenjie
Copy link

I want to use a 'user' table in contract to store register users.
User create a key pair with eosjs libaray. The wif is in client side.
Client use the wif to create a signature. Now in the contract, i need to verify this signature is valid, pubKey is stored in 'user' table.
After some digging, i didn't found related api. Can anyone help me?

Thanks in advance!

@86chenjie 86chenjie changed the title In contract, how to verify signature which is created by eosjs-ecc sign() method with wif? In contract, how to verify signature which is created by eosjs-ecc sign('xx', wif) method? Jul 6, 2018
@86chenjie
Copy link
Author

@XuNeal sorry to bring you here. I noticed your answer in EOSIO/eosjs-ecc#20.
so i think you probably know the answer to my question.

After some digging, i think this is the method to do verify, but i don't know how to use it in contract.
https://github.com/ElementsProject/secp256k1-zkp/blob/8de58308d883360023d9f03f7e29d6539366ca4f/src/java/org/bitcoin/NativeSecp256k1.java#L434

Thanks in advance.

@eosbet-io
Copy link

Yes, I am looking for something similar to this. Like ecrecover() in solidity, where a user can sign data and submit to contract, and the contract verifies that the data was signed correctly. Is there anything like this in EOS?

@andriantolie
Copy link
Contributor

You can use either recover_key or assert_recover_key of the Crypto API (contracts/eosiolib/crypto.h)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants