bend-kit-hash Releases (5): 0.3.0.2 0x5b6ad04bca944115c062500008ac429e indexed https://jend.leeeet.dev/files.txt?path=bend-kit-hash@0.3.0.2 0.3.0.1 0xc59d21f627dae931ca66d2dd6b5027e9 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-hash@0.3.0.1 0.3.0.0 0x7360992382668ebdebfec6904817673f unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-hash@0.3.0.0 0.2.0.0 0xb0776c613aafddb88fd284dd3c763501 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-hash@0.2.0.0 0.1.0.0 0xb046f8e1a4cca810f9fc9aa2234bbf2d unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-hash@0.1.0.0 Definitions (94): Hash.W64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64) # A 64-bit value as two halves. Base has no native U64, and int's U64 is a bit list. type W64 is Data: W64{hi: U32, lo: U32} Hash.W64.xor (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.xor) def W64.xor(a: W64, b: W64) -> W64: Hash.W64.add.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.add.of) def W64.add.of(+ah: U32, +bh: U32, +al: U32, +lo: U32) -> W64: Hash.W64.add (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.add) def W64.add(a: W64, b: W64) -> W64: Hash.mul32.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=mul32.of) # The full 64-bit product of two U32, from four 16-bit partial products. def mul32.of(+p00: U32, +p01: U32, +p10: U32, +p11: U32) -> W64: Hash.mul32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=mul32) def mul32(+x: U32, +y: U32) -> W64: Hash.W64.mul.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.mul.of) def W64.mul.of(+cross: U32, p: W64) -> W64: Hash.W64.mul (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.mul) def W64.mul(a: W64, b: W64) -> W64: Hash.W64.rotl (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.rotl) # Rotate left by k, for 0 < k < 32; j is 32 - k. def W64.rotl(+k: Nat, +j: Nat, a: W64) -> W64: Hash.W64.swap (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.swap) def W64.swap(a: W64) -> W64: Hash.W64.shr (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.shr) # Shift right by k, for 0 < k < 32; j is 32 - k. def W64.shr(+k: Nat, +j: Nat, a: W64) -> W64: Hash.W64.lo (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=W64.lo) def W64.lo(a: W64) -> U32: Hash.rotl32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=rotl32) def rotl32(+x: U32, +k: Nat, +j: Nat) -> U32: Hash.wfold (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=wfold) # Folds f over n words from word i on. r holds the array and word i. def wfold(~T: Type, ~f: T -> @+c: U32 -> T, n: Nat, r: Array & U32, +i: U32, acc: T) -> Array & T: Hash.wfrom (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=wfrom) def wfrom(~T: Type, ~f: T -> @+c: U32 -> T, n: Nat, a: Array, +i: U32, acc: T) -> Array & T: Hash.get2.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=get2.of) # Words i and i + 1 as one little-endian 64-bit lane. def get2.of(+lo: U32, r: Array & U32) -> Array & W64: Hash.get2.lo (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=get2.lo) def get2.lo(+i: U32, r: Array & U32) -> Array & W64: Hash.get2 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=get2) def get2(a: Array, +i: U32) -> Array & W64: Hash.dfold (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=dfold) # Folds f over n 64-bit lanes from word i on. r holds the array and the lane at i. def dfold(~T: Type, ~f: T -> @+m: W64 -> T, n: Nat, r: Array & W64, +i: U32, acc: T) -> Array & T: Hash.dfrom (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=dfrom) def dfrom(~T: Type, ~f: T -> @+m: W64 -> T, n: Nat, a: Array, +i: U32, acc: T) -> Array & T: Hash.tail (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=tail) # Folds f over the low k bytes of w, lowest first. def tail(~T: Type, ~f: T -> @+c: U32 -> T, k: Nat, +w: U32, acc: T) -> T: Hash.bytewise.last (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=bytewise.last) def bytewise.last(~T: Type, ~byte: T -> @+c: U32 -> T, +len: U32, acc: T, r: Array & U32) -> Bytes.Bytes & T: Hash.bytewise.rest (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=bytewise.rest) def bytewise.rest(~T: Type, ~byte: T -> @+c: U32 -> T, +len: U32, r: Array & T) -> Bytes.Bytes & T: Hash.bytewise (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=bytewise) # A hash that eats one byte at a time: word takes the four bytes of a word, byte one. def bytewise(~T: Type, ~byte: T -> @+c: U32 -> T, ~word: T -> @+c: U32 -> T, b: Bytes.Bytes, acc: T) -> Bytes.Bytes & T: Hash.fnv32.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv32.byte) # FNV-1a (draft-eastlake-fnv), 32 and 64 bits. def fnv32.byte(h: U32, +c: U32) -> U32: Hash.fnv32.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv32.word) def fnv32.word(h: U32, +w: U32) -> U32: Hash.fnv1a32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv1a32) def fnv1a32(b: Bytes.Bytes) -> Bytes.Bytes & U32: Hash.fnv64.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv64.byte) def fnv64.byte(h: W64, +c: U32) -> W64: Hash.fnv64.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv64.word) def fnv64.word(h: W64, +w: U32) -> W64: Hash.fnv1a64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv1a64) def fnv1a64(b: Bytes.Bytes) -> Bytes.Bytes & W64: Hash.crc.tab (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc.tab) # CRC-32 (ISO-HDLC, as in gzip and zlib): reflected, polynomial 0xEDB88320. # The 256-entry table as a match, so no call rebuilds it. def crc.tab(+i: U32) -> U32: Hash.crc.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc.byte) def crc.byte(h: U32, +c: U32) -> U32: Hash.crc.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc.word) def crc.word(h: U32, +w: U32) -> U32: Hash.crc.fin (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc.fin) def crc.fin(r: Bytes.Bytes & U32) -> Bytes.Bytes & U32: Hash.crc32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc32) def crc32(b: Bytes.Bytes) -> Bytes.Bytes & U32: Hash.adler.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=adler.of) # Adler-32 (RFC 1950 ยง9). The state is the checksum itself: s2 << 16 | s1. # A word takes mod 65521 once, after four bytes; no sum reaches 2^32 first. def adler.of(+s1: U32, +s2: U32) -> U32: Hash.adler.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=adler.byte) def adler.byte(h0: U32, +c: U32) -> U32: Hash.adler.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=adler.word) def adler.word(h0: U32, +w: U32) -> U32: Hash.adler32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=adler32) def adler32(b: Bytes.Bytes) -> Bytes.Bytes & U32: Hash.V4 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=V4) # xxHash32 (XXH32, xxHash spec 0.1.1). type V4 is Data: V4{a: U32, b: U32, c: U32, d: U32} Hash.x32.round (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.round) def x32.round(+acc: U32, +x: U32) -> U32: Hash.x32.lane (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.lane) # The four accumulators take lanes in turn: v1 eats this word and moves to the back. def x32.lane(v: V4, +w: U32) -> V4: Hash.x32.merge (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.merge) def x32.merge(r: Array & V4) -> Array & U32: Hash.x32.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.word) def x32.word(h: U32, +w: U32) -> U32: Hash.x32.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.byte) def x32.byte(h: U32, +c: U32) -> U32: Hash.x32.aval.c (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.aval.c) def x32.aval.c(+h: U32) -> U32: Hash.x32.aval.b (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.aval.b) def x32.aval.b(+h: U32) -> U32: Hash.x32.aval (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.aval) def x32.aval(+h: U32) -> U32: Hash.x32.tail (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.tail) def x32.tail(+len: U32, +h: U32, r: Array & U32) -> Bytes.Bytes & U32: Hash.x32.rest (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.rest) def x32.rest(+len: U32, r: Array & U32) -> Bytes.Bytes & U32: Hash.x32.mid (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.mid) def x32.mid(+len: U32, r: Array & U32) -> Bytes.Bytes & U32: Hash.x32.start (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x32.start) def x32.start(big: Bool, +len: U32, +seed: U32, a: Array) -> Array & U32: Hash.xxh32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=xxh32) def xxh32(b: Bytes.Bytes, +seed: U32) -> Bytes.Bytes & U32: Hash.V64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=V64) # xxHash64 (XXH64, xxHash spec 0.1.1). type V64 is Data: V64{a: W64, b: W64, c: W64, d: W64} Hash.x64.P1 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.P1) def x64.P1() -> W64: Hash.x64.P2 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.P2) def x64.P2() -> W64: Hash.x64.P3 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.P3) def x64.P3() -> W64: Hash.x64.P4 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.P4) def x64.P4() -> W64: Hash.x64.P5 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.P5) def x64.P5() -> W64: Hash.x64.round (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.round) def x64.round(acc: W64, x: W64) -> W64: Hash.x64.lane (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.lane) def x64.lane(v: V64, +m: W64) -> V64: Hash.x64.fold (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.fold) def x64.fold(h: W64, v: W64) -> W64: Hash.x64.merge (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.merge) def x64.merge(r: Array & V64) -> Array & W64: Hash.x64.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.word) def x64.word(h: W64, +m: W64) -> W64: Hash.x64.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.byte) def x64.byte(h: W64, +c: U32) -> W64: Hash.x64.four (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.four) def x64.four(h: W64, +w: U32) -> W64: Hash.x64.aval.c (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.aval.c) def x64.aval.c(h: W64) -> W64: Hash.x64.aval.b (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.aval.b) def x64.aval.b(+h: W64) -> W64: Hash.x64.aval (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.aval) def x64.aval(h: W64) -> W64: Hash.x64.bytes (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.bytes) # The last len % 8 bytes: a 4-byte lane when there is one, then single bytes. def x64.bytes(four: Bool, +k: Nat, h: W64, m: W64) -> W64: Hash.x64.tail (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.tail) def x64.tail(+len: U32, +h: W64, r: Array & W64) -> Bytes.Bytes & W64: Hash.x64.rest (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.rest) def x64.rest(+len: U32, r: Array & W64) -> Bytes.Bytes & W64: Hash.x64.mid (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.mid) def x64.mid(+len: U32, r: Array & W64) -> Bytes.Bytes & W64: Hash.x64.start (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=x64.start) def x64.start(big: Bool, +len: U32, +seed: W64, a: Array) -> Array & W64: Hash.xxh64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=xxh64) def xxh64(b: Bytes.Bytes, +seed: W64) -> Bytes.Bytes & W64: Hash.S4 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=S4) # SipHash-1-3 (Aumasson and Bernstein, 2012): one round per block, three to finish. type S4 is Data: S4{v0: W64, v1: W64, v2: W64, v3: W64} Hash.sip.round (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.round) def sip.round(s: S4) -> S4: Hash.sip.post (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.post) def sip.post(+m: W64, s: S4) -> S4: Hash.sip.block (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.block) def sip.block(s: S4, +m: W64) -> S4: Hash.sip.fin (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.fin) def sip.fin(s: S4) -> W64: Hash.sip.end (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.end) def sip.end(s: S4) -> W64: Hash.sip.keep (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.keep) # The low n bytes of w, for n <= 4, so bytes past len never reach the hash. def sip.keep(+w: U32, +n: U32) -> U32: Hash.sip.last (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.last) # The last block: the len % 8 bytes left, and len mod 256 in the top byte. def sip.last(+len: U32, r: Array & W64, s: S4) -> Bytes.Bytes & W64: Hash.sip.rest (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=sip.rest) def sip.rest(+len: U32, r: Array & S4) -> Bytes.Bytes & W64: Hash.siphash13 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=siphash13) def siphash13(b: Bytes.Bytes, +k0: W64, +k1: W64) -> Bytes.Bytes & W64: Hash.v32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=v32) # The same hashes over a byte string. ponytail: copies to Bytes; hash short strings in place if the copy shows up in profiles. def v32(r: Bytes.Bytes & U32) -> U32: Hash.v64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=v64) def v64(r: Bytes.Bytes & W64) -> W64: Hash.fnv1a32.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv1a32.str) def fnv1a32.str(+s: String) -> U32: Hash.fnv1a64.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=fnv1a64.str) def fnv1a64.str(+s: String) -> W64: Hash.xxh32.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=xxh32.str) def xxh32.str(+s: String, +seed: U32) -> U32: Hash.xxh64.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=xxh64.str) def xxh64.str(+s: String, +seed: W64) -> W64: Hash.siphash13.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=siphash13.str) def siphash13.str(+s: String, +k0: W64, +k1: W64) -> W64: Hash.crc32.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=crc32.str) def crc32.str(+s: String) -> U32: Hash.adler32.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-hash@0.3.0.2/hash.bend&name=adler32.str) def adler32.str(+s: String) -> U32: