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

crypto: add explicit base58 prefix check #53

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

emturner
Copy link
Collaborator

Previously, hashes could accidentally be parsed with an incorrect hash
type, provided:

  • the lengths of the encoded were the same
  • the lengths of the base58 prefixes were the same

This would manifest, for example, by the following succeeding:
ContractTz1Hash::from_base58check("tz4FENGt5zkiGaHPm1ya4MgLomgkL1k7Dy7q")

This will now return
Err(FromBase58CheckError::IncorrectBase58Prefix) instead.

@emturner emturner added the bug Something isn't working label Dec 13, 2023
Previously, hashes could accidentally be parsed with an incorrect hash
type, provided:
- the lengths of the encoded were the same
- the lengths of the base58 prefixes were the same

This would manifest, for example, by the following succeeding:
`ContractTz1Hash::from_base58check("tz4FENGt5zkiGaHPm1ya4MgLomgkL1k7Dy7q")`

This will now return
`Err(FromBase58CheckError::IncorrectBase58Prefix)` instead.
@emturner emturner force-pushed the emturner@base58-prefix-check branch from e94ba98 to 169f0ae Compare December 13, 2023 15:28
@victor-dumitrescu
Copy link

LGTM, fixes the bug!

@emturner emturner merged commit caefa03 into master Dec 13, 2023
7 checks passed
@emturner emturner deleted the emturner@base58-prefix-check branch December 13, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants