Hash any number of inputs to any number of outputs.
(hash inputs param count) → outputs
We initialize the sponge, we absorb all the inputs, and we squeeze all the outputs.
Note that inputs that only differ in
one input having more trailing zeros than the other
and not exceeeding a multiple of the rate length
result in the same outputs.
For instance, if
Function:
(defun hash (inputs param count) (declare (xargs :guard (and (paramp param) (natp count) (fe-listp inputs (param->prime param))))) (let ((__function__ 'hash)) (declare (ignorable __function__)) (b* ((sponge (init-sponge (param->size param))) (sponge (absorb inputs sponge param)) ((mv outputs &) (squeeze count sponge param))) outputs)))
Theorem:
(defthm fe-listp-of-hash (b* ((outputs (hash inputs param count))) (fe-listp outputs (param->prime param))) :rule-classes :rewrite)
Theorem:
(defthm true-listp-of-hash (b* ((outputs (hash inputs param count))) (true-listp outputs)) :rule-classes :type-prescription)
Theorem:
(defthm len-of-hash (b* ((?outputs (hash inputs param count))) (equal (len outputs) (nfix count))))
Theorem:
(defthm consp-of-hash (b* ((?outputs (hash inputs param count))) (equal (consp outputs) (< 0 (nfix count)))))