Stream: API design

Topic: `Crypt.Sha256` submodule in std lib


view this post on Zulip Sam Mohr (Sep 11 2024 at 19:53):

We don't yet have submodules in the standard library, but looking at this SHA-256 PR more and more, I'm becoming convinced that as we extend the module further, it would be better to have a Crypt.Sha256 module with empty, addBytes, and digest functions instead of sha256Empty, sha256AddBytes, and sha256Digest. I expect we'll be adding other Crypt types, like Argon2 or Sha1 or something at some point.

view this post on Zulip Sam Mohr (Sep 11 2024 at 19:54):

Is anyone opposed to this? Otherwise, I think we can still merge the above PR, and then migrate to the above design once we implement submodules in builtins, which don't exist yet.

view this post on Zulip Richard Feldman (Sep 11 2024 at 19:55):

I'd like to merge as-is and discuss options

view this post on Zulip Sam Mohr (Sep 11 2024 at 19:55):

Same

view this post on Zulip Luke Boswell (Sep 11 2024 at 20:56):

Aside, can we call it crypto instead of the shorter crypt. I think of a stone room below a church everytime someone mentions that. :upside_down:

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:06):

I'm not seeing a GitHub issue linked or at all that decided on the name. I'm okay with either, but I guess Crypt less implies Crypto like the currency

view this post on Zulip Richard Feldman (Sep 11 2024 at 21:06):

but do you think of Bitcoin when you think of Crypto? :stuck_out_tongue:

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:06):

But I don't think that's a strong reason?

view this post on Zulip Richard Feldman (Sep 11 2024 at 21:06):

it's not like Cryp or Cry are good either :laughing:

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:07):

Cipher? Math? Hash?

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:07):

Hash should be dedicated to a derive IMO for HashMaps

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:08):

Hacker :keyboard: :rabbit:

view this post on Zulip Richard Feldman (Sep 11 2024 at 21:08):

hm, we already have a Hash module :thinking:

view this post on Zulip Richard Feldman (Sep 11 2024 at 21:09):

could it make sense to have all the cryptography stuff in there?

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:09):

Probably misleading?

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:10):

I think we're doing that to avoid negative association with cryptocurrency lol

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:12):

aka I'm voting for Crypto

view this post on Zulip Brendan Hansknecht (Sep 11 2024 at 21:34):

Hash and CryptoHash. I think they should at least split the namespace somehow. Cause if you don't want someone to accidentally use a regular hash for a cryptographic purpose.

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:35):

Well, I'd vote Crypto.Hash

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:35):

Or even just Crypto.Sha256

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:37):

Unless we change submodule imports to make the unqualified submodule available, import Crypto.Hash.Sha256 would mean you'd need to do Crypto.Hash.Sha256.addBytes [...]

view this post on Zulip Sam Mohr (Sep 11 2024 at 21:37):

Pretty verbose

view this post on Zulip Luke Boswell (Sep 11 2024 at 22:08):

Richard Feldman said:

but do you think of Bitcoin when you think of Crypto? :stuck_out_tongue:

I definitely don't, but maybe I'm too old. I think of https://en.wikipedia.org/wiki/Cryptography and stories like the code breakers from WWII

view this post on Zulip Jasper Woudenberg (Sep 11 2024 at 22:21):

CryptoLikeWorldWar2CryptoButModern.Sha256 :stuck_out_tongue:

view this post on Zulip Luke Boswell (Sep 11 2024 at 22:37):

#notcurrency

view this post on Zulip Kilian Vounckx (Sep 12 2024 at 08:20):

I'm 24 and don't think of cryptocurrency at all. But maybe that is because I'm doing a security major at university

view this post on Zulip Oskar Hahn (Sep 12 2024 at 08:35):

In zig, the package is called crypto. In Go, its also called crypto. The Javascript Web API is called crypto. Maybe this is a common term :smile:

view this post on Zulip Sam Mohr (Sep 12 2024 at 20:26):

@Matthew Heath heads up, this is a discussion pertaining to your module/PR. Any thoughts?

view this post on Zulip Agus Zubiaga (Sep 13 2024 at 12:20):

What about Cryptography? I don’t mind the length

view this post on Zulip Sam Mohr (Sep 13 2024 at 16:41):

I also don't mind the length, but since we've been pushing for qualified function-aware naming, as we expect people to do Dict.insert without exposing the insert function, we have been pushing for concise module names

view this post on Zulip Richard Feldman (Sep 13 2024 at 17:28):

yeah I guess Crypto is fine

view this post on Zulip Richard Feldman (Sep 13 2024 at 17:28):

but I'd like to avoid introducing a dot in the name

view this post on Zulip Richard Feldman (Sep 13 2024 at 17:29):

we don't have that for any builtins and I don't think now is the time to change that

view this post on Zulip Richard Feldman (Sep 13 2024 at 17:29):

we can always revisit later

view this post on Zulip Sam Mohr (Sep 13 2024 at 17:30):

Then I can make a second PR later to change the name. This'll be on Sunday, in case we change our mind on the name

view this post on Zulip Richard Feldman (Feb 06 2025 at 19:52):

interesting note about crypto in Go: https://news.ycombinator.com/item?id=42965770

view this post on Zulip Richard Feldman (Feb 06 2025 at 19:53):

apparently "Microsoft Go" is a fork of Go just to make crypto FIPS 140-2 compliant: (I have no idea what that entails)

This repository produces a modified version of Go that can be used to build FIPS 140-2 compliant applications. Our goal is to share this implementation with others in the Go community who have the same requirement, and to merge this capability into upstream Go as soon as possible.


Last updated: Jul 06 2025 at 12:14 UTC