Skip to content

Commit 564e0ab

Browse files
chore: Switch to module system (#30)
* chore: Switch to module system * Remove unnecessary `@[expose]`
1 parent 810365c commit 564e0ab

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Blake3.lean

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
module
12
/-! Bindings to the BLAKE3 hashing library. -/
23

34
theorem 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

78
namespace Blake3
9+
public section
810

911
/-- BLAKE3 constants -/
1012
abbrev BLAKE3_OUT_LEN : Nat := 32
1113
abbrev BLAKE3_KEY_LEN : Nat := 32
1214

1315
/-- A wrapper around `ByteArray` whose size is `BLAKE3_OUT_LEN` -/
16+
@[expose]
1417
def Blake3Hash : Type := { r : ByteArray // r.size = BLAKE3_OUT_LEN }
1518

1619
/-- A wrapper around `ByteArray` whose size is `BLAKE3_KEY_LEN` -/
20+
@[expose]
1721
def Blake3Key : Type := { r : ByteArray // r.size = BLAKE3_KEY_LEN }
1822

1923
def Blake3Key.ofBytes (bytes : ByteArray)
@@ -107,7 +111,7 @@ namespace Sponge
107111
abbrev ABSORB_MAX_BYTES := UInt32.size - 1
108112
abbrev 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

113117
def ratchet (sponge : Sponge) : Sponge :=
@@ -149,4 +153,5 @@ def squeeze (sponge : Sponge) (length : USize)
149153

150154
end Sponge
151155

156+
end
152157
end Blake3

0 commit comments

Comments
 (0)