feat(tvix/store): add nixbase32 mod

This implements the nix-specific base32 encoding and decoding, exposing
a subset of the API that the data-encoding crate provides.

Nix uses a custom alphabet, no padding, and encodes bytes in reverse
order. The latter one is the reason we can't just use the data-encoding
crate directly.

Three odd corner case tests ported over from go-nix failed. We opened
b/235 to further investigate.

Change-Id: I73fab6ddd67177d882e4c3f2b48761c95853d558
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7683
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2022-12-29 22:47:02 +01:00 committed by flokli
parent 5ba47a2bc3
commit 357c4d4836
5 changed files with 247 additions and 33 deletions

View file

@ -6,13 +6,15 @@ edition = "2021"
[dependencies]
anyhow = "1.0.68"
blake3 = { version = "1.3.1", features = ["rayon", "std"] }
data-encoding = "2.3.3"
lazy_static = "1.4.0"
prost = "0.11.2"
thiserror = "1.0.38"
tonic = "0.8.2"
[dev-dependencies]
lazy_static = "1.4.0"
[build-dependencies]
prost-build = "0.11.2"
tonic-build = "0.8.2"
[dev-dependencies]
test-case = "2.2.2"