(type egg)
(signature "siphash egg")
(timestamp 1612269487)
(sxml ((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/siphash" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "siphash" (toc)) (section 2 "Description" (p "A Scheme implementation of the SipHash family of hash functions.") (p (link "https://131002.net/siphash" "SipHash") " is a cryptographically strong family of hash functions designed by Jean-Philippe Aumasson and Daniel J. Bernstein.") (p "The source for this extension is available " (link "https://git.foldling.org/siphash.git" "here") ".")) (section 2 "Requirements" (ul (li (int-link "numbers")))) (section 2 "API" (p "Three functions are provided:") (ul (li (tt "make-siphash")) (li (tt "siphash-2-4")) (li (tt "siphash-4-8"))) (def (sig (procedure "(make-siphash c d) => procedure" (id make-siphash))) (p (tt "make-siphash") " constructs a hashing function.") (p "It takes two positive integer arguments " (tt "c") " and " (tt "d") " and returns a hashing procedure with that many compression and finalization rounds, respectively.") (p "The returned procedure's signature matches those of " (tt "siphash-2-4") " and " (tt "siphash-4-8") ".")) (def (sig (procedure "(siphash-2-4 key) => (procedure message) => integer" (id siphash-2-4)) (procedure "(siphash-2-4 key message) => integer" (id siphash-2-4)) (procedure "(siphash-4-8 key) => (procedure message) => integer" (id siphash-4-8)) (procedure "(siphash-4-8 key message) => integer" (id siphash-4-8))) (p (tt "siphash-2-4") " and " (tt "siphash-4-8") " are predefined hashing procedures.") (p "Each takes one or two SRFI-4 u8vector arguments, the key and message to hash, and returns a positive integer. " (tt "key") " should have a length of 16, while " (tt "message") " may be any length. If " (tt "message") " isn't given, a prekeyed hashing function is returned.") (p "The SipHash specification recommends SipHash-2-4 for performance and SipHash-4-8 for cryptographic security."))) (section 2 "Examples" (highlight scheme "> (define string->u8vector (compose blob->u8vector string->blob))\n> (define key (u8vector 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))\n> (define msg (string->u8vector \"The rain in Spain falls mainly on the plain.\"))\n\n> (siphash-2-4 key msg)\n; => 8751579407287093977\n\n> ((siphash-4-8 key) msg)\n; => 13472556437817646137\n\n> ((make-siphash 8 16)\n   key\n   (string->u8vector\n    \"In Hertford, Hereford and Hampshire, hurricanes hardly ever happen.\"))\n; => 9275736844991428064")) (section 2 "Author" (p (int-link "/users/evan-hanson" "Evan Hanson"))) (section 2 "License" (p "3-Clause BSD"))))
