File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module
12/-! Bindings to the BLAKE3 hashing library. -/
23
34theorem ByteArray.size_of_extract {hash : ByteArray} (h : e ≤ hash.size) :
45 (hash.extract b e).size = e - b := by
56 simp [Nat.min_eq_left h]
67
78namespace Blake3
9+ public section
810
911/-- BLAKE3 constants -/
1012abbrev BLAKE3_OUT_LEN : Nat := 32
1113abbrev BLAKE3_KEY_LEN : Nat := 32
1214
1315/-- A wrapper around `ByteArray` whose size is `BLAKE3_OUT_LEN` -/
16+ @[expose]
1417def Blake3Hash : Type := { r : ByteArray // r.size = BLAKE3_OUT_LEN }
1518
1619/-- A wrapper around `ByteArray` whose size is `BLAKE3_KEY_LEN` -/
20+ @[expose]
1721def Blake3Key : Type := { r : ByteArray // r.size = BLAKE3_KEY_LEN }
1822
1923def Blake3Key.ofBytes (bytes : ByteArray)
@@ -107,7 +111,7 @@ namespace Sponge
107111abbrev ABSORB_MAX_BYTES := UInt32.size - 1
108112abbrev DEFAULT_REKEYING_STAGE := UInt16.size - 1
109113
110- def init (label : String) (_h : ¬label.isEmpty := by decide ) : Sponge :=
114+ def init (label : String) (_h : ¬label.isEmpty := by native_decide ) : Sponge :=
111115 ⟨Hasher.initDeriveKey label.toUTF8, 0 ⟩
112116
113117def ratchet (sponge : Sponge) : Sponge :=
@@ -149,4 +153,5 @@ def squeeze (sponge : Sponge) (length : USize)
149153
150154end Sponge
151155
156+ end
152157end Blake3
You can’t perform that action at this time.
0 commit comments