EOSCommunity.org Forums

Anchor Login: How can I verify the identity/signature on server?

Can I verify and Anchor Login Signature with ecc.verify()?
If so, where do I find the data used to sign the login request?

From the Anchor documentation: “The identity returned from the process of signing in a user contains a lot of useful information about the user, including their account information, signing key, and the parameters used to sign the request itself.

function login() {
    link.login(identifier).then((result) => {
       session = result.session;
       let signature = String(result.proof.signature);
       let publicKey = String(session.publicKey);
       let data = String(**result.?**);

       //Then I'll send parameters to server to run an identity check with ecc.verify
       if(ecc.verify(signature, data , publicKey) === true){
             //Identity is confirm on server and can return private data related to this account...      

If you’re using eosjs/ecc to try and do this, here’s a code sample in one of our demos from a while ago that shows the steps to do so. Hope these help!

We recently rewrote it to use some of our new helper methods in eosio-core (an eosjs replacement) that does the same thing, which can be found here:

Fantastic! Works like a charm. Thanks again.

1 Like