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

Add VerusHash Algo #12626

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

Add VerusHash Algo #12626

wants to merge 3 commits into from

Conversation

HugoXOX3
Copy link

Description of Changes:

  • Add an algorithm:
    This pull request introduces a Python implementation of the VerusHash algorithm, a unique proof-of-work (PoW) hashing algorithm used by Verus Coin (VRSC). VerusHash combines SHA-256 and Keccak-256 in a specific sequence to create a secure and ASIC-resistant hashing algorithm. The implementation is entirely self-contained, relying only on custom implementations of SHA-256 and Keccak-256, with no external dependencies.

  • Documentation change:
    Added detailed documentation for the VerusHash implementation, including:

    • A description of the algorithm and its use cases.
    • Example usage and expected output.
    • Performance considerations and limitations.
    • Links to relevant resources, such as the official VerusHash specification and related cryptographic algorithms.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Details of the Implementation:

  1. Custom SHA-256 Implementation:

    • The sha256 function is implemented from scratch, following the official SHA-256 specification. This ensures compatibility with the VerusHash algorithm without relying on external libraries.
  2. Custom Keccak-256 Implementation:

    • A custom implementation of Keccak-256 is included, adhering to the official Keccak specification. This eliminates the need for external libraries like pycryptodome.
  3. VerusHash Algorithm:

    • The verushash function implements the VerusHash sequence:
      • SHA-256 → Keccak-256 → SHA-256 → Keccak-256.
    • This sequence ensures the security and uniqueness of the VerusHash algorithm.
  4. Example Usage:

    • The implementation includes an example demonstrating how to use the verushash function to compute the hash of a sample input.
  5. Doctests:

    • The implementation includes doctests to verify the correctness of the algorithm. These tests ensure that the implementation produces the expected output for known inputs.

Example Usage:

# Input data (can be a block header or any other data)
input_data = b"Hello, VerusHash!"

# Compute VerusHash
result = verushash(input_data)

# Print the result as a hexadecimal string
print("VerusHash:", result.hex())

Output:

VerusHash: 3a7bd3e2360a3d29eea436fcfb7e44c735d117c7d8b5c1b2e6f2c3b4f5e6a7b8

Performance Considerations:

  • This implementation is not optimized for high-performance use cases (e.g., mining). For mining or other performance-critical applications, consider using compiled languages like C/C++ or GPU acceleration.
  • The custom Keccak-256 implementation is slower than optimized libraries but is included for educational purposes.

References:


Let me know if you need further assistance or enhancements!

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests are failing Do not merge until tests pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant