Skip to content

fix a bug relating non hex string #651

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

schaier-io
Copy link
Contributor

Thank you for contributing to Mesh! We appreciate your effort and dedication to improving this project. To ensure that your contribution is in line with the project's guidelines and can be reviewed efficiently, please fill out the template below.

Remember to follow our Contributing Guide before submitting your pull request.

Summary

Please provide a brief, concise summary of the changes in your pull request. Explain the problem you are trying to solve and the solution you have implemented.
The current version of MeshJs, signData and checkSignature implementation specifies to accept any data (string). It does not throw any errors, leading to a problem when signing the string "XYZ" to instead sign an empty string. This happens because the Buffer decoding, will just take any valid characters and discard the rest. This leads to a problem where The signed data "XYZ" will verify a signature check for "UVW" or any other non hex string.

This solution will check if the data is already hex encoded (to maintain backwards compatability) and otherwise auto encode the string into the hex format.

Possible other solutions would be to update the documentation to only allow hex strings for either function and throwing an error otherwise.

Affect components

Please indicate which part of the Mesh Repo

  • @meshsdk/common
  • @meshsdk/contract
  • @meshsdk/core
  • @meshsdk/core-csl
  • @meshsdk/core-cst
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • Added a helper function isHexString into common lib.
  • Implemented the fix into checkSignatureand signData

Please mark the relevant option(s) for your pull request:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project)

Related Issues

Please add the related issue here if any

Checklist

Please ensure that your pull request meets the following criteria:

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build)

Additional Information

If you have any additional information or context to provide, such as screenshots, relevant issues, or other details, please include them here.

Copy link

vercel bot commented Jun 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mesh-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 10, 2025 0:40am

Copy link

vercel bot commented Jun 10, 2025

@schaier-io is attempting to deploy a commit to the MeshJS Team on Vercel.

A member of the Team first needs to authorize it.

@twwu123 twwu123 merged commit 13b1292 into MeshJS:main Jun 11, 2025
3 of 4 checks passed
@twwu123 twwu123 mentioned this pull request Jun 11, 2025
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

Successfully merging this pull request may close these issues.

2 participants