val update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a): Lemma
  (ensures (update_multi a h () input == update a h input))
let update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a): Lemma
  (ensures (update_multi a h () input) == (update a h input))
=
  let h1 = update_multi a h () input in
  assert(h1 == Lib.UpdateMulti.mk_update_multi (block_length a) (update a) h input);
  if S.length input = 0 then
    begin
    assert(h1 == h)
    end
  else
    begin
    let block, rem = Lib.UpdateMulti.split_block (block_length a) input 1 in
    let h2 = update a h block in
    assert(rem `Seq.equal` Seq.empty);
    assert(block `Seq.equal` input);
    let h3 = Lib.UpdateMulti.mk_update_multi (block_length a) (update a) h2 rem in
    assert(h1 == h3)
    end
val update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a): Lemma
  (ensures (update_multi a h () input == update a h input))
let update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a)
    : Lemma (ensures (update_multi a h () input) == (update a h input)) =
let h1 = update_multi a h () input in
assert (h1 == Lib.UpdateMulti.mk_update_multi (block_length a) (update a) h input);
if S.length input = 0
then assert (h1 == h)
else
  let block, rem = Lib.UpdateMulti.split_block (block_length a) input 1 in
  let h2 = update a h block in
  assert (rem `Seq.equal` Seq.empty);
  assert (block `Seq.equal` input);
  let h3 = Lib.UpdateMulti.mk_update_multi (block_length a) (update a) h2 rem in
  assert (h1 == h3)
Spec.Hash.Lemmas.fst.checked
Spec.SHA3.fst.checked Spec.Hash.Definitions.fst.checked Spec.Blake2.fst.checked Spec.Agile.Hash.fst.checked Spec.Agile.Hash.fst.checked prims.fst.checked Lib.UpdateMulti.fst.checked Lib.Sequence.Lemmas.fsti.checked Lib.Sequence.fsti.checked Lib.LoopCombinators.fsti.checked Lib.IntTypes.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.fsti.checked FStar.Mul.fst.checked FStar.Math.Lemmas.fst.checked FStar.Classical.fsti.checked FStar.Calc.fsti.checked
Spec.Hash.Lemmas.fst
Spec.Hash.Definitions.md_alg Spec.Hash.Definitions.words_state Spec.Hash.Definitions.bytes_block Prims.op_Equality Prims.int FStar.Seq.Base.length Lib.IntTypes.uint8 Prims._assert Prims.eq2 Prims.bool FStar.Seq.Base.seq Lib.UpdateMulti.uint8 Lib.UpdateMulti.mk_update_multi Spec.Hash.Definitions.block_length Spec.Agile.Hash.update Prims.unit FStar.Seq.Base.equal FStar.Seq.Base.empty FStar.Pervasives.Native.tuple2 Lib.UpdateMulti.split_block Spec.Agile.Hash.update_multi Prims.l_True Prims.squash Prims.Nil FStar.Pervasives.pattern
module Spec.Hash.Lemmas

module S = FStar.Seq
open Lib.IntTypes

open Spec.Agile.Hash
open Spec.Hash.Definitions

friend Spec.Agile.Hash

(** Lemmas about the behavior of update_multi / update_last *)

#push-options "--fuel 0 --ifuel 1 --z3rlimit 50"

let update_multi_zero a h =
  match a with
  | MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 ->
    Lib.UpdateMulti.update_multi_zero (block_length a) (Spec.Agile.Hash.update a) h
  | SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
    let rateInBytes = rate a / 8 in
    let f = Spec.SHA3.absorb_inner rateInBytes in
    Lib.Sequence.lemma_repeat_blocks_multi rateInBytes S.empty f h;

    let nb = 0 / rateInBytes in
    Lib.LoopCombinators.eq_repeati0 nb (Lib.Sequence.repeat_blocks_f rateInBytes S.empty f nb) h

let update_multi_zero_blake a prevlen h =
  Lib.LoopCombinators.eq_repeati0 (0 / block_length a) (Spec.Blake2.blake2_update1 (to_blake_alg a) prevlen S.empty) h
#pop-options

#push-options "--fuel 1"
let update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a): Lemma
val update_multi_update (a: md_alg) (h: words_state a) (input: bytes_block a): Lemma
  (ensures (update_multi a h () input == update a h input))

    a: Spec.Hash.Definitions.md_alg ->
    h: Spec.Hash.Definitions.words_state a ->
    input: Spec.Hash.Definitions.bytes_block a
  -> FStar.Pervasives.Lemma
    (ensures Spec.Agile.Hash.update_multi a h () input == Spec.Agile.Hash.update a h input)