source: project/wiki/eggref/5/siphash @ 36801

Last change on this file since 36801 was 36801, checked in by evhan, 11 months ago

wiki/eggref: update docs/formatting/urls and eggref/5/{r7rs,fancypants,chicken-belt}

File size: 2.1 KB
Line 
1[[tags: egg]]
2
3== siphash
4
5[[toc:]]
6
7== Description
8
9A Scheme implementation of the SipHash family of hash functions.
10
11[[https://131002.net/siphash|SipHash]] is a cryptographically strong family of hash functions designed by Jean-Philippe Aumasson and Daniel J. Bernstein.
12
13The source for this extension is available [[https://git.foldling.org/siphash.git|here]].
14
15== API
16
17Three functions are provided:
18
19* {{make-siphash}}
20* {{siphash-2-4}}
21* {{siphash-4-8}}
22
23<procedure>(make-siphash c d) => procedure</procedure>
24
25{{make-siphash}} constructs a hashing function.
26
27It takes two positive integer arguments {{c}} and {{d}} and returns a hashing procedure with that many compression and finalization rounds, respectively.
28
29The returned procedure's signature matches those of {{siphash-2-4}} and {{siphash-4-8}}.
30
31<procedure>(siphash-2-4 key) => (procedure message) => integer</procedure>
32<procedure>(siphash-2-4 key message) => integer</procedure>
33<procedure>(siphash-4-8 key) => (procedure message) => integer</procedure>
34<procedure>(siphash-4-8 key message) => integer</procedure>
35
36{{siphash-2-4}} and {{siphash-4-8}} are predefined hashing procedures.
37
38Each takes one or two SRFI-4 u8vector arguments, the key and message to hash, and returns a positive integer. {{key}} should have a length of 16, while {{message}} may be any length. If {{message}} isn't given, a prekeyed hashing function is returned.
39
40The SipHash specification recommends SipHash-2-4 for performance and SipHash-4-8 for cryptographic security.
41
42== Examples
43
44<enscript highlight=scheme>
45> (define string->u8vector (compose blob->u8vector string->blob))
46> (define key (u8vector 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
47> (define msg (string->u8vector "The rain in Spain falls mainly on the plain."))
48
49> (siphash-2-4 key msg)
50; => 8751579407287093977
51
52> ((siphash-4-8 key) msg)
53; => 13472556437817646137
54
55> ((make-siphash 8 16)
56   key
57   (string->u8vector
58    "In Hertford, Hereford and Hampshire, hurricanes hardly ever happen."))
59; => 9275736844991428064
60</enscript>
61
62== Author
63
64[[/users/evan-hanson|Evan Hanson]]
65
66== License
67
683-Clause BSD
Note: See TracBrowser for help on using the repository browser.