feat(rt): add sha1/sha256 to hash ns - #690
Conversation
mparrett
left a comment
There was a problem hiding this comment.
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.
|
Heads up: this PR now conflicts with The conflict is entirely in generated artifacts — Those two files can't be merged textually; they need regenerating on the new base: CI was green on your previous head, so I expect this to be mechanical. I have |
|
I went ahead and pushed the rebase (
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.
Resolves: #689
(hash/sha1 s)and(hash/sha256 s)return the lowercase hex digest of the string's bytes — the same hexsha1sum/sha256sumprint. 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/shasumto verify Maven artifact checksums.pkg/rt/hash_sha.gocarries no build tags —crypto/sha1andcrypto/sha256are pure Go, so TinyGo/wasm builds get these too (unlike xxh3, which needs the murmur3 fallback). The installer seeds thehashnamespace from Go andpkg/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 realsha1sum/sha256sumoutput (proving byte- rather than rune-semantics), a spit/slurp round-trip, and arity/type rejection.