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

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