-
Notifications
You must be signed in to change notification settings - Fork 347
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
Suggestion: add UUID library support and an api to generate sha1 digest #2119
Conversation
bd5aa4a
to
937c19e
Compare
CI fails because of adding a new API. |
Thanks for the PR, but after discussing it internally a bit, we think that we don't want to add hash functions to the API interface. The points essentially boil down to:
Also WASM code execution is rather quick, so the need to add native functions, especially for digests such as SHA-1, isn't as pressing as with other VMs. As a suggestion for your use-case, if the gas cost for SHA-1 is too high, you could use RNGs such as LCG, WyRand, Mersenne Twister, etc. to stretch an input to the length you need. |
@aumetra Thank you for considering and kindly replying. I understand that you will not add hash functions and I agree with the reason. I close this issue. Thank you! |
This PR suggests adding UUID library support to package/std.
UUID is useful for managing something in gaming contracts or collection contracts, especially corporate with external servers or services.
This UUID generation uses UUID v5 for deterministic generation and the seed message for sha1 is concatenated bytes of contract address, block height, and an incremental number saved in the contract storage.
UUID v5 uses sha1 internally, and this PR suggests adding an API to calculate sha1 digests.
This API takes a little shorter time and a little cheaper gas to generate a UUID than calculating a digest in WASM native operators.
If the message size gets longer, it gets much faster and takes much cheaper gas than calculating with WASM native.
If this suggestion looks good (even if only the sha1 part), I will modify the gas cost after taking a benchmark with circle CI. (It looks like it is not usable circle ci bench workflow in my GitHub repo)
Only the sha1 part is merged, I will publish the uuid feature in my repository.