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

[Core] rename hasher #3651

Merged
merged 6 commits into from
Jan 7, 2025
Merged

[Core] rename hasher #3651

merged 6 commits into from
Jan 7, 2025

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 1, 2025

Description

As is pointed out by @Hecate2 and @cschuchardt88 #3633 (comment), the name Hasher is ambiguous and improper, thus having this pr to rename it to HashAlgorithmType.

Fixes # #3633 (comment)

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

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


namespace Neo.Cryptography
{
public enum HashAlgorithmType : byte
Copy link
Contributor

Choose a reason for hiding this comment

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

HashAlgorithm is better?

@Hecate2
Copy link
Contributor

Hecate2 commented Jan 2, 2025

public enum HashAlgorithm : byte is better, yet current changes are also good. Maybe it's better to handle the names in EcRecover PR (later) as well.

Hecate2
Hecate2 previously approved these changes Jan 2, 2025
Copy link
Contributor

@Hecate2 Hecate2 left a comment

Choose a reason for hiding this comment

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

Merge master into this?


namespace Neo.Cryptography
{
public enum HashAlgorithm : byte
Copy link
Contributor

@nan01ab nan01ab Jan 2, 2025

Choose a reason for hiding this comment

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

Maybe add an implicit operator here(it converts Hasher to HashAlgorithm)?

/// <returns>The ECDSA signature for the specified message.</returns>
public static byte[] Sign(byte[] message, byte[] priKey, ECC.ECCurve ecCurve = null, Hasher hasher = Hasher.SHA256)
public static byte[] Sign(byte[] message, byte[] priKey, ECC.ECCurve ecCurve = null, HashAlgorithm hashAlgorithm = HashAlgorithm.SHA256)
Copy link
Member

Choose a reason for hiding this comment

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

Only change the argument name for obsolete?

namespace Neo.Cryptography
{
/// <summary>
/// Represents hash function identifiers supported by ECDSA message signature and verification.
/// </summary>
[Obsolete("Use HashAlgorithm instead")]
Copy link
Member

Choose a reason for hiding this comment

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

I prefer rename the enum instead of duplicate all the methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have to, those methods are public, previously our principle is duplicate a new one and obsolete old one before remove it, at least previouly we deal with public methods that way.

@NGDAdmin NGDAdmin merged commit 02c5f3a into neo-project:master Jan 7, 2025
7 checks passed
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.

6 participants