delicious, heapless, unaudited cryptographic algorithms based on the Go standard library
the Go standard library is fantabulous but not great on microcontrollers
i want a Go standard library for use on microcontrollers
ergo: lcrypto.
yes.
relax, its fine. what i did was generate it based off the standard library so it's mostly ok
yes... and no. i used an llm to generate a program that parses the standard library and using a few rewrite-rules it translates the tried and tested standard library algorithms to heapless versions. so it is deterministically based on the standard library, unlike just asking an llm to rewrite it.
yes. determinism is good. the result is only as good as the rewrite program and standard library, so we'll get better with time, and likely only better.
however, not all is roses for all you purists. we are in process of defining brand new abstractions for the crypto algorithms we know and love at lneto. see lcrypto.go for a list of interfaces.
i swear i can do better than the standard library! my mother says im really smart!
generate files and print names of generated files with
go generate -v ./...
this also runs stringer for error messages: go install golang.org/x/tools/cmd/stringer@latest.
the generation program is in internal/cmd/cryptogen and all generated files live in internal/std and contain information of how they were generated and from what upstream Go standard library file.
go test ./... # everything, offline
go test -short ./... # quicker
go test ./mlkem -million # 1M accumulated ML-KEM vectors
tinygo test ./... # tinygo excludes some tests it cannot run
what runs:
- upstream tests of the ported packages.
- standard library conformance suites for AEAD, Block, Stream and Hash (
internal/lcryptotest). - Wycheproof, x509-limbo, ed25519vectors, NIST PKITS: vendored in
internal/lcryptotest/testdata, offline. add more viavectorSuitesin lcryptogen's config. - FIPS 140-3 known-answer self-tests (CASTs) as
TestCAST(Go blog). - accumulated test vectors for ML-KEM and cSHAKE.
- tinygo tests exclude some of standard library tests that require
os/execand other features not in tinygo. list skipped tests withtinygo test -v ./... 2>&1 | grep -- '--- SKIP'.
do not use x509 for critical software- we were not able to generate it deterministically from the standard library (it is currently llm slop)
lneto is a networking stack. we need tls in lneto and lcrypto will be the crypto side of lneto's networking https://github.com/soypat/lneto