-
Notifications
You must be signed in to change notification settings - Fork 385
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
feat(stdlibs): import crypto/sha256 #580
Conversation
Hello @albttx, thx for you comment back on #570. I have question for this pr. https://github.com/gnolang/gno/blob/master/stdlibs/stdlibs.go#L159 What do you think?? |
In general, let's try being as close as possible; but I'm sure many good reasons will show that we could be different. Right now I suggest keeping both, the idiomatic way and std.Hash. I don't have enough feedback or feeling yet. |
And what do you think about adding at the same time sha256.New ? |
sha256.New is difficult... in stdlibs we want to limit the things to things that can be persisted, and native objects like Go's sha256.New cannot be persisted. So we would have to write a Gno sha256.Digest shim. But it seems like a lot compared to just exposing some helper methods without .New(), for now. |
This PR as is with Sha256() seems good though! |
rebased and fixed lint |
@gnolang/core-tech can this be merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging as this is also pretty much the same code-wise as std.Hash
... I did notice, however, that std.Hash
and sha256.Sum256
are not the same, because std.Hash
trims the result to 20 bytes (from 32).
Judging from the references it is mostly used a few times internally, but probably doesn't have a real purpose in real gno code. It may make sense to remove it. I'll make an issue to discuss that
All credit to @r3v4s and his PR #570
Description
Import function
Sum256
from packagecrypto/sha256
.My goal is to implement a merkle-airdrop contract, so i need Sum256 function.
How has this been tested?
see unit test
TestSha256Sum