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

fix: solve wrong response for account.verifyMessage #895

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

PhilippeR26
Copy link
Collaborator

Motivation and Resolution

implement issue #858 about wrong answers of account.verifyMessage()
See issue for details.

Usage related changes

Breaking change : the result myAccount.verifyMessage(typedMessage, signature) is no more a boolean. It's now :

type SignatureVerifResult = {
  isVerificationProcessed: boolean;
  isSignatureValid?: boolean;
  error?: Error;
};

Example of usage :

const myAccount = new Account(provider, accountAddress, "0x0123"); // fake private key
const result = await myAccount.verifyMessage(typedMessage, signature);
if (result.isVerificationProcessed) {
    console.log("Result (boolean) =", result.isSignatureValid);
} else {
    console.log("verification failed :", result.error);
}

Development related changes

There is no standard in Starknet for Cairo IsValidSignature account function response.

  • OpenZeppelin 0.5.0 (cairo 0) and 0.8.0 (Cairo 2.3.1) are responding 0 in case of wrong signature.
  • ArgentX 0.3.0 (Cairo 2.0.0) is reverting with a specific message.
  • Same thing for Braavos (Cairo 0), with a different message.

The code is adapted in accordance.

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing (in beta 3)

src/account/default.ts Outdated Show resolved Hide resolved
src/account/default.ts Outdated Show resolved Hide resolved
@PhilippeR26 PhilippeR26 marked this pull request as ready for review January 17, 2024 11:08
Copy link
Collaborator

@tabaktoni tabaktoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good for now,
we can rethink-update support for C. Acc later on.

@tabaktoni tabaktoni merged commit 1c0f7d2 into starknet-io:beta Jan 23, 2024
3 checks passed
Copy link

🎉 This PR is included in version 6.0.0-beta.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Feb 5, 2024

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Jul 3, 2024

🎉 This issue has been resolved in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants