(* Functional implementation of Salsa20 whose structure matches the one of tweetnacl.c implementation, plus proof of coorrectness wrt Salsa20.v  Lennart Beringer, June 2015*)
(*Processing time for this file: approx 13mins*)
Local Open Scope logic.
(*Require Import general_lemmas.  Require Import split_array_lemmas.*)
Opaque littleendian_invert. Opaque Snuffle.Snuffle.

Lemma TP C1 C2 C3 C4 N1 N2 N3 N4 intsums OUT: Zlength intsums = 16 -> Zlength OUT = 32 ->
hPosLoop3 4 (hPosLoop2 4 intsums (C1, C2, C3, C4) (N1, N2, N3, N4)) OUT =
QuadByte2ValList (littleendian_invert (Int.sub (Znth 0 intsums)  (littleendian C1))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 5 intsums)  (littleendian C2))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 10 intsums) (littleendian C3))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 15 intsums) (littleendian C4))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 6 intsums)  (littleendian N1))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 7 intsums)  (littleendian N2))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 8 intsums)  (littleendian N3))) ++
QuadByte2ValList (littleendian_invert (Int.sub (Znth 9 intsums)  (littleendian N4))).