file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_nat32_to_seq_nat8_to_seq_nat32_LE
val seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) [SMTPat (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x))]
val seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) [SMTPat (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x))]
let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); ()
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 231, "start_col": 0, "start_line": 225 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length x % 4 == 0} -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE x) == x) [ SMTPat (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE x)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "FStar.Pervasives.reveal_opaque", "Vale.Def.Words_s.four", "Prims.op_Division", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "FStar.Mul.op_Star", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x: seq nat8 {length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) =
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); ()
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_uint8_to_seq_nat8_to_seq_uint8
val seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) : Lemma (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x) == x) [SMTPat (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x))]
val seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) : Lemma (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x) == x) [SMTPat (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x))]
let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x)
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 237, "start_col": 0, "start_line": 236 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 x) == x) [ SMTPat (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 x)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "Prims.unit" ]
[]
true
false
true
false
false
let seq_uint8_to_seq_nat8_to_seq_uint8 (x: seq nat8) =
assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x)
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_four_to_seq_LE_injective_specific
val seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x')
val seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x')
let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 263, "start_col": 0, "start_line": 260 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> x': FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_four_to_seq_LE x == Vale.Def.Words.Seq_s.seq_four_to_seq_LE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq.seq_four_to_seq_LE_injective", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "Prims.int", "FStar.Seq.Base.length", "FStar.Mul.op_Star", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let seq_four_to_seq_LE_injective_specific (#a: eqtype) (x x': seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') =
seq_four_to_seq_LE_injective a
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_four_to_seq_LE_injective
val seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x':seq (four a)).{:pattern seq_four_to_seq_LE x; seq_four_to_seq_LE x'} seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x')
val seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x':seq (four a)).{:pattern seq_four_to_seq_LE x; seq_four_to_seq_LE x'} seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x')
let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); ()
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 249, "start_col": 0, "start_line": 242 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b'
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.eqtype -> FStar.Pervasives.Lemma (ensures forall (x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a)) (x': FStar.Seq.Base.seq (Vale.Def.Words_s.four a)). {:pattern Vale.Def.Words.Seq_s.seq_four_to_seq_LE x; Vale.Def.Words.Seq_s.seq_four_to_seq_LE x'} Vale.Def.Words.Seq_s.seq_four_to_seq_LE x == Vale.Def.Words.Seq_s.seq_four_to_seq_LE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "Prims.unit", "Vale.Lib.Meta.generic_injective_proof", "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "Vale.Def.Words.Seq.seq_to_seq_four_to_seq_LE", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.l_or", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let seq_four_to_seq_LE_injective (a: eqtype) : Lemma (forall (x: seq (four a)) (x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') =
let seq_four_to_seq_LE_stronger (#b: Type) (x: seq (four b)) : (s: seq b {length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); ()
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_four_to_seq_BE_injective
val seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x':seq (four a)).{:pattern seq_four_to_seq_BE x; seq_four_to_seq_BE x'} seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x')
val seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x':seq (four a)).{:pattern seq_four_to_seq_BE x; seq_four_to_seq_BE x'} seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x')
let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); ()
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 258, "start_col": 0, "start_line": 251 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.eqtype -> FStar.Pervasives.Lemma (ensures forall (x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a)) (x': FStar.Seq.Base.seq (Vale.Def.Words_s.four a)). {:pattern Vale.Def.Words.Seq_s.seq_four_to_seq_BE x; Vale.Def.Words.Seq_s.seq_four_to_seq_BE x'} Vale.Def.Words.Seq_s.seq_four_to_seq_BE x == Vale.Def.Words.Seq_s.seq_four_to_seq_BE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "Prims.unit", "Vale.Lib.Meta.generic_injective_proof", "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.Def.Words.Seq_s.seq_to_seq_four_BE", "Vale.Def.Words.Seq.seq_to_seq_four_to_seq_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.l_or", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let seq_four_to_seq_BE_injective (a: eqtype) : Lemma (forall (x: seq (four a)) (x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') =
let seq_four_to_seq_BE_stronger (#b: Type) (x: seq (four b)) : (s: seq b {length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); ()
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.seq_four_to_seq_BE_injective_specific
val seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x')
val seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x')
let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 268, "start_col": 0, "start_line": 265 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> x': FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_four_to_seq_BE x == Vale.Def.Words.Seq_s.seq_four_to_seq_BE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq.seq_four_to_seq_BE_injective", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "Prims.int", "FStar.Seq.Base.length", "FStar.Mul.op_Star", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let seq_four_to_seq_BE_injective_specific (#a: eqtype) (x x': seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') =
seq_four_to_seq_BE_injective a
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.four_to_seq_BE_injective
val four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x':four a).{:pattern four_to_seq_BE x; four_to_seq_BE x'} four_to_seq_BE x == four_to_seq_BE x' ==> x == x')
val four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x':four a).{:pattern four_to_seq_BE x; four_to_seq_BE x'} four_to_seq_BE x == four_to_seq_BE x' ==> x == x')
let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a)
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 112, "end_line": 278, "start_col": 0, "start_line": 275 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.eqtype -> FStar.Pervasives.Lemma (ensures forall (x: Vale.Def.Words_s.four a) (x': Vale.Def.Words_s.four a). {:pattern Vale.Def.Words.Seq_s.four_to_seq_BE x; Vale.Def.Words.Seq_s.four_to_seq_BE x'} Vale.Def.Words.Seq_s.four_to_seq_BE x == Vale.Def.Words.Seq_s.four_to_seq_BE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "Vale.Lib.Meta.generic_injective_proof", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Words.Seq_s.four_to_seq_BE", "Vale.Def.Words.Seq_s.seq_to_four_BE", "Vale.Def.Words.Seq.seq_to_four_to_seq_BE", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let four_to_seq_BE_injective (a: eqtype) : Lemma (forall (x: four a) (x': four a). four_to_seq_BE x == four_to_seq_BE x' ==> x == x') =
generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a)
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.four_to_seq_LE_injective
val four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x':four a).{:pattern four_to_seq_LE x; four_to_seq_LE x'} four_to_seq_LE x == four_to_seq_LE x' ==> x == x')
val four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x':four a).{:pattern four_to_seq_LE x; four_to_seq_LE x'} four_to_seq_LE x == four_to_seq_LE x' ==> x == x')
let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a)
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 112, "end_line": 273, "start_col": 0, "start_line": 270 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.eqtype -> FStar.Pervasives.Lemma (ensures forall (x: Vale.Def.Words_s.four a) (x': Vale.Def.Words_s.four a). {:pattern Vale.Def.Words.Seq_s.four_to_seq_LE x; Vale.Def.Words.Seq_s.four_to_seq_LE x'} Vale.Def.Words.Seq_s.four_to_seq_LE x == Vale.Def.Words.Seq_s.four_to_seq_LE x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "Vale.Lib.Meta.generic_injective_proof", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Words.Seq_s.four_to_seq_LE", "Vale.Def.Words.Seq_s.seq_to_four_LE", "Vale.Def.Words.Seq.seq_to_four_to_seq_LE", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let four_to_seq_LE_injective (a: eqtype) : Lemma (forall (x: four a) (x': four a). four_to_seq_LE x == four_to_seq_LE x' ==> x == x') =
generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a)
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.four_to_nat_8_injective
val four_to_nat_8_injective (_:unit) : Lemma (forall (x x':four (natN (pow2_norm 8))).{:pattern four_to_nat 8 x; four_to_nat 8 x'} four_to_nat 8 x == four_to_nat 8 x' ==> x == x')
val four_to_nat_8_injective (_:unit) : Lemma (forall (x x':four (natN (pow2_norm 8))).{:pattern four_to_nat 8 x; four_to_nat 8 x'} four_to_nat 8 x == four_to_nat 8 x' ==> x == x')
let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 283, "start_col": 0, "start_line": 280 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (x: Vale.Def.Words_s.four (Vale.Def.Words_s.natN (Vale.Def.Words_s.pow2_norm 8))) (x': Vale.Def.Words_s.four (Vale.Def.Words_s.natN (Vale.Def.Words_s.pow2_norm 8))). {:pattern Vale.Def.Words.Four_s.four_to_nat 8 x; Vale.Def.Words.Four_s.four_to_nat 8 x'} Vale.Def.Words.Four_s.four_to_nat 8 x == Vale.Def.Words.Four_s.four_to_nat 8 x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Vale.Lib.Meta.generic_injective_proof", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq.nat_to_four_to_nat", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Vale.Def.Words_s.pow2_norm", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let four_to_nat_8_injective () : Lemma (forall (x: four (natN (pow2_norm 8))) (x': four (natN (pow2_norm 8))). four_to_nat 8 x == four_to_nat 8 x' ==> x == x') =
generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.append_distributes_seq_to_seq_four_BE
val append_distributes_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y)
val append_distributes_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y)
let append_distributes_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (x @| y)) (seq_to_seq_four_BE x @| seq_to_seq_four_BE y)); ()
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 309, "start_col": 0, "start_line": 304 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a) let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat let nat_to_four_8_injective () : Lemma (forall (x x':natN (pow2_norm 32)) . nat_to_four 8 x == nat_to_four 8 x' ==> x == x') = generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8 (* let seq_to_four_LE_injective () : Lemma (forall (#a:Type) (x x':seq4 a) . seq_to_four_LE x == seq_to_four_LE x' ==> x == x') = generic_injective_proof seq_to_four_LE four_to_seq_LE four_to_seq_to_four_LE *) let append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_to_seq_four_LE (x @| y)) (seq_to_seq_four_LE x @| seq_to_seq_four_LE y)); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq a {FStar.Seq.Base.length x % 4 == 0} -> y: FStar.Seq.Base.seq a {FStar.Seq.Base.length y % 4 == 0} -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_to_seq_four_BE (x @| y) == Vale.Def.Words.Seq_s.seq_to_seq_four_BE x @| Vale.Def.Words.Seq_s.seq_to_seq_four_BE y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq_s.seq_to_seq_four_BE", "FStar.Seq.Base.op_At_Bar", "FStar.Pervasives.reveal_opaque", "Prims.op_Division", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let append_distributes_seq_to_seq_four_BE (#a: Type) (x: seq a {length x % 4 == 0}) (y: seq a {length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y) =
reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (x @| y)) (seq_to_seq_four_BE x @| seq_to_seq_four_BE y)); ()
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.nat_to_four_8_injective
val nat_to_four_8_injective (_:unit) : Lemma (forall (x x':natN (pow2_norm 32)).{:pattern nat_to_four 8 x; nat_to_four 8 x'} nat_to_four 8 x == nat_to_four 8 x' ==> x == x')
val nat_to_four_8_injective (_:unit) : Lemma (forall (x x':natN (pow2_norm 32)).{:pattern nat_to_four 8 x; nat_to_four 8 x'} nat_to_four 8 x == nat_to_four 8 x' ==> x == x')
let nat_to_four_8_injective () : Lemma (forall (x x':natN (pow2_norm 32)) . nat_to_four 8 x == nat_to_four 8 x' ==> x == x') = generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 288, "start_col": 0, "start_line": 285 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a) let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (x: Vale.Def.Words_s.natN (Vale.Def.Words_s.pow2_norm 32)) (x': Vale.Def.Words_s.natN (Vale.Def.Words_s.pow2_norm 32)). {:pattern Vale.Def.Words.Four_s.nat_to_four 8 x; Vale.Def.Words.Four_s.nat_to_four 8 x'} Vale.Def.Words.Four_s.nat_to_four 8 x == Vale.Def.Words.Four_s.nat_to_four 8 x' ==> x == x')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Vale.Lib.Meta.generic_injective_proof", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words_s.four", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq.four_to_nat_to_four_8", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Vale.Def.Words_s.pow2_norm", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let nat_to_four_8_injective () : Lemma (forall (x: natN (pow2_norm 32)) (x': natN (pow2_norm 32)). nat_to_four 8 x == nat_to_four 8 x' ==> x == x') =
generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.append_distributes_seq_four_to_seq_BE
val append_distributes_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) (y:seq (four a)) : Lemma (seq_four_to_seq_BE (x @| y) == seq_four_to_seq_BE x @| seq_four_to_seq_BE y)
val append_distributes_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) (y:seq (four a)) : Lemma (seq_four_to_seq_BE (x @| y) == seq_four_to_seq_BE x @| seq_four_to_seq_BE y)
let append_distributes_seq_four_to_seq_BE #a x y = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (seq_four_to_seq_BE (x @| y)) (seq_four_to_seq_BE x @| seq_four_to_seq_BE y))
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 93, "end_line": 317, "start_col": 0, "start_line": 315 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a) let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat let nat_to_four_8_injective () : Lemma (forall (x x':natN (pow2_norm 32)) . nat_to_four 8 x == nat_to_four 8 x' ==> x == x') = generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8 (* let seq_to_four_LE_injective () : Lemma (forall (#a:Type) (x x':seq4 a) . seq_to_four_LE x == seq_to_four_LE x' ==> x == x') = generic_injective_proof seq_to_four_LE four_to_seq_LE four_to_seq_to_four_LE *) let append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_to_seq_four_LE (x @| y)) (seq_to_seq_four_LE x @| seq_to_seq_four_LE y)); () let append_distributes_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (x @| y)) (seq_to_seq_four_BE x @| seq_to_seq_four_BE y)); () let append_distributes_seq_four_to_seq_LE #a x y = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (seq_four_to_seq_LE (x @| y)) (seq_four_to_seq_LE x @| seq_four_to_seq_LE y))
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> y: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_four_to_seq_BE (x @| y) == Vale.Def.Words.Seq_s.seq_four_to_seq_BE x @| Vale.Def.Words.Seq_s.seq_four_to_seq_BE y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "FStar.Seq.Base.op_At_Bar", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "FStar.Mul.op_Star" ]
[]
true
false
true
false
false
let append_distributes_seq_four_to_seq_BE #a x y =
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (seq_four_to_seq_BE (x @| y)) (seq_four_to_seq_BE x @| seq_four_to_seq_BE y))
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.append_distributes_seq_to_seq_four_LE
val append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y)
val append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y)
let append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_to_seq_four_LE (x @| y)) (seq_to_seq_four_LE x @| seq_to_seq_four_LE y)); ()
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 302, "start_col": 0, "start_line": 297 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a) let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat let nat_to_four_8_injective () : Lemma (forall (x x':natN (pow2_norm 32)) . nat_to_four 8 x == nat_to_four 8 x' ==> x == x') = generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8 (* let seq_to_four_LE_injective () : Lemma (forall (#a:Type) (x x':seq4 a) . seq_to_four_LE x == seq_to_four_LE x' ==> x == x') = generic_injective_proof seq_to_four_LE four_to_seq_LE four_to_seq_to_four_LE *)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq a {FStar.Seq.Base.length x % 4 == 0} -> y: FStar.Seq.Base.seq a {FStar.Seq.Base.length y % 4 == 0} -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_to_seq_four_LE (x @| y) == Vale.Def.Words.Seq_s.seq_to_seq_four_LE x @| Vale.Def.Words.Seq_s.seq_to_seq_four_LE y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "FStar.Seq.Base.op_At_Bar", "FStar.Pervasives.reveal_opaque", "Prims.op_Division", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let append_distributes_seq_to_seq_four_LE (#a: Type) (x: seq a {length x % 4 == 0}) (y: seq a {length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_to_seq_four_LE (x @| y)) (seq_to_seq_four_LE x @| seq_to_seq_four_LE y)); ()
false
Vale.Def.Words.Seq.fst
Vale.Def.Words.Seq.append_distributes_seq_four_to_seq_LE
val append_distributes_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) (y:seq (four a)) : Lemma (seq_four_to_seq_LE (x @| y) == seq_four_to_seq_LE x @| seq_four_to_seq_LE y)
val append_distributes_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) (y:seq (four a)) : Lemma (seq_four_to_seq_LE (x @| y) == seq_four_to_seq_LE x @| seq_four_to_seq_LE y)
let append_distributes_seq_four_to_seq_LE #a x y = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (seq_four_to_seq_LE (x @| y)) (seq_four_to_seq_LE x @| seq_four_to_seq_LE y))
{ "file_name": "vale/code/lib/util/Vale.Def.Words.Seq.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 93, "end_line": 313, "start_col": 0, "start_line": 311 }
module Vale.Def.Words.Seq open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open FStar.Mul open Vale.Lib.Meta open Vale.Lib.Seqs_s open Vale.Lib.Seqs let two_to_seq_to_two_LE #a x = assert (equal (two_to_seq_LE (seq_to_two_LE x)) x) let seq_to_two_to_seq_LE #a x = () let seq_to_seq_four_to_seq_LE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_LE (seq_four_to_seq_LE x) == x) [SMTPat (seq_to_seq_four_LE (seq_four_to_seq_LE x))] = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); let bytes = seq_four_to_seq_LE x in let fours = seq_to_seq_four_LE bytes in assert (equal fours x); () let seq_to_seq_four_to_seq_BE (#a:Type) (x:seq (four a)) : Lemma (seq_to_seq_four_BE (seq_four_to_seq_BE x) == x) [SMTPat (seq_to_seq_four_BE (seq_four_to_seq_BE x))] = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (seq_four_to_seq_BE x)) x); () let seq_four_to_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_LE (seq_to_seq_four_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_four_to_seq_LE (seq_to_seq_four_LE x)) x); () let seq_four_to_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) : Lemma (seq_four_to_seq_BE (seq_to_seq_four_BE x) == x) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_four_to_seq_BE (seq_to_seq_four_BE x)) x); () unfold let pow2_24 = 16777216 //normalize_term (pow2 24) #push-options "--z3rlimit 200 --using_facts_from 'Prims Vale.Def.Words_s'" let lemma_fundamental_div_mod_4 (x:nat32) : Lemma (x = x % pow2_8 + pow2_8 * ((x / pow2_8) % pow2_8) + pow2_16 * ((x / pow2_16) % pow2_8) + pow2_24 * ((x / pow2_24) % pow2_8)) = () #pop-options let four_to_nat_to_four_8 (x:natN (pow2_norm 32)) : Lemma (four_to_nat 8 (nat_to_four 8 x) == x) [SMTPat (four_to_nat 8 (nat_to_four 8 x))] = let size = 8 in let n1 = pow2_norm size in let n2 = pow2_norm (2 * size) in let n3 = pow2_norm (3 * size) in let n4 = pow2_norm (4 * size) in assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 0x10000); assert_norm (pow2 24 == 0x1000000); assert_norm (pow2 32 == 0x100000000); let fourX = nat_to_four 8 x in assert_norm (nat_to_four 8 x == Mkfour (x % n1) ((x / n1) % n1) ((x / n2) % n1) ((x / n3) % n1)); let Mkfour x0 x1 x2 x3 = fourX in let x' = x0 + x1 * n1 + x2 * n2 + x3 * n3 in assert_norm (four_to_nat 8 fourX == int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)); lemma_fundamental_div_mod_4 x; () #push-options "--z3rlimit 20 --z3cliopt smt.arith.nl=true" (* Localized use of NL arith. The makefile passes the option to disable it in this file, so we reenable it here. *) let rec base_to_nat (base:pos) (cs : list (natN base)) : nat = match cs with | [] -> 0 | c :: cs' -> c + base_to_nat base cs' * base (* NB: right-multiplying by base is a lot better than left-multiplying since it more closely matches the lemmas in FStar.Math.Lemmas. *) #pop-options (* If two lists represent the same number, their heads must match, otherwise their modulus wrt the base would differ. *) let base_to_nat_inj_head (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ Cons? x /\ Cons? y) (ensures List.Tot.hd x == List.Tot.hd y) = match x, y with | x1 :: xs, y1 :: ys -> let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { x1 <: int; == { small_mod x1 base } x1 % base; == { lemma_mod_plus x1 (base_to_nat base xs) base } (x1 + base_to_nat base xs * base) % base; == {} x' % base; == {} y' % base; == {} (y1 + base_to_nat base ys * base) % base; == { lemma_mod_plus y1 (base_to_nat base ys) base } y1 % base; == { small_mod y1 base } y1; } (* Generalizing the lemma above, if two lists represent the same number, and they have the same length, they must be the same list. The length requirement is due to the possibility of trailing zeroes. Another possibility is stating that one of them is a prefix of the other, which is enough for this module, even without stating that the "rest" is all zeroes. *) let rec base_to_nat_inj (base:pos) (x y : list (natN base)) : Lemma (requires base_to_nat base x == base_to_nat base y /\ List.length x == List.length y) (ensures x == y) = match x, y with | [], [] -> () | x1 :: xs, y1 :: ys -> base_to_nat_inj_head base x y; let x' = base_to_nat base x in let y' = base_to_nat base y in let open FStar.Math.Lemmas in calc (==) { base_to_nat base xs * base; == {} x' - x1; == {} y' - y1; == {} base_to_nat base ys * base; }; lemma_cancel_mul (base_to_nat base xs) (base_to_nat base ys) base; assert (base_to_nat base xs == base_to_nat base ys); base_to_nat_inj base xs ys #push-options "--fuel 4" (* Fuel needed to prove length equality *) let four_to_nat_inj (x y : four (natN 256)) : Lemma (requires four_to_nat 8 x == four_to_nat 8 y) (ensures x == y) = let Mkfour x0 x1 x2 x3 = x in let Mkfour y0 y1 y2 y3 = y in assert_norm (four_to_nat 8 (Mkfour x0 x1 x2 x3) == base_to_nat 256 [x0; x1; x2; x3]); assert_norm (four_to_nat 8 (Mkfour y0 y1 y2 y3) == base_to_nat 256 [y0; y1; y2; y3]); base_to_nat_inj 256 [x0; x1; x2; x3] [y0; y1; y2; y3]; () #pop-options let nat_to_four_to_nat (x:four (natN 256)) : Lemma (nat_to_four 8 (four_to_nat 8 x) == x) [SMTPat (nat_to_four 8 (four_to_nat 8 x))] = four_to_nat_to_four_8 (four_to_nat 8 x); four_to_nat_inj (nat_to_four 8 (four_to_nat 8 x)) x let four_to_seq_to_four_LE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_LE (seq_to_four_LE x) == x) = assert (equal (four_to_seq_LE (seq_to_four_LE x)) x); () let seq_to_four_to_seq_LE (#a:Type) (x:four a) : Lemma (seq_to_four_LE (four_to_seq_LE x) == x) = () let four_to_seq_to_four_BE (#a:Type) (x:seq4 a) : Lemma (four_to_seq_BE (seq_to_four_BE x) == x) = assert (equal (four_to_seq_BE (seq_to_four_BE x)) x); () let seq_to_four_to_seq_BE (#a:Type) (x:four a) : Lemma (seq_to_four_BE (four_to_seq_BE x) == x) = () let four_to_seq_LE_is_seq_four_to_seq_LE(#a:Type) (x:four a) : Lemma (four_to_seq_LE x == seq_four_to_seq_LE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); let s0 = four_to_seq_LE x in let s1 = seq_four_to_seq_LE (create 1 x) in assert (equal s0 s1); () let four_to_seq_BE_is_seq_four_to_seq_BE (x:four nat32) : Lemma (four_to_seq_BE x == seq_four_to_seq_BE (create 1 x)) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); let s0 = four_to_seq_BE x in let s1 = seq_four_to_seq_BE (create 1 x) in assert (equal s0 s1); () let seq_nat8_to_seq_nat32_to_seq_nat8_LE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x) == x) = assert (equal (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE x)) x); () let seq_nat8_to_seq_nat32_to_seq_nat8_BE (x:seq nat32) : Lemma (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x) == x) = assert (equal (seq_nat8_to_seq_nat32_BE (seq_nat32_to_seq_nat8_BE x)) x); () let seq_nat32_to_seq_nat8_to_seq_nat32_LE (x:seq nat8{length x % 4 == 0}) : Lemma (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x) == x) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (equal (seq_nat32_to_seq_nat8_LE (seq_nat8_to_seq_nat32_LE x)) x); () let seq_nat8_to_seq_uint8_to_seq_nat8 (x:seq UInt8.t) = assert (equal (seq_nat8_to_seq_uint8 (seq_uint8_to_seq_nat8 x)) x) let seq_uint8_to_seq_nat8_to_seq_uint8 (x:seq nat8) = assert (equal (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 x)) x) let seq_nat8_to_seq_uint8_injective b b' = seq_map_injective UInt8.uint_to_t b b' let seq_four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_LE #a x == seq_four_to_seq_LE #a x' ==> x == x') = let seq_four_to_seq_LE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_LE x in generic_injective_proof (seq_four_to_seq_LE_stronger) (seq_to_seq_four_LE #a) (seq_to_seq_four_to_seq_LE #a); () let seq_four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': seq (four a)). seq_four_to_seq_BE #a x == seq_four_to_seq_BE #a x' ==> x == x') = let seq_four_to_seq_BE_stronger (#b:Type) (x:seq (four b)) : (s:seq b{length s % 4 == 0}) = seq_four_to_seq_BE x in generic_injective_proof (seq_four_to_seq_BE_stronger) (seq_to_seq_four_BE #a) (seq_to_seq_four_to_seq_BE #a); () let seq_four_to_seq_LE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_LE x == seq_four_to_seq_LE x' ==> x == x') = seq_four_to_seq_LE_injective a let seq_four_to_seq_BE_injective_specific (#a:eqtype) (x x':seq (four a)) : Lemma (seq_four_to_seq_BE x == seq_four_to_seq_BE x' ==> x == x') = seq_four_to_seq_BE_injective a let four_to_seq_LE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_LE x == four_to_seq_LE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_LE #a) (seq_to_four_LE #a) (seq_to_four_to_seq_LE #a) let four_to_seq_BE_injective (a:eqtype) : Lemma (forall (x x': four a) . four_to_seq_BE x == four_to_seq_BE x' ==> x == x') = generic_injective_proof #(four a) #(seq4 a) (four_to_seq_BE #a) (seq_to_four_BE #a) (seq_to_four_to_seq_BE #a) let four_to_nat_8_injective () : Lemma (forall (x x':four (natN (pow2_norm 8))) . four_to_nat 8 x == four_to_nat 8 x' ==> x == x') = generic_injective_proof (four_to_nat 8) (nat_to_four 8) nat_to_four_to_nat let nat_to_four_8_injective () : Lemma (forall (x x':natN (pow2_norm 32)) . nat_to_four 8 x == nat_to_four 8 x' ==> x == x') = generic_injective_proof (nat_to_four 8) (four_to_nat 8) four_to_nat_to_four_8 (* let seq_to_four_LE_injective () : Lemma (forall (#a:Type) (x x':seq4 a) . seq_to_four_LE x == seq_to_four_LE x' ==> x == x') = generic_injective_proof seq_to_four_LE four_to_seq_LE four_to_seq_to_four_LE *) let append_distributes_seq_to_seq_four_LE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_LE (x @| y) == seq_to_seq_four_LE x @| seq_to_seq_four_LE y) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (seq_to_seq_four_LE (x @| y)) (seq_to_seq_four_LE x @| seq_to_seq_four_LE y)); () let append_distributes_seq_to_seq_four_BE (#a:Type) (x:seq a{length x % 4 == 0}) (y:seq a{length y % 4 == 0}) : Lemma (seq_to_seq_four_BE (x @| y) == seq_to_seq_four_BE x @| seq_to_seq_four_BE y) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (seq_to_seq_four_BE (x @| y)) (seq_to_seq_four_BE x @| seq_to_seq_four_BE y)); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Def.Words.Seq.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> y: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> FStar.Pervasives.Lemma (ensures Vale.Def.Words.Seq_s.seq_four_to_seq_LE (x @| y) == Vale.Def.Words.Seq_s.seq_four_to_seq_LE x @| Vale.Def.Words.Seq_s.seq_four_to_seq_LE y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "FStar.Seq.Base.op_At_Bar", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "FStar.Mul.op_Star" ]
[]
true
false
true
false
false
let append_distributes_seq_four_to_seq_LE #a x y =
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (seq_four_to_seq_LE (x @| y)) (seq_four_to_seq_LE x @| seq_four_to_seq_LE y))
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_cons
val on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True)
val on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True)
let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 76, "start_col": 0, "start_line": 66 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_join", "Prims.unit", "Steel.ST.OnRange.on_range_singleton_intro", "Steel.Effect.Common.star", "Steel.ST.OnRange.on_range", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) =
on_range_singleton_intro p i j; on_range_join p i j k
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_unsnoc
val on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (on_range p i j) `star` (p j)) (i <= j /\ k == j + 1) (fun _ -> True)
val on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (on_range p i j) `star` (p j)) (i <= j /\ k == j + 1) (fun _ -> True)
let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` p j) (i <= j /\ k == j + 1) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p j k
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 132, "start_col": 0, "start_line": 122 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k) let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_singleton_elim", "Prims.unit", "Steel.ST.OnRange.on_range_split", "Steel.ST.OnRange.on_range", "Steel.Effect.Common.star", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (on_range p i j) `star` (p j)) (i <= j /\ k == j + 1) (fun _ -> True) =
on_range_split p i j k; on_range_singleton_elim p j k
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_uncons
val on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p i) `star` (on_range p j k)) (j == i + 1 /\ j <= k) (fun _ -> True)
val on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p i) `star` (on_range p j k)) (j == i + 1 /\ j <= k) (fun _ -> True)
let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 88, "start_col": 0, "start_line": 78 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_singleton_elim", "Prims.unit", "Steel.ST.OnRange.on_range_split", "Steel.ST.OnRange.on_range", "Steel.Effect.Common.star", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p i) `star` (on_range p j k)) (j == i + 1 /\ j <= k) (fun _ -> True) =
on_range_split p i j k; on_range_singleton_elim p i j
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.felem4
val felem4 : Type0
let felem4 = uint64 & uint64 & uint64 & uint64
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 12, "start_col": 0, "start_line": 12 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let felem4 =
uint64 & uint64 & uint64 & uint64
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.as_nat4
val as_nat4 : f: Hacl.Spec.K256.Field52.Definitions.felem4 -> Prims.int
let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 17, "start_col": 0, "start_line": 15 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.K256.Field52.Definitions.felem4 -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem4", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Prims.pow2", "Prims.int" ]
[]
false
false
false
true
false
let as_nat4 (f: felem4) =
let f0, f1, f2, f3 = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.scale64
val scale64 : Type0
let scale64 = x:nat{x <= 4096}
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 78, "start_col": 0, "start_line": 78 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64 =
x: nat{x <= 4096}
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.felem5
val felem5 : Type0
let felem5 = uint64 & uint64 & uint64 & uint64 & uint64
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 21, "start_col": 0, "start_line": 21 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let felem5 =
uint64 & uint64 & uint64 & uint64 & uint64
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.mk_nat5
val mk_nat5 (x: nat) : nat5
val mk_nat5 (x: nat) : nat5
let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 81, "start_col": 0, "start_line": 81 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536}
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> Hacl.Spec.K256.Field52.Definitions.nat5
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Pervasives.Native.Mktuple5", "Hacl.Spec.K256.Field52.Definitions.nat5" ]
[]
false
false
false
true
false
let mk_nat5 (x: nat) : nat5 =
(x, x, x, x, x)
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.scale64_last
val scale64_last : Type0
let scale64_last = x:nat{x <= 65536}
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 79, "start_col": 0, "start_line": 79 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64_last =
x: nat{x <= 65536}
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.nat5
val nat5 : Type0
let nat5 = nat & nat & nat & nat & nat
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 80, "start_col": 0, "start_line": 80 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096}
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple5", "Prims.nat" ]
[]
false
false
false
true
true
let nat5 =
nat & nat & nat & nat & nat
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.scale64_5
val scale64_5 : Type0
let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536}
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 84, "start_col": 0, "start_line": 83 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.nat5", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64_5 =
x: nat5 { let x0, x1, x2, x3, x4 = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536 }
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.max52
val max52:pos
val max52:pos
let max52 : pos = assert_norm (pow2 52 - 1 > 0); pow2 52 - 1
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 106, "start_col": 0, "start_line": 104 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x) let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536} let ( <=* ) (x y:nat5) : Type = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in x0 <= y0 /\ x1 <= y1 /\ x2 <= y2 /\ x3 <= y3 /\ x4 <= y4 let ( +* ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 + y0, x1 + y1, x2 + y2, x3 + y3, x4 + y4) let ( ** ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 * y0, x1 * y1, x2 * y2, x3 * y3, x4 * y4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.pos
Prims.Tot
[ "total" ]
[]
[ "Prims.op_Subtraction", "Prims.pow2", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_GreaterThan" ]
[]
false
false
false
true
false
let max52:pos =
assert_norm (pow2 52 - 1 > 0); pow2 52 - 1
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.felem_fits1
val felem_fits1 : x: Lib.IntTypes.uint64 -> m: Hacl.Spec.K256.Field52.Definitions.scale64 -> Prims.bool
let felem_fits1 (x:uint64) (m:scale64) = v x <= m * max52
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 115, "start_col": 0, "start_line": 114 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x) let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536} let ( <=* ) (x y:nat5) : Type = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in x0 <= y0 /\ x1 <= y1 /\ x2 <= y2 /\ x3 <= y3 /\ x4 <= y4 let ( +* ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 + y0, x1 + y1, x2 + y2, x3 + y3, x4 + y4) let ( ** ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 * y0, x1 * y1, x2 * y2, x3 * y3, x4 * y4) noextract let max52 : pos = assert_norm (pow2 52 - 1 > 0); pow2 52 - 1 noextract let max48 : pos = assert_norm (pow2 48 - 1 > 0); pow2 48 - 1
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.uint64 -> m: Hacl.Spec.K256.Field52.Definitions.scale64 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "Hacl.Spec.K256.Field52.Definitions.scale64", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.K256.Field52.Definitions.max52", "Prims.bool" ]
[]
false
false
false
true
false
let felem_fits1 (x: uint64) (m: scale64) =
v x <= m * max52
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.mask52
val mask52:x: uint64{v x == pow2 52 - 1}
val mask52:x: uint64{v x == pow2 52 - 1}
let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 35, "start_col": 0, "start_line": 33 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC {Lib.IntTypes.v x == Prims.pow2 52 - 1}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.u64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
false
false
false
false
false
let mask52:x: uint64{v x == pow2 52 - 1} =
assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.max48
val max48:pos
val max48:pos
let max48 : pos = assert_norm (pow2 48 - 1 > 0); pow2 48 - 1
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 111, "start_col": 0, "start_line": 109 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x) let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536} let ( <=* ) (x y:nat5) : Type = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in x0 <= y0 /\ x1 <= y1 /\ x2 <= y2 /\ x3 <= y3 /\ x4 <= y4 let ( +* ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 + y0, x1 + y1, x2 + y2, x3 + y3, x4 + y4) let ( ** ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 * y0, x1 * y1, x2 * y2, x3 * y3, x4 * y4) noextract let max52 : pos = assert_norm (pow2 52 - 1 > 0); pow2 52 - 1
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.pos
Prims.Tot
[ "total" ]
[]
[ "Prims.op_Subtraction", "Prims.pow2", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_GreaterThan" ]
[]
false
false
false
true
false
let max48:pos =
assert_norm (pow2 48 - 1 > 0); pow2 48 - 1
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.felem_fits_last1
val felem_fits_last1 : x: Lib.IntTypes.uint64 -> m: Hacl.Spec.K256.Field52.Definitions.scale64_last -> Prims.bool
let felem_fits_last1 (x:uint64) (m:scale64_last) = v x <= m * max48
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 118, "start_col": 0, "start_line": 117 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x) let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536} let ( <=* ) (x y:nat5) : Type = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in x0 <= y0 /\ x1 <= y1 /\ x2 <= y2 /\ x3 <= y3 /\ x4 <= y4 let ( +* ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 + y0, x1 + y1, x2 + y2, x3 + y3, x4 + y4) let ( ** ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 * y0, x1 * y1, x2 * y2, x3 * y3, x4 * y4) noextract let max52 : pos = assert_norm (pow2 52 - 1 > 0); pow2 52 - 1 noextract let max48 : pos = assert_norm (pow2 48 - 1 > 0); pow2 48 - 1 let felem_fits1 (x:uint64) (m:scale64) = v x <= m * max52
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.uint64 -> m: Hacl.Spec.K256.Field52.Definitions.scale64_last -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "Hacl.Spec.K256.Field52.Definitions.scale64_last", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.K256.Field52.Definitions.max48", "Prims.bool" ]
[]
false
false
false
true
false
let felem_fits_last1 (x: uint64) (m: scale64_last) =
v x <= m * max48
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.pow52
val pow52:(pow52: pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52})
val pow52:(pow52: pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52})
let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 29, "start_col": 0, "start_line": 24 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow52: Prims.pos { Prims.pow2 64 == 4096 * pow52 /\ Prims.pow2 128 == (16777216 * pow52) * pow52 /\ Prims.pow2 52 == pow52 }
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.pow2", "FStar.Mul.op_Star", "Prims.pos", "FStar.Pervasives.normalize_term" ]
[]
false
false
false
false
false
let pow52:(pow52: pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) =
let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = (16777216 * pow52) * pow52); pow52
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.feval5
val feval5 (f: felem5) : S.felem
val feval5 (f: felem5) : S.felem
let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 75, "start_col": 0, "start_line": 75 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Spec.K256.PointOps.felem
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Prims.op_Modulus", "Hacl.Spec.K256.Field52.Definitions.as_nat5", "Spec.K256.PointOps.prime", "Spec.K256.PointOps.felem" ]
[]
false
false
false
true
false
let feval5 (f: felem5) : S.felem =
as_nat5 f % S.prime
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.mask48
val mask48:x: uint64{v x == pow2 48 - 1}
val mask48:x: uint64{v x == pow2 48 - 1}
let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 20, "end_line": 41, "start_col": 0, "start_line": 39 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC {Lib.IntTypes.v x == Prims.pow2 48 - 1}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.u64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
false
false
false
false
false
let mask48:x: uint64{v x == pow2 48 - 1} =
assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.pow156
val pow156:(pow156: pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52})
val pow156:(pow156: pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52})
let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 57, "start_col": 0, "start_line": 52 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow156: Prims.pos { Prims.pow2 156 == pow156 /\ pow156 == (Hacl.Spec.K256.Field52.Definitions.pow52 * Hacl.Spec.K256.Field52.Definitions.pow52) * Hacl.Spec.K256.Field52.Definitions.pow52 }
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Math.Lemmas.pow2_plus", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pos", "Prims.pow2", "FStar.Pervasives.normalize_term" ]
[]
false
false
false
false
false
let pow156:(pow156: pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) =
let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.as_nat5
val as_nat5 (f: felem5) : nat
val as_nat5 (f: felem5) : nat
let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 69, "end_line": 72, "start_col": 0, "start_line": 70 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.K256.Field52.Definitions.pow52", "Hacl.Spec.K256.Field52.Definitions.pow104", "Hacl.Spec.K256.Field52.Definitions.pow156", "Hacl.Spec.K256.Field52.Definitions.pow208", "Prims.nat" ]
[]
false
false
false
true
false
let as_nat5 (f: felem5) : nat =
let f0, f1, f2, f3, f4 = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.pow208
val pow208:(pow208: pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52})
val pow208:(pow208: pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52})
let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 66, "start_col": 0, "start_line": 60 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow208: Prims.pos { Prims.pow2 208 == pow208 /\ pow208 == ((Hacl.Spec.K256.Field52.Definitions.pow52 * Hacl.Spec.K256.Field52.Definitions.pow52) * Hacl.Spec.K256.Field52.Definitions.pow52) * Hacl.Spec.K256.Field52.Definitions.pow52 }
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Math.Lemmas.pow2_plus", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pos", "Prims.pow2", "FStar.Pervasives.normalize_term" ]
[]
false
false
false
false
false
let pow208:(pow208: pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) =
let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.pow104
val pow104:(pow104: pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52})
val pow104:(pow104: pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52})
let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 49, "start_col": 0, "start_line": 45 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow104: Prims.pos { Prims.pow2 104 == pow104 /\ pow104 == Hacl.Spec.K256.Field52.Definitions.pow52 * Hacl.Spec.K256.Field52.Definitions.pow52 }
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Math.Lemmas.pow2_plus", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pos", "Prims.pow2", "FStar.Pervasives.normalize_term" ]
[]
false
false
false
false
false
let pow104:(pow104: pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) =
let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104
false
Hacl.Hash.MD.fsti
Hacl.Hash.MD.legacy_alg
val legacy_alg : Type0
let legacy_alg = a:hash_alg { a == MD5 \/ a == SHA1 }
{ "file_name": "code/hash/Hacl.Hash.MD.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 8, "start_col": 0, "start_line": 8 }
module Hacl.Hash.MD open Hacl.Hash.Definitions open Spec.Hash.Definitions module U32 = FStar.UInt32
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Hash.MD.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Prims.l_or", "Prims.eq2", "Spec.Hash.Definitions.MD5", "Spec.Hash.Definitions.SHA1" ]
[]
false
false
false
true
true
let legacy_alg =
a: hash_alg{a == MD5 \/ a == SHA1}
false
Hacl.Spec.K256.Field52.Definitions.fst
Hacl.Spec.K256.Field52.Definitions.felem_fits5
val felem_fits5 : f: Hacl.Spec.K256.Field52.Definitions.felem5 -> m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> Prims.logical
let felem_fits5 (f:felem5) (m:scale64_5) = let (f0,f1,f2,f3,f4) = f in let (m0,m1,m2,m3,m4) = m in felem_fits1 f0 m0 /\ felem_fits1 f1 m1 /\ felem_fits1 f2 m2 /\ felem_fits1 f3 m3 /\ felem_fits_last1 f4 m4
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 127, "start_col": 0, "start_line": 120 }
module Hacl.Spec.K256.Field52.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let felem4 = uint64 & uint64 & uint64 & uint64 noextract let as_nat4 (f:felem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 inline_for_extraction noextract let felem5 = uint64 & uint64 & uint64 & uint64 & uint64 [@"opaque_to_smt"] let pow52: (pow52:pos{pow2 64 == 4096 * pow52 /\ pow2 128 == 16777216 * pow52 * pow52 /\ pow2 52 == pow52}) = let pow52:pos = normalize_term (pow2 52) in assert_norm (pow52 = pow2 52); assert_norm (pow2 64 = 4096 * pow52); assert_norm (pow2 128 = 16777216 * pow52 * pow52); pow52 inline_for_extraction noextract let mask52: x:uint64{v x == pow2 52 - 1} = assert_norm (pow2 52 - 1 = 0xfffffffffffff); u64 0xfffffffffffff inline_for_extraction noextract let mask48: x:uint64{v x == pow2 48 - 1} = assert_norm (pow2 48 - 1 = 0xffffffffffff); u64 0xffffffffffff [@"opaque_to_smt"] let pow104: (pow104:pos{pow2 104 == pow104 /\ pow104 == pow52 * pow52}) = let pow104:pos = normalize_term (pow2 104) in assert_norm (pow104 = pow2 104); Math.Lemmas.pow2_plus 52 52; pow104 [@"opaque_to_smt"] let pow156: (pow156:pos{pow2 156 == pow156 /\ pow156 == pow52 * pow52 * pow52}) = let pow156:pos = normalize_term (pow2 156) in assert_norm (pow156 = pow2 156); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; pow156 [@"opaque_to_smt"] let pow208: (pow208:pos{pow2 208 == pow208 /\ pow208 == pow52 * pow52 * pow52 * pow52}) = let pow208:pos = normalize_term (pow2 208) in assert_norm (pow208 = pow2 208); Math.Lemmas.pow2_plus 52 52; Math.Lemmas.pow2_plus 104 52; Math.Lemmas.pow2_plus 156 52; pow208 noextract let as_nat5 (f:felem5) : nat = let (f0, f1, f2, f3, f4) = f in v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 noextract let feval5 (f:felem5) : S.felem = as_nat5 f % S.prime let scale64 = x:nat{x <= 4096} let scale64_last = x:nat{x <= 65536} let nat5 = nat & nat & nat & nat & nat let mk_nat5 (x:nat) : nat5 = (x,x,x,x,x) let scale64_5 = x:nat5{let (x0,x1,x2,x3,x4) = x in x0 <= 4096 /\ x1 <= 4096 /\ x2 <= 4096 /\ x3 <= 4096 /\ x4 <= 65536} let ( <=* ) (x y:nat5) : Type = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in x0 <= y0 /\ x1 <= y1 /\ x2 <= y2 /\ x3 <= y3 /\ x4 <= y4 let ( +* ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 + y0, x1 + y1, x2 + y2, x3 + y3, x4 + y4) let ( ** ) (x y:nat5) : nat5 = let (x0,x1,x2,x3,x4) = x in let (y0,y1,y2,y3,y4) = y in (x0 * y0, x1 * y1, x2 * y2, x3 * y3, x4 * y4) noextract let max52 : pos = assert_norm (pow2 52 - 1 > 0); pow2 52 - 1 noextract let max48 : pos = assert_norm (pow2 48 - 1 > 0); pow2 48 - 1 let felem_fits1 (x:uint64) (m:scale64) = v x <= m * max52 let felem_fits_last1 (x:uint64) (m:scale64_last) = v x <= m * max48
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.K256.Field52.Definitions.felem5 -> m: Hacl.Spec.K256.Field52.Definitions.scale64_5 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Hacl.Spec.K256.Field52.Definitions.scale64_5", "Lib.IntTypes.uint64", "Prims.nat", "Prims.l_and", "Prims.b2t", "Hacl.Spec.K256.Field52.Definitions.felem_fits1", "Hacl.Spec.K256.Field52.Definitions.felem_fits_last1", "Prims.logical" ]
[]
false
false
false
true
true
let felem_fits5 (f: felem5) (m: scale64_5) =
let f0, f1, f2, f3, f4 = f in let m0, m1, m2, m3, m4 = m in felem_fits1 f0 m0 /\ felem_fits1 f1 m1 /\ felem_fits1 f2 m2 /\ felem_fits1 f3 m3 /\ felem_fits_last1 f4 m4
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.max_simple_value_additional_info
val max_simple_value_additional_info : FStar.UInt8.t
let max_simple_value_additional_info = 23uy
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 29, "start_col": 0, "start_line": 29 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.__uint_to_t" ]
[]
false
false
false
true
false
let max_simple_value_additional_info =
23uy
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.min_simple_value_long_argument
val min_simple_value_long_argument : FStar.UInt8.t
let min_simple_value_long_argument = 32uy
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 26, "start_col": 0, "start_line": 26 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.__uint_to_t" ]
[]
false
false
false
true
false
let min_simple_value_long_argument =
32uy
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.simple_value_wf
val simple_value_wf (x: U8.t) : Tot bool
val simple_value_wf (x: U8.t) : Tot bool
let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 90, "end_line": 36, "start_col": 0, "start_line": 33 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "Prims.op_BarBar", "FStar.UInt8.lte", "CBOR.Spec.Type.max_simple_value_additional_info", "CBOR.Spec.Type.min_simple_value_long_argument", "Prims.bool" ]
[]
false
false
false
true
false
let simple_value_wf (x: U8.t) : Tot bool =
x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.dummy_raw_data_item
val dummy_raw_data_item:Ghost.erased raw_data_item
val dummy_raw_data_item:Ghost.erased raw_data_item
let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 57, "start_col": 0, "start_line": 56 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Ghost.erased CBOR.Spec.Type.raw_data_item
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.hide", "CBOR.Spec.Type.raw_data_item", "CBOR.Spec.Type.Int64", "CBOR.Spec.Constants.cbor_major_type_uint64", "FStar.UInt64.__uint_to_t" ]
[]
false
false
false
true
false
let dummy_raw_data_item:Ghost.erased raw_data_item =
Int64 cbor_major_type_uint64 0uL
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_pair
val holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool
val holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool
let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 84, "start_col": 0, "start_line": 78 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pred: (_: t -> Prims.bool) -> x: (t * t) -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "FStar.Pervasives.Native.tuple2", "Prims.op_AmpAmp" ]
[]
false
false
false
true
false
let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool =
let x1, x2 = x in pred x1 && pred x2
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item'
val holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool
val holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool
let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 98, "start_col": 0, "start_line": 87 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> x: CBOR.Spec.Type.raw_data_item -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "Prims.op_AmpAmp", "Prims.list", "Prims.b2t", "FStar.UInt.fits", "FStar.List.Tot.Base.length", "FStar.UInt64.n", "FStar.List.Tot.Base.for_all", "CBOR.Spec.Type.holds_on_raw_data_item", "FStar.Pervasives.Native.tuple2", "CBOR.Spec.Type.holds_on_pair", "FStar.UInt64.t" ]
[]
false
false
false
true
false
let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool =
p x && (match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.simple_value
val simple_value:eqtype
val simple_value:eqtype
let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } )
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 41, "start_col": 0, "start_line": 40 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "Prims.eq2", "Prims.bool", "CBOR.Spec.Type.simple_value_wf" ]
[]
false
false
false
true
false
let simple_value:eqtype =
(x: U8.t{simple_value_wf x == true})
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.get_major_type
val get_major_type (d: raw_data_item) : Tot major_type_t
val get_major_type (d: raw_data_item) : Tot major_type_t
let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 40, "end_line": 69, "start_col": 0, "start_line": 60 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: CBOR.Spec.Type.raw_data_item -> CBOR.Spec.Constants.major_type_t
Prims.Tot
[ "total" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "CBOR.Spec.Type.simple_value", "CBOR.Spec.Constants.cbor_major_type_simple_value", "CBOR.Spec.Constants.major_type_uint64_or_neg_int64", "FStar.UInt64.t", "CBOR.Spec.Constants.major_type_byte_string_or_text_string", "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.b2t", "FStar.UInt.fits", "FStar.Seq.Base.length", "FStar.UInt64.n", "Prims.list", "FStar.List.Tot.Base.length", "CBOR.Spec.Constants.cbor_major_type_array", "FStar.Pervasives.Native.tuple2", "CBOR.Spec.Constants.cbor_major_type_map", "CBOR.Spec.Constants.cbor_major_type_tagged", "CBOR.Spec.Constants.major_type_t" ]
[]
false
false
false
true
false
let get_major_type (d: raw_data_item) : Tot major_type_t =
match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_string
val holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t {FStar.UInt.fits (Seq.length v) U64.n}) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))]
val holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t {FStar.UInt.fits (Seq.length v) U64.n}) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))]
let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 44, "end_line": 130, "start_col": 0, "start_line": 123 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> typ: CBOR.Spec.Constants.major_type_byte_string_or_text_string -> v: FStar.Seq.Base.seq FStar.UInt8.t {FStar.UInt.fits (FStar.Seq.Base.length v) FStar.UInt64.n} -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.String typ v) == p (CBOR.Spec.Type.String typ v)) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.String typ v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "CBOR.Spec.Constants.major_type_byte_string_or_text_string", "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.b2t", "FStar.UInt.fits", "FStar.Seq.Base.length", "FStar.UInt64.n", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.String", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t {FStar.UInt.fits (Seq.length v) U64.n}) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] =
holds_on_raw_data_item_eq p (String typ v)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_int64
val holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))]
val holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))]
let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 121, "start_col": 0, "start_line": 114 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> typ: CBOR.Spec.Constants.major_type_uint64_or_neg_int64 -> v: FStar.UInt64.t -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Int64 typ v) == p (CBOR.Spec.Type.Int64 typ v)) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Int64 typ v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "CBOR.Spec.Constants.major_type_uint64_or_neg_int64", "FStar.UInt64.t", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.Int64", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] =
holds_on_raw_data_item_eq p (Int64 typ v)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.map_entry_order
val map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1 m2: (key & value)) : Tot bool
val map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1 m2: (key & value)) : Tot bool
let map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1: (key & value)) (m2: (key & value)) : Tot bool = key_order (fst m1) (fst m2)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 165, "start_col": 0, "start_line": 158 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v) let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v) let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v)) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] = holds_on_raw_data_item_eq p (Tagged tag v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
key_order: (_: key -> _: key -> Prims.bool) -> value: Type -> m1: (key * value) -> m2: (key * value) -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.fst" ]
[]
false
false
false
true
false
let map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1 m2: (key & value)) : Tot bool =
key_order (fst m1) (fst m2)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_simple
val holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))]
val holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))]
let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 40, "end_line": 112, "start_col": 0, "start_line": 106 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> v: CBOR.Spec.Type.simple_value -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Simple v) == p (CBOR.Spec.Type.Simple v)) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Simple v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "CBOR.Spec.Type.simple_value", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.Simple", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] =
holds_on_raw_data_item_eq p (Simple v)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.data_item_wf_head
val data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool
val data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool
let data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool = match x with | Map l -> FStar.List.Tot.sorted (map_entry_order order _) l | _ -> true
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 172, "start_col": 0, "start_line": 168 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v) let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v) let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v)) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] = holds_on_raw_data_item_eq p (Tagged tag v) noextract let map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1: (key & value)) (m2: (key & value)) : Tot bool = key_order (fst m1) (fst m2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
order: (_: CBOR.Spec.Type.raw_data_item -> _: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> x: CBOR.Spec.Type.raw_data_item -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "FStar.UInt.fits", "FStar.List.Tot.Base.length", "FStar.UInt64.n", "FStar.List.Tot.Properties.sorted", "CBOR.Spec.Type.map_entry_order" ]
[]
false
false
false
true
false
let data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool =
match x with | Map l -> FStar.List.Tot.sorted (map_entry_order order _) l | _ -> true
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.data_item_wf
val data_item_wf (order: (raw_data_item -> raw_data_item -> bool)) : Tot (raw_data_item -> bool)
val data_item_wf (order: (raw_data_item -> raw_data_item -> bool)) : Tot (raw_data_item -> bool)
let data_item_wf (order: (raw_data_item -> raw_data_item -> bool)) : Tot (raw_data_item -> bool) = holds_on_raw_data_item (data_item_wf_head order)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 176, "start_col": 0, "start_line": 175 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v) let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v) let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v)) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] = holds_on_raw_data_item_eq p (Tagged tag v) noextract let map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1: (key & value)) (m2: (key & value)) : Tot bool = key_order (fst m1) (fst m2) noextract let data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool = match x with | Map l -> FStar.List.Tot.sorted (map_entry_order order _) l | _ -> true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
order: (_: CBOR.Spec.Type.raw_data_item -> _: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> _: CBOR.Spec.Type.raw_data_item -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "CBOR.Spec.Type.holds_on_raw_data_item", "CBOR.Spec.Type.data_item_wf_head" ]
[]
false
false
false
true
false
let data_item_wf (order: (raw_data_item -> raw_data_item -> bool)) : Tot (raw_data_item -> bool) =
holds_on_raw_data_item (data_item_wf_head order)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_array
val holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))]
val holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))]
let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 138, "start_col": 0, "start_line": 132 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> v: Prims.list CBOR.Spec.Type.raw_data_item {FStar.UInt.fits (FStar.List.Tot.Base.length v) FStar.UInt64.n} -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Array v) == (p (CBOR.Spec.Type.Array v) && FStar.List.Tot.Base.for_all (CBOR.Spec.Type.holds_on_raw_data_item p) v)) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Array v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "Prims.list", "Prims.b2t", "FStar.UInt.fits", "FStar.List.Tot.Base.length", "FStar.UInt64.n", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.Array", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.op_AmpAmp", "FStar.List.Tot.Base.for_all", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] =
holds_on_raw_data_item_eq p (Array v)
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.u51
val u51 : Type0
let u51 = n:nat{n < 0x8000000000000}
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 52, "start_col": 0, "start_line": 52 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
false
false
false
true
true
let u51 =
n: nat{n < 0x8000000000000}
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_map
val holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))]
val holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))]
let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 146, "start_col": 0, "start_line": 140 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> v: Prims.list (CBOR.Spec.Type.raw_data_item * CBOR.Spec.Type.raw_data_item) {FStar.UInt.fits (FStar.List.Tot.Base.length v) FStar.UInt64.n} -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Map v) == (p (CBOR.Spec.Type.Map v) && FStar.List.Tot.Base.for_all (CBOR.Spec.Type.holds_on_pair (CBOR.Spec.Type.holds_on_raw_data_item p)) v)) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Map v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "FStar.UInt.fits", "FStar.List.Tot.Base.length", "FStar.UInt64.n", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.Map", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.op_AmpAmp", "FStar.List.Tot.Base.for_all", "CBOR.Spec.Type.holds_on_pair", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) {FStar.UInt.fits (List.Tot.length v) U64.n}) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] =
holds_on_raw_data_item_eq p (Map v)
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.data_item
val data_item : order: (_: CBOR.Spec.Type.raw_data_item -> _: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> Type0
let data_item (order: (raw_data_item -> raw_data_item -> bool)) = (x: raw_data_item { data_item_wf order x == true })
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 53, "end_line": 179, "start_col": 0, "start_line": 178 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v) let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v) let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v)) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] = holds_on_raw_data_item_eq p (Tagged tag v) noextract let map_entry_order (#key: Type) (key_order: (key -> key -> bool)) (value: Type) (m1: (key & value)) (m2: (key & value)) : Tot bool = key_order (fst m1) (fst m2) noextract let data_item_wf_head (order: (raw_data_item -> raw_data_item -> bool)) (x: raw_data_item) : Tot bool = match x with | Map l -> FStar.List.Tot.sorted (map_entry_order order _) l | _ -> true noextract let data_item_wf (order: (raw_data_item -> raw_data_item -> bool)) : Tot (raw_data_item -> bool) = holds_on_raw_data_item (data_item_wf_head order)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
order: (_: CBOR.Spec.Type.raw_data_item -> _: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> Type0
Prims.Tot
[ "total" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "Prims.eq2", "CBOR.Spec.Type.data_item_wf" ]
[]
false
false
false
true
true
let data_item (order: (raw_data_item -> raw_data_item -> bool)) =
(x: raw_data_item{data_item_wf order x == true})
false
CBOR.Spec.Type.fsti
CBOR.Spec.Type.holds_on_raw_data_item_eq_tagged
val holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v) ) [SMTPat (holds_on_raw_data_item p (Tagged tag v))]
val holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v) ) [SMTPat (holds_on_raw_data_item p (Tagged tag v))]
let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v)) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] = holds_on_raw_data_item_eq p (Tagged tag v)
{ "file_name": "share/steel/examples/pulse/dice/cbor/CBOR.Spec.Type.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 44, "end_line": 155, "start_col": 0, "start_line": 148 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CBOR.Spec.Type include CBOR.Spec.Constants module U8 = FStar.UInt8 module U64 = FStar.UInt64 (* Simple values *) [@@CMacro] let min_simple_value_long_argument = 32uy [@@CMacro] let max_simple_value_additional_info = 23uy inline_for_extraction noextract let simple_value_wf (x: U8.t) : Tot bool = x `U8.lte` max_simple_value_additional_info || min_simple_value_long_argument `U8.lte` x inline_for_extraction noextract let simple_value : eqtype = (x: U8.t { simple_value_wf x == true } ) (* Raw data items, disregarding ordering of map entries *) noextract noeq type raw_data_item = | Simple: (v: simple_value) -> raw_data_item | Int64: (typ: major_type_uint64_or_neg_int64) -> (v: U64.t) -> raw_data_item | String: (typ: major_type_byte_string_or_text_string) -> (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) -> raw_data_item // Section 3.1: "a string containing an invalid UTF-8 sequence is well-formed but invalid", so we don't care about UTF-8 specifics here. | Array: (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Map: (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) -> raw_data_item | Tagged: (tag: U64.t) -> (v: raw_data_item) -> raw_data_item // | Float: (v: Float.float) -> raw_data_item // TODO let dummy_raw_data_item : Ghost.erased raw_data_item = Int64 cbor_major_type_uint64 0uL noextract let get_major_type (d: raw_data_item) : Tot major_type_t = match d with | Simple _ -> cbor_major_type_simple_value | Int64 m _ -> m | String m _ -> m | Array _ -> cbor_major_type_array | Map _ -> cbor_major_type_map | Tagged _ _ -> cbor_major_type_tagged noextract val holds_on_raw_data_item (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool noextract let holds_on_pair (#t: Type) (pred: (t -> bool)) (x: (t & t)) : Tot bool = let (x1, x2) = x in pred x1 && pred x2 noextract let holds_on_raw_data_item' (p: (raw_data_item -> bool)) (x: raw_data_item) : Tot bool = p x && begin match x with | Array l -> List.Tot.for_all (holds_on_raw_data_item p) l | Map l -> List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) l | Tagged _ v -> holds_on_raw_data_item p v | _ -> true end val holds_on_raw_data_item_eq (p: (raw_data_item -> bool)) (x: raw_data_item) : Lemma (holds_on_raw_data_item p x == holds_on_raw_data_item' p x) let holds_on_raw_data_item_eq_simple (p: (raw_data_item -> bool)) (v: simple_value) : Lemma (holds_on_raw_data_item p (Simple v) == p (Simple v)) [SMTPat (holds_on_raw_data_item p (Simple v))] = holds_on_raw_data_item_eq p (Simple v) let holds_on_raw_data_item_eq_int64 (p: (raw_data_item -> bool)) (typ: major_type_uint64_or_neg_int64) (v: U64.t) : Lemma (holds_on_raw_data_item p (Int64 typ v) == p (Int64 typ v)) [SMTPat (holds_on_raw_data_item p (Int64 typ v))] = holds_on_raw_data_item_eq p (Int64 typ v) let holds_on_raw_data_item_eq_string (p: (raw_data_item -> bool)) (typ: major_type_byte_string_or_text_string) (v: Seq.seq U8.t { FStar.UInt.fits (Seq.length v) U64.n }) : Lemma (holds_on_raw_data_item p (String typ v) == p (String typ v)) [SMTPat (holds_on_raw_data_item p (String typ v))] = holds_on_raw_data_item_eq p (String typ v) let holds_on_raw_data_item_eq_array (p: (raw_data_item -> bool)) (v: list raw_data_item { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Array v) == (p (Array v) && List.Tot.for_all (holds_on_raw_data_item p) v)) [SMTPat (holds_on_raw_data_item p (Array v))] = holds_on_raw_data_item_eq p (Array v) let holds_on_raw_data_item_eq_map (p: (raw_data_item -> bool)) (v: list (raw_data_item & raw_data_item) { FStar.UInt.fits (List.Tot.length v) U64.n }) : Lemma (holds_on_raw_data_item p (Map v) == (p (Map v) && List.Tot.for_all (holds_on_pair (holds_on_raw_data_item p)) v)) [SMTPat (holds_on_raw_data_item p (Map v))] = holds_on_raw_data_item_eq p (Map v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked", "CBOR.Spec.Constants.fst.checked" ], "interface_file": false, "source_file": "CBOR.Spec.Type.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "CBOR.Spec.Constants", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "CBOR.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: CBOR.Spec.Type.raw_data_item -> Prims.bool) -> tag: FStar.UInt64.t -> v: CBOR.Spec.Type.raw_data_item -> FStar.Pervasives.Lemma (ensures CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Tagged tag v) <==> p (CBOR.Spec.Type.Tagged tag v) && CBOR.Spec.Type.holds_on_raw_data_item p v) [SMTPat (CBOR.Spec.Type.holds_on_raw_data_item p (CBOR.Spec.Type.Tagged tag v))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "CBOR.Spec.Type.raw_data_item", "Prims.bool", "FStar.UInt64.t", "CBOR.Spec.Type.holds_on_raw_data_item_eq", "CBOR.Spec.Type.Tagged", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "CBOR.Spec.Type.holds_on_raw_data_item", "Prims.op_AmpAmp", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let holds_on_raw_data_item_eq_tagged (p: (raw_data_item -> bool)) (tag: U64.t) (v: raw_data_item) : Lemma (holds_on_raw_data_item p (Tagged tag v) <==> (p (Tagged tag v) && holds_on_raw_data_item p v) ) [SMTPat (holds_on_raw_data_item p (Tagged tag v))] =
holds_on_raw_data_item_eq p (Tagged tag v)
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_snoc
val on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened ((on_range p i j) `star` (p j')) (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True)
val on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened ((on_range p i j) `star` (p j')) (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True)
let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 120, "start_col": 0, "start_line": 109 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> j': Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_join", "Prims.unit", "Steel.ST.OnRange.on_range_singleton_intro", "Steel.ST.Util.rewrite", "Steel.Effect.Common.star", "Steel.ST.OnRange.on_range", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened ((on_range p i j) `star` (p j')) (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) =
rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_get
val on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> ((on_range p i j) `star` (p j)) `star` (on_range p k l)) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True)
val on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> ((on_range p i j) `star` (p j)) `star` (on_range p k l)) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True)
let on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> on_range p i j `star` p j `star` on_range p k l) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True) = on_range_split p i j l; on_range_split p j k l; on_range_singleton_elim p j k
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 165, "start_col": 0, "start_line": 154 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k) let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` p j) (i <= j /\ k == j + 1) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p j k let on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k `star` (on_range p i k `implies_` (on_range p i j `star` p j'))) (j' == j /\ k == j + 1) (fun _ -> True) = on_range_le p i j; on_range_snoc p i j j' k; intro_implies (on_range p i k) (on_range p i j `star` p j') emp (fun _ -> on_range_unsnoc p i j k; rewrite (p j) (p j') )
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> l: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_singleton_elim", "Prims.unit", "Steel.ST.OnRange.on_range_split", "Steel.ST.OnRange.on_range", "Steel.Effect.Common.star", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> ((on_range p i j) `star` (p j)) `star` (on_range p k l)) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True) =
on_range_split p i j l; on_range_split p j k l; on_range_singleton_elim p j k
false
Hacl.HPKE.P256_CP128_SHA256.fsti
Hacl.HPKE.P256_CP128_SHA256.cs
val cs:S.ciphersuite
val cs:S.ciphersuite
let cs:S.ciphersuite = (DH.DH_P256, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256)
{ "file_name": "code/hpke/Hacl.HPKE.P256_CP128_SHA256.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 10, "start_col": 0, "start_line": 10 }
module Hacl.HPKE.P256_CP128_SHA256 open Hacl.Impl.HPKE module S = Spec.Agile.HPKE module DH = Spec.Agile.DH module AEAD = Spec.Agile.AEAD module Hash = Spec.Agile.Hash
{ "checked_file": "/", "dependencies": [ "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.Hash.fsti.checked", "Spec.Agile.DH.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "Hacl.Impl.HPKE.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HPKE.P256_CP128_SHA256.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.Agile.HPKE.ciphersuite
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple4", "Spec.Agile.DH.algorithm", "Spec.Agile.HPKE.hash_algorithm", "Spec.Agile.HPKE.aead", "Spec.Hash.Definitions.hash_alg", "Spec.Agile.DH.DH_P256", "Spec.Hash.Definitions.SHA2_256", "Spec.Agile.HPKE.Seal", "Spec.Agile.AEAD.CHACHA20_POLY1305" ]
[]
false
false
false
true
false
let cs:S.ciphersuite =
(DH.DH_P256, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256)
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.eq
val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) )
val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) )
let eq a b = let a0 = a.(0ul) in let a1 = a.(1ul) in let a2 = a.(2ul) in let a3 = a.(3ul) in let a4 = a.(4ul) in let b0 = b.(0ul) in let b1 = b.(1ul) in let b2 = b.(2ul) in let b3 = b.(3ul) in let b4 = b.(4ul) in assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); assert_norm(pow2 255 - 19 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed); let h0 = ST.get() in lemma_equality1 (v a0) (v a1) (v a2) (v a3) (v a4) (v b0) (v b1) (v b2) (v b3) (v b4); let open Lib.RawIntTypes in let open FStar.UInt64 in (u64_to_UInt64 a0 =^ u64_to_UInt64 b0 && u64_to_UInt64 a1 =^ u64_to_UInt64 b1 && u64_to_UInt64 a2 =^ u64_to_UInt64 b2 && u64_to_UInt64 a3 =^ u64_to_UInt64 b3 && u64_to_UInt64 a4 =^ u64_to_UInt64 b4)
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 216, "start_col": 0, "start_line": 192 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false) let u51 = n:nat{n < 0x8000000000000} val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')) open FStar.Calc #push-options "--z3rlimit 100" let lemma_equality1 a b c d e a' b' c' d' e' = assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc (==) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102) } (a + pow2 51 * b) % (pow2 102); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp () val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) )
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Bignum25519.felem -> b: Hacl.Bignum25519.felem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.felem", "Prims.op_AmpAmp", "FStar.UInt64.op_Equals_Hat", "Lib.RawIntTypes.u64_to_UInt64", "Prims.unit", "Hacl.Impl.Ed25519.PointEqual.lemma_equality1", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.int_t", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let eq a b =
let a0 = a.(0ul) in let a1 = a.(1ul) in let a2 = a.(2ul) in let a3 = a.(3ul) in let a4 = a.(4ul) in let b0 = b.(0ul) in let b1 = b.(1ul) in let b2 = b.(2ul) in let b3 = b.(3ul) in let b4 = b.(4ul) in assert_norm (pow2 51 = 0x8000000000000); assert_norm (pow2 102 = 0x40000000000000000000000000); assert_norm (pow2 153 = 0x200000000000000000000000000000000000000); assert_norm (pow2 204 = 0x1000000000000000000000000000000000000000000000000000); assert_norm (pow2 255 - 19 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed); let h0 = ST.get () in lemma_equality1 (v a0) (v a1) (v a2) (v a3) (v a4) (v b0) (v b1) (v b2) (v b3) (v b4); let open Lib.RawIntTypes in let open FStar.UInt64 in (u64_to_UInt64 a0 =^ u64_to_UInt64 b0 && u64_to_UInt64 a1 =^ u64_to_UInt64 b1 && u64_to_UInt64 a2 =^ u64_to_UInt64 b2 && u64_to_UInt64 a3 =^ u64_to_UInt64 b3 && u64_to_UInt64 a4 =^ u64_to_UInt64 b4)
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.gte_q
val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) )
val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) )
let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false)
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 50, "start_col": 0, "start_line": 32 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) )
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Lib.Buffer.lbuffer Lib.IntTypes.uint64 5ul -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "FStar.UInt64.op_Greater_Hat", "Lib.RawIntTypes.u64_to_UInt64", "FStar.UInt64.__uint_to_t", "Prims.bool", "FStar.UInt64.op_Less_Hat", "FStar.UInt64.op_Greater_Equals_Hat", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Spec.Ed25519.q", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let gte_q s =
let h0 = ST.get () in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false)
false
LowParse.Norm.fst
LowParse.Norm.norm_steps
val norm_steps : Prims.list FStar.Pervasives.norm_step
let norm_steps = [delta_attr [`%Norm]; iota; zeta; primops]
{ "file_name": "src/lowparse/LowParse.Norm.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 59, "end_line": 6, "start_col": 0, "start_line": 6 }
module LowParse.Norm noeq type norm_t : Type = | Norm
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Norm.fst" }
[ { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list FStar.Pervasives.norm_step
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops" ]
[]
false
false
false
true
false
let norm_steps =
[delta_attr [`%Norm]; iota; zeta; primops]
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_focus
val on_range_focus (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p j) `star` ((p j) `implies_` (on_range p i k))) (i <= j /\ j < k) (fun _ -> True)
val on_range_focus (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p j) `star` ((p j) `implies_` (on_range p i k))) (i <= j /\ j < k) (fun _ -> True)
let on_range_focus (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p j `star` (p j `implies_` on_range p i k)) (i <= j /\ j < k) (fun _ -> True) = on_range_get p i j (j + 1) k; intro_implies (p j) (on_range p i k) (on_range p i j `star` on_range p (j + 1) k) (fun _ -> on_range_put p i j j (j + 1) k )
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 197, "start_col": 0, "start_line": 181 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k) let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` p j) (i <= j /\ k == j + 1) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p j k let on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k `star` (on_range p i k `implies_` (on_range p i j `star` p j'))) (j' == j /\ k == j + 1) (fun _ -> True) = on_range_le p i j; on_range_snoc p i j j' k; intro_implies (on_range p i k) (on_range p i j `star` p j') emp (fun _ -> on_range_unsnoc p i j k; rewrite (p j) (p j') ) let on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> on_range p i j `star` p j `star` on_range p k l) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True) = on_range_split p i j l; on_range_split p j k l; on_range_singleton_elim p j k let on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (on_range p i j `star` p k `star` on_range p l m) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True) = rewrite (p k) (p j); on_range_singleton_intro p j l; on_range_join p i j l; on_range_join p i l m
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_implies", "Steel.ST.OnRange.on_range", "Steel.Effect.Common.star", "Prims.op_Addition", "Steel.ST.OnRange.on_range_put", "Prims.unit", "Steel.ST.OnRange.on_range_get", "Steel.ST.Util.implies_", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_focus (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> (p j) `star` ((p j) `implies_` (on_range p i k))) (i <= j /\ j < k) (fun _ -> True) =
on_range_get p i j (j + 1) k; intro_implies (p j) (on_range p i k) ((on_range p i j) `star` (on_range p (j + 1) k)) (fun _ -> on_range_put p i j j (j + 1) k)
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_weaken
val on_range_weaken (#opened: _) (p p': (nat -> vprop)) (i j: nat) (phi: (k: nat{i <= k /\ k < j} -> STGhostT unit opened (p k) (fun _ -> p' k))) : STGhostT unit opened (on_range p i j) (fun _ -> on_range p' i j)
val on_range_weaken (#opened: _) (p p': (nat -> vprop)) (i j: nat) (phi: (k: nat{i <= k /\ k < j} -> STGhostT unit opened (p k) (fun _ -> p' k))) : STGhostT unit opened (on_range p i j) (fun _ -> on_range p' i j)
let on_range_weaken (#opened: _) (p p': (nat -> vprop)) (i: nat) (j: nat) (phi: (k: nat { i <= k /\ k < j }) -> STGhostT unit opened (p k) (fun _ -> p' k)) : STGhostT unit opened (on_range p i j) (fun _ -> on_range p' i j) = on_range_weaken_and_shift p p' 0 i j (fun k -> phi k; rewrite (p' k) (p' (k + 0))) i j
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 241, "start_col": 0, "start_line": 227 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k) let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` p j) (i <= j /\ k == j + 1) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p j k let on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k `star` (on_range p i k `implies_` (on_range p i j `star` p j'))) (j' == j /\ k == j + 1) (fun _ -> True) = on_range_le p i j; on_range_snoc p i j j' k; intro_implies (on_range p i k) (on_range p i j `star` p j') emp (fun _ -> on_range_unsnoc p i j k; rewrite (p j) (p j') ) let on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> on_range p i j `star` p j `star` on_range p k l) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True) = on_range_split p i j l; on_range_split p j k l; on_range_singleton_elim p j k let on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (on_range p i j `star` p k `star` on_range p l m) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True) = rewrite (p k) (p j); on_range_singleton_intro p j l; on_range_join p i j l; on_range_join p i l m let on_range_focus (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p j `star` (p j `implies_` on_range p i k)) (i <= j /\ j < k) (fun _ -> True) = on_range_get p i j (j + 1) k; intro_implies (p j) (on_range p i k) (on_range p i j `star` on_range p (j + 1) k) (fun _ -> on_range_put p i j j (j + 1) k ) let rec on_range_weaken_and_shift (#opened: _) (p p': (nat -> vprop)) (delta: int) (i: nat { i + delta >= 0 }) (j: nat) (phi: (k: nat { i <= k /\ k < j }) -> STGhostT unit opened (p k) (fun _ -> p' (k + delta))) (i': nat { i' == i + delta }) (j': nat { j' == j + delta }) : STGhostT unit opened (on_range p i j) (fun _ -> on_range p' i' j') (decreases (if j >= i then j - i else 0)) = on_range_le p i j; if j <= i then begin drop (on_range p i j); on_range_empty p' i' j' end else begin on_range_split p i (i + 1) j; on_range_singleton_elim p i (i + 1); phi i; rewrite (p' _) (p' i'); on_range_singleton_intro p' i' (i' + 1); on_range_weaken_and_shift p p' delta (i + 1) j phi (i' + 1) j'; on_range_join p' i' (i' + 1) j' end
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> p': (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> phi: (k: Prims.nat{i <= k /\ k < j} -> Steel.ST.Effect.Ghost.STGhostT Prims.unit) -> Steel.ST.Effect.Ghost.STGhostT Prims.unit
Steel.ST.Effect.Ghost.STGhostT
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.unit", "Steel.ST.OnRange.on_range_weaken_and_shift", "Steel.ST.Util.rewrite", "Prims.op_Addition", "Steel.ST.OnRange.on_range" ]
[]
false
true
false
false
false
let on_range_weaken (#opened: _) (p p': (nat -> vprop)) (i j: nat) (phi: (k: nat{i <= k /\ k < j} -> STGhostT unit opened (p k) (fun _ -> p' k))) : STGhostT unit opened (on_range p i j) (fun _ -> on_range p' i j) =
on_range_weaken_and_shift p p' 0 i j (fun k -> phi k; rewrite (p' k) (p' (k + 0))) i j
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.point_equal_1
val point_equal_1: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z <==> ((px `SC.fmul` qz) == (qx `SC.fmul` pz)) ) )
val point_equal_1: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z <==> ((px `SC.fmul` qz) == (qx `SC.fmul` pz)) ) )
let point_equal_1 p q tmp = let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in let h0 = ST.get() in fmul pxqz (getx p) (getz q); reduce pxqz; fmul qxpz (getx q) (getz p); reduce qxpz; eq pxqz qxpz
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 247, "start_col": 0, "start_line": 237 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false) let u51 = n:nat{n < 0x8000000000000} val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')) open FStar.Calc #push-options "--z3rlimit 100" let lemma_equality1 a b c d e a' b' c' d' e' = assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc (==) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102) } (a + pow2 51 * b) % (pow2 102); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp () val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) ) [@CInline] let eq a b = let a0 = a.(0ul) in let a1 = a.(1ul) in let a2 = a.(2ul) in let a3 = a.(3ul) in let a4 = a.(4ul) in let b0 = b.(0ul) in let b1 = b.(1ul) in let b2 = b.(2ul) in let b3 = b.(3ul) in let b4 = b.(4ul) in assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); assert_norm(pow2 255 - 19 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed); let h0 = ST.get() in lemma_equality1 (v a0) (v a1) (v a2) (v a3) (v a4) (v b0) (v b1) (v b2) (v b3) (v b4); let open Lib.RawIntTypes in let open FStar.UInt64 in (u64_to_UInt64 a0 =^ u64_to_UInt64 b0 && u64_to_UInt64 a1 =^ u64_to_UInt64 b1 && u64_to_UInt64 a2 =^ u64_to_UInt64 b2 && u64_to_UInt64 a3 =^ u64_to_UInt64 b3 && u64_to_UInt64 a4 =^ u64_to_UInt64 b4) inline_for_extraction noextract val point_equal_1: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z <==> ((px `SC.fmul` qz) == (qx `SC.fmul` pz)) ) )
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.PointEqual.eq", "Prims.bool", "Prims.unit", "Hacl.Bignum25519.reduce", "Hacl.Bignum25519.fmul", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.getz", "Hacl.Bignum25519.getx", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let point_equal_1 p q tmp =
let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in let h0 = ST.get () in fmul pxqz (getx p) (getz q); reduce pxqz; fmul qxpz (getx q) (getz p); reduce qxpz; eq pxqz qxpz
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.point_equal
val point_equal: p:point -> q:point -> Stack bool (requires fun h -> live h p /\ live h q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> Spec.Ed25519.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)) )
val point_equal: p:point -> q:point -> Stack bool (requires fun h -> live h p /\ live h q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> Spec.Ed25519.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)) )
let point_equal p q = push_frame(); let tmp = create 20ul (u64 0) in let b = point_equal_1 p q tmp in let res = if b then point_equal_2 p q tmp else false in pop_frame(); res
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 296, "start_col": 0, "start_line": 290 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false) let u51 = n:nat{n < 0x8000000000000} val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')) open FStar.Calc #push-options "--z3rlimit 100" let lemma_equality1 a b c d e a' b' c' d' e' = assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc (==) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102) } (a + pow2 51 * b) % (pow2 102); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp () val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) ) [@CInline] let eq a b = let a0 = a.(0ul) in let a1 = a.(1ul) in let a2 = a.(2ul) in let a3 = a.(3ul) in let a4 = a.(4ul) in let b0 = b.(0ul) in let b1 = b.(1ul) in let b2 = b.(2ul) in let b3 = b.(3ul) in let b4 = b.(4ul) in assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); assert_norm(pow2 255 - 19 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed); let h0 = ST.get() in lemma_equality1 (v a0) (v a1) (v a2) (v a3) (v a4) (v b0) (v b1) (v b2) (v b3) (v b4); let open Lib.RawIntTypes in let open FStar.UInt64 in (u64_to_UInt64 a0 =^ u64_to_UInt64 b0 && u64_to_UInt64 a1 =^ u64_to_UInt64 b1 && u64_to_UInt64 a2 =^ u64_to_UInt64 b2 && u64_to_UInt64 a3 =^ u64_to_UInt64 b3 && u64_to_UInt64 a4 =^ u64_to_UInt64 b4) inline_for_extraction noextract val point_equal_1: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z <==> ((px `SC.fmul` qz) == (qx `SC.fmul` pz)) ) ) let point_equal_1 p q tmp = let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in let h0 = ST.get() in fmul pxqz (getx p) (getz q); reduce pxqz; fmul qxpz (getx q) (getz p); reduce qxpz; eq pxqz qxpz inline_for_extraction noextract val point_equal_2: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z == (if ((py `SC.fmul` qz) <> (qy `SC.fmul` pz)) then false else true)) ) let point_equal_2 p q tmp = let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in fmul pyqz (gety p) (getz q); reduce pyqz; fmul qypz (gety q) (getz p); reduce qypz; eq pyqz qypz val point_equal: p:point -> q:point -> Stack bool (requires fun h -> live h p /\ live h q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> Spec.Ed25519.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)) )
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.Ed25519.PointEqual.point_equal_2", "Hacl.Impl.Ed25519.PointEqual.point_equal_1", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let point_equal p q =
push_frame (); let tmp = create 20ul (u64 0) in let b = point_equal_1 p q tmp in let res = if b then point_equal_2 p q tmp else false in pop_frame (); res
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.point_equal_2
val point_equal_2: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z == (if ((py `SC.fmul` qz) <> (qy `SC.fmul` pz)) then false else true)) )
val point_equal_2: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z == (if ((py `SC.fmul` qz) <> (qy `SC.fmul` pz)) then false else true)) )
let point_equal_2 p q tmp = let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in fmul pyqz (gety p) (getz q); reduce pyqz; fmul qypz (gety q) (getz p); reduce qypz; eq pyqz qypz
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 276, "start_col": 0, "start_line": 267 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false) let u51 = n:nat{n < 0x8000000000000} val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')) open FStar.Calc #push-options "--z3rlimit 100" let lemma_equality1 a b c d e a' b' c' d' e' = assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc (==) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102) } (a + pow2 51 * b) % (pow2 102); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp () val eq: a:felem -> b:felem -> Stack bool (requires fun h -> live h a /\ live h b /\ F51.fevalh h a == F51.as_nat h a /\ F51.fevalh h b == F51.as_nat h b /\ F51.felem_fits h a (1, 1, 1, 1, 1) /\ F51.felem_fits h b (1, 1, 1, 1, 1) ) (ensures fun h0 r h1 -> h0 == h1 /\ (r <==> F51.fevalh h0 a == F51.fevalh h0 b) ) [@CInline] let eq a b = let a0 = a.(0ul) in let a1 = a.(1ul) in let a2 = a.(2ul) in let a3 = a.(3ul) in let a4 = a.(4ul) in let b0 = b.(0ul) in let b1 = b.(1ul) in let b2 = b.(2ul) in let b3 = b.(3ul) in let b4 = b.(4ul) in assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); assert_norm(pow2 255 - 19 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed); let h0 = ST.get() in lemma_equality1 (v a0) (v a1) (v a2) (v a3) (v a4) (v b0) (v b1) (v b2) (v b3) (v b4); let open Lib.RawIntTypes in let open FStar.UInt64 in (u64_to_UInt64 a0 =^ u64_to_UInt64 b0 && u64_to_UInt64 a1 =^ u64_to_UInt64 b1 && u64_to_UInt64 a2 =^ u64_to_UInt64 b2 && u64_to_UInt64 a3 =^ u64_to_UInt64 b3 && u64_to_UInt64 a4 =^ u64_to_UInt64 b4) inline_for_extraction noextract val point_equal_1: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z <==> ((px `SC.fmul` qz) == (qx `SC.fmul` pz)) ) ) let point_equal_1 p q tmp = let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in let h0 = ST.get() in fmul pxqz (getx p) (getz q); reduce pxqz; fmul qxpz (getx q) (getz p); reduce qxpz; eq pxqz qxpz inline_for_extraction noextract val point_equal_2: p:point -> q:point -> tmp:lbuffer uint64 20ul -> Stack bool (requires fun h -> live h p /\ live h q /\live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q ) (ensures fun h0 z h1 -> modifies (loc tmp) h0 h1 /\ (let px, py, pz, pt = F51.point_eval h0 p in let qx, qy, qz, qt = F51.point_eval h0 q in z == (if ((py `SC.fmul` qz) <> (qy `SC.fmul` pz)) then false else true)) )
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.PointEqual.eq", "Prims.bool", "Prims.unit", "Hacl.Bignum25519.reduce", "Hacl.Bignum25519.fmul", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.getz", "Hacl.Bignum25519.gety", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let point_equal_2 p q tmp =
let pxqz = sub tmp 0ul 5ul in let qxpz = sub tmp 5ul 5ul in let pyqz = sub tmp 10ul 5ul in let qypz = sub tmp 15ul 5ul in fmul pyqz (gety p) (getz q); reduce pyqz; fmul qypz (gety q) (getz p); reduce qypz; eq pyqz qypz
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_cons_with_implies
val on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> (on_range p i k) `star` (on_range p i k @==> ((p i) `star` (on_range p j k)))) (j == i + 1) (fun _ -> True)
val on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> (on_range p i k) `star` (on_range p i k @==> ((p i) `star` (on_range p j k)))) (j == i + 1) (fun _ -> True)
let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k)
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 107, "start_col": 0, "start_line": 90 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_implies", "Steel.ST.OnRange.on_range", "Steel.Effect.Common.star", "Steel.Effect.Common.emp", "Steel.ST.OnRange.on_range_uncons", "Prims.unit", "Steel.ST.OnRange.on_range_cons", "Steel.ST.OnRange.on_range_le", "Steel.ST.Util.op_At_Equals_Equals_Greater", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened ((p i) `star` (on_range p j k)) (fun _ -> (on_range p i k) `star` (on_range p i k @==> ((p i) `star` (on_range p j k)))) (j == i + 1) (fun _ -> True) =
on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) ((p i) `star` (on_range p j k)) emp (fun _ -> on_range_uncons p i j k)
false
Steel.ST.OnRange.fsti
Steel.ST.OnRange.on_range_put
val on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (((on_range p i j) `star` (p k)) `star` (on_range p l m)) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True)
val on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (((on_range p i j) `star` (p k)) `star` (on_range p l m)) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True)
let on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (on_range p i j `star` p k `star` on_range p l m) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True) = rewrite (p k) (p j); on_range_singleton_intro p j l; on_range_join p i j l; on_range_join p i l m
{ "file_name": "lib/steel/Steel.ST.OnRange.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 179, "start_col": 0, "start_line": 167 }
module Steel.ST.OnRange include Steel.ST.Util val on_range (p: (nat -> vprop)) (i j: nat) : vprop val on_range_le (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> on_range p i j) True (fun _ -> i <= j) val on_range_empty (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened emp (fun _ -> on_range p i j) (i == j) (fun _ -> True) val on_range_singleton_intro (#opened: _) (p: (nat -> vprop)) (i: nat) (j: nat) : STGhost unit opened (p i) (fun _ -> on_range p i j) (j == i + 1) (fun _ -> True) val on_range_singleton_elim (#opened: _) (p: (nat -> vprop)) (i j: nat) : STGhost unit opened (on_range p i j) (fun _ -> p i) (j == i + 1) (fun _ -> True) val on_range_split (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` on_range p j k) (i <= j /\ j <= k) (fun _ -> True) val on_range_join (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhostT unit opened (on_range p i j `star` on_range p j k) (fun _ -> on_range p i k) let on_range_cons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k) (j == i + 1) (fun _ -> True) = on_range_singleton_intro p i j; on_range_join p i j k let on_range_uncons (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> p i `star` on_range p j k) (j == i + 1 /\ j <= k) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p i j let on_range_cons_with_implies (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (p i `star` on_range p j k) (fun _ -> on_range p i k `star` (on_range p i k @==> (p i `star` on_range p j k)) ) (j == i + 1) (fun _ -> True) = on_range_le p j k; on_range_cons p i j k; intro_implies (on_range p i k) (p i `star` on_range p j k) emp (fun _ -> on_range_uncons p i j k) let on_range_snoc (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k) (j' == j /\ k == j + 1) (fun _ -> True) = rewrite (p j') (p j); on_range_singleton_intro p j k; on_range_join p i j k let on_range_unsnoc (#opened: _) (p: (nat -> vprop)) (i j k: nat) : STGhost unit opened (on_range p i k) (fun _ -> on_range p i j `star` p j) (i <= j /\ k == j + 1) (fun _ -> True) = on_range_split p i j k; on_range_singleton_elim p j k let on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat) : STGhost unit opened (on_range p i j `star` p j') (fun _ -> on_range p i k `star` (on_range p i k `implies_` (on_range p i j `star` p j'))) (j' == j /\ k == j + 1) (fun _ -> True) = on_range_le p i j; on_range_snoc p i j j' k; intro_implies (on_range p i k) (on_range p i j `star` p j') emp (fun _ -> on_range_unsnoc p i j k; rewrite (p j) (p j') ) let on_range_get (#opened: _) (p: (nat -> vprop)) (i j k l: nat) : STGhost unit opened (on_range p i l) (fun _ -> on_range p i j `star` p j `star` on_range p k l) (i <= j /\ j + 1 == k /\ k <= l) (fun _ -> True) = on_range_split p i j l; on_range_split p j k l; on_range_singleton_elim p j k
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.OnRange.fsti" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat -> l: Prims.nat -> m: Prims.nat -> Steel.ST.Effect.Ghost.STGhost Prims.unit
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "Prims.nat", "Steel.Effect.Common.vprop", "Steel.ST.OnRange.on_range_join", "Prims.unit", "Steel.ST.OnRange.on_range_singleton_intro", "Steel.ST.Util.rewrite", "Steel.Effect.Common.star", "Steel.ST.OnRange.on_range", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.l_True" ]
[]
false
true
false
false
false
let on_range_put (#opened: _) (p: (nat -> vprop)) (i j k l m: nat) : STGhost unit opened (((on_range p i j) `star` (p k)) `star` (on_range p l m)) (fun _ -> on_range p i m) (j == k /\ k + 1 == l) (fun _ -> True) =
rewrite (p k) (p j); on_range_singleton_intro p j l; on_range_join p i j l; on_range_join p i l m
false
Vale.X64.Flags.fsti
Vale.X64.Flags.flag_val_t
val flag_val_t : Type0
let flag_val_t = option bool
{ "file_name": "vale/code/arch/x64/Vale.X64.Flags.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 9, "start_col": 7, "start_line": 9 }
module Vale.X64.Flags open FStar.Mul // This interface should not refer to Semantics_s open Vale.Def.Prop_s open Vale.X64.Machine_s open Vale.Lib.Map16
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Flags.fsti" }
[ { "abbrev": false, "full_module": "Vale.Lib.Map16", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "Prims.bool" ]
[]
false
false
false
true
true
let flag_val_t =
option bool
false
Vale.X64.Flags.fsti
Vale.X64.Flags.sel_curry
val sel_curry (m: t) (f: flag) : flag_val_t
val sel_curry (m: t) (f: flag) : flag_val_t
let sel_curry (m:t) (f:flag) : flag_val_t = sel f m
{ "file_name": "vale/code/arch/x64/Vale.X64.Flags.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 17, "start_col": 0, "start_line": 17 }
module Vale.X64.Flags open FStar.Mul // This interface should not refer to Semantics_s open Vale.Def.Prop_s open Vale.X64.Machine_s open Vale.Lib.Map16 unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) val t : Type0 val sel (f:flag) (m:t) : flag_val_t val upd (f:flag) (v:flag_val_t) (m:t) : t
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Flags.fsti" }
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Map16", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: Vale.X64.Flags.t -> f: Vale.X64.Machine_s.flag -> Vale.X64.Flags.flag_val_t
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Flags.t", "Vale.X64.Machine_s.flag", "Vale.X64.Flags.sel", "Vale.X64.Flags.flag_val_t" ]
[]
false
false
false
true
false
let sel_curry (m: t) (f: flag) : flag_val_t =
sel f m
false
Vale.X64.Flags.fsti
Vale.X64.Flags.to_fun
val to_fun (m: t) : (FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t))
val to_fun (m: t) : (FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t))
let to_fun (m:t) : (FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)) = FStar.FunctionalExtensionality.on flag (sel_curry m)
{ "file_name": "vale/code/arch/x64/Vale.X64.Flags.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 20, "start_col": 0, "start_line": 19 }
module Vale.X64.Flags open FStar.Mul // This interface should not refer to Semantics_s open Vale.Def.Prop_s open Vale.X64.Machine_s open Vale.Lib.Map16 unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) val t : Type0 val sel (f:flag) (m:t) : flag_val_t val upd (f:flag) (v:flag_val_t) (m:t) : t let sel_curry (m:t) (f:flag) : flag_val_t = sel f m
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Flags.fsti" }
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Map16", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: Vale.X64.Flags.t -> FStar.FunctionalExtensionality.restricted_t Vale.X64.Machine_s.flag (fun _ -> Vale.X64.Flags.flag_val_t)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Flags.t", "FStar.FunctionalExtensionality.on", "Vale.X64.Machine_s.flag", "Vale.X64.Flags.flag_val_t", "Vale.X64.Flags.sel_curry", "FStar.FunctionalExtensionality.restricted_t" ]
[]
false
false
false
false
false
let to_fun (m: t) : (FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)) =
FStar.FunctionalExtensionality.on flag (sel_curry m)
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline
val test_inline: Prims.unit -> FStar.All.ML unit
val test_inline: Prims.unit -> FStar.All.ML unit
let test_inline () : FStar.All.ML unit = test_inline_mov_input (); test_inline_mov_add_input (); test_inline_mul_inputs (); test_inline_mov_mul_rax_100 (); test_inline_mov_mul_inputs (); // This test leads (rightfully) to a failure in the printer due to a gcc bug // test_inline_mov_add_input_dummy_mul (); test_inline_comment_add (); test_inline_same_line (); test_inline_same_line_newline (); ()
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 160, "start_col": 0, "start_line": 149 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c let test_inline_mov_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c // This test generates the correct inline assembly code, but only works with gcc >= 9 // On prior versions, gcc ignores the register asm("rax") annotation, and does not correctly // allocate the output "result" into register rax (* let test_inline_mov_add_input_dummy_mul () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Mul64 (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input_dummy_mul" (Some "result") args regs_mod c *) let test_inline_comment_add () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let s = "This is a comment" in let c = Block [ Ins (make_instr_annotate (ins_Comment s) (AnnotateComment s)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_comment_add" (Some "result") args regs_mod c let test_inline_same_line () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 0) (AnnotateSpace 0)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_same_line" (Some "result") args regs_mod c let test_inline_same_line_newline () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr_annotate ins_Newline (AnnotateNewline ())); Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rRax)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_same_line_newline" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.test_inline_same_line_newline", "Vale.Test.TestInline.test_inline_same_line", "Vale.Test.TestInline.test_inline_comment_add", "Vale.Test.TestInline.test_inline_mov_mul_inputs", "Vale.Test.TestInline.test_inline_mov_mul_rax_100", "Vale.Test.TestInline.test_inline_mul_inputs", "Vale.Test.TestInline.test_inline_mov_add_input", "Vale.Test.TestInline.test_inline_mov_input" ]
[]
false
true
false
false
false
let test_inline () : FStar.All.ML unit =
test_inline_mov_input (); test_inline_mov_add_input (); test_inline_mul_inputs (); test_inline_mov_mul_rax_100 (); test_inline_mov_mul_inputs (); test_inline_comment_add (); test_inline_same_line (); test_inline_same_line_newline (); ()
false
Hacl.Impl.Ed25519.PointEqual.fst
Hacl.Impl.Ed25519.PointEqual.lemma_equality1
val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e'))
val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e'))
let lemma_equality1 a b c d e a' b' c' d' e' = assert_norm(pow2 51 = 0x8000000000000); assert_norm(pow2 102 = 0x40000000000000000000000000); assert_norm(pow2 153 = 0x200000000000000000000000000000000000000); assert_norm(pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc (==) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc (==) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102) } (a + pow2 51 * b) % (pow2 102); }; calc (==) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp ()
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointEqual.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 174, "start_col": 0, "start_line": 68 }
module Hacl.Impl.Ed25519.PointEqual module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module F56 = Hacl.Impl.BignumQ.Mul module S51 = Hacl.Spec.Curve25519.Field51.Definition module SC = Spec.Curve25519 #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" val gte_q: s:lbuffer uint64 5ul -> Stack bool (requires fun h -> live h s /\ F56.qelem_fits h s (1, 1, 1, 1, 1) ) (ensures fun h0 b h1 -> h0 == h1 /\ (b <==> F56.as_nat h0 s >= Spec.Ed25519.q) ) [@CInline] let gte_q s = let h0 = ST.get() in let s0 = s.(0ul) in let s1 = s.(1ul) in let s2 = s.(2ul) in let s3 = s.(3ul) in let s4 = s.(4ul) in assert_norm (Spec.Ed25519.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); let open FStar.UInt64 in let open Lib.RawIntTypes in if u64_to_UInt64 s4 >^ 0x00000010000000uL then true else if u64_to_UInt64 s4 <^ 0x00000010000000uL then false else (if u64_to_UInt64 s3 >^ 0x00000000000000uL then true else if u64_to_UInt64 s2 >^ 0x000000000014deuL then true else if u64_to_UInt64 s2 <^ 0x000000000014deuL then false else if u64_to_UInt64 s1 >^ 0xf9dea2f79cd658uL then true else if u64_to_UInt64 s1 <^ 0xf9dea2f79cd658uL then false else if u64_to_UInt64 s0 >=^ 0x12631a5cf5d3eduL then true else false) let u51 = n:nat{n < 0x8000000000000} val lemma_equality1: a:u51 -> b:u51 -> c:u51 -> d:u51 -> e:u51 -> a':u51 -> b':u51 -> c':u51 -> d':u51 -> e':u51 -> Lemma (requires a < pow2 51 /\ b < pow2 51 /\ c < pow2 51 /\ d < pow2 51 /\ e < pow2 51 /\ a' < pow2 51 /\ b' < pow2 51 /\ c' < pow2 51 /\ d' < pow2 51 /\ e' < pow2 51) (ensures (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') <==> (a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')) open FStar.Calc #push-options "--z3rlimit 100"
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field51.Definition.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointEqual.fst" }
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field51.Definition", "short_module": "S51" }, { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Impl.Ed25519.PointEqual.u51 -> b: Hacl.Impl.Ed25519.PointEqual.u51 -> c: Hacl.Impl.Ed25519.PointEqual.u51 -> d: Hacl.Impl.Ed25519.PointEqual.u51 -> e: Hacl.Impl.Ed25519.PointEqual.u51 -> a': Hacl.Impl.Ed25519.PointEqual.u51 -> b': Hacl.Impl.Ed25519.PointEqual.u51 -> c': Hacl.Impl.Ed25519.PointEqual.u51 -> d': Hacl.Impl.Ed25519.PointEqual.u51 -> e': Hacl.Impl.Ed25519.PointEqual.u51 -> FStar.Pervasives.Lemma (requires a < Prims.pow2 51 /\ b < Prims.pow2 51 /\ c < Prims.pow2 51 /\ d < Prims.pow2 51 /\ e < Prims.pow2 51 /\ a' < Prims.pow2 51 /\ b' < Prims.pow2 51 /\ c' < Prims.pow2 51 /\ d' < Prims.pow2 51 /\ e' < Prims.pow2 51) (ensures a + Prims.pow2 51 * b + Prims.pow2 102 * c + Prims.pow2 153 * d + Prims.pow2 204 * e == a' + Prims.pow2 51 * b' + Prims.pow2 102 * c' + Prims.pow2 153 * d' + Prims.pow2 204 * e' <==> a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Impl.Ed25519.PointEqual.u51", "FStar.Classical.move_requires", "Prims.unit", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.squash", "Prims.op_Multiply", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Math.Lemmas.lemma_mod_injective", "FStar.Math.Lemmas.cancel_mul_mod", "FStar.Calc.calc_finish", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Subtraction", "FStar.Math.Lemmas.lemma_mult_le_left", "Prims.op_Equality" ]
[]
false
false
true
false
false
let lemma_equality1 a b c d e a' b' c' d' e' =
assert_norm (pow2 51 = 0x8000000000000); assert_norm (pow2 102 = 0x40000000000000000000000000); assert_norm (pow2 153 = 0x200000000000000000000000000000000000000); assert_norm (pow2 204 = 0x1000000000000000000000000000000000000000000000000000); let lemma_l_imp () : Lemma (requires a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') (ensures a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') = FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 51) b' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 102) c' (pow2 51 - 1); FStar.Math.Lemmas.lemma_mult_le_left (pow2 153) d' (pow2 51 - 1); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) < pow2 102); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) < pow2 153); assert_norm (pow2 51 - 1 + pow2 51 * (pow2 51 - 1) + pow2 102 * (pow2 51 - 1) + pow2 153 * (pow2 51 - 1) < pow2 204); calc ( == ) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e) % (pow2 204); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (pow2 204 * e) (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e (pow2 204)) } (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 204); }; calc ( == ) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') % (pow2 204); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') (pow2 204 * e') (pow2 204); FStar.Math.Lemmas.cancel_mul_mod e' (pow2 204)) } (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 204); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 204) (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d'); calc ( == ) { (a + pow2 51 * b + pow2 102 * c + pow2 153 * d) % (pow2 153); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b + pow2 102 * c) (pow2 153 * d) (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d (pow2 153)) } (a + pow2 51 * b + pow2 102 * c) % (pow2 153); }; calc ( == ) { (a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d') % (pow2 153); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b' + pow2 102 * c') (pow2 153 * d') (pow2 153); FStar.Math.Lemmas.cancel_mul_mod d' (pow2 153)) } (a' + pow2 51 * b' + pow2 102 * c') % (pow2 153); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 153) (a + pow2 51 * b + pow2 102 * c) (a' + pow2 51 * b' + pow2 102 * c'); calc ( == ) { (a + pow2 51 * b + pow2 102 * c) % (pow2 102); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a + pow2 51 * b) (pow2 102 * c) (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c (pow2 102)) } (a + pow2 51 * b) % (pow2 102); }; calc ( == ) { (a' + pow2 51 * b' + pow2 102 * c') % (pow2 102); ( == ) { (FStar.Math.Lemmas.lemma_mod_plus_distr_r (a' + pow2 51 * b') (pow2 102 * c') (pow2 102); FStar.Math.Lemmas.cancel_mul_mod c' (pow2 102)) } (a' + pow2 51 * b') % (pow2 102); }; FStar.Math.Lemmas.lemma_mod_injective (pow2 102) (a + pow2 51 * b) (a' + pow2 51 * b'); FStar.Math.Lemmas.cancel_mul_mod b (pow2 51); FStar.Math.Lemmas.cancel_mul_mod b' (pow2 51); FStar.Math.Lemmas.lemma_mod_injective (pow2 51) a a' in let lemma_r_imp () : Lemma (requires a == a' /\ b == b' /\ c == c' /\ d == d' /\ e == e') (ensures a + pow2 51 * b + pow2 102 * c + pow2 153 * d + pow2 204 * e == a' + pow2 51 * b' + pow2 102 * c' + pow2 153 * d' + pow2 204 * e') = () in Classical.move_requires lemma_l_imp (); Classical.move_requires lemma_r_imp ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_set_to_one_reverse_equality
val lemma_set_to_one_reverse_equality (q0 q1: quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
val lemma_set_to_one_reverse_equality (q0 q1: quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 32, "start_col": 0, "start_line": 26 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
q0: Vale.Def.Types_s.quad32 -> q1: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.GCM.lower3_equal q0 q1) (ensures Vale.AES.GCM.set_to_one_LE (Vale.Def.Types_s.reverse_bytes_quad32 q0) == Vale.AES.GCM.set_to_one_LE (Vale.Def.Types_s.reverse_bytes_quad32 q1))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Types_s.reveal_reverse_bytes_quad32", "Prims.b2t", "Vale.AES.GCM.lower3_equal", "Prims.squash", "Prims.eq2", "Vale.AES.GCM.set_to_one_LE", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_set_to_one_reverse_equality (q0 q1: quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) =
reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_compute_iv_hard
val lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
val lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 147, "start_col": 0, "start_line": 124 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
iv: Vale.AES.GCM_s.supported_iv_LE -> quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> length_quad: Vale.Def.Types_s.quad32 -> h_LE: Vale.Def.Types_s.quad32 -> j0: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires ~(FStar.Seq.Base.length iv == 96 / 8) /\ quads == Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.AES.GCTR_s.pad_to_128_bits iv) /\ j0 == Vale.AES.GHash.ghash_incremental h_LE (Vale.Def.Words_s.Mkfour 0 0 0 0) (FStar.Seq.Base.append quads (FStar.Seq.Base.create 1 length_quad)) /\ length_quad == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour 0 0 0 0) 0 1) (8 * FStar.Seq.Base.length iv) 0)) (ensures Vale.Def.Types_s.reverse_bytes_quad32 j0 == Vale.AES.GCM_s.compute_iv_BE h_LE iv)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.GCM_s.supported_iv_LE", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.AES.GCM_s.compute_iv_BE_reveal", "Vale.AES.GHash.ghash_incremental_to_ghash", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Prims._assert", "Prims.eq2", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.insert_nat64_def", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.insert_nat64_reveal", "Vale.Def.Words_s.four", "Vale.Def.Types_s.insert_nat64", "Vale.Arch.Types.lemma_insert_nat64_nat32s", "Vale.Def.Words_s.nat32", "Prims.int", "Vale.Arch.Types.two_to_nat32", "Vale.Def.Words_s.Mktwo", "Prims.l_and", "Prims.l_not", "Prims.op_Division", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.AES.GCTR_s.pad_to_128_bits", "Vale.AES.GHash.ghash_incremental", "Prims.squash", "Vale.AES.GCM_s.compute_iv_BE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_compute_iv_hard (iv: supported_iv_LE) (quads: seq quad32) (length_quad h_LE j0: quad32) : Lemma (requires ~(length iv == 96 / 8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) =
assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_le_seq_quad32_to_bytes_prefix_equality
val lemma_le_seq_quad32_to_bytes_prefix_equality (q: quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
val lemma_le_seq_quad32_to_bytes_prefix_equality (q: quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 55, "start_col": 0, "start_line": 50 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i))
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Types_s.le_quad32_to_bytes q) 0 12 == FStar.Seq.Base.slice (Vale.AES.GCTR_s.pad_to_128_bits (FStar.Seq.Base.slice (Vale.Def.Types_s.le_quad32_to_bytes q) 0 12)) 0 12)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Types_s.nat8", "FStar.Seq.Base.slice", "Vale.AES.GCTR_s.pad_to_128_bits", "Vale.Def.Types_s.le_quad32_to_bytes", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_le_seq_quad32_to_bytes_prefix_equality (q: quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) =
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_le_bytes_to_quad32_prefix_equality
val lemma_le_bytes_to_quad32_prefix_equality (b0: seq nat8 {length b0 == 16}) (b1: seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
val lemma_le_bytes_to_quad32_prefix_equality (b0: seq nat8 {length b0 == 16}) (b1: seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i))
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 48, "start_col": 0, "start_line": 34 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b0: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length b0 == 16} -> b1: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length b1 == 16} -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.slice b0 0 12 == FStar.Seq.Base.slice b1 0 12) (ensures Vale.AES.GCM.lower3_equal (Vale.Def.Types_s.le_bytes_to_quad32 b0) (Vale.Def.Types_s.le_bytes_to_quad32 b1))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims._assert", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.index", "FStar.Seq.Base.slice", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Prims.op_Modulus", "Vale.Def.Words_s.four", "Prims.op_Division", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "Vale.Def.Types_s.le_bytes_to_quad32_reveal", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.le_bytes_to_quad32", "Prims.squash", "Vale.AES.GCM.lower3_equal", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_le_bytes_to_quad32_prefix_equality (b0: seq nat8 {length b0 == 16}) (b1: seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) =
let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i: int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i))
false
Vale.AES.GCM.fst
Vale.AES.GCM.pad_to_128_bits_multiple_append
val pad_to_128_bits_multiple_append (x y: seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
val pad_to_128_bits_multiple_append (x y: seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) = assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y)))
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 78, "end_line": 330, "start_col": 0, "start_line": 326 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); () let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> y: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length x % 16 == 0) (ensures Vale.AES.GCTR_s.pad_to_128_bits (FStar.Seq.Base.append x y) == FStar.Seq.Base.append x (Vale.AES.GCTR_s.pad_to_128_bits y))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Types_s.nat8", "Vale.AES.GCTR_s.pad_to_128_bits", "FStar.Seq.Base.append", "Prims.unit", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let pad_to_128_bits_multiple_append (x y: seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) =
assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y)))
false
Vale.AES.GCM.fst
Vale.AES.GCM.gcm_encrypt_LE_fst_helper
val gcm_encrypt_LE_fst_helper (iv: supported_iv_LE) (iv_enc iv_BE: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32)) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
val gcm_encrypt_LE_fst_helper (iv: supported_iv_LE) (iv_enc iv_BE: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32)) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 160, "start_col": 0, "start_line": 149 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
iv: Vale.AES.GCM_s.supported_iv_LE -> iv_enc: Vale.Def.Types_s.quad32 -> iv_BE: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> cipher: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_s.is_aes_key_LE alg key /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) in iv_enc == Vale.AES.GCTR_s.inc32 (Vale.AES.GCM_s.compute_iv_BE h_LE iv) 1 /\ cipher == Vale.AES.GCTR_s.gctr_encrypt_LE iv_enc (Vale.AES.GCTR.make_gctr_plain_LE plain) alg key /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32)) (ensures cipher == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain auth))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.GCM_s.supported_iv_LE", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Words_s.nat32", "Vale.AES.GCM_s.gcm_encrypt_LE_reveal", "Prims.unit", "Prims.l_and", "Vale.AES.AES_s.is_aes_key_LE", "Prims.eq2", "Vale.AES.GCTR_s.inc32", "Vale.AES.GCM_s.compute_iv_BE", "Vale.Def.Types_s.nat8", "Vale.AES.GCTR_s.gctr_encrypt_LE", "Vale.AES.GCTR.make_gctr_plain_LE", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Prims.squash", "FStar.Pervasives.Native.fst", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gcm_encrypt_LE_fst_helper (iv: supported_iv_LE) (iv_enc iv_BE: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32)) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) =
gcm_encrypt_LE_reveal ()
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_mov_add_input
val test_inline_mov_add_input: Prims.unit -> FStar.All.ML unit
val test_inline_mov_add_input: Prims.unit -> FStar.All.ML unit
let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 50, "start_col": 0, "start_line": 41 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Prims.Nil", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rR15", "Vale.X64.Instruction_s.opFlagsCf", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_Add64", "Vale.X64.Machine_s.OConst", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdx", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_mov_add_input () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)) ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_mov_mul_rax_100
val test_inline_mov_mul_rax_100: Prims.unit -> FStar.All.ML unit
val test_inline_mov_mul_rax_100: Prims.unit -> FStar.All.ML unit
let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 78, "end_line": 74, "start_col": 0, "start_line": 64 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Prims.Nil", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.OConst", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_IMul64", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdx", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_mov_mul_rax_100 () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rRbx)] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)) ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c
false
Vale.AES.GCM.fst
Vale.AES.GCM.slice_append_back
val slice_append_back (#a: Type) (x y: seq a) (i: nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
val slice_append_back (#a: Type) (x y: seq a) (i: nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 319, "start_col": 0, "start_line": 314 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq a -> y: FStar.Seq.Base.seq a -> i: Prims.nat -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length x <= i /\ i <= FStar.Seq.Base.length x + FStar.Seq.Base.length y) (ensures FStar.Seq.Base.slice (FStar.Seq.Base.append x y) 0 i == FStar.Seq.Base.append x (FStar.Seq.Base.slice y 0 (i - FStar.Seq.Base.length x)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Seq.Base.append", "Prims.op_Subtraction", "FStar.Seq.Base.length", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let slice_append_back (#a: Type) (x y: seq a) (i: nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) =
assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); ()
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_mov_input
val test_inline_mov_input: Prims.unit -> FStar.All.ML unit
val test_inline_mov_input: Prims.unit -> FStar.All.ML unit
let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 39, "start_col": 0, "start_line": 31 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Prims.Nil", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rR15", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdx", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_mov_input () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15))] in print_function "test_inline_mov_input" (Some "result") args regs_mod c
false
Vale.AES.GCM.fst
Vale.AES.GCM.append_distributes_le_seq_quad32_to_bytes
val append_distributes_le_seq_quad32_to_bytes (x y: seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
val append_distributes_le_seq_quad32_to_bytes (x y: seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 324, "start_col": 0, "start_line": 321 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> y: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append x y) == FStar.Seq.Base.append (Vale.Def.Types_s.le_seq_quad32_to_bytes x) (Vale.Def.Types_s.le_seq_quad32_to_bytes y))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Arch.Types.append_distributes_le_seq_quad32_to_bytes", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Base.append", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let append_distributes_le_seq_quad32_to_bytes (x y: seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) =
append_distributes_le_seq_quad32_to_bytes x y
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_same_line
val test_inline_same_line: Prims.unit -> FStar.All.ML unit
val test_inline_same_line: Prims.unit -> FStar.All.ML unit
let test_inline_same_line () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 0) (AnnotateSpace 0)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_same_line" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 130, "start_col": 0, "start_line": 120 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c let test_inline_mov_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c // This test generates the correct inline assembly code, but only works with gcc >= 9 // On prior versions, gcc ignores the register asm("rax") annotation, and does not correctly // allocate the output "result" into register rax (* let test_inline_mov_add_input_dummy_mul () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Mul64 (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input_dummy_mul" (Some "result") args regs_mod c *) let test_inline_comment_add () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let s = "This is a comment" in let c = Block [ Ins (make_instr_annotate (ins_Comment s) (AnnotateComment s)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_comment_add" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr_annotate", "Prims.Nil", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Space", "Vale.X64.Machine_Semantics_s.AnnotateSpace", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.opFlagsCf", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.op64", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_Add64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rR15", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.rRax", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_same_line () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 0) (AnnotateSpace 0)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)) ] in print_function "test_inline_same_line" (Some "result") args regs_mod c
false
Vale.AES.GCM.fst
Vale.AES.GCM.gcm_encrypt_LE_snd_helper
val gcm_encrypt_LE_snd_helper (iv: supported_iv_LE) (j0_BE length_quad32 hash mac: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key))) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
val gcm_encrypt_LE_snd_helper (iv: supported_iv_LE) (j0_BE length_quad32 hash mac: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key))) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 198, "start_col": 0, "start_line": 180 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
iv: Vale.AES.GCM_s.supported_iv_LE -> j0_BE: Vale.Def.Types_s.quad32 -> length_quad32: Vale.Def.Types_s.quad32 -> hash: Vale.Def.Types_s.quad32 -> mac: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> cipher: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_s.is_aes_key_LE alg key /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) in j0_BE = Vale.AES.GCM_s.compute_iv_BE h_LE iv /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32 /\ cipher == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour 0 0 0 0) (8 * FStar.Seq.Base.length auth) 1) (8 * FStar.Seq.Base.length plain) 0) /\ (let auth_padded_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.AES.GCTR_s.pad_to_128_bits auth) in let cipher_padded_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.AES.GCTR_s.pad_to_128_bits cipher) in hash == Vale.AES.GHash_s.ghash_LE h_LE (FStar.Seq.Base.append auth_padded_quads (FStar.Seq.Base.append cipher_padded_quads (FStar.Seq.Base.create 1 length_quad32) )) /\ Vale.Def.Types_s.le_quad32_to_bytes mac == Vale.AES.GCTR_s.gctr_encrypt_LE j0_BE (Vale.Def.Types_s.le_quad32_to_bytes hash) alg key ))) (ensures Vale.Def.Types_s.le_quad32_to_bytes mac == FStar.Pervasives.Native.snd (Vale.AES.GCM_s.gcm_encrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain auth))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.GCM_s.supported_iv_LE", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Words_s.nat32", "Vale.AES.GCM_s.gcm_encrypt_LE_reveal", "Prims.unit", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.l_and", "Vale.AES.AES_s.is_aes_key_LE", "Prims.b2t", "Prims.op_Equality", "Vale.AES.GCM_s.compute_iv_BE", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.eq2", "Vale.Def.Types_s.nat8", "FStar.Pervasives.Native.fst", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.insert_nat64", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.Mul.op_Star", "Vale.AES.GHash_s.ghash_LE", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.AES.GCTR_s.gctr_encrypt_LE", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.AES.GCTR_s.pad_to_128_bits", "Vale.AES.AES_s.aes_encrypt_LE", "Prims.squash", "FStar.Pervasives.Native.snd", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gcm_encrypt_LE_snd_helper (iv: supported_iv_LE) (j0_BE length_quad32 hash mac: quad32) (plain auth cipher: seq nat8) (alg: algorithm) (key: seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key))) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) =
insert_nat64_reveal (); gcm_encrypt_LE_reveal ()
false
Hacl.HMAC.Blake2s_128.fst
Hacl.HMAC.Blake2s_128.compute_blake2s_128
val compute_blake2s_128:compute_st Blake2S
val compute_blake2s_128:compute_st Blake2S
let compute_blake2s_128: compute_st Blake2S = mk_compute (D.mk_impl Blake2S Hacl.Impl.Blake2.Core.M128) hash alloca init update_multi update_last finish
{ "file_name": "code/hmac/Hacl.HMAC.Blake2s_128.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 24, "start_col": 0, "start_line": 22 }
module Hacl.HMAC.Blake2s_128 module B = LowStar.Buffer module D = Hacl.Hash.Definitions open Spec.Agile.HMAC open Spec.Hash.Definitions open FStar.HyperStack.ST open Lib.IntTypes open EverCrypt.Helpers open Hacl.HMAC open Hacl.Hash.Blake2s_128 #set-options "--z3rlimit 25 --fuel 0 --ifuel 0" [@@ Comment "Write the HMAC-BLAKE2s MAC of a message (`data`) by using a key (`key`) into `dst`. The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes.
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2s_128.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "EverCrypt.Helpers.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HMAC.Blake2s_128.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.Blake2s_128", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HMAC", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Helpers", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HMAC", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "D" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.HMAC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HMAC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 25, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.HMAC.compute_st Spec.Hash.Definitions.Blake2S
Prims.Tot
[ "total" ]
[]
[ "Hacl.HMAC.mk_compute", "Hacl.Hash.Definitions.mk_impl", "Spec.Hash.Definitions.Blake2S", "Hacl.Impl.Blake2.Core.M128", "Hacl.Hash.Blake2s_128.hash", "Hacl.Hash.Blake2s_128.alloca", "Hacl.Hash.Blake2s_128.init", "Hacl.Hash.Blake2s_128.update_multi", "Hacl.Hash.Blake2s_128.update_last", "Hacl.Hash.Blake2s_128.finish" ]
[]
false
false
false
true
false
let compute_blake2s_128:compute_st Blake2S =
mk_compute (D.mk_impl Blake2S Hacl.Impl.Blake2.Core.M128) hash alloca init update_multi update_last finish
false
Vale.AES.GCM.fst
Vale.AES.GCM.decrypt_helper
val decrypt_helper (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (rax:nat64) (alleged_tag_quad computed_tag:quad32) : Lemma (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ (if alleged_tag_quad = computed_tag then rax = 0 else rax > 0) /\ le_quad32_to_bytes computed_tag == gcm_decrypt_LE_tag alg key iv cipher auth ) (ensures (rax = 0) == snd (gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad)))
val decrypt_helper (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (rax:nat64) (alleged_tag_quad computed_tag:quad32) : Lemma (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ (if alleged_tag_quad = computed_tag then rax = 0 else rax > 0) /\ le_quad32_to_bytes computed_tag == gcm_decrypt_LE_tag alg key iv cipher auth ) (ensures (rax = 0) == snd (gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad)))
let decrypt_helper (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (rax:nat64) (alleged_tag_quad computed_tag:quad32) : Lemma (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ (if alleged_tag_quad = computed_tag then rax = 0 else rax > 0) /\ le_quad32_to_bytes computed_tag == gcm_decrypt_LE_tag alg key iv cipher auth ) (ensures (rax = 0) == snd (gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad))) = gcm_decrypt_LE_reveal (); insert_nat64_reveal (); (* let b = snd (gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad)) in let (_, ct) = gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad) in assert (b = (ct = (le_quad32_to_bytes alleged_tag_quad))); assert (ct == le_quad32_to_bytes computed_tag); assert (b == (le_quad32_to_bytes computed_tag = le_quad32_to_bytes alleged_tag_quad)); *) le_quad32_to_bytes_injective_specific alleged_tag_quad computed_tag; (* assert (b == (computed_tag = alleged_tag_quad)); assert ((rax = 0) == (computed_tag = alleged_tag_quad)); *) ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 1174, "start_col": 0, "start_line": 1147 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); () let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) = assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y))) #reset-options "--z3rlimit 100" let gcm_blocks_helper (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in let hash = ghash_LE h final_quads in gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE; //assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes calc (==) { enc_hash; == {} gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0; == {} gctr_encrypt_block ctr_BE_1 hash alg key 0; == {} quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == { aes_encrypt_LE_reveal () } quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == {} quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1); }; calc (==) { gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key; == { gctr_encrypt_one_block ctr_BE_1 hash alg key } le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1))); == {} le_seq_quad32_to_bytes (create 1 enc_hash); == { le_seq_quad32_to_bytes_of_singleton enc_hash } le_quad32_to_bytes enc_hash; }; if p_num_bytes > (length p128x6 + length p128) * 16 then ( let c = append (append c128x6 c128) c_bytes in calc (==) { append (append (append auth_quads c128x6) c128) c_bytes; == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) c_bytes; == { append_assoc auth_quads (append c128x6 c128) c_bytes } append auth_quads (append (append c128x6 c128) c_bytes); == {} append auth_quads c; }; calc (==) { append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad); = {} // See previous calc append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad); == { append_assoc auth_quads c (create 1 length_quad) } append auth_quads (append c (create 1 length_quad)); }; let raw_quads_old = append auth_quads c in calc (==) { raw_quads; == {} le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes)); == { calc (==) { pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes); == { calc (==) { slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes; == { append_distributes_le_seq_quad32_to_bytes auth_quads c } slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes; == { slice_append_back (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c) total_bytes } append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes); == {} append (le_seq_quad32_to_bytes auth_quads) cipher_bytes; } } pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes); == { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes } append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes); } } le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes)); == { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes) } append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); == { le_bytes_to_seq_quad32_to_bytes auth_quads } append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); }; let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in calc (==) { append raw_quads (create 1 length_quad); == {} append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad); == { assert (equal auth_quads auth_padded_quads') } append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad); == { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) } append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad)); }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ) else ( calc (==) { append (append (append auth_quads c128x6) c128) (create 1 length_quad); == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) (create 1 length_quad); == { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) } append auth_quads (append (append c128x6 c128) (create 1 length_quad)); }; let c = append c128x6 c128 in calc (==) { le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)); == { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) } le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c)); == { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) } le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c); == { le_bytes_to_seq_quad32_to_bytes c } c; }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ); () // TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes) = if num_bytes > (length s) * 16 then ( () ) else ( calc (==) { slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes; == { append_distributes_le_seq_quad32_to_bytes s bytes } slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes; == { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) } le_seq_quad32_to_bytes s; == { assert (length (le_seq_quad32_to_bytes s) == num_bytes) } slice (le_seq_quad32_to_bytes s) 0 num_bytes; }; () ) #reset-options "--z3rlimit 10" let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = append a128 a_bytes in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) ) = gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad; let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes; lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; () let lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth) ) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag)) = gcm_encrypt_LE_reveal (); gcm_decrypt_LE_reveal (); () let gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes alleged_tag:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 )) (ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag))) = gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_bytes p_num_bytes iv j0_BE; let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)); lemma_gcm_encrypt_decrypt_equiv alg key iv j0_BE cipher_bytes plain_bytes auth_bytes alleged_tag; () #reset-options "--z3rlimit 60" let gcm_blocks_dec_helper (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads p128x6) p128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads p_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) = insert_nat64_reveal (); let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads p128x6) p128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads p_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in let hash = ghash_LE h final_quads in //gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes j0_BE; //assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes j0_BE) plain_bytes auth_input_bytes)); // Passes calc (==) { enc_hash; == {} gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0; == {} gctr_encrypt_block ctr_BE_1 hash alg key 0; == {} quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == { aes_encrypt_LE_reveal () } quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == {} quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1); }; calc (==) { gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key; == { gctr_encrypt_one_block ctr_BE_1 hash alg key } le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1))); == {} le_seq_quad32_to_bytes (create 1 enc_hash); == { le_seq_quad32_to_bytes_of_singleton enc_hash } le_quad32_to_bytes enc_hash; }; if p_num_bytes > (length p128x6 + length p128) * 16 then ( let c = append (append p128x6 p128) p_bytes in calc (==) { append (append (append auth_quads p128x6) p128) p_bytes; == { append_assoc auth_quads p128x6 p128 } append (append auth_quads (append p128x6 p128)) p_bytes; == { append_assoc auth_quads (append p128x6 p128) p_bytes } append auth_quads (append (append p128x6 p128) p_bytes); == {} append auth_quads c; }; calc (==) { append (append (append (append auth_quads p128x6) p128) p_bytes) (create 1 length_quad); = {} // See previous calc append (append auth_quads (append (append p128x6 p128) p_bytes)) (create 1 length_quad); == { append_assoc auth_quads c (create 1 length_quad) } append auth_quads (append c (create 1 length_quad)); }; let raw_quads_old = append auth_quads c in calc (==) { raw_quads; == {} le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes)); == { calc (==) { pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes); == { calc (==) { slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes; == { append_distributes_le_seq_quad32_to_bytes auth_quads c } slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes; == { slice_append_back (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c) total_bytes } append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes); == { assert(equal (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes) plain_bytes) } append (le_seq_quad32_to_bytes auth_quads) plain_bytes; } } pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) plain_bytes); == { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) plain_bytes } append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes); } } le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes)); == { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes) } append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes)); == { le_bytes_to_seq_quad32_to_bytes auth_quads } append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes)); }; let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes) in calc (==) { append raw_quads (create 1 length_quad); == {} append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes))) (create 1 length_quad); == { assert (equal auth_quads auth_padded_quads') } append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad); == { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) } append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad)); }; () ) else ( calc (==) { append (append (append auth_quads p128x6) p128) (create 1 length_quad); == { append_assoc auth_quads p128x6 p128 } append (append auth_quads (append p128x6 p128)) (create 1 length_quad); == { append_assoc auth_quads (append p128x6 p128) (create 1 length_quad) } append auth_quads (append (append p128x6 p128) (create 1 length_quad)); }; let c = append p128x6 p128 in calc (==) { le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)); == { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) } le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c)); == { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) } le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c); == { le_bytes_to_seq_quad32_to_bytes c } c; }; () ); () #reset-options "" let gcm_blocks_dec_helper_simplified (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads p128x6) p128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads p_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures(let auth_raw_quads = append a128 a_bytes in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) = gcm_blocks_dec_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad; let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes; lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> cipher: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> rax: Vale.Def.Words_s.nat64 -> alleged_tag_quad: Vale.Def.Types_s.quad32 -> computed_tag: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_common_s.is_aes_key alg key /\ FStar.Seq.Base.length cipher < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32 /\ (match alleged_tag_quad = computed_tag with | true -> rax = 0 | _ -> rax > 0) /\ Vale.Def.Types_s.le_quad32_to_bytes computed_tag == Vale.AES.GCM.gcm_decrypt_LE_tag alg key iv cipher auth) (ensures rax = 0 == FStar.Pervasives.Native.snd (Vale.AES.GCM_s.gcm_decrypt_LE alg key iv cipher auth (Vale.Def.Types_s.le_quad32_to_bytes alleged_tag_quad)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Def.Words_s.nat64", "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Arch.Types.le_quad32_to_bytes_injective_specific", "Vale.Def.Types_s.insert_nat64_reveal", "Vale.AES.GCM_s.gcm_decrypt_LE_reveal", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_GreaterThan", "Prims.logical", "Prims.eq2", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.AES.GCM.gcm_decrypt_LE_tag", "Prims.squash", "FStar.Pervasives.Native.snd", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.gcm_decrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let decrypt_helper (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (cipher auth: seq nat8) (rax: nat64) (alleged_tag_quad computed_tag: quad32) : Lemma (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ (if alleged_tag_quad = computed_tag then rax = 0 else rax > 0) /\ le_quad32_to_bytes computed_tag == gcm_decrypt_LE_tag alg key iv cipher auth) (ensures (rax = 0) == snd (gcm_decrypt_LE alg key iv cipher auth (le_quad32_to_bytes alleged_tag_quad))) =
gcm_decrypt_LE_reveal (); insert_nat64_reveal (); le_quad32_to_bytes_injective_specific alleged_tag_quad computed_tag; ()
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_mov_mul_inputs
val test_inline_mov_mul_inputs: Prims.unit -> FStar.All.ML unit
val test_inline_mov_mul_inputs: Prims.unit -> FStar.All.ML unit
let test_inline_mov_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 87, "start_col": 0, "start_line": 76 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Prims.Nil", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rR15", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_IMul64", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdx", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_mov_mul_inputs () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)) ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_comment_add
val test_inline_comment_add: Prims.unit -> FStar.All.ML unit
val test_inline_comment_add: Prims.unit -> FStar.All.ML unit
let test_inline_comment_add () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let s = "This is a comment" in let c = Block [ Ins (make_instr_annotate (ins_Comment s) (AnnotateComment s)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_comment_add" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 118, "start_col": 0, "start_line": 107 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c let test_inline_mov_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c // This test generates the correct inline assembly code, but only works with gcc >= 9 // On prior versions, gcc ignores the register asm("rax") annotation, and does not correctly // allocate the output "result" into register rax (* let test_inline_mov_add_input_dummy_mul () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Mul64 (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input_dummy_mul" (Some "result") args regs_mod c *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr_annotate", "Prims.Nil", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Comment", "Vale.X64.Machine_Semantics_s.AnnotateComment", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.opFlagsCf", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.op64", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_Add64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rR15", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.rRax", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_comment_add () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rR15 || r = rRax) in let s = "This is a comment" in let c = Block [ Ins (make_instr_annotate (ins_Comment s) (AnnotateComment s)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)) ] in print_function "test_inline_comment_add" (Some "result") args regs_mod c
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_length_simplifier
val lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes)
val lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes)
let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes) = if num_bytes > (length s) * 16 then ( () ) else ( calc (==) { slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes; == { append_distributes_le_seq_quad32_to_bytes s bytes } slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes; == { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) } le_seq_quad32_to_bytes s; == { assert (length (le_seq_quad32_to_bytes s) == num_bytes) } slice (le_seq_quad32_to_bytes s) 0 num_bytes; }; () )
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 611, "start_col": 0, "start_line": 588 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); () let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) = assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y))) #reset-options "--z3rlimit 100" let gcm_blocks_helper (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in let hash = ghash_LE h final_quads in gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE; //assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes calc (==) { enc_hash; == {} gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0; == {} gctr_encrypt_block ctr_BE_1 hash alg key 0; == {} quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == { aes_encrypt_LE_reveal () } quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == {} quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1); }; calc (==) { gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key; == { gctr_encrypt_one_block ctr_BE_1 hash alg key } le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1))); == {} le_seq_quad32_to_bytes (create 1 enc_hash); == { le_seq_quad32_to_bytes_of_singleton enc_hash } le_quad32_to_bytes enc_hash; }; if p_num_bytes > (length p128x6 + length p128) * 16 then ( let c = append (append c128x6 c128) c_bytes in calc (==) { append (append (append auth_quads c128x6) c128) c_bytes; == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) c_bytes; == { append_assoc auth_quads (append c128x6 c128) c_bytes } append auth_quads (append (append c128x6 c128) c_bytes); == {} append auth_quads c; }; calc (==) { append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad); = {} // See previous calc append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad); == { append_assoc auth_quads c (create 1 length_quad) } append auth_quads (append c (create 1 length_quad)); }; let raw_quads_old = append auth_quads c in calc (==) { raw_quads; == {} le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes)); == { calc (==) { pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes); == { calc (==) { slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes; == { append_distributes_le_seq_quad32_to_bytes auth_quads c } slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes; == { slice_append_back (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c) total_bytes } append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes); == {} append (le_seq_quad32_to_bytes auth_quads) cipher_bytes; } } pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes); == { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes } append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes); } } le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes)); == { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes) } append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); == { le_bytes_to_seq_quad32_to_bytes auth_quads } append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); }; let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in calc (==) { append raw_quads (create 1 length_quad); == {} append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad); == { assert (equal auth_quads auth_padded_quads') } append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad); == { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) } append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad)); }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ) else ( calc (==) { append (append (append auth_quads c128x6) c128) (create 1 length_quad); == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) (create 1 length_quad); == { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) } append auth_quads (append (append c128x6 c128) (create 1 length_quad)); }; let c = append c128x6 c128 in calc (==) { le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)); == { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) } le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c)); == { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) } le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c); == { le_bytes_to_seq_quad32_to_bytes c } c; }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> t: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> num_bytes: Prims.nat -> FStar.Pervasives.Lemma (requires t == (match num_bytes > FStar.Seq.Base.length s * 16 with | true -> FStar.Seq.Base.append s bytes | _ -> s) /\ (num_bytes <= FStar.Seq.Base.length s * 16 ==> num_bytes == FStar.Seq.Base.length s * 16) /\ FStar.Seq.Base.length s * 16 <= num_bytes /\ num_bytes < FStar.Seq.Base.length s * 16 + 16 /\ FStar.Seq.Base.length bytes == 1) (ensures FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes t) 0 num_bytes == FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append s bytes )) 0 num_bytes)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.op_GreaterThan", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Prims.bool", "Prims.unit", "FStar.Calc.calc_finish", "Vale.Def.Types_s.nat8", "Prims.eq2", "FStar.Seq.Base.slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Base.append", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.AES.GCM.append_distributes_le_seq_quad32_to_bytes", "Prims.squash", "Vale.Lib.Seqs.lemma_slice_first_exactly_in_append", "Prims._assert", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.int", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_length_simplifier (s bytes t: seq quad32) (num_bytes: nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes) =
if num_bytes > (length s) * 16 then (()) else (calc ( == ) { slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes; ( == ) { append_distributes_le_seq_quad32_to_bytes s bytes } slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes; ( == ) { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) } le_seq_quad32_to_bytes s; ( == ) { assert (length (le_seq_quad32_to_bytes s) == num_bytes) } slice (le_seq_quad32_to_bytes s) 0 num_bytes; }; ())
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.print_function
val print_function (name: string) (ret_val: option string) (args: list (string & td & reg_64)) (regs_mod: (reg_64 -> bool)) (c: code) : FStar.All.ML unit
val print_function (name: string) (ret_val: option string) (args: list (string & td & reg_64)) (regs_mod: (reg_64 -> bool)) (c: code) : FStar.All.ML unit
let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in ()
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 29, "start_col": 0, "start_line": 14 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
name: Prims.string -> ret_val: FStar.Pervasives.Native.option Prims.string -> args: Prims.list ((Prims.string * Vale.Interop.Base.td) * Vale.X64.Machine_s.reg_64) -> regs_mod: (_: Vale.X64.Machine_s.reg_64 -> Prims.bool) -> c: Vale.X64.Machine_Semantics_s.code -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.string", "FStar.Pervasives.Native.option", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "Vale.X64.Machine_s.reg_64", "Prims.bool", "Vale.X64.Machine_Semantics_s.code", "Prims.unit", "Prims.int", "Vale.X64.Print_Inline_s.print_inline", "Prims.Nil", "Vale.Interop.X64.reg_nat", "FStar.List.Tot.Base.nth", "FStar.List.Tot.Base.map", "Prims.nat", "FStar.List.Tot.Base.length" ]
[]
false
true
false
false
false
let print_function (name: string) (ret_val: option string) (args: list (string & td & reg_64)) (regs_mod: (reg_64 -> bool)) (c: code) : FStar.All.ML unit =
let len = List.length args in let arg_names n = match List.Tot.nth args n with | None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n: reg_nat len) : reg_64 = match List.Tot.nth args n with | None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.lemma_gcm_encrypt_decrypt_equiv
val lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth) ) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag))
val lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth) ) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag))
let lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth) ) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag)) = gcm_encrypt_LE_reveal (); gcm_decrypt_LE_reveal (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 728, "start_col": 0, "start_line": 715 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); () let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) = assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y))) #reset-options "--z3rlimit 100" let gcm_blocks_helper (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in let hash = ghash_LE h final_quads in gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE; //assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes calc (==) { enc_hash; == {} gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0; == {} gctr_encrypt_block ctr_BE_1 hash alg key 0; == {} quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == { aes_encrypt_LE_reveal () } quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == {} quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1); }; calc (==) { gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key; == { gctr_encrypt_one_block ctr_BE_1 hash alg key } le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1))); == {} le_seq_quad32_to_bytes (create 1 enc_hash); == { le_seq_quad32_to_bytes_of_singleton enc_hash } le_quad32_to_bytes enc_hash; }; if p_num_bytes > (length p128x6 + length p128) * 16 then ( let c = append (append c128x6 c128) c_bytes in calc (==) { append (append (append auth_quads c128x6) c128) c_bytes; == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) c_bytes; == { append_assoc auth_quads (append c128x6 c128) c_bytes } append auth_quads (append (append c128x6 c128) c_bytes); == {} append auth_quads c; }; calc (==) { append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad); = {} // See previous calc append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad); == { append_assoc auth_quads c (create 1 length_quad) } append auth_quads (append c (create 1 length_quad)); }; let raw_quads_old = append auth_quads c in calc (==) { raw_quads; == {} le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes)); == { calc (==) { pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes); == { calc (==) { slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes; == { append_distributes_le_seq_quad32_to_bytes auth_quads c } slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes; == { slice_append_back (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c) total_bytes } append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes); == {} append (le_seq_quad32_to_bytes auth_quads) cipher_bytes; } } pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes); == { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes } append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes); } } le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes)); == { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes) } append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); == { le_bytes_to_seq_quad32_to_bytes auth_quads } append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); }; let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in calc (==) { append raw_quads (create 1 length_quad); == {} append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad); == { assert (equal auth_quads auth_padded_quads') } append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad); == { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) } append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad)); }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ) else ( calc (==) { append (append (append auth_quads c128x6) c128) (create 1 length_quad); == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) (create 1 length_quad); == { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) } append auth_quads (append (append c128x6 c128) (create 1 length_quad)); }; let c = append c128x6 c128 in calc (==) { le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)); == { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) } le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c)); == { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) } le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c); == { le_bytes_to_seq_quad32_to_bytes c } c; }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ); () // TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes) = if num_bytes > (length s) * 16 then ( () ) else ( calc (==) { slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes; == { append_distributes_le_seq_quad32_to_bytes s bytes } slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes; == { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) } le_seq_quad32_to_bytes s; == { assert (length (le_seq_quad32_to_bytes s) == num_bytes) } slice (le_seq_quad32_to_bytes s) 0 num_bytes; }; () ) #reset-options "--z3rlimit 10" let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = append a128 a_bytes in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) ) = gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad; let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes; lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> iv: Vale.AES.GCM_s.supported_iv_LE -> j0_BE: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> cipher: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> alleged_tag: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_s.is_aes_key_LE alg key /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) in j0_BE = Vale.AES.GCM_s.compute_iv_BE h_LE iv) /\ FStar.Seq.Base.length cipher < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length auth < Vale.Def.Words_s.pow2_32 /\ plain == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher auth)) (ensures plain == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.nat8", "Prims.unit", "Vale.AES.GCM_s.gcm_decrypt_LE_reveal", "Vale.AES.GCM_s.gcm_encrypt_LE_reveal", "Prims.l_and", "Vale.AES.AES_s.is_aes_key_LE", "Prims.b2t", "Prims.op_Equality", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.eq2", "Vale.Def.Types_s.nat8", "FStar.Pervasives.Native.fst", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Prims.squash", "Prims.bool", "Vale.AES.GCM_s.gcm_decrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_gcm_encrypt_decrypt_equiv (alg: algorithm) (key: seq nat32) (iv: supported_iv_LE) (j0_BE: quad32) (plain cipher auth alleged_tag: seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth)) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag)) =
gcm_encrypt_LE_reveal (); gcm_decrypt_LE_reveal (); ()
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_mul_inputs
val test_inline_mul_inputs: Prims.unit -> FStar.All.ML unit
val test_inline_mul_inputs: Prims.unit -> FStar.All.ML unit
let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 62, "start_col": 0, "start_line": 52 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Prims.Nil", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRbx", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_IMul64", "Vale.X64.Machine_s.rR15", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdx", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_mul_inputs () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)) ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c
false
Vale.Test.TestInline.fst
Vale.Test.TestInline.test_inline_same_line_newline
val test_inline_same_line_newline: Prims.unit -> FStar.All.ML unit
val test_inline_same_line_newline: Prims.unit -> FStar.All.ML unit
let test_inline_same_line_newline () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr_annotate ins_Newline (AnnotateNewline ())); Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rRax)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_same_line_newline" (Some "result") args regs_mod c
{ "file_name": "vale/code/test/Vale.Test.TestInline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 146, "start_col": 0, "start_line": 132 }
module Vale.Test.TestInline open FStar.Mul open FStar.IO open Vale.Arch.HeapTypes_s open Vale.X64.Machine_s open Vale.X64.Instructions_s open Vale.X64.Bytes_Code_s open Vale.X64.Machine_Semantics_s open Vale.X64.InsLemmas open Vale.Interop.Base open Vale.Interop.X64 open Vale.X64.Print_Inline_s let print_function (name:string) (ret_val:option string) (args:list (string & td & reg_64)) (regs_mod:reg_64 -> bool) (c:code) : FStar.All.ML unit = let len = List.length args in let arg_names n = match List.Tot.nth args n with None -> "" | Some (x, _, _) -> x in let arg_types = List.Tot.map (fun (_, t, _) -> t) args in let arg_regs (n:reg_nat len) : reg_64 = match List.Tot.nth args n with None -> 0 | Some (_, _, r) -> r in let _ = print_inline name 0 ret_val len arg_types arg_names c arg_regs regs_mod [] in () let test_inline_mov_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mov_input" (Some "result") args regs_mod c let test_inline_mov_add_input () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input" (Some "result") args regs_mod c let test_inline_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_mul_inputs" (Some "result") args regs_mod c let test_inline_mov_mul_rax_100 () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OConst 100)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_rax_100" (Some "result") args regs_mod c let test_inline_mov_mul_inputs () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rRbx); ("second_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRcx || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rRbx)); Ins (make_instr ins_Mov64 (OReg rRcx) (OReg rR15)); Ins (make_instr ins_IMul64 (OReg rRax) (OReg rRcx)); ] in print_function "test_inline_mov_mul_inputs" (Some "result") args regs_mod c // This test generates the correct inline assembly code, but only works with gcc >= 9 // On prior versions, gcc ignores the register asm("rax") annotation, and does not correctly // allocate the output "result" into register rax (* let test_inline_mov_add_input_dummy_mul () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rRax || r = rRdx) in let c = Block [ Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Mul64 (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rRax) (OConst 1)); ] in print_function "test_inline_mov_add_input_dummy_mul" (Some "result") args regs_mod c *) let test_inline_comment_add () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let s = "This is a comment" in let c = Block [ Ins (make_instr_annotate (ins_Comment s) (AnnotateComment s)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_comment_add" (Some "result") args regs_mod c let test_inline_same_line () : FStar.All.ML unit = let args = [ ("first_arg", TD_Base TUInt64, rR15); ] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 0) (AnnotateSpace 0)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); ] in print_function "test_inline_same_line" (Some "result") args regs_mod c
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.Test.TestInline.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Print_Inline_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.Test.TestInline.print_function", "FStar.Pervasives.Native.Some", "Prims.string", "Vale.X64.Machine_s.precode", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Machine_s.Block", "Prims.Cons", "Vale.X64.Machine_s.Ins", "Vale.X64.InsLemmas.make_instr_annotate", "Prims.Nil", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.PreserveFlags", "Vale.X64.Instructions_s.ins_Space", "Vale.X64.Machine_Semantics_s.AnnotateSpace", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.InsLemmas.make_instr", "Vale.X64.Instruction_s.out", "Vale.X64.Instruction_s.op64", "Vale.X64.Instructions_s.ins_Mov64", "Vale.X64.Machine_s.OReg", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rR15", "Vale.X64.Instruction_s.opFlagsCf", "Vale.X64.Instruction_s.inOut", "Vale.X64.Instruction_s.HavocFlags", "Vale.X64.Instructions_s.ins_Add64", "Vale.X64.Instructions_s.ins_Newline", "Vale.X64.Machine_Semantics_s.AnnotateNewline", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "Prims.list", "FStar.Pervasives.Native.tuple3", "Vale.Interop.Base.td", "FStar.Pervasives.Native.Mktuple3", "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
true
false
false
false
let test_inline_same_line_newline () : FStar.All.ML unit =
let args = [("first_arg", TD_Base TUInt64, rR15)] in let regs_mod r = (r = rR15 || r = rRax) in let c = Block [ Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rR15)); Ins (make_instr_annotate ins_Newline (AnnotateNewline ())); Ins (make_instr_annotate (ins_Space 4) (AnnotateSpace 4)); Ins (make_instr ins_Add64 (OReg rR15) (OReg rRax)); Ins (make_instr ins_Mov64 (OReg rRax) (OReg rR15)) ] in print_function "test_inline_same_line_newline" (Some "result") args regs_mod c
false
Vale.AES.GCM.fst
Vale.AES.GCM.gcm_blocks_helper_enc
val gcm_blocks_helper_enc (alg: algorithm) (key: seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32) (auth_bytes: seq nat8) (p_num_bytes: nat) (iv: supported_iv_LE) (j0_BE: quad32) : Lemma (requires length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
val gcm_blocks_helper_enc (alg: algorithm) (key: seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32) (auth_bytes: seq nat8) (p_num_bytes: nat) (iv: supported_iv_LE) (j0_BE: quad32) : Lemma (requires length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 311, "start_col": 0, "start_line": 205 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> auth_bytes: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> p_num_bytes: Prims.nat -> iv: Vale.AES.GCM_s.supported_iv_LE -> j0_BE: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\ p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\ FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\ FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\ FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\ FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) in j0_BE = Vale.AES.GCM_s.compute_iv_BE h_LE iv /\ p_num_bytes < Vale.Def.Words_s.pow2_32 /\ (let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in let plain = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes | _ -> FStar.Seq.Base.append p128x6 p128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let cipher = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes | _ -> FStar.Seq.Base.append c128x6 c128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let cipher_bound = FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 + (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> 1 | _ -> 0) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2))) (ensures (let plain = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes | _ -> FStar.Seq.Base.append p128x6 p128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let cipher = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes | _ -> FStar.Seq.Base.append c128x6 c128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in let plain_bytes = FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher) 0 p_num_bytes in cipher_bytes == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.nat8", "Prims.nat", "Vale.AES.GCM_s.supported_iv_LE", "Prims.unit", "Vale.AES.GCM.gcm_encrypt_LE_fst_helper", "Prims.op_GreaterThan", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims._assert", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.AES.GCTR_s.gctr_encrypt_LE", "Vale.AES.GCTR.gctr_partial_to_full_advanced", "Vale.AES.AES_s.aes_encrypt_LE_reveal", "Vale.AES.GCTR_s.gctr_encrypt_block", "FStar.Seq.Base.index", "Vale.AES.GCTR_s.inc32", "Vale.AES.GCTR.gctr_encrypt_block_offset", "Vale.Def.Types_s.quad32_xor", "Vale.AES.GCTR.aes_encrypt_BE", "Prims.int", "Prims.op_Division", "Vale.AES.GCTR.gctr_partial_opaque_completed", "FStar.Seq.Base.append", "Vale.AES.GCTR.gctr_partial", "Vale.AES.GCTR.gctr_partial_opaque_ignores_postfix", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.AES.GCTR.gctr_partial_reveal", "Prims.bool", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "Vale.AES.GCTR.gctr_partial_to_full_basic", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Vale.AES.AES_s.is_aes_key_LE", "Prims.op_Equality", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Prims.squash", "FStar.Pervasives.Native.fst", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let gcm_blocks_helper_enc (alg: algorithm) (key: seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32) (auth_bytes: seq nat8) (p_num_bytes: nat) (iv: supported_iv_LE) (j0_BE: quad32) : Lemma (requires length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) =
let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then (gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert (index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert (gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) else (gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; ()
false
Vale.AES.GCM.fst
Vale.AES.GCM.gcm_blocks_helper_dec_simplified
val gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes alleged_tag:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 )) (ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag)))
val gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes alleged_tag:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 )) (ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag)))
let gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes alleged_tag:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 )) (ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag))) = gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_bytes p_num_bytes iv j0_BE; let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)); lemma_gcm_encrypt_decrypt_equiv alg key iv j0_BE cipher_bytes plain_bytes auth_bytes alleged_tag; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 798, "start_col": 0, "start_line": 731 }
module Vale.AES.GCM open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_s open Vale.AES.AES_s open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GHash_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Calc open Vale.Def.Words.Four_s let lemma_set_to_one_equality (q0 q1:quad32) : Lemma (requires upper3_equal q0 q1) (ensures set_to_one_LE q0 == set_to_one_LE q1) = () let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma (requires lower3_equal q0 q1) (ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1)) = reveal_reverse_bytes_quad32 q0; reveal_reverse_bytes_quad32 q1; () let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma (requires slice b0 0 12 == slice b1 0 12) (ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1)) = let q0 = le_bytes_to_quad32 b0 in let q1 = le_bytes_to_quad32 b1 in le_bytes_to_quad32_reveal (); (* * AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this? *) reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8); assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\ index b1 i == index (slice b1 0 12) i)) let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma (slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) = assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12) (slice (le_quad32_to_bytes q) 0 12)); () let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) = assert (length iv == 12); assert (length iv_b == 0); lemma_empty iv_b; append_empty_l iv_extra_b; assert (append iv_b iv_extra_b == iv_extra_b); let q = index iv_extra_b 0 in le_seq_quad32_to_bytes_of_singleton q; assert (equal iv_extra_b (create 1 q)); assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q); // Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below calc (==) { slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12; == {} slice (pad_to_128_bits iv) 0 12; }; // Prove this so we can call lemma_set_to_one_reverse_equality below calc (==) { le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes)); == {} le_bytes_to_quad32 (pad_to_128_bits iv); }; calc (==) { j0; == {} set_to_one_LE (reverse_bytes_quad32 q); == { le_bytes_to_quad32_to_bytes q } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q))); == { lemma_le_seq_quad32_to_bytes_prefix_equality q; lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q) (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)); lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q)) (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))); == { lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))) (le_bytes_to_quad32 (pad_to_128_bits iv)); lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) (pad_to_128_bits iv) } set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv))); == {compute_iv_BE_reveal ()} compute_iv_BE h_LE iv; }; () open Vale.AES.GHash let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) 0 1) (8 * (length iv)) 0)) (ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv) = assert (two_to_nat32 (Mktwo 0 0) == 0); let q0 = Mkfour 0 0 0 0 in lemma_insert_nat64_nat32s q0 0 0; assert (insert_nat64 q0 0 1 == q0); insert_nat64_reveal (); assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0)); ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad)); compute_iv_BE_reveal (); () let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\ cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )) (ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = gcm_encrypt_LE_reveal () (* let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in be_bytes_to_quad32_to_bytes iv_BE; assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE); assert (s_iv_BE == iv_BE); assert (s_key_LE == key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key == gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key); assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key); () *) let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ length plain < pow2_32 /\ length auth < pow2_32 /\ cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\ length_quad32 == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\ (let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\ le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key) )) (ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth)) = insert_nat64_reveal (); gcm_encrypt_LE_reveal () //be_bytes_to_quad32_to_bytes iv_BE; //let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in //() #reset-options "--z3rlimit 10" let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (auth_bytes:seq nat8) (p_num_bytes:nat) (iv:supported_iv_LE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 ))) (ensures (let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in //cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)) cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in gctr_partial_opaque_completed alg plain cipher key ctr_BE_2; if p_num_bytes > (length p128x6 + length p128) * 16 then ( gctr_partial_reveal (); assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2); assert (equal (slice plain 0 (length p128x6 + length p128)) (slice (append p128x6 p128) 0 (length p128x6 + length p128))); assert (equal (slice cipher 0 (length p128x6 + length p128)) (slice (append c128x6 c128) 0 (length p128x6 + length p128))); gctr_partial_opaque_ignores_postfix alg (length p128x6 + length p128) plain (append p128x6 p128) cipher (append c128x6 c128) key ctr_BE_2; assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2); gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2; let num_blocks = p_num_bytes / 16 in assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks))); gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks; assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks == gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0); aes_encrypt_LE_reveal (); gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes; assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ) else ( gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher; assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key); let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in assert (equal plain_bytes (le_seq_quad32_to_bytes plain)); assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher)); assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key) ); gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key; () let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma (requires length x <= i /\ i <= length x + length y) (ensures slice (append x y) 0 i == append x (slice y 0 (i - length x))) = assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x)))); () let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) : Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y)) = append_distributes_le_seq_quad32_to_bytes x y let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma (requires length x % 16 == 0) (ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y)) = assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y))) #reset-options "--z3rlimit 100" let gcm_blocks_helper (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) = let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in let hash = ghash_LE h final_quads in gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE; //assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes calc (==) { enc_hash; == {} gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0; == {} gctr_encrypt_block ctr_BE_1 hash alg key 0; == {} quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == { aes_encrypt_LE_reveal () } quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1)); == {} quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1); }; calc (==) { gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key; == { gctr_encrypt_one_block ctr_BE_1 hash alg key } le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1))); == {} le_seq_quad32_to_bytes (create 1 enc_hash); == { le_seq_quad32_to_bytes_of_singleton enc_hash } le_quad32_to_bytes enc_hash; }; if p_num_bytes > (length p128x6 + length p128) * 16 then ( let c = append (append c128x6 c128) c_bytes in calc (==) { append (append (append auth_quads c128x6) c128) c_bytes; == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) c_bytes; == { append_assoc auth_quads (append c128x6 c128) c_bytes } append auth_quads (append (append c128x6 c128) c_bytes); == {} append auth_quads c; }; calc (==) { append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad); = {} // See previous calc append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad); == { append_assoc auth_quads c (create 1 length_quad) } append auth_quads (append c (create 1 length_quad)); }; let raw_quads_old = append auth_quads c in calc (==) { raw_quads; == {} le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes)); == { calc (==) { pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes); == { calc (==) { slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes; == { append_distributes_le_seq_quad32_to_bytes auth_quads c } slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes; == { slice_append_back (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c) total_bytes } append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes); == {} append (le_seq_quad32_to_bytes auth_quads) cipher_bytes; } } pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes); == { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes } append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes); } } le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes)); == { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes) } append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); == { le_bytes_to_seq_quad32_to_bytes auth_quads } append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)); }; let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in calc (==) { append raw_quads (create 1 length_quad); == {} append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad); == { assert (equal auth_quads auth_padded_quads') } append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad); == { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) } append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad)); }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ) else ( calc (==) { append (append (append auth_quads c128x6) c128) (create 1 length_quad); == { append_assoc auth_quads c128x6 c128 } append (append auth_quads (append c128x6 c128)) (create 1 length_quad); == { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) } append auth_quads (append (append c128x6 c128) (create 1 length_quad)); }; let c = append c128x6 c128 in calc (==) { le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)); == { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) } le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c)); == { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) } le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c); == { le_bytes_to_seq_quad32_to_bytes c } c; }; insert_nat64_reveal (); gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key; () ); () // TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes == slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes) = if num_bytes > (length s) * 16 then ( () ) else ( calc (==) { slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes; == { append_distributes_le_seq_quad32_to_bytes s bytes } slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes; == { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) } le_seq_quad32_to_bytes s; == { assert (length (le_seq_quad32_to_bytes s) == num_bytes) } slice (le_seq_quad32_to_bytes s) 0 num_bytes; }; () ) #reset-options "--z3rlimit 10" let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32) (a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\ j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append (append auth_quads c128x6) c128 in let total_bytes = (length auth_quads) * 16 + p_num_bytes in let raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in le_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = append a128 a_bytes in let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\ le_quad32_to_bytes enc_hash == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) ) = gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad; let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes; lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; () let lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma (requires is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ length cipher < pow2_32 /\ length auth < pow2_32 /\ plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth) ) (ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag)) = gcm_encrypt_LE_reveal (); gcm_decrypt_LE_reveal (); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCM.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> auth_bytes: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> alleged_tag: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> p_num_bytes: Prims.nat -> iv: Vale.AES.GCM_s.supported_iv_LE -> j0_BE: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\ p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\ FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\ FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\ FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\ FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) in j0_BE = Vale.AES.GCM_s.compute_iv_BE h_LE iv) /\ p_num_bytes < Vale.Def.Words_s.pow2_32 /\ (let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in let plain = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes | _ -> FStar.Seq.Base.append p128x6 p128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let cipher = (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes | _ -> FStar.Seq.Base.append c128x6 c128) <: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 in let cipher_bound = FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 + (match p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16 with | true -> 1 | _ -> 0) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2)) (ensures (let plain_raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes in let plain_bytes = FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes in let cipher_bytes = FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length plain_bytes < Vale.Def.Words_s.pow2_32 /\ cipher_bytes == FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.nat8", "Prims.nat", "Vale.AES.GCM_s.supported_iv_LE", "Prims.unit", "Vale.AES.GCM.lemma_gcm_encrypt_decrypt_equiv", "Prims._assert", "Prims.eq2", "Vale.Def.Types_s.nat8", "FStar.Pervasives.Native.fst", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "FStar.Seq.Base.slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Base.append", "Vale.AES.GCM.lemma_length_simplifier", "Prims.op_GreaterThan", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.bool", "Vale.AES.GCM.gcm_blocks_helper_enc", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.int", "Vale.Def.Words_s.pow2_32", "Vale.AES.AES_s.is_aes_key_LE", "Prims.op_Equality", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.AES.GCTR.gctr_partial", "Vale.AES.GCTR_s.inc32", "Prims.squash", "Vale.AES.GCM_s.gcm_decrypt_LE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let gcm_blocks_helper_dec_simplified (alg: algorithm) (key: seq nat32) (p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32) (auth_bytes alleged_tag: seq nat8) (p_num_bytes: nat) (iv: supported_iv_LE) (j0_BE: quad32) : Lemma (requires length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_LE alg key /\ (let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_LE iv) /\ p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in let cipher_bound:nat = length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2)) (ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag))) =
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_bytes p_num_bytes iv j0_BE; let plain_raw_quads = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append p128x6 p128) p_bytes else append p128x6 p128 in let cipher_raw_quads:seq quad32 = if p_num_bytes > (length p128x6 + length p128) * 16 then append (append c128x6 c128) c_bytes else append c128x6 c128 in lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes; lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes; let plain_raw_quads = append (append p128x6 p128) p_bytes in let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in let cipher_raw_quads = append (append c128x6 c128) c_bytes in let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)); lemma_gcm_encrypt_decrypt_equiv alg key iv j0_BE cipher_bytes plain_bytes auth_bytes alleged_tag; ()
false