vc_hacher.miaou
← Le code · src/outil/miaou/vc_hacher.miaou · 32 lignes
(node vc_hacher
(params (xs (Liste Octet)) (h Hache))
(returns Hache)
(intent "les octets xs passés dans les quatre hachages polynomiaux de h, modulo le nombre premier 2^31 - 1, chacun de sa base (1000003, 16777619, 1103515245, 69069) : h' = h × base + octet")
(origin "phase H1c : la vérification incrémentale ; le SHA-256 en miaou, 8,8 s par Mio, aurait coûté plus que la plupart des vérifications : ces quatre hachages passent 3,8 Mio en 0,08 s")
(effects)
(requires
(and (lt (get h a) 2147483647)
(and (lt (get h b) 2147483647) (and (lt (get h c) 2147483647) (lt (get h d) 2147483647)))))
(ensures
(and (lt (get r a) 2147483647)
(and (lt (get r b) 2147483647) (and (lt (get r c) 2147483647) (lt (get r d) 2147483647)))))
(decreases xs)
(examples
(ex ("" (record Hache (a 1) (b 2) (c 3) (d 4))) (record Hache (a 1) (b 2) (c 3) (d 4)))
(ex ("a" (record Hache (a 1) (b 1) (c 1) (d 1)))
(record Hache (a 1000100) (b 16777716) (c 1103515342) (d 69166)))
(ex ("ab" (record Hache (a 0) (b 0) (c 0) (d 0)))
(record Hache (a 97000389) (b 1627429141) (c 1814280160) (d 6699791))))
(equivalence exact)
(body.high
(match xs
(case empty () h)
(case cons
(o reste)
(vc_hacher reste
(record Hache
(a (mod (add (mul (get h a) 1000003) (to_nat o)) 2147483647))
(b (mod (add (mul (get h b) 16777619) (to_nat o)) 2147483647))
(c (mod (add (mul (get h c) 1103515245) (to_nat o)) 2147483647))
(d (mod (add (mul (get h d) 69069) (to_nat o)) 2147483647)))))))
(end node vc_hacher))