-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Builtin SHA256 hashing #6977
base: main
Are you sure you want to change the base?
Builtin SHA256 hashing #6977
Conversation
@MatthewJohnHeath I tried to push to your branch but I got permission denied. Made a PR in case that helps. |
Hi Luke,
Sorry I'm slow to respond. I've been travelling. There are definitely some
problems on the branch; it builds but then in the REPL the functions seem
to be missing (although triggering a different error to *actually*
non-existent function names). I created the initial PR mostly in order to
get feedback on what might be wring (I was also expecting to be able to get
more time online these couple of weeks).
I think I am going to need some help to get it working.
…On Wed, 14 Aug 2024 at 02:26, Luke Boswell ***@***.***> wrote:
@MatthewJohnHeath <https://github.com/MatthewJohnHeath> I tried to push
to your branch but I got permission denied. Made a PR in case that helps.
—
Reply to this email directly, view it on GitHub
<#6977 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZKVQQ7LL7GIFEDIJSQHBTZRKW3PAVCNFSM6AAAAABMI4AGLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBXGY2TMNZVHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Matthew Heath <http://mattheath.wordpress.com>
|
344ac11
to
4da18e6
Compare
The shape of this PR is a good start, but I'm seeing a potential issue if we add other cryptographic code to this module, which would be quite unsurprising. You have |
Otherwise, I'm attempting to get things running |
Okay, I'm almost done getting this working, just need to coordinate the Zig and Roc builtin types. |
The REPL worked for me! We'll still need some tests, but it should be good to go, above comments notwithstanding. |
Also, there's no code currently to extract state from the new |
I was thinking of (only) having the type implement |
If I want to store the hash for future comparison. Not that using SHA-256 would be recommended over Argon2, but the idea holds. There are a few algorithms out there that use SHA-256 digest bytes for computation (Wikipedia), at least UUID v5 uses SHA-1 in that way. |
f7fc408
to
c9ab4e5
Compare
Tests are currently failing. @MatthewJohnHeath do you have time to implement the above fixes any time soon? If not, I can help, but it's your PR, so I'll defer to you. |
@smores56 It's not really clear to me why the build is hanging (which seems to be what is happening). I will try a few things, but might need to ask for help |
@smores56 It's building now. Hopefully I can do those last 2 renamings of functions you asked for tomorrow. |
b2f8ca2
to
fcee861
Compare
If this gets through the tests, would it be to merge and then do docs and tests? Or do those need to be there first? |
It's always preferable to do at least testing, but ideally also docs, in the same PR. We'd usually avoid them if they're going to make the PR too big, or if they're blocking us merging an important change/bug fix. Since it's neither of those, I'd prefer if we can get them in this change. I'm happy to help with either the tests or docs! |
29db7e0
to
aada47b
Compare
Sha256 := { location : U64 } | ||
|
||
## Represents the digest of soem data produced by the SHA256 cryptographic hashing function as an opaque type. | ||
## `Digest256`implements the `Eq` ability. |
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.
nitpick: Digest256
(space)implements ...
also, consider adding an empty doc comment between these two doc comments, that'll follow the "one-line summary on top, context beneath" structure for docs.
Digest256 := { firstHalf : U128, secondHalf : U128 } implements [Eq] | ||
|
||
## Returns a `Sha256` to which no data have been added. | ||
emptySha256 : {} -> Sha256 |
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.
I'd recommend "An empty SHA-256 digest."
And it's "to which no data has been added." https://www.thesaurus.com/e/grammar/data-is-or-data-are/
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.
The word shouldn't be "digest", I think. We should save that for the Digest256
returned after "finalize" has been called on the zig object.
I am struggling to find a good term to describe what the Sha256
object does. My mental model of it is as the state of the algorithm, but that doesn't seem useful wording here. Something like "An empty SHA-256 hasher", maybe?
I agree that data (EDIT)is in this context; I've had too much time in settings where I get corrected the other way.
import Result | ||
import Str | ||
|
||
## Represents, as an opaque type, the state of a SHA256 cryptographic hashing function, after some (or no) data have been added to the hash. |
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.
nitpick: it being an opaque type is implied, I don't think we need to explicitly mention that here.
This reverts commit 77b9223.
So I made progress on running things. Tests are running for the builtins, and there is some LLVM issue I'll have to investigate tomorrow:
|
I've been distracted, but I'll be looking at this again today. I might have to ask for help from @bhansconnect since I'm not much of an LLVM guy, which seems to be the last issue here. Needless to say, @MatthewJohnHeath there's nothing left that you need to do on this PR. If you have any changes you want to make, feel free, but otherwise I'm planning on merging as soon as I fix the LLVM issue. |
Signed-off-by: Sam Mohr <[email protected]>
Expose the functionality of Zig's
std.crypto.hash.sha2.Sha256
through a pure-functional interface to Roc.