-
Notifications
You must be signed in to change notification settings - Fork 3
/
SerializationHelpers.fst
1081 lines (977 loc) · 46.7 KB
/
SerializationHelpers.fst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// SerializationHelpers
/// ====================
///
/// This module provides a small set of helper functions to implement serializing/parsing of
/// messages and sessions. While the single functions can be used stand-alone, the intended use of
/// this module is to call ``labeled_crypto_funs`` once and use the functions from the result of
/// that call.
///
/// All implementations are "open" on purpose, so F* can reason about these functions in the context
/// of :doc:`LabeledCryptoAPI` (instead of being limited to the functions within here).
module SerializationHelpers
open SecrecyLabels
open CryptoLib
open LabeledCryptoAPI
(*! Note: Most of this file is auto-generated, do not touch by hand *)
let concat3 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 b3))
let split3 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, b3) -> Success (b1, b2, b3)
)
let parse3_split3_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l)
: Lemma (split3 #p #i #l (concat3 #p #i #l b1 b2 b3) == Success (b1, b2, b3))
[SMTPat (split3 #p #i #l (concat3 #p #i #l b1 b2 b3))] = ()
let split_raw3 (t1:bytes) : result (bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, b3) -> Success (b1, b2, b3)
)
let parse3_split_raw3_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l)
: Lemma (split_raw3 (concat3 #p #i #l b1 b2 b3) == Success (b1, b2, b3))
[SMTPat (split_raw3 (concat3 #p #i #l b1 b2 b3))] = ()
let split3_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split3 #p #i #l t in
let raw_res = split_raw3 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3) = res in
let Success (br1, br2, br3) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3
))
)
[SMTPat (split_raw3 t); SMTPat (split3 #p #i #l t)] = ()
let concat4 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 b4)))
let split4 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, b4) -> Success (b1, b2, b3, b4)
)
)
let parse4_split4_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l)
: Lemma (split4 #p #i #l (concat4 #p #i #l b1 b2 b3 b4) == Success (b1, b2, b3, b4))
[SMTPat (split4 #p #i #l (concat4 #p #i #l b1 b2 b3 b4))] = ()
let split_raw4 (t1:bytes) : result (bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, b4) -> Success (b1, b2, b3, b4)
)
)
let parse4_split_raw4_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l)
: Lemma (split_raw4 (concat4 #p #i #l b1 b2 b3 b4) == Success (b1, b2, b3, b4))
[SMTPat (split_raw4 (concat4 #p #i #l b1 b2 b3 b4))] = ()
let split4_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split4 #p #i #l t in
let raw_res = split_raw4 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4) = res in
let Success (br1, br2, br3, br4) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4
))
)
[SMTPat (split_raw4 t); SMTPat (split4 #p #i #l t)] = ()
let concat5 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 b5))))
let split5 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, b5) -> Success (b1, b2, b3, b4, b5)
)
)
)
let parse5_split5_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l)
: Lemma (split5 #p #i #l (concat5 #p #i #l b1 b2 b3 b4 b5) == Success (b1, b2, b3, b4, b5))
[SMTPat (split5 #p #i #l (concat5 #p #i #l b1 b2 b3 b4 b5))] = ()
let split_raw5 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, b5) -> Success (b1, b2, b3, b4, b5)
)
)
)
let parse5_split_raw5_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l)
: Lemma (split_raw5 (concat5 #p #i #l b1 b2 b3 b4 b5) == Success (b1, b2, b3, b4, b5))
[SMTPat (split_raw5 (concat5 #p #i #l b1 b2 b3 b4 b5))] = ()
let split5_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split5 #p #i #l t in
let raw_res = split_raw5 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5) = res in
let Success (br1, br2, br3, br4, br5) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5
))
)
[SMTPat (split_raw5 t); SMTPat (split5 #p #i #l t)] = ()
let concat6 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 b6)))))
let split6 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, b6) -> Success (b1, b2, b3, b4, b5, b6)
)
)
)
)
let parse6_split6_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l)
: Lemma (split6 #p #i #l (concat6 #p #i #l b1 b2 b3 b4 b5 b6) == Success (b1, b2, b3, b4, b5, b6))
[SMTPat (split6 #p #i #l (concat6 #p #i #l b1 b2 b3 b4 b5 b6))] = ()
let split_raw6 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, b6) -> Success (b1, b2, b3, b4, b5, b6)
)
)
)
)
let parse6_split_raw6_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l)
: Lemma (split_raw6 (concat6 #p #i #l b1 b2 b3 b4 b5 b6) == Success (b1, b2, b3, b4, b5, b6))
[SMTPat (split_raw6 (concat6 #p #i #l b1 b2 b3 b4 b5 b6))] = ()
let split6_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split6 #p #i #l t in
let raw_res = split_raw6 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6) = res in
let Success (br1, br2, br3, br4, br5, br6) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6
))
)
[SMTPat (split_raw6 t); SMTPat (split6 #p #i #l t)] = ()
let concat7 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 b7))))))
let split7 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, b7) -> Success (b1, b2, b3, b4, b5, b6, b7)
)
)
)
)
)
let parse7_split7_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l)
: Lemma (split7 #p #i #l (concat7 #p #i #l b1 b2 b3 b4 b5 b6 b7) == Success (b1, b2, b3, b4, b5, b6, b7))
[SMTPat (split7 #p #i #l (concat7 #p #i #l b1 b2 b3 b4 b5 b6 b7))] = ()
let split_raw7 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, b7) -> Success (b1, b2, b3, b4, b5, b6, b7)
)
)
)
)
)
let parse7_split_raw7_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l)
: Lemma (split_raw7 (concat7 #p #i #l b1 b2 b3 b4 b5 b6 b7) == Success (b1, b2, b3, b4, b5, b6, b7))
[SMTPat (split_raw7 (concat7 #p #i #l b1 b2 b3 b4 b5 b6 b7))] = ()
let split7_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split7 #p #i #l t in
let raw_res = split_raw7 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7) = res in
let Success (br1, br2, br3, br4, br5, br6, br7) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7
))
)
[SMTPat (split_raw7 t); SMTPat (split7 #p #i #l t)] = ()
let concat8 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 (concat #p #i #l b7 b8)))))))
let split8 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match split #p #i #l t7 with
| Error e -> Error e
| Success (b7, b8) -> Success (b1, b2, b3, b4, b5, b6, b7, b8)
)
)
)
)
)
)
let parse8_split8_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l)
: Lemma (split8 #p #i #l (concat8 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8) == Success (b1, b2, b3, b4, b5, b6, b7, b8))
[SMTPat (split8 #p #i #l (concat8 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8))] = ()
let split_raw8 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match CryptoLib.split t7 with
| Error e -> Error e
| Success (b7, b8) -> Success (b1, b2, b3, b4, b5, b6, b7, b8)
)
)
)
)
)
)
let parse8_split_raw8_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l)
: Lemma (split_raw8 (concat8 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8) == Success (b1, b2, b3, b4, b5, b6, b7, b8))
[SMTPat (split_raw8 (concat8 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8))] = ()
let split8_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split8 #p #i #l t in
let raw_res = split_raw8 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7, b8) = res in
let Success (br1, br2, br3, br4, br5, br6, br7, br8) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7 /\ b8 == br8
))
)
[SMTPat (split_raw8 t); SMTPat (split8 #p #i #l t)] = ()
let concat9 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 (concat #p #i #l b7 (concat #p #i #l b8 b9))))))))
let split9 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match split #p #i #l t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match split #p #i #l t8 with
| Error e -> Error e
| Success (b8, b9) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9)
)
)
)
)
)
)
)
let parse9_split9_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l)
: Lemma (split9 #p #i #l (concat9 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9))
[SMTPat (split9 #p #i #l (concat9 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9))] = ()
let split_raw9 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match CryptoLib.split t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match CryptoLib.split t8 with
| Error e -> Error e
| Success (b8, b9) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9)
)
)
)
)
)
)
)
let parse9_split_raw9_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l)
: Lemma (split_raw9 (concat9 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9))
[SMTPat (split_raw9 (concat9 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9))] = ()
let split9_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split9 #p #i #l t in
let raw_res = split_raw9 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7, b8, b9) = res in
let Success (br1, br2, br3, br4, br5, br6, br7, br8, br9) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7 /\ b8 == br8 /\ b9 == br9
))
)
[SMTPat (split_raw9 t); SMTPat (split9 #p #i #l t)] = ()
let concat10 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 (concat #p #i #l b7 (concat #p #i #l b8 (concat #p #i #l b9 b10)))))))))
let split10 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match split #p #i #l t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match split #p #i #l t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match split #p #i #l t9 with
| Error e -> Error e
| Success (b9, b10) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10)
)
)
)
)
)
)
)
)
let parse10_split10_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l)
: Lemma (split10 #p #i #l (concat10 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10))
[SMTPat (split10 #p #i #l (concat10 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10))] = ()
let split_raw10 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match CryptoLib.split t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match CryptoLib.split t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match CryptoLib.split t9 with
| Error e -> Error e
| Success (b9, b10) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10)
)
)
)
)
)
)
)
)
let parse10_split_raw10_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l)
: Lemma (split_raw10 (concat10 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10))
[SMTPat (split_raw10 (concat10 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10))] = ()
let split10_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split10 #p #i #l t in
let raw_res = split_raw10 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) = res in
let Success (br1, br2, br3, br4, br5, br6, br7, br8, br9, br10) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7 /\ b8 == br8 /\ b9 == br9 /\ b10 == br10
))
)
[SMTPat (split_raw10 t); SMTPat (split10 #p #i #l t)] = ()
let concat11 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 (concat #p #i #l b7 (concat #p #i #l b8 (concat #p #i #l b9 (concat #p #i #l b10 b11))))))))))
let split11 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match split #p #i #l t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match split #p #i #l t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match split #p #i #l t9 with
| Error e -> Error e
| Success (b9, t10) -> (
match split #p #i #l t10 with
| Error e -> Error e
| Success (b10, b11) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11)
)
)
)
)
)
)
)
)
)
let parse11_split11_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l)
: Lemma (split11 #p #i #l (concat11 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11))
[SMTPat (split11 #p #i #l (concat11 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11))] = ()
let split_raw11 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match CryptoLib.split t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match CryptoLib.split t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match CryptoLib.split t9 with
| Error e -> Error e
| Success (b9, t10) -> (
match CryptoLib.split t10 with
| Error e -> Error e
| Success (b10, b11) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11)
)
)
)
)
)
)
)
)
)
let parse11_split_raw11_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l)
: Lemma (split_raw11 (concat11 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11))
[SMTPat (split_raw11 (concat11 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11))] = ()
let split11_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split11 #p #i #l t in
let raw_res = split_raw11 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11) = res in
let Success (br1, br2, br3, br4, br5, br6, br7, br8, br9, br10, br11) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7 /\ b8 == br8 /\ b9 == br9 /\ b10 == br10 /\ b11 == br11
))
)
[SMTPat (split_raw11 t); SMTPat (split11 #p #i #l t)] = ()
let concat12 (#p:global_usage) (#i:timestamp) (#l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l) (b12:msg p i l) : (b:msg p i l) =
(concat #p #i #l b1 (concat #p #i #l b2 (concat #p #i #l b3 (concat #p #i #l b4 (concat #p #i #l b5 (concat #p #i #l b6 (concat #p #i #l b7 (concat #p #i #l b8 (concat #p #i #l b9 (concat #p #i #l b10 (concat #p #i #l b11 b12)))))))))))
let split12 (#p:global_usage) (#i:timestamp) (#l:label) (t1:msg p i l) : result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l) =
match split #p #i #l t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match split #p #i #l t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match split #p #i #l t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match split #p #i #l t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match split #p #i #l t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match split #p #i #l t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match split #p #i #l t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match split #p #i #l t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match split #p #i #l t9 with
| Error e -> Error e
| Success (b9, t10) -> (
match split #p #i #l t10 with
| Error e -> Error e
| Success (b10, t11) -> (
match split #p #i #l t11 with
| Error e -> Error e
| Success (b11, b12) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12)
)
)
)
)
)
)
)
)
)
)
let parse12_split12_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l) (b12:msg p i l)
: Lemma (split12 #p #i #l (concat12 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12))
[SMTPat (split12 #p #i #l (concat12 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12))] = ()
let split_raw12 (t1:bytes) : result (bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes & bytes) =
match CryptoLib.split t1 with
| Error e -> Error e
| Success (b1, t2) -> (
match CryptoLib.split t2 with
| Error e -> Error e
| Success (b2, t3) -> (
match CryptoLib.split t3 with
| Error e -> Error e
| Success (b3, t4) -> (
match CryptoLib.split t4 with
| Error e -> Error e
| Success (b4, t5) -> (
match CryptoLib.split t5 with
| Error e -> Error e
| Success (b5, t6) -> (
match CryptoLib.split t6 with
| Error e -> Error e
| Success (b6, t7) -> (
match CryptoLib.split t7 with
| Error e -> Error e
| Success (b7, t8) -> (
match CryptoLib.split t8 with
| Error e -> Error e
| Success (b8, t9) -> (
match CryptoLib.split t9 with
| Error e -> Error e
| Success (b9, t10) -> (
match CryptoLib.split t10 with
| Error e -> Error e
| Success (b10, t11) -> (
match CryptoLib.split t11 with
| Error e -> Error e
| Success (b11, b12) -> Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12)
)
)
)
)
)
)
)
)
)
)
let parse12_split_raw12_lemma (p:global_usage) (i:timestamp) (l:label) (b1:msg p i l) (b2:msg p i l) (b3:msg p i l) (b4:msg p i l) (b5:msg p i l) (b6:msg p i l) (b7:msg p i l) (b8:msg p i l) (b9:msg p i l) (b10:msg p i l) (b11:msg p i l) (b12:msg p i l)
: Lemma (split_raw12 (concat12 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12) == Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12))
[SMTPat (split_raw12 (concat12 #p #i #l b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12))] = ()
let split12_eq_lemma (p:global_usage) (i:timestamp) (l:label) (t:msg p i l)
: Lemma (
let res = split12 #p #i #l t in
let raw_res = split_raw12 t in
(Success? res <==> Success? raw_res) /\
(Success? res ==> (
let Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12) = res in
let Success (br1, br2, br3, br4, br5, br6, br7, br8, br9, br10, br11, br12) = raw_res in
b1 == br1 /\ b2 == br2 /\ b3 == br3 /\ b4 == br4 /\ b5 == br5 /\ b6 == br6 /\ b7 == br7 /\ b8 == br8 /\ b9 == br9 /\ b10 == br10 /\ b11 == br11 /\ b12 == br12
))
)
[SMTPat (split_raw12 t); SMTPat (split12 #p #i #l t)] = ()
/// Since the do-notation is deprecated and monadic let does not seem to work, we use this "manual
/// bind" for now.
let bsplit_raw (#a:Type) (b:bytes) (f:bytes -> bytes -> result a) : result a =
let? (b1,b2) = CryptoLib.split b in
f b1 b2
let bsplit_raw3 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> result a) : result a =
match split_raw3 b with
| Error e -> Error e
| Success (b1, b2, b3) -> f b1 b2 b3
let bsplit_raw4 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw4 b with
| Error e -> Error e
| Success (b1, b2, b3, b4) -> f b1 b2 b3 b4
let bsplit_raw5 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw5 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5) -> f b1 b2 b3 b4 b5
let bsplit_raw6 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw6 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6) -> f b1 b2 b3 b4 b5 b6
let bsplit_raw7 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw7 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7) -> f b1 b2 b3 b4 b5 b6 b7
let bsplit_raw8 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw8 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7, b8) -> f b1 b2 b3 b4 b5 b6 b7 b8
let bsplit_raw9 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw9 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7, b8, b9) -> f b1 b2 b3 b4 b5 b6 b7 b8 b9
let bsplit_raw10 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw10 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) -> f b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
let bsplit_raw11 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw11 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11) -> f b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11
let bsplit_raw12 (#a:Type) (b:bytes) (f:bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> bytes -> result a) : result a =
match split_raw12 b with
| Error e -> Error e
| Success (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12) -> f b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12
/// Labeled Crypto Functions as Record
/// ==================================
///
/// Type for a set of labeled crypto functions, to avoid having to pass usage, timestamp, and label
/// everytime.
noeq type labeled_crypto_funs_t (p:global_usage) (i:timestamp) (l:label) = {
empty: lbytes p i public;
bool_to_bytes: bool -> Tot (lbytes p i public);
bytes_to_bool: msg p i l -> result bool;
string_to_bytes: string -> Tot (lbytes p i public);
bytes_to_string: msg p i l -> result string;
nat_to_bytes: nat -> Tot (lbytes p i public);
bytes_to_nat: msg p i l -> result nat;
concat: b1:msg p i l -> b2:msg p i l -> b:msg p i l{get_label p.key_usages b == meet (get_label p.key_usages b1) (get_label p.key_usages b2)};
split: msg p i l -> result (msg p i l & msg p i l);
concat3: msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat4: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat5: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat6: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat7: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat8: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat9: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat10: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat11: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
concat12: msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l -> msg p i l;
split3: msg p i l -> result (msg p i l & msg p i l & msg p i l);
split4: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l);
split5: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split6: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split7: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split8: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split9: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split10: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split11: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
split12: msg p i l -> result (msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l & msg p i l);
}
/// Function to create a ``labeled_crypto_funs_t``
let labeled_crypto_funs (gu:global_usage) (i:timestamp) (l:label): labeled_crypto_funs_t gu i l = {
empty = LabeledCryptoAPI.empty #gu #i;
bool_to_bytes = LabeledCryptoAPI.bool_to_bytes #gu #i;
bytes_to_bool = LabeledCryptoAPI.bytes_to_bool #gu #i #l;
string_to_bytes = LabeledCryptoAPI.string_to_bytes #gu #i;
bytes_to_string = LabeledCryptoAPI.bytes_to_string #gu #i #l;
nat_to_bytes = LabeledCryptoAPI.nat_to_bytes #gu #i 0;
bytes_to_nat = LabeledCryptoAPI.bytes_to_nat #gu #i #l;
concat = LabeledCryptoAPI.concat #gu #i #l;
split = LabeledCryptoAPI.split #gu #i #l;
concat3 = concat3 #gu #i #l;
concat4 = concat4 #gu #i #l;
concat5 = concat5 #gu #i #l;
concat6 = concat6 #gu #i #l;
concat7 = concat7 #gu #i #l;
concat8 = concat8 #gu #i #l;
concat9 = concat9 #gu #i #l;
concat10 = concat10 #gu #i #l;
concat11 = concat11 #gu #i #l;
concat12 = concat12 #gu #i #l;
split3 = split3 #gu #i #l;
split4 = split4 #gu #i #l;
split5 = split5 #gu #i #l;
split6 = split6 #gu #i #l;
split7 = split7 #gu #i #l;
split8 = split8 #gu #i #l;
split9 = split9 #gu #i #l;
split10 = split10 #gu #i #l;
split11 = split11 #gu #i #l;
split12 = split12 #gu #i #l;
}
/// Serialization/Parsing for some common data types
/// ================================================
///
/// Optional ``bytes``
/// ------------------
let serialize_opt_bytes (#gu:global_usage) (#i:timestamp) (#l:label) (m:option bytes{Some? m ==> is_msg gu i (Some?.v m) l}) : msg gu i l =
let c = labeled_crypto_funs gu i l in
if None? m then
c.concat (c.string_to_bytes "Opt:None") c.empty
else
c.concat (c.string_to_bytes "Opt:Some") (Some?.v m)
let parse_opt_bytes_ (#gu:global_usage) (#i:timestamp) (#l:label) (m:msg gu i l) : (r:result (option (t:bytes{is_msg gu i t l}))) =
let c = labeled_crypto_funs gu i l in
match c.split m with
| Error e -> Error e
| Success (str, v) ->
match c.bytes_to_string str with
| Success "Opt:None" -> if v = c.empty then Success None else Error "Not an option bytes"
| Success "Opt:Some" -> Success (Some (v <: t:bytes{is_msg gu i t l}))
| _ -> Error "Not an option bytes"
let is_msg_in_result_opt (gu:global_usage) (i:timestamp) (l:label) (r:result (option bytes)) : Type =
match r with
| Success (Some t) -> is_msg gu i t l
| _ -> True
let parse_opt_bytes (#gu:global_usage) (#i:timestamp) (#l:label) (m:msg gu i l) : (r:result (option bytes){is_msg_in_result_opt gu i l r}) =
match parse_opt_bytes_ #gu #i #l m with
| Success None -> Success None
| Error e -> Error e
| Success (Some v) -> Success (Some v)
let parse_opt_bytes_raw (m:bytes) : result (option bytes) =
match CryptoLib.split m with
| Error e -> Error e
| Success (str, v) ->
match CryptoLib.bytes_to_string str with
| Success "Opt:None" -> if v = CryptoLib.empty then Success None else Error "Not an option bytes"
| Success "Opt:Some" -> Success (Some v)
| _ -> Error "Not an option bytes"
let parse_serialize_opt_bytes_lemma #gu #i #l m
: Lemma (
let r = parse_opt_bytes #gu #i #l (serialize_opt_bytes #gu #i #l m) in
let r2 = parse_opt_bytes_raw (serialize_opt_bytes #gu #i #l m) in
match r with
| Error _ -> False
| Success m' -> m == m' /\ r == r2
)
[SMTPatOr [[SMTPat (parse_opt_bytes #gu #i #l (serialize_opt_bytes #gu #i #l m))];
[SMTPat (parse_opt_bytes_raw (serialize_opt_bytes #gu #i #l m))]]]
= ()
/// "Constructors" for additional serialization/parsing of optional values
/// ----------------------------------------------------------------------
let serialize_opt_a (#a:Type) (gu:global_usage) (i:timestamp) (l:label) (serialize_a:a -> msg gu i l) (v:option a) : (r:msg gu i l) =
match v with
| None -> serialize_opt_bytes #gu #i #l None
| Some va -> serialize_opt_bytes #gu #i #l (Some (serialize_a va))
let parse_opt_a (#a:Type) (gu:global_usage) (i:timestamp) (l:label) (parse_a:msg gu i l -> result a) (m:msg gu i l) : (r:result (option a)) =
match parse_opt_bytes #gu #i #l m with
| Success (Some a_bytes) -> (
match parse_a a_bytes with
| Success a_val -> Success (Some a_val)
| Error e -> Error e
)
| Success None -> Success None
| _ -> Error "parse_opt_a: Not an option bytes"