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

Runtime sha256 should work for arbitrary strings even with length >= 128 #1056

Open
anton-trunov opened this issue Nov 18, 2024 · 3 comments
Labels
bug Something isn't working or isn't right scope: builtins
Milestone

Comments

@anton-trunov
Copy link
Member

anton-trunov commented Nov 18, 2024

sha256 at run-time uses the SHA256U TVM instruction, which only works with data with up to 1023 bits, so strings of length 128 bytes basically get truncated. This is confusing for smart-contract authors because it breaks the abstraction of the String type. Since we allow strings with more than 127 characters, those sha256 should work on those.

See also, #1085

@anton-trunov anton-trunov added bug Something isn't working or isn't right scope: builtins labels Nov 18, 2024
@anton-trunov anton-trunov added this to the v1.6.0 milestone Nov 18, 2024
@novusnota
Copy link
Member

novusnota commented Nov 18, 2024

The statically known strings is one story, where we can accurately compute their hashes with sha256_sync() no matter their length. And FunC can do the same with their "..."H string. But the run-time strings is a different case.

Do you mean to check the length of the string at runtime somehow?

@anton-trunov
Copy link
Member Author

Do you mean to check the length of the string at runtime somehow?

the implementation should traverse all the chunks of the string

@anton-trunov
Copy link
Member Author

related issue: #1085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or isn't right scope: builtins
Projects
None yet
Development

No branches or pull requests

2 participants