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

EC Recover #3696

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

EC Recover #3696

wants to merge 9 commits into from

Conversation

shargon
Copy link
Member

@shargon shargon commented Jan 24, 2025

Description

Close #3628
Alternative to #3633

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Crypto tests

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@shargon shargon mentioned this pull request Jan 24, 2025
15 tasks
@shargon shargon marked this pull request as ready for review January 24, 2025 09:12
@shargon
Copy link
Member Author

shargon commented Jan 24, 2025

@neo-project/core Please take special look into HashAlgorithm.None I think that is well implemented and it can't produce a state difference in other places

@shargon shargon requested a review from Jim8y January 26, 2025 10:11
/// <param name="hashAlgorithm">The hash algorithm to be used hash the message.</param>
/// <returns>The recovered public key in compressed format, or null if recovery fails.</returns>
[ContractMethod(Hardfork.HF_Echidna, CpuFee = 1 << 10, Name = "recoverSecp256K1")]
public static byte[] RecoverSecp256K1(byte[] message, byte[] signature, HashAlgorithm hashAlgorithm)
Copy link
Contributor

@Jim8y Jim8y Jan 27, 2025

Choose a reason for hiding this comment

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

@shargon Hi shagon, i think what we should handle is passing the hash and signature, since the message sometimes require special format to be hashed which is not possible to be handled by our native contract, such as keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)) . So we should leave the hash thing to the costum contract.

Copy link
Member Author

Choose a reason for hiding this comment

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

HasAlgoritm.None is allowed

Copy link

Choose a reason for hiding this comment

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

@Jim8y Check this recent conversation #3696 (comment).

Copy link

Choose a reason for hiding this comment

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

Maybe Jimmy's input could be taken as a hint that the current function signature might be misleading if one is not aware of HashAlgorithm.None.

I'm not strongly opinionated on this, but it might be better to just remove the HashAlgorithm parameter from the function signature. Then, it might be more clear that all the function does - as its name says - is recover the public key.

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.

Recover Public Key from Signature for Secp256k1
3 participants