Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v16
with:
name: argumentcomputer
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: nix run
- run: nix build --accept-flake-config
- run: nix run --accept-flake-config
6 changes: 3 additions & 3 deletions Blake3.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

theorem ByteArray.size_of_extract {hash : ByteArray} (hbe : b ≤ e) (h : e ≤ hash.data.size) :
(hash.extract b e).size = e - b := by
simp [ByteArray.size, ByteArray.extract, ByteArray.copySlice, ByteArray.empty, ByteArray.mkEmpty]
simp [ByteArray.size, ByteArray.extract, ByteArray.copySlice, ByteArray.empty, ByteArray.emptyWithCapacity]
rw [Nat.add_comm, Nat.sub_add_cancel hbe, Nat.min_eq_left h]

namespace Blake3
Expand Down Expand Up @@ -61,7 +61,7 @@ opaque update (hasher : Hasher) (input : @& ByteArray) : Hasher
instance {length : USize} : Inhabited { r : ByteArray // r.size = length.toNat } where
default := ⟨
⟨⟨List.replicate length.toNat 0⟩⟩,
by simp only [ByteArray.size, List.toArray_replicate, Array.size_mkArray]
by simp only [ByteArray.size, List.toArray_replicate, Array.size_replicate]

/-- Finalize the hasher and write the output to an array of a given length. -/
Expand All @@ -70,7 +70,7 @@ opaque finalize : (hasher : Hasher) → (length : USize) →
{r : ByteArray // r.size = length.toNat}

def finalizeWithLength (hasher : Hasher) (length : Nat)
(h : length % 2 ^ System.Platform.numBits = length := by native_decide) :
(h : length < 2 ^ System.Platform.numBits := by native_decide) :
{ r : ByteArray // r.size = length } :=
let ⟨hash, h'⟩ := hasher.finalize length.toUSize
have hash_size_eq_len : hash.size = length := by
Expand Down
2 changes: 1 addition & 1 deletion blake3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
buildSteps =
builtins.map (file: "gcc -O3 -Wall -c ${blake3}/c/${file}.c -o ${file}.o ${blake3Flags}") blake3Files
++ [
"gcc -O3 -Wall -c ffi.c -o ffi.o -I ${pkgs.lean4}/include -I ${blake3}/c"
"gcc -O3 -Wall -c ffi.c -o ffi.o -I ${pkgs.lean}/include -I ${blake3}/c"
"ar rcs libblake3.a ${(builtins.concatStringsSep " " (builtins.map (str: "${str}.o") blake3Files))} ffi.o"
];
# The `libblake3.a` static library is exposed as the `staticLib` package, as it must be explicitly linked against
Expand Down
66 changes: 32 additions & 34 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
description = "Blake3 Nix Flake";

nixConfig = {
extra-substituters = [
"https://cache.garnix.io"
];
extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.follows = "lean4-nix/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
lean4-nix = {
url = "github:argumentcomputer/lean4-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
lean4-nix.url = "github:lenianiva/lean4-nix";
blake3 = {
url = "github:BLAKE3-team/BLAKE3?ref=refs/tags/1.6.1";
url = "github:BLAKE3-team/BLAKE3?ref=refs/tags/1.8.2";
flake = false;
};
};
Expand Down
4 changes: 2 additions & 2 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lean_lib Blake3 where
lean_exe Blake3Test

abbrev blake3RepoURL := "https://github.com/BLAKE3-team/BLAKE3"
abbrev blake3RepoTag := "1.6.1"
abbrev blake3RepoTag := "1.8.2"

target cloneBlake3 pkg : GitRepo := do
let repoDir : GitRepo := pkg.dir / "blake3"
Expand Down Expand Up @@ -67,4 +67,4 @@ extern_lib ffi pkg := do
let oFileJobs := #[blake3O, blake3DispatchO, blake3PortableO, ffiO]

let name := nameToStaticLib "ffi"
buildStaticLib (pkg.nativeLibDir / name) oFileJobs
buildStaticLib (pkg.staticLibDir / name) oFileJobs
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.18.0
leanprover/lean4:v4.21.0