(* Copyright 2012-2015 by Adam Petcher.				* * Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
(* A generic one-time pad that can be reused in other proofs. Also included are specializations for bit vectors and finite cyclic groups. *)
Set Implicit Arguments.
Definition D := evalDist.
Definition dist_iso := evalDist_iso.
Ltac r_ident_r :=
symmetry;
rewrite <- evalDist_right_ident;
symmetry.
Ltac xorTac_once :=
match goal with
| [|- context[?x xor (?x xor ?x0)] ]=> rewrite <- BVxor_assoc; rewrite BVxor_same_id; rewrite BVxor_id_l
| [|- context[(?x xor ?x0) xor ?x] ]=> rewrite <- BVxor_comm
end.
Ltac xorTac := repeat xorTac_once;
simpl; try reflexivity; try eapply in_getAllBvectors.
(* (* Simple example used for illustration *)
Section OTP.
Variable c : nat.
Definition OTP (x : Bvector c) : Comp (Bvector c)
:= p <-$ {0, 1}^c; ret (BVxor c p x).

(* Specifications: *)
Theorem OTP_eq_Rnd:
forall (x y : Bvector c),
D (OTP x) y == D ({0, 1}^c) y.