Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Argent siwe signature validation error #1443

Open
1 task done
MickaelNeves opened this issue Aug 2, 2023 · 7 comments
Open
1 task done

[bug] Argent siwe signature validation error #1443

MickaelNeves opened this issue Aug 2, 2023 · 7 comments

Comments

@MickaelNeves
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

RainbowKit Version

^1.0.6

wagmi Version

^1.3.9

Current Behavior

I can't verify my account. I'm using WalletConnect + Argent Wallet and when the signature modal pops up to send a message, I accept it in Argent wallet, but in the modal I get the message "Error verifying signature, please retry!". After debugging using breakpoints (cause the try/catch error is not handled btw) I found that im getting the error "No matching key. keychain"

Expected Behavior

Excepted to sign the message and connect my wallet

Steps To Reproduce

1 - visit www.botto.com
2 - connect wallet
3 - choose walletconnect or argent wallet
4 - follow the steps until reaching the sign modal

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

Screenshot 2023-08-02 at 11 04 31

@DanielSinclair
Copy link
Contributor

@MickaelNeves I believe this caused by the version of next-auth that you have adopted. Please use 4.20.1 or earlier. A bug/API change was introduced in later versions, and we will have a package upgrade soon to support those versions. This will be described in release notes. Let me know if that resolves your issue.

@DanielSinclair
Copy link
Contributor

Have released @rainbow-me/[email protected] to support more recent versions of next-auth. Let me know if that resolves your issue. Reference the Migration Guide

@MickaelNeves
Copy link
Author

I'm not using next-auth @DanielSinclair , these are the ones:

  • @rainbow-me/rainbowkit: "^1.0.6"
  • siwe: "^2.1.4"
  • viem: "^1.3.0"
  • wagmi: "^1.3.9"

and this is my adapter

`const authenticationAdapter = createAuthenticationAdapter({
getNonce: async () => {
const url = URL_FOR_NONCE
const response = await request({ url })

  return response.nonce
},

createMessage: ({ nonce, address, chainId }) => {
  return new SiweMessage({
    domain: window.location.host,
    address,
    statement: `You are about to sign this message.\nThe signature is: ${nonce}`,
    uri: window.location.origin,
    version: '1',
    chainId,
    nonce,
  })
},

getMessageBody: ({ message }) => {
  return message.prepareMessage()
},

verify: async ({ message, signature }) => {
  verifyingRef.current = true

  try {
    // request to fetch JWT
    const response = await request({......})

    if (!response.jwt) {
      setAuthStatus('unauthenticated')
      return false
    }

    const user = {
      account: response.data.address,
      token: response.jwt,
    } as User
    const updatedAccounts = addOrReplaceAccount(userAccounts, user)

    setCookie(LOCALSTORAGE_ITEMS.AuthToken, response.jwt)
    setUserAccounts(updatedAccounts)
    setCurrentAccount(user.account)
    setAuthStatus('authenticated')
    Sentry.setUser({ id: user.account })
    handleOnboarding(user.account)

    return true
  } catch (error) {
    setAuthStatus('unauthenticated')

    return false
  } finally {
    verifyingRef.current = false
  }
},

signOut: async () => {
  setAuthStatus('unauthenticated')
  deleteCookie(LOCALSTORAGE_ITEMS.AuthToken)
  Sentry.setUser(null)
},

})`

@DanielSinclair DanielSinclair reopened this Aug 3, 2023
@MickaelNeves
Copy link
Author

other wallets work fine,for example WalletConnect + MetaMask, but WalletConnect + Argent or just the Argent adapter does not seem to work

@DanielSinclair
Copy link
Contributor

I see. The No matching key. keychain error is actually a WalletConnect error that (unfortunately) still fires from their libraries. But this sounds like an Argent specific problem. I was able to replicate. Are you using Argent Vault by chance?

@MickaelNeves
Copy link
Author

I think so. I dont use this wallet, this error was reported from users that interact with our website, so what I did was just installing Argent on my phone, top up ETH account to activate and scan the WalletConnect QR

@DanielSinclair DanielSinclair changed the title [bug] No matching key. keychain: [bug] Argent siwe signature validation error Aug 3, 2023
@eliezerbasubi
Copy link

@MickaelNeves, have you considered adding the 0x prefix to the signature before verifying it?

Upon reviewing the signature in the images of your console, it's evident that the signature lacks the 0x prefix. Some wallets may be overlooking the necessity of adding this prefix to the signature, leading to errors in the verify method.

I encountered a similar problem with Trust Wallet, where both siwe and eth typed data signatures failed to work due to the absence of the 0x prefix.

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

No branches or pull requests

3 participants