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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sha1
builtin
#3126
Add Sha1
builtin
#3126
Conversation
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.
Looks pretty straight forward to me.
For reference, To get them in base, you should submit a PR to it. The simplest way I know how to prepare that is to run |
Awesome, thanks @dfreeman ! Could you add yourself to CONTRIBUTORS.markdown and we'll get this merged! |
@dfreeman once this is merged you can add an alias to base or at least file a ticket at https://github.com/unisonweb/base so we don't lose track of adding it for the next release. But basically, for builtins like this, you can do what @dolio said above, or do -
Also you can create a doc called And then push that somewhere and open a ticket on base that says where to pull from. |
Done! Sorry for the delay. Once this is merged and I'm back home from traveling later this week I'll plan to open a ticket for base as well. Thanks for the guidance! |
@dfreeman sounds good, I created unisonweb/base#95 to track. |
Applied ready-to-merge, it should merge after CI completes. Thanks again @dfreeman! |
Overview
We discussed this briefly in Slack last weekend. While SHA-1 is a broken algorithm from a cryptographic perspective, it's still useful to have available for existing protocols that require its use (e.g. the WebSocket handshake).
Implementation notes
This introduces a new builtin
crypto.HashAlgorithm.Sha1
using the existingdeclareHashAlgorithm
machinery inparser-typechecker
.Interesting/controversial decisions
In principle there's no reason this couldn't be implemented in pure Unison (and in fact I did just that as an exercise), but that's likely significantly slower, and there's already a fairly established pattern of exposing well-known cryptographic primitives as builtins.
Test coverage
I've mirrored the transcript coverage that the other hash builtins have using test vectors from the same source as the existing ones.
Loose ends
I'm not 100% clear about the relationship between
.base
and.builtin
, and whether there are any additional steps necessary to integrate this. If so, I'd welcome guidance 馃檪