Skip to content

feat(rt): add sha1/sha256 to hash ns - #690

Merged
nnunley merged 1 commit into
nooga:mainfrom
abogoyavlensky:feat-hash-sha
Aug 7, 2026
Merged

feat(rt): add sha1/sha256 to hash ns#690
nnunley merged 1 commit into
nooga:mainfrom
abogoyavlensky:feat-hash-sha

Conversation

@abogoyavlensky

Copy link
Copy Markdown
Contributor

Resolves: #689

(hash/sha1 s) and (hash/sha256 s) return the lowercase hex digest of the string's bytes — the same hex sha1sum / sha256sum print. let-go strings are raw Go byte strings, so binary content (a jar slurped from disk) hashes correctly.

Motivation: dependency tooling built on let-go currently shells out to sha1sum/shasum to verify Maven artifact checksums.

pkg/rt/hash_sha.go carries no build tags — crypto/sha1 and crypto/sha256 are pure Go, so TinyGo/wasm builds get these too (unlike xxh3, which needs the murmur3 fallback). The installer seeds the hash namespace from Go and pkg/rt/core/hash.lg's (ns hash) extends it.

Tests in test/hash_sha_test.lg: empty and "abc" vectors for both, a multibyte literal pinned to real sha1sum/sha256sum output (proving byte- rather than rune-semantics), a spit/slurp round-trip, and arity/type rejection.

@mparrett mparrett left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Built it and confirmed that (ns hash) in hash.lg extends the Go-seeded namespace rather than replacing it: hash/sha1 and hash/xxh3-64 both resolve in the same build. Full suite green, and TestGeneratedArtifactsAreFresh passes with the regenerated .lgb and generated.sums. The no-build-tags claim holds — it builds for js/wasm, plan9/amd64, and linux/amd64.

No findings.

@nnunley

nnunley commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Heads up: this PR now conflicts with main after today's merges (#564, #647, #648, #650, #666, #688).

The conflict is entirely in generated artifacts — pkg/rt/core_compiled.lgb and pkg/rt/generated.sums. Your source changes (pkg/rt/core/hash.lg, pkg/rt/hash_sha.go, test/hash_sha_test.lg) don't conflict with anything.

Those two files can't be merged textually; they need regenerating on the new base:

git fetch upstream && git rebase upstream/main   # take either side for .lgb/.sums
make generate                                     # regenerates both from source
make check-generated                              # verifies lockstep

CI was green on your previous head, so I expect this to be mechanical. I have maintainerCanModify and could push the rebase for you, but I'd rather not rewrite your branch without asking — say the word if you'd prefer I do it.

@nnunley

nnunley commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

I went ahead and pushed the rebase (maintainerCanModify is on) — say the word if you'd rather I hadn't and I'll leave the next one to you.

87b3afae9a3e57, rebased onto main@5ac4d62. Your commit and authorship are unchanged; the only thing I touched was the conflict:

  • pkg/rt/generated.sums conflicted, so I regenerated it with make generate rather than merging it textually. pkg/rt/core_compiled.lgb was regenerated in the same pass.
  • Your source diff (hash.lg, hash_sha.go, hash_sha_test.lg) is byte-identical to what you pushed — verified by diffing the old and new patches.
  • make check-generated passes, and the repo's pre-push hooks (go test, Clojure compat suite, ir-stress ratchet) pass on the exact rebased commit.

CI is running now; I'll merge once it's green.

(hash/sha1 s) and (hash/sha256 s) return the lowercase hex digest of the
string's bytes — the same hex sha1sum/sha256sum print. let-go strings are
raw Go byte strings, so binary content (e.g. a jar slurped from disk)
hashes correctly.

Motivation: dependency tooling built on let-go currently shells out to
sha1sum/shasum to verify Maven artifact checksums. A native digest
removes that host-binary requirement.

pkg/rt/hash_sha.go carries no build tags — crypto/sha1 and crypto/sha256
are pure Go, so tinygo/wasm builds get these too (unlike xxh3, which
needs the murmur3 fallback). The installer seeds the `hash` namespace
from Go; pkg/rt/core/hash.lg's (ns hash) then extends it.
@nnunley
nnunley merged commit aeac42d into nooga:main Aug 7, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sha1/sha256 to the hash namespace

3 participants