Skip to content

Commit 10ebb3a

Browse files
loutrstrub
authored andcommitted
feat(theories, SplitRO): remove requirement of axiom ofpairK
Removed instantiation from the ChaChaPoly example (the lemma is a priori still needed there, so it was not removed, but just moved where appropriate)
1 parent c8e119e commit 10ebb3a

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

examples/ChaChaPoly/chacha_poly.ec

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -865,23 +865,20 @@ proof.
865865
smt (ge0_poly_in_size ge0_poly_out_size ge0_extra_block_size).
866866
qed.
867867
868-
realize ofpairK.
869-
proof.
870-
move=> [x1 x2]; rewrite /topair /ofpair /=.
871-
rewrite Block.block_of_bytesdK.
872-
+ by rewrite size_cat TPoly.bytes_of_polyP Extra_block.bytes_of_extra_blockP.
873-
by rewrite
874-
take_size_cat 1:TPoly.bytes_of_polyP 1:// drop_size_cat
875-
1:TPoly.bytes_of_polyP 1:// TPoly.bytes_of_polyKd
876-
Extra_block.bytes_of_extra_blockKd.
877-
qed.
878-
879868
realize sample_spec.
880869
proof.
870+
have ofpairK : cancel ofpair topair.
871+
+ move=> [x1 x2]; rewrite /topair /ofpair /=.
872+
rewrite Block.block_of_bytesdK.
873+
+ by rewrite size_cat TPoly.bytes_of_polyP Extra_block.bytes_of_extra_blockP.
874+
by rewrite
875+
take_size_cat 1:TPoly.bytes_of_polyP 1:// drop_size_cat
876+
1:TPoly.bytes_of_polyP 1:// TPoly.bytes_of_polyKd
877+
Extra_block.bytes_of_extra_blockKd.
881878
move=> _; rewrite /dblock; apply eq_distr => b.
882879
rewrite !dmap1E.
883880
apply (eq_trans _ (mu1 (dpoly `*` dextra_block) ((topair b).`1, (topair b).`2))); last first.
884-
+ congr; apply fun_ext; smt (topairK ofpairK).
881+
+ congr; apply fun_ext; smt (topairK).
885882
rewrite dprod1E (_:block_size = poly_size + extra_block_size) //.
886883
rewrite dlist_add 1:ge0_poly_size 1:ge0_extra_block_size dmapE.
887884
rewrite !dmap1E /(\o) -dprodE &(mu_eq_support) => -[l1 l2] /supp_dprod /= [h1 h2].
@@ -936,23 +933,20 @@ proof.
936933
smt (ge0_poly_in_size ge0_poly_out_size).
937934
qed.
938935
939-
realize ofpairK.
940-
proof.
941-
move=> [x1 x2]; rewrite /topair /ofpair /=.
942-
rewrite TPoly.poly_of_bytesdK.
943-
+ by rewrite size_cat Poly_in.bytes_of_poly_inP Poly_out.bytes_of_poly_outP.
944-
by rewrite
945-
take_size_cat 1:Poly_in.bytes_of_poly_inP 1:// drop_size_cat
946-
1:Poly_in.bytes_of_poly_inP 1:// Poly_in.bytes_of_poly_inKd
947-
Poly_out.bytes_of_poly_outKd.
948-
qed.
949-
950936
realize sample_spec.
951937
proof.
938+
have ofpairK : cancel ofpair topair.
939+
+ move=> [x1 x2]; rewrite /topair /ofpair /=.
940+
rewrite TPoly.poly_of_bytesdK.
941+
+ by rewrite size_cat Poly_in.bytes_of_poly_inP Poly_out.bytes_of_poly_outP.
942+
by rewrite
943+
take_size_cat 1:Poly_in.bytes_of_poly_inP 1:// drop_size_cat
944+
1:Poly_in.bytes_of_poly_inP 1:// Poly_in.bytes_of_poly_inKd
945+
Poly_out.bytes_of_poly_outKd.
952946
move=> _; rewrite /dpoly; apply eq_distr => b.
953947
rewrite !dmap1E.
954948
apply (eq_trans _ (mu1 (dpoly_in `*` dpoly_out) ((topair b).`1, (topair b).`2))); last first.
955-
+ congr; apply fun_ext; smt (topairK ofpairK).
949+
+ congr; apply fun_ext; smt (topairK).
956950
rewrite dprod1E (_:poly_size = poly_in_size + poly_out_size) //.
957951
rewrite dlist_add 1:ge0_poly_in_size 1:ge0_poly_out_size dmapE.
958952
rewrite !dmap1E /(\o) -dprodE &(mu_eq_support) => -[l1 l2] /supp_dprod /= [h1 h2].

theories/crypto/SplitRO.ec

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ op topair : to -> to1 * to2.
8888
op ofpair : to1 * to2 -> to.
8989

9090
axiom topairK: cancel topair ofpair.
91-
axiom ofpairK: cancel ofpair topair.
9291

9392
op sampleto1 : from -> to1 distr.
9493
op sampleto2 : from -> to2 distr.
@@ -153,15 +152,19 @@ section PROOFS.
153152
swap{2} 5 -3; swap{2} 6 -2; sp 0 2.
154153
seq 1 2 : (#pre /\ r{1} = ofpair (r{2}, r0{2})).
155154
+ conseq />.
156-
outline {2} [1 .. 2] ~ S.sample2.
157-
rewrite equiv[{2} 1 -sample_sample2].
158-
inline *; wp; rnd topair ofpair; auto => /> &2 ?; split.
159-
+ by move=> ??; rewrite ofpairK.
160-
move=> _; split.
161-
+ move=> [t1 t2]?; rewrite sample_spec dmap1E; congr; apply fun_ext => p.
162-
by rewrite /pred1 /(\o) (can_eq _ _ ofpairK).
163-
move=> _ t; rewrite sample_spec supp_dmap => -[[t1 t2] []] + ->>.
164-
by rewrite topairK ofpairK => ->.
155+
alias{2} 2 one = 1. swap{2} 2 1.
156+
alias{2} 3 rr = ofpair (r, r0).
157+
kill{2} 4 ! 1; first by auto.
158+
transitivity{2}
159+
{
160+
r <$ sampleto1 x;
161+
r0 <$ sampleto2 x;
162+
rr <- ofpair (r, r0);
163+
}
164+
(={x} /\ (x0 = x /\ x1 = x){2} ==> r{1} = rr{2})
165+
(={x} /\ (x0 = x /\ x1 = x){2} ==> rr{1} = ofpair(r, r0){2}); 1,2,4: by auto => /#.
166+
rndsem*{2} 0.
167+
auto => *. rewrite -dmap_dprodE sample_spec. by smt().
165168
by auto => />; smt (get_setE map_set set_pair_map mem_map mem_pair_map mem_set mapE mergeE).
166169
qed.
167170

@@ -178,7 +181,7 @@ section PROOFS.
178181
by rewrite /pair_map merge_empty // map_empty /= => ?; rewrite !mem_empty.
179182
+ by conseq RO_get.
180183
+ by proc; inline *; auto => />;
181-
smt (get_setE map_set set_pair_map mem_map mem_pair_map mem_set mapE mergeE ofpairK topairK).
184+
smt (get_setE map_set set_pair_map mem_map mem_pair_map mem_set mapE mergeE topairK).
182185
+ by proc; inline *; auto; smt (map_rem rem_merge mem_map mem_pair_map mem_rem).
183186
+ proc *.
184187
inline {1} 1.

0 commit comments

Comments
 (0)