effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
FStar.Pervasives.Lemma
val gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
val gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) let gctr_partial_opaque_completed (alg: algorithm) (plain cipher: seq quad32) (key: seq nat32) (icb: quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) =
false
null
true
gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Vale.AES.GCTR_BE.gctr_partial_completed", "Prims.unit", "Vale.AES.GCTR_BE.gctr_partial_reveal", "Prims.l_and", "Vale.AES.AES_BE_s.is_aes_key_word", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Vale.AES.GCTR_BE.gctr_partial", "Prims.squash", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[]
Vale.AES.GCTR_BE.gctr_partial_opaque_completed
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ Vale.AES.GCTR_BE.gctr_partial alg (FStar.Seq.Base.length cipher) plain cipher key icb) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
{ "end_col": 49, "end_line": 136, "start_col": 2, "start_line": 135 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; ()
val nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3) let nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3) =
false
null
true
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper2
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t')
{ "end_col": 4, "end_line": 236, "start_col": 3, "start_line": 228 }
FStar.Pervasives.Lemma
val gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial_def alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; ()
val gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial_def alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) let gctr_partial_completed (alg: algorithm) (plain cipher: seq quad32) (key: seq nat32) (icb: quad32) =
false
null
true
gctr_indexed icb plain alg key cipher; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR_BE.gctr_indexed" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial_def alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[]
Vale.AES.GCTR_BE.gctr_partial_completed
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ Vale.AES.GCTR_BE.gctr_partial_def alg (FStar.Seq.Base.length cipher) plain cipher key icb) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
{ "end_col": 4, "end_line": 124, "start_col": 2, "start_line": 123 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
val nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100) let nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100) =
false
null
true
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper3
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s' /\ Mkfour?.lo1 s == Mkfour?.lo1 s') (ensures k / 0x100 == k' / 0x100)
{ "end_col": 4, "end_line": 314, "start_col": 3, "start_line": 309 }
FStar.Pervasives.Lemma
val gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) : Lemma (requires is_aes_key_word alg key /\ cipher == gctr_encrypt_recursive icb plain alg key 0 /\ length plain * 16 < pow2_32 ) (ensures seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher) == gctr_encrypt icb (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) alg key)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; ()
val gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) : Lemma (requires is_aes_key_word alg key /\ cipher == gctr_encrypt_recursive icb plain alg key 0 /\ length plain * 16 < pow2_32 ) (ensures seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher) == gctr_encrypt icb (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) alg key) let gctr_partial_to_full_basic (icb: quad32) (plain: seq quad32) (alg: algorithm) (key: seq nat32) (cipher: seq quad32) =
false
null
true
gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes", "Vale.Def.Words_s.nat8", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) : Lemma (requires is_aes_key_word alg key /\ cipher == gctr_encrypt_recursive icb plain alg key 0 /\ length plain * 16 < pow2_32 ) (ensures seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher) == gctr_encrypt icb (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) alg key)
[]
Vale.AES.GCTR_BE.gctr_partial_to_full_basic
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0 /\ FStar.Seq.Base.length plain * 16 < Vale.Def.Words_s.pow2_32) (ensures Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE cipher ) == Vale.AES.GCTR_BE_s.gctr_encrypt icb (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE plain )) alg key)
{ "end_col": 4, "end_line": 146, "start_col": 2, "start_line": 139 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; ()
val nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) let nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) =
false
null
true
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper2
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t')
{ "end_col": 4, "end_line": 255, "start_col": 3, "start_line": 245 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; ()
val nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) let nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) =
false
null
true
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper2
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t' /\ Mkfour?.lo1 t == Mkfour?.lo1 t')
{ "end_col": 4, "end_line": 272, "start_col": 3, "start_line": 264 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; ()
val nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) let nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) =
false
null
true
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper2", "Vale.AES.GCTR_BE.lemma_ishr_ixor_32", "Vale.AES.Types_helpers.lemma_ishr_32", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper3", "Vale.Def.Words_s.nat8", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_3
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s' /\ Mkfour?.lo1 s == Mkfour?.lo1 s') (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t' /\ Mkfour?.lo1 t == Mkfour?.lo1 t')
{ "end_col": 4, "end_line": 393, "start_col": 3, "start_line": 380 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
val nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000) let nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000) =
false
null
true
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper3
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s') (ensures k / 0x1000000 == k' / 0x1000000)
{ "end_col": 4, "end_line": 286, "start_col": 3, "start_line": 281 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; ()
val nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3) let nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3) =
false
null
true
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper2", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Vale.AES.Types_helpers.pow2_24", "Vale.AES.GCTR_BE.lemma_ishr_ixor_32", "Vale.AES.Types_helpers.lemma_ishr_32", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper3", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_1
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ Mkfour?.hi3 s == Mkfour?.hi3 s') (ensures Mkfour?.hi3 t == Mkfour?.hi3 t')
{ "end_col": 4, "end_line": 341, "start_col": 3, "start_line": 327 }
FStar.Pervasives.Lemma
val slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); ()
val slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s) let slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s) =
false
null
true
assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s)
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s)
[]
Vale.AES.GCTR_BE.slice_pad_to_128_bits
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 {0 < FStar.Seq.Base.length s /\ FStar.Seq.Base.length s < 16} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.AES.GCTR_BE_s.pad_to_128_bits s) 0 (FStar.Seq.Base.length s) == s)
{ "end_col": 4, "end_line": 487, "start_col": 2, "start_line": 485 }
FStar.Pervasives.Lemma
val lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i))
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux
val lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i)) let lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i)) =
false
null
true
let aux (i: nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Prims.nat", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Seq.Base.lemma_index_slice", "Prims.op_Subtraction", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.l_Forall", "Prims.int", "Prims.l_imp" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n)
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i))
[]
Vale.AES.GCTR_BE.lemma_slice_orig_index
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq a -> s': FStar.Seq.Base.seq a -> m: Prims.nat -> n: Prims.nat -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == FStar.Seq.Base.length s' /\ m <= n /\ n <= FStar.Seq.Base.length s /\ FStar.Seq.Base.slice s m n == FStar.Seq.Base.slice s' m n) (ensures forall (i: Prims.int). {:pattern FStar.Seq.Base.index s i\/FStar.Seq.Base.index s' i} m <= i /\ i < n ==> FStar.Seq.Base.index s i == FStar.Seq.Base.index s' i)
{ "end_col": 31, "end_line": 178, "start_col": 3, "start_line": 174 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
val nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) let nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) =
false
null
true
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 )
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000)
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper3
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s') (ensures k / 0x10000 == k' / 0x10000)
{ "end_col": 4, "end_line": 300, "start_col": 3, "start_line": 295 }
FStar.Pervasives.Lemma
val gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c)
val gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) let gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) =
false
null
true
gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert (equal cipher c)
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain_internal", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Prims.unit", "Vale.AES.GCTR_BE.gctr_indexed_helper", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Prims.l_Forall", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.index", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE_s.inc32", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
[]
Vale.AES.GCTR_BE.gctr_indexed
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain_internal -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length cipher == FStar.Seq.Base.length plain /\ (forall (i: Prims.int { i >= 0 /\ i < FStar.Seq.Base.length plain /\ (i >= 0) /\ (i < FStar.Seq.Base.length cipher) }). {:pattern FStar.Seq.Base.index cipher i} 0 <= i /\ i < FStar.Seq.Base.length cipher ==> FStar.Seq.Base.index cipher i == Vale.Def.Types_s.quad32_xor (FStar.Seq.Base.index plain i) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 icb i)))) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
{ "end_col": 24, "end_line": 120, "start_col": 2, "start_line": 118 }
FStar.Pervasives.Lemma
val step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); ()
val step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) let step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) =
false
null
true
let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes0", "Prims.int", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Division", "Prims.op_Modulus", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE)
[]
Vale.AES.GCTR_BE.step1
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> num_bytes: Prims.nat{num_bytes < 16 * FStar.Seq.Base.length p} -> FStar.Pervasives.Lemma (ensures (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let _ = FStar.Seq.Properties.split (FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ full_blocks _ = _ in let full_quads_BE = Vale.Def.Types_s.be_bytes_to_seq_quad32 full_blocks in let p_prefix = FStar.Seq.Base.slice p 0 num_blocks in p_prefix == full_quads_BE) <: Type0))
{ "end_col": 4, "end_line": 168, "start_col": 3, "start_line": 155 }
FStar.Pervasives.Lemma
val gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_encrypt icb (be_quad32_to_bytes plain) alg key == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 (quad32_xor plain (aes_encrypt_word alg key icb)))) )
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) = gctr_encrypt_reveal (); assert(inc32 icb 0 == icb); let encrypted_icb = aes_encrypt_word alg key icb in let p = be_quad32_to_bytes plain in let plain_quads = be_bytes_to_seq_quad32 p in let p_seq = create 1 plain in assert (length p == 16); be_bytes_to_seq_quad32_to_bytes_one_quad plain; assert (p_seq == plain_quads); let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in assert (cipher_quads == cons (gctr_encrypt_block icb (head plain_quads) alg key 0) (gctr_encrypt_recursive icb (tail plain_quads) alg key (1))); assert (head plain_quads == plain); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == (quad32_xor (head plain_quads) (aes_encrypt_word alg key icb))); assert (quad32_xor plain (aes_encrypt_word alg key icb) == (quad32_xor (head plain_quads) (aes_encrypt_word alg key (inc32 icb 0)))); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); aes_encrypt_word_reveal (); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain encrypted_icb); assert(gctr_encrypt_recursive icb (tail p_seq) alg key 1 == empty); // OBSERVE let x = quad32_xor plain encrypted_icb in append_empty_r (create 1 x); ()
val gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_encrypt icb (be_quad32_to_bytes plain) alg key == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 (quad32_xor plain (aes_encrypt_word alg key icb)))) ) let gctr_encrypt_one_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) =
false
null
true
gctr_encrypt_reveal (); assert (inc32 icb 0 == icb); let encrypted_icb = aes_encrypt_word alg key icb in let p = be_quad32_to_bytes plain in let plain_quads = be_bytes_to_seq_quad32 p in let p_seq = create 1 plain in assert (length p == 16); be_bytes_to_seq_quad32_to_bytes_one_quad plain; assert (p_seq == plain_quads); let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in assert (cipher_quads == cons (gctr_encrypt_block icb (head plain_quads) alg key 0) (gctr_encrypt_recursive icb (tail plain_quads) alg key (1))); assert (head plain_quads == plain); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == (quad32_xor (head plain_quads) (aes_encrypt_word alg key icb))); assert (quad32_xor plain (aes_encrypt_word alg key icb) == (quad32_xor (head plain_quads) (aes_encrypt_word alg key (inc32 icb 0)))); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); aes_encrypt_word_reveal (); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain encrypted_icb); assert (gctr_encrypt_recursive icb (tail p_seq) alg key 1 == empty); let x = quad32_xor plain encrypted_icb in append_empty_r (create 1 x); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.unit", "FStar.Seq.Base.append_empty_r", "FStar.Seq.Base.create", "Vale.Def.Types_s.quad32_xor", "Prims._assert", "Prims.eq2", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "FStar.Seq.Properties.tail", "FStar.Seq.Base.empty", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "FStar.Seq.Properties.head", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.AES_BE_s.aes_encrypt_word_reveal", "Vale.AES.GCTR_BE_s.inc32", "FStar.Seq.Properties.cons", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes_one_quad", "Prims.int", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Vale.Def.Words.Seq_s.seq16", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); () let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); () #reset-options "--z3rlimit 30" open FStar.Seq.Properties let gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) = gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); // LHS quads let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); // LHS bytes assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert(final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); // RHS bytes be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_encrypt icb (be_quad32_to_bytes plain) alg key == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 (quad32_xor plain (aes_encrypt_word alg key icb)))) )
[]
Vale.AES.GCTR_BE.gctr_encrypt_one_block
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key) (ensures Vale.AES.GCTR_BE_s.gctr_encrypt icb (Vale.Arch.Types.be_quad32_to_bytes plain) alg key == Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.create 1 (Vale.Def.Types_s.quad32_xor plain (Vale.AES.AES_BE_s.aes_encrypt_word alg key icb)))))
{ "end_col": 4, "end_line": 596, "start_col": 2, "start_line": 571 }
FStar.Pervasives.Lemma
val gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))]
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () )
val gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] let gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] =
false
null
true
reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then (let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0) else (let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); ())
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.op_Equality", "Prims.int", "Vale.AES.GCTR_BE.gctr_encrypt_recursive_length", "FStar.Seq.Base.seq", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims.bool", "Vale.Def.Types_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Prims.op_Division", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Subtraction", "Vale.AES.GCTR_BE_s.gctr_encrypt", "Prims.op_Modulus", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal", "FStar.Pervasives.reveal_opaque", "Prims.l_True", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))]
false
false
Vale.AES.GCTR_BE.fst
{ "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))]
[]
Vale.AES.GCTR_BE.gctr_encrypt_length
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt icb plain alg key) == FStar.Seq.Base.length plain) [SMTPat (FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt icb plain alg key))]
{ "end_col": 3, "end_line": 83, "start_col": 2, "start_line": 56 }
FStar.Pervasives.Lemma
val step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); ()
val step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) let step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) =
false
null
true
let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then (be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); ()); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Types_s.quad32", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.int", "Prims.unit", "Prims.op_Equality", "Vale.AES.GCTR_BE.quad32_xor_bytewise", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE.slice_pad_to_128_bits", "Vale.Arch.Types.be_quad32_to_bytes_to_quad32", "Prims.bool", "Vale.AES.GCTR_BE_s.inc32", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Vale.Def.Words.Seq_s.seq16", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); () let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes)
[]
Vale.AES.GCTR_BE.step2
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 {0 < FStar.Seq.Base.length s /\ FStar.Seq.Base.length s < 16} -> q: Vale.Def.Types_s.quad32 -> icb_BE: Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q_bytes_prefix = FStar.Seq.Base.slice q_bytes 0 (FStar.Seq.Base.length s) in let q_cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = FStar.Seq.Base.slice (Vale.Arch.Types.be_quad32_to_bytes q_cipher) 0 (FStar.Seq.Base.length s) in let s_quad = Vale.Def.Types_s.be_bytes_to_quad32 (Vale.AES.GCTR_BE_s.pad_to_128_bits s) in let s_cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = FStar.Seq.Base.slice (Vale.Arch.Types.be_quad32_to_bytes s_cipher) 0 (FStar.Seq.Base.length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes))
{ "end_col": 4, "end_line": 516, "start_col": 3, "start_line": 498 }
FStar.Pervasives.Lemma
val gctr_partial_opaque_ignores_postfix (alg:algorithm) (bound:nat32) (plain plain' cipher cipher':seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain >= bound /\ length cipher >= bound /\ length plain' >= bound /\ length cipher' >= bound /\ slice plain 0 bound == slice plain' 0 bound /\ slice cipher 0 bound == slice cipher' 0 bound) (ensures gctr_partial alg bound plain cipher key icb <==> gctr_partial alg bound plain' cipher' key icb)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); ()
val gctr_partial_opaque_ignores_postfix (alg:algorithm) (bound:nat32) (plain plain' cipher cipher':seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain >= bound /\ length cipher >= bound /\ length plain' >= bound /\ length cipher' >= bound /\ slice plain 0 bound == slice plain' 0 bound /\ slice cipher 0 bound == slice cipher' 0 bound) (ensures gctr_partial alg bound plain cipher key icb <==> gctr_partial alg bound plain' cipher' key icb) let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb =
false
null
true
gctr_partial_reveal (); assert (forall i. 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.eq2", "FStar.Seq.Base.index", "Vale.AES.GCTR_BE.gctr_partial_reveal" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); ()
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_partial_opaque_ignores_postfix (alg:algorithm) (bound:nat32) (plain plain' cipher cipher':seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain >= bound /\ length cipher >= bound /\ length plain' >= bound /\ length cipher' >= bound /\ slice plain 0 bound == slice plain' 0 bound /\ slice cipher 0 bound == slice cipher' 0 bound) (ensures gctr_partial alg bound plain cipher key icb <==> gctr_partial alg bound plain' cipher' key icb)
[]
Vale.AES.GCTR_BE.gctr_partial_opaque_ignores_postfix
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> bound: Vale.Def.Types_s.nat32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> plain': FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher': FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain >= bound /\ FStar.Seq.Base.length cipher >= bound /\ FStar.Seq.Base.length plain' >= bound /\ FStar.Seq.Base.length cipher' >= bound /\ FStar.Seq.Base.slice plain 0 bound == FStar.Seq.Base.slice plain' 0 bound /\ FStar.Seq.Base.slice cipher 0 bound == FStar.Seq.Base.slice cipher' 0 bound) (ensures Vale.AES.GCTR_BE.gctr_partial alg bound plain cipher key icb <==> Vale.AES.GCTR_BE.gctr_partial alg bound plain' cipher' key icb)
{ "end_col": 4, "end_line": 37, "start_col": 2, "start_line": 31 }
FStar.Pervasives.Lemma
val gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain])
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper
val gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain]) let rec gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain]) =
false
null
true
if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i + 1) in let helper (j: int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j))) )) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then (gctr_indexed_helper icb tl alg key (i + 1); assert (index r_cipher (j - 1) == quad32_xor (index tl (j - 1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1))))) in FStar.Classical.forall_intro helper
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma", "" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain_internal", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.int", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.bool", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE_s.inc32", "Prims.op_Addition", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.op_AmpAmp", "Prims._assert", "Prims.op_Subtraction", "Vale.AES.GCTR_BE.gctr_indexed_helper", "Vale.AES.AES_BE_s.aes_encrypt_word_reveal", "FStar.Seq.Base.seq", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "FStar.Seq.Properties.tail", "Prims.nat", "Prims.l_Forall", "Prims.op_GreaterThanOrEqual" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain])
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain])
[ "recursion" ]
Vale.AES.GCTR_BE.gctr_indexed_helper
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain_internal -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures (let cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key i in FStar.Seq.Base.length cipher == FStar.Seq.Base.length plain /\ (forall (j: i: Prims.int { i >= 0 /\ i < FStar.Seq.Base.length plain /\ (i >= 0) /\ (i < FStar.Seq.Base.length cipher) }). {:pattern FStar.Seq.Base.index cipher j} 0 <= j /\ j < FStar.Seq.Base.length plain ==> FStar.Seq.Base.index cipher j == Vale.Def.Types_s.quad32_xor (FStar.Seq.Base.index plain j) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 icb (i + j)))) )) (decreases FStar.Seq.Base.length plain)
{ "end_col": 41, "end_line": 109, "start_col": 2, "start_line": 95 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i))
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; ()
val nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i)) let nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i)) =
false
null
true
assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Types_s.nat8", "Prims.nat", "Prims.unit", "Vale.AES.GCTR_BE.lemma_slice_orig_index", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Prims.op_Equality", "Prims.int", "Vale.AES.GCTR_BE.nat32_xor_bytewise_4", "Vale.Def.Words.Seq_s.seq_to_four_BE", "Prims.bool", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1", "Vale.Def.Words_s.natN", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.pow2_32", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThan", "Prims.eq2", "FStar.Seq.Base.index", "Prims.l_and", "Prims.op_LessThanOrEqual", "Vale.Def.Words.Four_s.four_to_nat", "Prims.pow2", "FStar.Mul.op_Star", "Prims.squash", "Prims.l_Forall", "Prims.op_LessThan", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i))
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i))
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> s': Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> t: Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> t': Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> n: Prims.nat -> FStar.Pervasives.Lemma (requires n <= 4 /\ k == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE s) /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE s') /\ Vale.Def.Types_s.ixor k m == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE t) /\ Vale.Def.Types_s.ixor k' m == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE t') /\ FStar.Seq.Base.equal (FStar.Seq.Base.slice s 0 n) (FStar.Seq.Base.slice s' 0 n)) (ensures forall (i: Prims.nat). {:pattern FStar.Seq.Base.index t i\/FStar.Seq.Base.index t' i} i < n ==> FStar.Seq.Base.index t i == FStar.Seq.Base.index t' i)
{ "end_col": 4, "end_line": 440, "start_col": 2, "start_line": 428 }
FStar.Pervasives.Lemma
val gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) : Lemma (requires is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * length plain /\ 16 * (length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < pow2_32 /\ length plain == length cipher /\ ( let num_blocks = num_bytes / 16 in slice cipher 0 num_blocks == gctr_encrypt_recursive icb_BE (slice plain 0 num_blocks) alg key 0 /\ index cipher num_blocks == gctr_encrypt_block icb_BE (index plain num_blocks) alg key num_blocks) ) (ensures ( let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == gctr_encrypt icb_BE plain_bytes alg key ))
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) = gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); // LHS quads let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); // LHS bytes assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert(final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); // RHS bytes be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
val gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) : Lemma (requires is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * length plain /\ 16 * (length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < pow2_32 /\ length plain == length cipher /\ ( let num_blocks = num_bytes / 16 in slice cipher 0 num_blocks == gctr_encrypt_recursive icb_BE (slice plain 0 num_blocks) alg key 0 /\ index cipher num_blocks == gctr_encrypt_block icb_BE (index plain num_blocks) alg key num_blocks) ) (ensures ( let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == gctr_encrypt icb_BE plain_bytes alg key )) let gctr_partial_to_full_advanced (icb_BE: quad32) (plain cipher: seq quad32) (alg: algorithm) (key: seq nat32) (num_bytes: nat) =
false
null
true
gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert (final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "Prims.nat", "Vale.Def.Words_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.op_At_Bar", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "FStar.Seq.Base.index", "FStar.Mul.op_Star", "Vale.Lib.Seqs.slice_append_adds", "FStar.Seq.Base.length", "Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes0", "Vale.AES.GCM_helpers_BE.be_seq_quad32_to_bytes_tail_prefix", "Prims.int", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Prims.op_Division", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims.op_Modulus", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Subtraction", "Vale.AES.GCTR_BE.step2", "Vale.AES.GCTR_BE.step1", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); () let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); () #reset-options "--z3rlimit 30" open FStar.Seq.Properties
false
false
Vale.AES.GCTR_BE.fst
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) : Lemma (requires is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * length plain /\ 16 * (length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < pow2_32 /\ length plain == length cipher /\ ( let num_blocks = num_bytes / 16 in slice cipher 0 num_blocks == gctr_encrypt_recursive icb_BE (slice plain 0 num_blocks) alg key 0 /\ index cipher num_blocks == gctr_encrypt_block icb_BE (index plain num_blocks) alg key num_blocks) ) (ensures ( let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == gctr_encrypt icb_BE plain_bytes alg key ))
[]
Vale.AES.GCTR_BE.gctr_partial_to_full_advanced
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb_BE: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> num_bytes: Prims.nat -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * FStar.Seq.Base.length plain /\ 16 * (FStar.Seq.Base.length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ (let num_blocks = num_bytes / 16 in FStar.Seq.Base.slice cipher 0 num_blocks == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb_BE (FStar.Seq.Base.slice plain 0 num_blocks) alg key 0 /\ FStar.Seq.Base.index cipher num_blocks == Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE (FStar.Seq.Base.index plain num_blocks) alg key num_blocks)) (ensures (let plain_bytes = FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == Vale.AES.GCTR_BE_s.gctr_encrypt icb_BE plain_bytes alg key))
{ "end_col": 4, "end_line": 568, "start_col": 2, "start_line": 522 }
FStar.Pervasives.Lemma
val lemma_gctr_partial_append (alg:algorithm) (b1 b2:nat) (p1 c1 p2 c2:seq quad32) (key:seq nat32) (icb1 icb2:quad32) : Lemma (requires gctr_partial alg b1 p1 c1 key icb1 /\ gctr_partial alg b2 p2 c2 key icb2 /\ b1 == length p1 /\ b1 == length c1 /\ b2 == length p2 /\ b2 == length c2 /\ icb2 == inc32 icb1 b1) (ensures gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); ()
val lemma_gctr_partial_append (alg:algorithm) (b1 b2:nat) (p1 c1 p2 c2:seq quad32) (key:seq nat32) (icb1 icb2:quad32) : Lemma (requires gctr_partial alg b1 p1 c1 key icb1 /\ gctr_partial alg b2 p2 c2 key icb2 /\ b1 == length p1 /\ b1 == length c1 /\ b2 == length p2 /\ b2 == length c2 /\ icb2 == inc32 icb1 b1) (ensures gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1) let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 =
false
null
true
gctr_partial_reveal (); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR_BE.gctr_partial_reveal" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val lemma_gctr_partial_append (alg:algorithm) (b1 b2:nat) (p1 c1 p2 c2:seq quad32) (key:seq nat32) (icb1 icb2:quad32) : Lemma (requires gctr_partial alg b1 p1 c1 key icb1 /\ gctr_partial alg b2 p2 c2 key icb2 /\ b1 == length p1 /\ b1 == length c1 /\ b2 == length p2 /\ b2 == length c2 /\ icb2 == inc32 icb1 b1) (ensures gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
[]
Vale.AES.GCTR_BE.lemma_gctr_partial_append
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> b1: Prims.nat -> b2: Prims.nat -> p1: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c1: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p2: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c2: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb1: Vale.Def.Types_s.quad32 -> icb2: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.GCTR_BE.gctr_partial alg b1 p1 c1 key icb1 /\ Vale.AES.GCTR_BE.gctr_partial alg b2 p2 c2 key icb2 /\ b1 == FStar.Seq.Base.length p1 /\ b1 == FStar.Seq.Base.length c1 /\ b2 == FStar.Seq.Base.length p2 /\ b2 == FStar.Seq.Base.length c2 /\ icb2 == Vale.AES.GCTR_BE_s.inc32 icb1 b1) (ensures Vale.AES.GCTR_BE.gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
{ "end_col": 4, "end_line": 28, "start_col": 2, "start_line": 27 }
FStar.Pervasives.Lemma
val quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n))
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); ()
val quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) let quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) =
false
null
true
let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else (nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else (nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else (nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); ()))); assert (equal (slice t 0 n) (slice t' 0 n)); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "Prims.op_LessThan", "Vale.AES.GCTR_BE.nat32_xor_bytewise", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.nat32", "Prims.bool", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.op_Subtraction", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.quad32_xor_reveal", "Vale.AES.GCTR_BE.lemma_slice_orig_index", "Vale.AES.Types_helpers.lemma_slices_be_quad32_to_bytes", "Vale.Def.Types_s.quad32_xor", "Vale.Def.Words.Seq_s.seq16", "Vale.Arch.Types.be_quad32_to_bytes", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in
false
false
Vale.AES.GCTR_BE.fst
{ "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" }
null
val quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n))
[]
Vale.AES.GCTR_BE.quad32_xor_bytewise
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> q': Vale.Def.Types_s.quad32 -> r: Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= 16} -> FStar.Pervasives.Lemma (requires (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q'_bytes = Vale.Arch.Types.be_quad32_to_bytes q' in FStar.Seq.Base.slice q_bytes 0 n == FStar.Seq.Base.slice q'_bytes 0 n)) (ensures (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q'_bytes = Vale.Arch.Types.be_quad32_to_bytes q' in let qr_bytes = Vale.Arch.Types.be_quad32_to_bytes (Vale.Def.Types_s.quad32_xor q r) in let q'r_bytes = Vale.Arch.Types.be_quad32_to_bytes (Vale.Def.Types_s.quad32_xor q' r) in FStar.Seq.Base.slice qr_bytes 0 n == FStar.Seq.Base.slice q'r_bytes 0 n))
{ "end_col": 4, "end_line": 480, "start_col": 3, "start_line": 451 }
FStar.Pervasives.Lemma
val nat32_xor_bytewise_4 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s') (ensures t == t')
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "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": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_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.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_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 } ]
false
let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); ()
val nat32_xor_bytewise_4 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s') (ensures t == t') let nat32_xor_bytewise_4 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s') (ensures t == t') =
false
null
true
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); ()
{ "checked_file": "Vale.AES.GCTR_BE.fst.checked", "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.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Types_s.ixor", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' )
false
false
Vale.AES.GCTR_BE.fst
{ "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": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat32_xor_bytewise_4 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s') (ensures t == t')
[]
Vale.AES.GCTR_BE.nat32_xor_bytewise_4
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ s == s') (ensures t == t')
{ "end_col": 4, "end_line": 414, "start_col": 3, "start_line": 407 }
FStar.HyperStack.ST.Stack
val store_sha512_modq_pre_pre2: out:lbuffer uint8 32ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let store_sha512_modq_pre_pre2 out prefix prefix2 len input = push_frame (); let tmp = create 5ul (u64 0) in sha512_modq_pre_pre2 tmp prefix prefix2 len input; Hacl.Impl.Store56.store_56 out tmp; pop_frame ()
val store_sha512_modq_pre_pre2: out:lbuffer uint8 32ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input)))) let store_sha512_modq_pre_pre2 out prefix prefix2 len input =
true
null
false
push_frame (); let tmp = create 5ul (u64 0) in sha512_modq_pre_pre2 tmp prefix prefix2 len input; Hacl.Impl.Store56.store_56 out tmp; pop_frame ()
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Store56.store_56", "Hacl.Impl.SHA512.ModQ.sha512_modq_pre_pre2", "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", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_pre_pre2_msg hash prefix prefix2 len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_modq_pre out prefix len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_msg hash prefix len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame() val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_modq_pre_pre2 out prefix prefix2 len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_pre2_msg hash prefix prefix2 len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame() inline_for_extraction noextract val store_sha512_modq_pre: out:lbuffer uint8 32ul -> outq:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h outq /\ disjoint prefix out /\ disjoint out input /\ disjoint out outq /\ disjoint prefix outq /\ disjoint outq input) (ensures fun h0 _ h1 -> modifies (loc out |+| loc outq) h0 h1 /\ F56.scalar_inv_full_t h1 outq /\ F56.as_nat h1 outq == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)) /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (F56.as_nat h1 outq)) let store_sha512_modq_pre out outq prefix len input = sha512_modq_pre outq prefix len input; Hacl.Impl.Store56.store_56 out outq inline_for_extraction noextract val store_sha512_modq_pre_pre2: out:lbuffer uint8 32ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))))
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val store_sha512_modq_pre_pre2: out:lbuffer uint8 32ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))))
[]
Hacl.Impl.SHA512.ModQ.store_sha512_modq_pre_pre2
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> prefix2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 173, "start_col": 2, "start_line": 169 }
FStar.HyperStack.ST.Stack
val store_sha512_modq_pre: out:lbuffer uint8 32ul -> outq:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h outq /\ disjoint prefix out /\ disjoint out input /\ disjoint out outq /\ disjoint prefix outq /\ disjoint outq input) (ensures fun h0 _ h1 -> modifies (loc out |+| loc outq) h0 h1 /\ F56.scalar_inv_full_t h1 outq /\ F56.as_nat h1 outq == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)) /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (F56.as_nat h1 outq))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let store_sha512_modq_pre out outq prefix len input = sha512_modq_pre outq prefix len input; Hacl.Impl.Store56.store_56 out outq
val store_sha512_modq_pre: out:lbuffer uint8 32ul -> outq:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h outq /\ disjoint prefix out /\ disjoint out input /\ disjoint out outq /\ disjoint prefix outq /\ disjoint outq input) (ensures fun h0 _ h1 -> modifies (loc out |+| loc outq) h0 h1 /\ F56.scalar_inv_full_t h1 outq /\ F56.as_nat h1 outq == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)) /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (F56.as_nat h1 outq)) let store_sha512_modq_pre out outq prefix len input =
true
null
false
sha512_modq_pre outq prefix len input; Hacl.Impl.Store56.store_56 out outq
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint64", "Lib.IntTypes.size_t", "Hacl.Impl.Store56.store_56", "Prims.unit", "Hacl.Impl.SHA512.ModQ.sha512_modq_pre" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_pre_pre2_msg hash prefix prefix2 len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_modq_pre out prefix len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_msg hash prefix len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame() val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_modq_pre_pre2 out prefix prefix2 len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_pre2_msg hash prefix prefix2 len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame() inline_for_extraction noextract val store_sha512_modq_pre: out:lbuffer uint8 32ul -> outq:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h outq /\ disjoint prefix out /\ disjoint out input /\ disjoint out outq /\ disjoint prefix outq /\ disjoint outq input) (ensures fun h0 _ h1 -> modifies (loc out |+| loc outq) h0 h1 /\ F56.scalar_inv_full_t h1 outq /\ F56.as_nat h1 outq == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)) /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (F56.as_nat h1 outq))
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val store_sha512_modq_pre: out:lbuffer uint8 32ul -> outq:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h outq /\ disjoint prefix out /\ disjoint out input /\ disjoint out outq /\ disjoint prefix outq /\ disjoint outq input) (ensures fun h0 _ h1 -> modifies (loc out |+| loc outq) h0 h1 /\ F56.scalar_inv_full_t h1 outq /\ F56.as_nat h1 outq == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)) /\ as_seq h1 out == BSeq.nat_to_bytes_le 32 (F56.as_nat h1 outq))
[]
Hacl.Impl.SHA512.ModQ.store_sha512_modq_pre
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> outq: Lib.Buffer.lbuffer Lib.IntTypes.uint64 5ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 37, "end_line": 150, "start_col": 2, "start_line": 149 }
FStar.HyperStack.ST.Stack
val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let sha512_modq_pre out prefix len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_msg hash prefix len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame()
val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input))) let sha512_modq_pre out prefix len input =
true
null
false
push_frame (); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_msg hash prefix len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame ()
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Hacl.Impl.BignumQ.Mul.barrett_reduction", "Hacl.Impl.Load56.load_64_bytes", "Hacl.Impl.SHA512.ModQ.sha512_pre_msg", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.IntTypes.U64", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_pre_pre2_msg hash prefix prefix2 len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline]
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input)))
[]
Hacl.Impl.SHA512.ModQ.sha512_modq_pre
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Lib.Buffer.lbuffer Lib.IntTypes.uint64 5ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 101, "start_col": 2, "start_line": 94 }
FStar.HyperStack.ST.Stack
val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input)))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let sha512_modq_pre_pre2 out prefix prefix2 len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_pre2_msg hash prefix prefix2 len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame()
val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) let sha512_modq_pre_pre2 out prefix prefix2 len input =
true
null
false
push_frame (); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_pre2_msg hash prefix prefix2 len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame ()
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Hacl.Impl.BignumQ.Mul.barrett_reduction", "Hacl.Impl.Load56.load_64_bytes", "Hacl.Impl.SHA512.ModQ.sha512_pre_pre2_msg", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.IntTypes.U64", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline] let sha512_pre_pre2_msg hash prefix prefix2 len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_modq_pre: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ disjoint prefix out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (32 + v len) (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_modq_pre out prefix len input = push_frame(); let tmp = create 10ul (u64 0) in let hash = create 64ul (u8 0) in sha512_pre_msg hash prefix len input; Hacl.Impl.Load56.load_64_bytes tmp hash; Hacl.Impl.BignumQ.Mul.barrett_reduction out tmp; assert_norm (pow2 56 == 0x100000000000000); pop_frame() val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline]
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val sha512_modq_pre_pre2: out:lbuffer uint64 5ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h input /\ live h out /\ live h prefix /\ live h prefix2 /\ disjoint prefix out /\ disjoint prefix2 out /\ disjoint out input) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F56.scalar_inv_full_t h1 out /\ F56.as_nat h1 out == Spec.Ed25519.sha512_modq (64 + v len) (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input)))
[]
Hacl.Impl.SHA512.ModQ.sha512_modq_pre_pre2
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Lib.Buffer.lbuffer Lib.IntTypes.uint64 5ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> prefix2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 128, "start_col": 2, "start_line": 121 }
FStar.HyperStack.ST.Stack
val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input)))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame ()
val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) let sha512_pre_msg hash prefix len input =
true
null
false
push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame ()
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.Seq.Base.append_empty_l", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.hash_length'", "Spec.Hash.Definitions.SHA2_512", "Spec.Agile.Hash.hash", "FStar.Seq.Base.append", "FStar.Seq.Base.empty", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Streaming.SHA2.finish_512", "LowStar.Ignore.ignore", "Hacl.Streaming.Types.error_code", "Hacl.Streaming.SHA2.update_512", "Hacl.Streaming.Functor.state", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_t_512", "FStar.Ghost.erased", "Hacl.Streaming.SHA2.alloca_512", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline]
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input)))
[]
Hacl.Impl.SHA512.ModQ.sha512_pre_msg
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hash: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 45, "start_col": 2, "start_line": 33 }
FStar.HyperStack.ST.Stack
val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input)))
[ { "abbrev": true, "full_module": "Hacl.Impl.BignumQ.Mul", "short_module": "F56" }, { "abbrev": true, "full_module": "Hacl.Streaming.SHA2", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA512", "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 } ]
false
let sha512_pre_pre2_msg hash prefix prefix2 len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame ()
val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) let sha512_pre_pre2_msg hash prefix prefix2 len input =
true
null
false
push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st prefix2 32ul in let err2 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; LowStar.Ignore.ignore err2; Hash.finish_512 st hash (); Seq.append_empty_l (as_seq h0 prefix); pop_frame ()
{ "checked_file": "Hacl.Impl.SHA512.ModQ.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Ed25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Store56.fst.checked", "Hacl.Impl.Load56.fst.checked", "Hacl.Impl.BignumQ.Mul.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA512.ModQ.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.Seq.Base.append_empty_l", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Streaming.SHA2.finish_512", "LowStar.Ignore.ignore", "Hacl.Streaming.Types.error_code", "Hacl.Streaming.SHA2.update_512", "Hacl.Streaming.Functor.state", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_t_512", "FStar.Ghost.erased", "Hacl.Streaming.SHA2.alloca_512", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.SHA512.ModQ open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module Hash = Hacl.Streaming.SHA2 module F56 = Hacl.Impl.BignumQ.Mul #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val sha512_pre_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h input /\ disjoint input hash /\ disjoint prefix hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (as_seq h0 prefix) (as_seq h0 input))) [@CInline] let sha512_pre_msg hash prefix len input = push_frame (); let h0 = ST.get () in let st = Hash.alloca_512 () in let err0 = Hash.update_512 st prefix 32ul in let err1 = Hash.update_512 st input len in LowStar.Ignore.ignore err0; LowStar.Ignore.ignore err1; Hash.finish_512 st hash (); let h1 = ST.get () in assert (as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (Seq.empty) (as_seq h0 prefix)) (as_seq h0 input))); Seq.append_empty_l (as_seq h0 prefix); pop_frame () val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input))) [@CInline]
false
false
Hacl.Impl.SHA512.ModQ.fst
{ "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" }
null
val sha512_pre_pre2_msg: hash:lbuffer uint8 64ul -> prefix:lbuffer uint8 32ul -> prefix2:lbuffer uint8 32ul -> len:size_t -> input:lbuffer uint8 len -> Stack unit (requires fun h -> live h hash /\ live h prefix /\ live h prefix2 /\ live h input /\ disjoint prefix hash /\ disjoint prefix2 hash /\ disjoint input hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 (Seq.append (Seq.append (as_seq h0 prefix) (as_seq h0 prefix2)) (as_seq h0 input)))
[]
Hacl.Impl.SHA512.ModQ.sha512_pre_pre2_msg
{ "file_name": "code/ed25519/Hacl.Impl.SHA512.ModQ.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hash: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> prefix: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> prefix2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> len: Lib.IntTypes.size_t -> input: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 75, "start_col": 2, "start_line": 64 }
Prims.Tot
val va_code_Stack_lemma : va_dummy:unit -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Stack_lemma () = (va_Block (va_CNil ()))
val va_code_Stack_lemma : va_dummy:unit -> Tot va_code let va_code_Stack_lemma () =
false
null
false
(va_Block (va_CNil ()))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Stack_lemma : va_dummy:unit -> Tot va_code
[]
Vale.X64.InsStack.va_code_Stack_lemma
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_code
{ "end_col": 25, "end_line": 27, "start_col": 2, "start_line": 27 }
Prims.Tot
val va_codegen_success_Pop : dst:va_operand_dst_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Pop dst = (va_ttrue ())
val va_codegen_success_Pop : dst:va_operand_dst_opr64 -> Tot va_pbool let va_codegen_success_Pop dst =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Pop : dst:va_operand_dst_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Pop
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 60, "start_col": 2, "start_line": 60 }
Prims.Tot
val va_codegen_success_Push_Secret : src:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Push_Secret src = (va_ttrue ())
val va_codegen_success_Push_Secret : src:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_Push_Secret src =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Push_Secret : src:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Push_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 156, "start_col": 2, "start_line": 156 }
Prims.Tot
val va_code_Push_Secret : src:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Push_Secret src = (Ins (BC.Push src Secret))
val va_code_Push_Secret : src:va_operand_reg_opr64 -> Tot va_code let va_code_Push_Secret src =
false
null
false
(Ins (BC.Push src Secret))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Push_Secret : src:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_Push_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 28, "end_line": 152, "start_col": 2, "start_line": 152 }
Prims.Tot
val va_codegen_success_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Pop_Secret dst = (va_ttrue ())
val va_codegen_success_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_pbool let va_codegen_success_Pop_Secret dst =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Pop_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 124, "start_col": 2, "start_line": 124 }
Prims.Tot
val va_codegen_success_Push : src:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Push src = (va_ttrue ())
val va_codegen_success_Push : src:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_Push src =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Push : src:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Push
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 92, "start_col": 2, "start_line": 92 }
Prims.Tot
val va_code_Push : src:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Push src = (Ins (BC.Push src Public))
val va_code_Push : src:va_operand_reg_opr64 -> Tot va_code let va_code_Push src =
false
null
false
(Ins (BC.Push src Public))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Push : src:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_Push
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 28, "end_line": 88, "start_col": 2, "start_line": 88 }
Prims.Tot
val va_codegen_success_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
val va_codegen_success_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_PopXmm dst tmp =
false
null
false
(va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsStack.va_codegen_success_Pop", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_codegen_success_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_PopXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 90, "end_line": 279, "start_col": 2, "start_line": 276 }
Prims.Tot
val va_codegen_success_Stack_lemma : va_dummy:unit -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Stack_lemma () = (va_ttrue ())
val va_codegen_success_Stack_lemma : va_dummy:unit -> Tot va_pbool let va_codegen_success_Stack_lemma () =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Stack_lemma : va_dummy:unit -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Stack_lemma
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 31, "start_col": 2, "start_line": 31 }
Prims.Tot
val va_code_Pop : dst:va_operand_dst_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Pop dst = (Ins (BC.Pop dst Public))
val va_code_Pop : dst:va_operand_dst_opr64 -> Tot va_code let va_code_Pop dst =
false
null
false
(Ins (BC.Pop dst Public))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Pop : dst:va_operand_dst_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_Pop
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 27, "end_line": 56, "start_col": 2, "start_line": 56 }
Prims.Tot
val va_codegen_success_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_PopXmm_Secret dst tmp = (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
val va_codegen_success_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_PopXmm_Secret dst tmp =
false
null
false
(va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsStack.va_codegen_success_Pop_Secret", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_codegen_success_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret [@ "opaque_to_smt"] let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_PopXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 11, "end_line": 382, "start_col": 2, "start_line": 378 }
Prims.Tot
val va_code_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ()))))))
val va_code_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code let va_code_PushXmm_Secret src tmp =
false
null
false
(va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ()))))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_code_Push_Secret", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_PushXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 60, "end_line": 323, "start_col": 2, "start_line": 321 }
Prims.Tot
val va_code_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret))
val va_code_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_code let va_code_Pop_Secret dst =
false
null
false
(Ins (BC.Pop dst Secret))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_Pop_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 27, "end_line": 120, "start_col": 2, "start_line": 120 }
Prims.Tot
val va_codegen_success_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ())))))
val va_codegen_success_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_PushXmm src tmp =
false
null
false
(va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ())))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_codegen_success_Push", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_PushXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 21, "end_line": 228, "start_col": 2, "start_line": 225 }
Prims.Tot
val va_codegen_success_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_Load64_stack dst src offset = (va_ttrue ())
val va_codegen_success_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_pbool let va_codegen_success_Load64_stack dst src offset =
false
null
false
(va_ttrue ())
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_Load64_stack
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_reg_opr64 -> offset: Prims.int -> Vale.X64.Decls.va_pbool
{ "end_col": 15, "end_line": 189, "start_col": 2, "start_line": 189 }
Prims.Tot
val va_code_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ()))))))
val va_code_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code let va_code_PushXmm src tmp =
false
null
false
(va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ()))))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_code_Push", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_PushXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 50, "end_line": 221, "start_col": 2, "start_line": 219 }
Prims.Tot
val va_code_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
val va_code_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code let va_code_PopXmm dst tmp =
false
null
false
(va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))) )
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsStack.va_code_Pop", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_code_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_PopXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 59, "end_line": 272, "start_col": 2, "start_line": 269 }
Prims.Tot
val va_codegen_success_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ())))))
val va_codegen_success_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool let va_codegen_success_PushXmm_Secret src tmp =
false
null
false
(va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ())))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_codegen_success_Push_Secret", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
[]
Vale.X64.InsStack.va_codegen_success_PushXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
{ "end_col": 26, "end_line": 330, "start_col": 2, "start_line": 327 }
Prims.Tot
val va_code_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
val va_code_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code let va_code_PopXmm_Secret dst tmp =
false
null
false
(va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))) )
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsStack.va_code_Pop_Secret", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_code_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
[]
Vale.X64.InsStack.va_code_PopXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
{ "end_col": 59, "end_line": 374, "start_col": 2, "start_line": 371 }
Prims.Tot
val va_code_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public)))))
val va_code_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_code let va_code_Load64_stack dst src offset =
false
null
false
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public)))))
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.Taint_Semantics.mk_ins", "Vale.X64.InsLemmas.make_instr_annotate", "Prims.Cons", "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_Semantics_s.AnnotateMov64", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.Machine_s.OStack", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_s.MReg", "Vale.X64.Decls.get_reg", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"]
false
true
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_code
[]
Vale.X64.InsStack.va_code_Load64_stack
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_reg_opr64 -> offset: Prims.int -> Vale.X64.Decls.va_code
{ "end_col": 23, "end_line": 185, "start_col": 2, "start_line": 184 }
Prims.Ghost
val va_lemma_Stack_lemma : va_b0:va_code -> va_s0:va_state -> base:operand64 -> offset:int -> t:taint -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Stack_lemma ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_state_eq va_sM (va_update_ok va_sM va_s0)))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
val va_lemma_Stack_lemma : va_b0:va_code -> va_s0:va_state -> base:operand64 -> offset:int -> t:taint -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Stack_lemma ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_state_eq va_sM (va_update_ok va_sM va_s0))) let va_lemma_Stack_lemma va_b0 va_s0 base offset t =
false
null
false
va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_sM, va_fM = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Machine_s.operand64", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Stack_lemma" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Stack_lemma : va_b0:va_code -> va_s0:va_state -> base:operand64 -> offset:int -> t:taint -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Stack_lemma ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_state_eq va_sM (va_update_ok va_sM va_s0)))
[]
Vale.X64.InsStack.va_lemma_Stack_lemma
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> base: Vale.X64.Machine_s.operand64 -> offset: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 39, "start_col": 2, "start_line": 35 }
Prims.Ghost
val va_wpProof_Stack_lemma : base:operand64 -> offset:int -> t:taint -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Stack_lemma base offset t va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Stack_lemma ()) ([]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Stack_lemma : base:operand64 -> offset:int -> t:taint -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Stack_lemma base offset t va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Stack_lemma ()) ([]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Stack_lemma base offset t va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Machine_s.operand64", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Nil", "Vale.X64.QuickCode.mod_t", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Stack_lemma", "Vale.X64.InsStack.va_code_Stack_lemma" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Stack_lemma : base:operand64 -> offset:int -> t:taint -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Stack_lemma base offset t va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Stack_lemma ()) ([]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Stack_lemma
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
base: Vale.X64.Machine_s.operand64 -> offset: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 49, "start_col": 53, "start_line": 43 }
Prims.Ghost
val va_wpProof_Push_Secret : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push_Secret src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push_Secret src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Push_Secret : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push_Secret src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push_Secret src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Push_Secret src va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Push_Secret", "Vale.X64.InsStack.va_code_Push_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Push_Secret : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push_Secret src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push_Secret src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Push_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 177, "start_col": 43, "start_line": 170 }
Prims.Ghost
val va_wpProof_Pop_Secret : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop_Secret dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop_Secret dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Pop_Secret : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop_Secret dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop_Secret dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Pop_Secret dst va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Pop_Secret", "Vale.X64.InsStack.va_code_Pop_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Pop_Secret : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop_Secret dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop_Secret dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Pop_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 145, "start_col": 42, "start_line": 138 }
Prims.Ghost
val va_wpProof_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm_Secret dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm_Secret dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_PopXmm_Secret dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm_Secret (va_code_PopXmm_Secret dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm_Secret dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm_Secret dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_PopXmm_Secret dst tmp expected_xmm va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_PopXmm_Secret (va_code_PopXmm_Secret dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0))))) ); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_update_operand_xmm", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PopXmm_Secret", "Vale.X64.InsStack.va_code_PopXmm_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret [@ "opaque_to_smt"] let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm_Secret dst tmp = (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm_Secret va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm_Secret) (va_code_PopXmm_Secret dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop_Secret (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop_Secret (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm_Secret dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm_Secret dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_PopXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> expected_xmm: Vale.X64.Decls.quad32 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 420, "start_col": 62, "start_line": 411 }
Prims.Ghost
val va_wpProof_Push : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Push : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Push src va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Push", "Vale.X64.InsStack.va_code_Push" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Push : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Push
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 113, "start_col": 36, "start_line": 106 }
Prims.Ghost
val va_lemma_Push_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push_Secret src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Secret (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
val va_lemma_Push_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push_Secret src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Secret (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0)))))) let va_lemma_Push_Secret va_b0 va_s0 src =
false
null
false
va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_Sems.equiv_store_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Decls.va_eval_reg_opr64", "Vale.X64.Decls.va_get_stack", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Push_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Push_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push_Secret src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Secret (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
[]
Vale.X64.InsStack.va_lemma_Push_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 166, "start_col": 2, "start_line": 160 }
Prims.Ghost
val va_wpProof_Pop : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Pop : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Pop dst va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Pop", "Vale.X64.InsStack.va_code_Pop" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Pop : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Pop
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 81, "start_col": 35, "start_line": 74 }
Prims.Ghost
val va_wpProof_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Load64_stack dst src offset va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load64_stack dst src offset) ([va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Load64_stack dst src offset va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load64_stack dst src offset) ([va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_Load64_stack dst src offset va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Load64_stack", "Vale.X64.InsStack.va_code_Load64_stack" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Load64_stack dst src offset va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load64_stack dst src offset) ([va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_Load64_stack
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_reg_opr64 -> offset: Prims.int -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 212, "start_col": 55, "start_line": 205 }
Prims.Ghost
val va_wpProof_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm_Secret src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm_Secret src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm_Secret src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm_Secret src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_PushXmm_Secret src tmp va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PushXmm_Secret", "Vale.X64.InsStack.va_code_PushXmm_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm_Secret src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm_Secret src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_PushXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 364, "start_col": 50, "start_line": 356 }
Prims.Ghost
val va_lemma_Push : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Public (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
val va_lemma_Push : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Public (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0)))))) let va_lemma_Push va_b0 va_s0 src =
false
null
false
va_reveal_opaque (`%va_code_Push) (va_code_Push src); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_Sems.equiv_store_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Decls.va_eval_reg_opr64", "Vale.X64.Decls.va_get_stack", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Push" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Push : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Public (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
[]
Vale.X64.InsStack.va_lemma_Push
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 102, "start_col": 2, "start_line": 96 }
Prims.Ghost
val va_wpProof_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_PushXmm src tmp va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PushXmm", "Vale.X64.InsStack.va_code_PushXmm" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_PushXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 262, "start_col": 43, "start_line": 254 }
Prims.Ghost
val va_wpProof_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0))))) ); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_update_operand_xmm", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PopXmm", "Vale.X64.InsStack.va_code_PopXmm" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.X64.InsStack.va_wpProof_PopXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> expected_xmm: Vale.X64.Decls.quad32 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
{ "end_col": 22, "end_line": 314, "start_col": 55, "start_line": 306 }
Prims.Ghost
val va_lemma_PushXmm_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm_Secret src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Secret (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Secret (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
val va_lemma_PushXmm_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm_Secret src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Secret (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Secret (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0))))))) let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp =
false
null
false
va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsStack.va_lemma_Push_Secret", "Vale.X64.Decls.va_hd", "Vale.X64.InsVector.va_lemma_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PushXmm_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_PushXmm_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm_Secret src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Secret (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Secret (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
[]
Vale.X64.InsStack.va_lemma_PushXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 352, "start_col": 2, "start_line": 334 }
Prims.Ghost
val va_lemma_PopXmm : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Public (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
val va_lemma_PopXmm : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Public (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0))))))) let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm =
false
null
false
va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.unit", "Vale.Arch.Types.push_pop_xmm", "Vale.X64.Decls.va_eval_xmm", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsVector.va_lemma_Pinsrq", "Vale.X64.Decls.va_hd", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.InsStack.va_lemma_Pop", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PopXmm" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_PopXmm : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Public (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))))
[]
Vale.X64.InsStack.va_lemma_PopXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> expected_xmm: Vale.X64.Decls.quad32 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 302, "start_col": 2, "start_line": 283 }
Prims.Ghost
val va_lemma_PushXmm : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Public (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Public (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
val va_lemma_PushXmm : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Public (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Public (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0))))))) let va_lemma_PushXmm va_b0 va_s0 src tmp =
false
null
false
va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsStack.va_lemma_Push", "Vale.X64.Decls.va_hd", "Vale.X64.InsVector.va_lemma_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PushXmm" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_PushXmm : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Public (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Public (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
[]
Vale.X64.InsStack.va_lemma_PushXmm
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 250, "start_col": 2, "start_line": 232 }
Prims.Ghost
val va_lemma_PopXmm_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm_Secret dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Secret (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_PopXmm_Secret va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm_Secret) (va_code_PopXmm_Secret dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop_Secret (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop_Secret (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
val va_lemma_PopXmm_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm_Secret dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Secret (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0))))))) let va_lemma_PopXmm_Secret va_b0 va_s0 dst tmp expected_xmm =
false
null
false
va_reveal_opaque (`%va_code_PopXmm_Secret) (va_code_PopXmm_Secret dst tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pop_Secret (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pop_Secret (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.unit", "Vale.Arch.Types.push_pop_xmm", "Vale.X64.Decls.va_eval_xmm", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsVector.va_lemma_Pinsrq", "Vale.X64.Decls.va_hd", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.InsStack.va_lemma_Pop_Secret", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PopXmm_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret [@ "opaque_to_smt"] let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm_Secret dst tmp = (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_PopXmm_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PopXmm_Secret dst tmp) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0 + 8) Secret (va_get_stackTaint va_s0) /\ Vale.Arch.Types.hi64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.Arch.Types.lo64 expected_xmm == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 16 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == expected_xmm /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 16 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 16) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))))
[]
Vale.X64.InsStack.va_lemma_PopXmm_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> expected_xmm: Vale.X64.Decls.quad32 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 407, "start_col": 2, "start_line": 386 }
Prims.Ghost
val va_lemma_Pop_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop_Secret dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
val va_lemma_Pop_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop_Secret dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)))))) let va_lemma_Pop_Secret va_b0 va_s0 dst =
false
null
false
va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_i.lemma_valid_taint_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_get_stackTaint", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Pop_Secret" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Pop_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop_Secret dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
[]
Vale.X64.InsStack.va_lemma_Pop_Secret
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_dst_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 134, "start_col": 2, "start_line": 128 }
Prims.Ghost
val va_lemma_Pop : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
val va_lemma_Pop : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)))))) let va_lemma_Pop va_b0 va_s0 dst =
false
null
false
va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_i.lemma_valid_taint_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_get_stackTaint", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Pop" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Pop : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
[]
Vale.X64.InsStack.va_lemma_Pop
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_dst_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 70, "start_col": 2, "start_line": 64 }
Prims.Ghost
val va_lemma_Load64_stack : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Load64_stack dst src offset) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_eval_reg_opr64 va_s0 src + offset) Public (va_get_stackTaint va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_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.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "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": "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 } ]
false
let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
val va_lemma_Load64_stack : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Load64_stack dst src offset) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_eval_reg_opr64 va_s0 src + offset) Public (va_get_stackTaint va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)))) let va_lemma_Load64_stack va_b0 va_s0 dst src offset =
false
null
false
va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let va_old_s:va_state = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let va_sM, va_fM = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "Vale.X64.InsStack.fst.checked", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_i.lemma_valid_taint_stack64", "Prims.op_Addition", "Vale.X64.Decls.va_eval_reg_opr64", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_get_stackTaint", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Taint_Semantics.mk_ins", "Vale.X64.InsLemmas.make_instr_annotate", "Prims.Cons", "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_Semantics_s.AnnotateMov64", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.Machine_s.OStack", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_s.MReg", "Vale.X64.Decls.get_reg", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Load64_stack" ]
[]
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"]
false
false
Vale.X64.InsStack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_Load64_stack : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Load64_stack dst src offset) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_eval_reg_opr64 va_s0 src + offset) Public (va_get_stackTaint va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_eval_reg_opr64 va_s0 src + offset) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))
[]
Vale.X64.InsStack.va_lemma_Load64_stack
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_reg_opr64 -> offset: Prims.int -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 201, "start_col": 2, "start_line": 193 }
Prims.Tot
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var)
let vprop_equiv_refl_type =
false
null
false
let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var)
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "total" ]
[ "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Reflection.Util.stt_vprop_equiv", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.tm_vprop", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **)
false
true
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val vprop_equiv_refl_type : FStar.Reflection.Types.term
[]
Pulse.Soundness.VPropEquiv.vprop_equiv_refl_type
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
FStar.Reflection.Types.term
{ "end_col": 52, "end_line": 23, "start_col": 27, "start_line": 18 }
Prims.Tot
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid))
let vprop_tm =
false
null
false
R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid))
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_FVar", "FStar.Reflection.V2.Builtins.pack_fv", "Pulse.Reflection.Util.vprop_lid" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit()
false
true
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val vprop_tm : FStar.Reflection.Types.term
[]
Pulse.Soundness.VPropEquiv.vprop_tm
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
FStar.Reflection.Types.term
{ "end_col": 59, "end_line": 108, "start_col": 15, "start_line": 108 }
Prims.GTot
val vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1)))
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1))) = let (| pf, s |) = vprop_equiv_soundness d0 eq in let d1 = fst (vprop_equiv_typing eq) d0 in let s_prop = stt_vprop_equiv_is_prop (tot_typing_soundness d0) (tot_typing_soundness d1) in RT.T_PropIrrelevance _ _ _ _ _ s s_prop
val vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1))) let vprop_equiv_unit_soundness (#g: stt_env) (#v0 #v1: term) (d0: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1))) =
false
null
false
let (| pf , s |) = vprop_equiv_soundness d0 eq in let d1 = fst (vprop_equiv_typing eq) d0 in let s_prop = stt_vprop_equiv_is_prop (tot_typing_soundness d0) (tot_typing_soundness d1) in RT.T_PropIrrelevance _ _ _ _ _ s s_prop
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "sometrivial" ]
[ "Pulse.Soundness.Common.stt_env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.vprop_equiv", "FStar.Reflection.Types.term", "FStar.Reflection.Typing.tot_typing", "Pulse.Typing.elab_env", "Pulse.Reflection.Util.stt_vprop_equiv", "Pulse.Elaborate.Pure.elab_term", "FStar.Reflection.Typing.T_PropIrrelevance", "FStar.Stubs.TypeChecker.Core.E_Total", "FStar.Reflection.Typing.tm_prop", "Pulse.Soundness.VPropEquiv.stt_vprop_equiv_is_prop", "Pulse.Soundness.Common.tot_typing_soundness", "FStar.Pervasives.Native.fst", "Pulse.Typing.Combinators.vprop_equiv_typing", "Prims.dtuple2", "Pulse.Soundness.VPropEquiv.vprop_equiv_soundness" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid)) let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) ) let inst_vprop_equiv_ext_aux #g #v0 #v1 (token:T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) = let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token)) let inst_vprop_equiv_ext #g #v0 #v1 (d0:RT.tot_typing g v0 vprop_tm) (d1:RT.tot_typing g v1 vprop_tm) (token:T.equiv_token g v0 v1) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) = let (| pf, typing |) : (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v0)) = inst_vprop_equiv_refl d0 in let d_st_equiv : RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = inst_vprop_equiv_ext_aux token in let sub_typing : RT.sub_typing g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = RT.Rel_equiv _ _ _ _ d_st_equiv in let pf_typing : RT.tot_typing g pf (stt_vprop_equiv v0 v1) = RT.T_Sub _ _ _ _ typing (RT.Relc_typ _ _ _ _ _ sub_typing) in (| pf, pf_typing |) #push-options "--z3rlimit_factor 4" let rec vprop_equiv_soundness (#g:stt_env) (#v0 #v1:term) (d:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (pf:R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq) = match eq with | VE_Refl _ _ -> let d = tot_typing_soundness d in inst_vprop_equiv_refl d | VE_Sym g _v1 _v0 eq' -> let fwd, _ = vprop_equiv_typing eq in let d' = fwd d in let (| pf, dd |) = vprop_equiv_soundness d' eq' in inst_vprop_equiv_sym (tot_typing_soundness d') (tot_typing_soundness d) dd | VE_Trans _ _ v _ eq_0v eq_v1 -> let dv = fst (vprop_equiv_typing eq_0v) d in let d1 = fst (vprop_equiv_typing eq_v1) dv in let (| pf_0v, eq_0v |) = vprop_equiv_soundness d eq_0v in let (| pf_v1, eq_v1 |) = vprop_equiv_soundness dv eq_v1 in inst_vprop_equiv_trans (tot_typing_soundness d) (tot_typing_soundness dv) (tot_typing_soundness d1) eq_0v eq_v1 | VE_Ctxt _ t0 t1 t0' t1' eq0 eq1 -> let t0_typing, t1_typing = star_typing_inversion d in let t0'_typing = fst (vprop_equiv_typing eq0) t0_typing in let t1'_typing = fst (vprop_equiv_typing eq1) t1_typing in let (| pf0, dd0 |) = vprop_equiv_soundness t0_typing eq0 in let (| pf1, dd1 |) = vprop_equiv_soundness t1_typing eq1 in inst_vprop_equiv_cong (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t0'_typing) (tot_typing_soundness t1'_typing) dd0 dd1 | VE_Unit _ _v1 -> let v1_typing = fst (vprop_equiv_typing eq) d in inst_vprop_equiv_unit (tot_typing_soundness v1_typing) | VE_Comm _ t0 t1 -> let t0_typing, t1_typing = star_typing_inversion #_ #t0 #t1 d in inst_vprop_equiv_comm (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) | VE_Assoc _ t0 t1 t2 -> let t0_typing, t12_typing = star_typing_inversion #_ #t0 #(tm_star t1 t2) d in let t1_typing, t2_typing = star_typing_inversion #_ #t1 #t2 t12_typing in inst_vprop_equiv_assoc (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t2_typing) | VE_Ext _ t0 t1 token -> let t0_typing, t1_typing = vprop_eq_typing_inversion _ t0 t1 token in inst_vprop_equiv_ext (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) token #pop-options let stt_vprop_equiv_is_prop (#g:R.env) (#v0 #v1:R.term) (d0: RT.tot_typing g v0 (elab_term tm_vprop)) (d1: RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (RT.tot_typing g (stt_vprop_equiv v0 v1) RT.tm_prop) = admit() let vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1)
false
false
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1)))
[]
Pulse.Soundness.VPropEquiv.vprop_equiv_unit_soundness
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d0: Pulse.Typing.tot_typing g v0 Pulse.Syntax.Base.tm_vprop -> eq: Pulse.Typing.vprop_equiv g v0 v1 -> Prims.GTot (FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g) (`()) (Pulse.Reflection.Util.stt_vprop_equiv (Pulse.Elaborate.Pure.elab_term v0) (Pulse.Elaborate.Pure.elab_term v1)))
{ "end_col": 43, "end_line": 253, "start_col": 3, "start_line": 250 }
Prims.Tot
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0)
let vprop_equiv_sym_type =
false
null
false
let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0)
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "total" ]
[ "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.close_term", "Pulse.Reflection.Util.stt_vprop_equiv", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.tm_vprop", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit()
false
true
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val vprop_equiv_sym_type : FStar.Reflection.Types.term
[]
Pulse.Soundness.VPropEquiv.vprop_equiv_sym_type
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
FStar.Reflection.Types.term
{ "end_col": 13, "end_line": 46, "start_col": 26, "start_line": 31 }
Prims.Tot
val vprop_equiv_ext_type:R.term
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) )
val vprop_equiv_ext_type:R.term let vprop_equiv_ext_type:R.term =
false
null
false
let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv ({ ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun }))) in mk_arrow (vprop_tm, Q_Explicit) (mk_arrow (vprop_tm, Q_Explicit) (mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) (stt_vprop_equiv (mk_bv 2) (mk_bv 1))) )
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "total" ]
[ "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.aqualv", "Pulse.Soundness.VPropEquiv.vprop_tm", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.vprop_eq_tm", "Pulse.Reflection.Util.stt_vprop_equiv", "Prims.nat", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_BVar", "FStar.Reflection.V2.Builtins.pack_bv", "FStar.Reflection.V2.Data.Mkbv_view", "FStar.Sealed.seal", "FStar.Reflection.Types.typ", "Pulse.Reflection.Util.tun", "FStar.Reflection.Typing.pp_name_default", "FStar.Reflection.V2.Data.Tv_FVar", "FStar.Reflection.V2.Builtins.pack_fv", "Pulse.Reflection.Util.vprop_lid" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid))
false
true
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val vprop_equiv_ext_type:R.term
[]
Pulse.Soundness.VPropEquiv.vprop_equiv_ext_type
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
FStar.Reflection.Types.term
{ "end_col": 5, "end_line": 131, "start_col": 15, "start_line": 111 }
Prims.GTot
val inst_vprop_equiv_ext (#g #v0 #v1: _) (d0: RT.tot_typing g v0 vprop_tm) (d1: RT.tot_typing g v1 vprop_tm) (token: T.equiv_token g v0 v1) : GTot (pf: R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1))
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let inst_vprop_equiv_ext #g #v0 #v1 (d0:RT.tot_typing g v0 vprop_tm) (d1:RT.tot_typing g v1 vprop_tm) (token:T.equiv_token g v0 v1) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) = let (| pf, typing |) : (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v0)) = inst_vprop_equiv_refl d0 in let d_st_equiv : RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = inst_vprop_equiv_ext_aux token in let sub_typing : RT.sub_typing g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = RT.Rel_equiv _ _ _ _ d_st_equiv in let pf_typing : RT.tot_typing g pf (stt_vprop_equiv v0 v1) = RT.T_Sub _ _ _ _ typing (RT.Relc_typ _ _ _ _ _ sub_typing) in (| pf, pf_typing |)
val inst_vprop_equiv_ext (#g #v0 #v1: _) (d0: RT.tot_typing g v0 vprop_tm) (d1: RT.tot_typing g v1 vprop_tm) (token: T.equiv_token g v0 v1) : GTot (pf: R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) let inst_vprop_equiv_ext #g #v0 #v1 (d0: RT.tot_typing g v0 vprop_tm) (d1: RT.tot_typing g v1 vprop_tm) (token: T.equiv_token g v0 v1) : GTot (pf: R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) =
false
null
false
let (| pf , typing |):(pf: R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v0)) = inst_vprop_equiv_refl d0 in let d_st_equiv:RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = inst_vprop_equiv_ext_aux token in let sub_typing:RT.sub_typing g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = RT.Rel_equiv _ _ _ _ d_st_equiv in let pf_typing:RT.tot_typing g pf (stt_vprop_equiv v0 v1) = RT.T_Sub _ _ _ _ typing (RT.Relc_typ _ _ _ _ _ sub_typing) in (| pf, pf_typing |)
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "sometrivial" ]
[ "FStar.Reflection.Types.env", "FStar.Reflection.Types.term", "FStar.Reflection.Typing.tot_typing", "Pulse.Soundness.VPropEquiv.vprop_tm", "FStar.Tactics.Types.equiv_token", "Pulse.Reflection.Util.stt_vprop_equiv", "Prims.Mkdtuple2", "FStar.Reflection.Typing.T_Sub", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Reflection.Types.typ", "FStar.Stubs.TypeChecker.Core.E_Total", "FStar.Reflection.Typing.Relc_typ", "FStar.Reflection.Typing.R_Sub", "FStar.Reflection.Typing.sub_typing", "FStar.Reflection.Typing.Rel_equiv", "FStar.Reflection.Typing.equiv", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_ext_aux", "Prims.dtuple2", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_refl" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid)) let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) ) let inst_vprop_equiv_ext_aux #g #v0 #v1 (token:T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) = let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token)) let inst_vprop_equiv_ext #g #v0 #v1 (d0:RT.tot_typing g v0 vprop_tm) (d1:RT.tot_typing g v1 vprop_tm) (token:T.equiv_token g v0 v1)
false
false
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val inst_vprop_equiv_ext (#g #v0 #v1: _) (d0: RT.tot_typing g v0 vprop_tm) (d1: RT.tot_typing g v1 vprop_tm) (token: T.equiv_token g v0 v1) : GTot (pf: R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1))
[]
Pulse.Soundness.VPropEquiv.inst_vprop_equiv_ext
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d0: FStar.Reflection.Typing.tot_typing g v0 Pulse.Soundness.VPropEquiv.vprop_tm -> d1: FStar.Reflection.Typing.tot_typing g v1 Pulse.Soundness.VPropEquiv.vprop_tm -> token: FStar.Tactics.Types.equiv_token g v0 v1 -> Prims.GTot (Prims.dtuple2 FStar.Reflection.Types.term (fun pf -> FStar.Reflection.Typing.tot_typing g pf (Pulse.Reflection.Util.stt_vprop_equiv v0 v1)))
{ "end_col": 21, "end_line": 169, "start_col": 55, "start_line": 149 }
Prims.GTot
val inst_vprop_equiv_ext_aux (#g #v0 #v1: _) (token: T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1))
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let inst_vprop_equiv_ext_aux #g #v0 #v1 (token:T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) = let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token))
val inst_vprop_equiv_ext_aux (#g #v0 #v1: _) (token: T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) let inst_vprop_equiv_ext_aux #g #v0 #v1 (token: T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) =
false
null
false
let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token))
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "sometrivial" ]
[ "FStar.Reflection.Types.env", "FStar.Reflection.Types.typ", "FStar.Tactics.Types.equiv_token", "FStar.Reflection.Typing.Rel_ctxt", "FStar.Reflection.Typing.Rel_eq_token", "FStar.Squash.return_squash", "FStar.Reflection.Typing.term_ctxt", "FStar.Reflection.Typing.Ctxt_app_arg", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_App", "Pulse.Reflection.Util.stt_vprop_equiv_tm", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.Ctxt_hole", "FStar.Reflection.Typing.equiv", "Pulse.Reflection.Util.stt_vprop_equiv" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid)) let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) ) let inst_vprop_equiv_ext_aux #g #v0 #v1
false
false
Pulse.Soundness.VPropEquiv.fst
{ "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" }
null
val inst_vprop_equiv_ext_aux (#g #v0 #v1: _) (token: T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1))
[]
Pulse.Soundness.VPropEquiv.inst_vprop_equiv_ext_aux
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
token: FStar.Tactics.Types.equiv_token g v0 v1 -> Prims.GTot (FStar.Reflection.Typing.equiv g (Pulse.Reflection.Util.stt_vprop_equiv v0 v0) (Pulse.Reflection.Util.stt_vprop_equiv v0 v1))
{ "end_col": 77, "end_line": 142, "start_col": 71, "start_line": 135 }
Prims.GTot
val vprop_equiv_soundness (#g: stt_env) (#v0 #v1: term) (d: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (pf: R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq)
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "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 } ]
false
let rec vprop_equiv_soundness (#g:stt_env) (#v0 #v1:term) (d:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (pf:R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq) = match eq with | VE_Refl _ _ -> let d = tot_typing_soundness d in inst_vprop_equiv_refl d | VE_Sym g _v1 _v0 eq' -> let fwd, _ = vprop_equiv_typing eq in let d' = fwd d in let (| pf, dd |) = vprop_equiv_soundness d' eq' in inst_vprop_equiv_sym (tot_typing_soundness d') (tot_typing_soundness d) dd | VE_Trans _ _ v _ eq_0v eq_v1 -> let dv = fst (vprop_equiv_typing eq_0v) d in let d1 = fst (vprop_equiv_typing eq_v1) dv in let (| pf_0v, eq_0v |) = vprop_equiv_soundness d eq_0v in let (| pf_v1, eq_v1 |) = vprop_equiv_soundness dv eq_v1 in inst_vprop_equiv_trans (tot_typing_soundness d) (tot_typing_soundness dv) (tot_typing_soundness d1) eq_0v eq_v1 | VE_Ctxt _ t0 t1 t0' t1' eq0 eq1 -> let t0_typing, t1_typing = star_typing_inversion d in let t0'_typing = fst (vprop_equiv_typing eq0) t0_typing in let t1'_typing = fst (vprop_equiv_typing eq1) t1_typing in let (| pf0, dd0 |) = vprop_equiv_soundness t0_typing eq0 in let (| pf1, dd1 |) = vprop_equiv_soundness t1_typing eq1 in inst_vprop_equiv_cong (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t0'_typing) (tot_typing_soundness t1'_typing) dd0 dd1 | VE_Unit _ _v1 -> let v1_typing = fst (vprop_equiv_typing eq) d in inst_vprop_equiv_unit (tot_typing_soundness v1_typing) | VE_Comm _ t0 t1 -> let t0_typing, t1_typing = star_typing_inversion #_ #t0 #t1 d in inst_vprop_equiv_comm (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) | VE_Assoc _ t0 t1 t2 -> let t0_typing, t12_typing = star_typing_inversion #_ #t0 #(tm_star t1 t2) d in let t1_typing, t2_typing = star_typing_inversion #_ #t1 #t2 t12_typing in inst_vprop_equiv_assoc (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t2_typing) | VE_Ext _ t0 t1 token -> let t0_typing, t1_typing = vprop_eq_typing_inversion _ t0 t1 token in inst_vprop_equiv_ext (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) token
val vprop_equiv_soundness (#g: stt_env) (#v0 #v1: term) (d: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (pf: R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq) let rec vprop_equiv_soundness (#g: stt_env) (#v0 #v1: term) (d: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (pf: R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq) =
false
null
false
match eq with | VE_Refl _ _ -> let d = tot_typing_soundness d in inst_vprop_equiv_refl d | VE_Sym g _v1 _v0 eq' -> let fwd, _ = vprop_equiv_typing eq in let d' = fwd d in let (| pf , dd |) = vprop_equiv_soundness d' eq' in inst_vprop_equiv_sym (tot_typing_soundness d') (tot_typing_soundness d) dd | VE_Trans _ _ v _ eq_0v eq_v1 -> let dv = fst (vprop_equiv_typing eq_0v) d in let d1 = fst (vprop_equiv_typing eq_v1) dv in let (| pf_0v , eq_0v |) = vprop_equiv_soundness d eq_0v in let (| pf_v1 , eq_v1 |) = vprop_equiv_soundness dv eq_v1 in inst_vprop_equiv_trans (tot_typing_soundness d) (tot_typing_soundness dv) (tot_typing_soundness d1) eq_0v eq_v1 | VE_Ctxt _ t0 t1 t0' t1' eq0 eq1 -> let t0_typing, t1_typing = star_typing_inversion d in let t0'_typing = fst (vprop_equiv_typing eq0) t0_typing in let t1'_typing = fst (vprop_equiv_typing eq1) t1_typing in let (| pf0 , dd0 |) = vprop_equiv_soundness t0_typing eq0 in let (| pf1 , dd1 |) = vprop_equiv_soundness t1_typing eq1 in inst_vprop_equiv_cong (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t0'_typing) (tot_typing_soundness t1'_typing) dd0 dd1 | VE_Unit _ _v1 -> let v1_typing = fst (vprop_equiv_typing eq) d in inst_vprop_equiv_unit (tot_typing_soundness v1_typing) | VE_Comm _ t0 t1 -> let t0_typing, t1_typing = star_typing_inversion #_ #t0 #t1 d in inst_vprop_equiv_comm (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) | VE_Assoc _ t0 t1 t2 -> let t0_typing, t12_typing = star_typing_inversion #_ #t0 #(tm_star t1 t2) d in let t1_typing, t2_typing = star_typing_inversion #_ #t1 #t2 t12_typing in inst_vprop_equiv_assoc (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t2_typing) | VE_Ext _ t0 t1 token -> let t0_typing, t1_typing = vprop_eq_typing_inversion _ t0 t1 token in inst_vprop_equiv_ext (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) token
{ "checked_file": "Pulse.Soundness.VPropEquiv.fst.checked", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ "sometrivial", "" ]
[ "Pulse.Soundness.Common.stt_env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.vprop_equiv", "Pulse.Typing.Env.env", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_refl", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "FStar.Reflection.Typing.tot_typing", "Pulse.Soundness.Common.tot_typing_soundness", "FStar.Reflection.Types.term", "Pulse.Reflection.Util.stt_vprop_equiv", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_sym", "Prims.dtuple2", "Pulse.Soundness.VPropEquiv.vprop_equiv_soundness", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Combinators.vprop_equiv_typing", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_trans", "FStar.Pervasives.Native.fst", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_cong", "Pulse.Typing.star_typing_inversion", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_unit", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_comm", "Pulse.Syntax.Base.tm_star", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_assoc", "FStar.Tactics.Types.equiv_token", "Pulse.Soundness.VPropEquiv.inst_vprop_equiv_ext", "Pulse.Typing.vprop_eq_typing_inversion" ]
[]
module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid)) let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) ) let inst_vprop_equiv_ext_aux #g #v0 #v1 (token:T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) = let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token)) let inst_vprop_equiv_ext #g #v0 #v1 (d0:RT.tot_typing g v0 vprop_tm) (d1:RT.tot_typing g v1 vprop_tm) (token:T.equiv_token g v0 v1) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) = let (| pf, typing |) : (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v0)) = inst_vprop_equiv_refl d0 in let d_st_equiv : RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = inst_vprop_equiv_ext_aux token in let sub_typing : RT.sub_typing g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = RT.Rel_equiv _ _ _ _ d_st_equiv in let pf_typing : RT.tot_typing g pf (stt_vprop_equiv v0 v1) = RT.T_Sub _ _ _ _ typing (RT.Relc_typ _ _ _ _ _ sub_typing) in (| pf, pf_typing |) #push-options "--z3rlimit_factor 4" let rec vprop_equiv_soundness (#g:stt_env) (#v0 #v1:term) (d:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (pf:R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1)))
false
false
Pulse.Soundness.VPropEquiv.fst
{ "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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vprop_equiv_soundness (#g: stt_env) (#v0 #v1: term) (d: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (pf: R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq)
[ "recursion" ]
Pulse.Soundness.VPropEquiv.vprop_equiv_soundness
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.tot_typing g v0 Pulse.Syntax.Base.tm_vprop -> eq: Pulse.Typing.vprop_equiv g v0 v1 -> Prims.GTot (Prims.dtuple2 FStar.Reflection.Types.term (fun pf -> FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g) pf (Pulse.Reflection.Util.stt_vprop_equiv (Pulse.Elaborate.Pure.elab_term v0) (Pulse.Elaborate.Pure.elab_term v1))))
{ "end_col": 32, "end_line": 237, "start_col": 4, "start_line": 180 }
Prims.Tot
val mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; }
val mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) let mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) =
false
null
false
{ LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu }
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.Exponentiation.Definition.Mkcomm_monoid", "Lib.NatMod.nat_mod", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one_ll", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_assoc", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_comm", "Lib.Exponentiation.Definition.comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n)
[]
Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod n)
{ "end_col": 61, "end_line": 209, "start_col": 2, "start_line": 205 }
Prims.Tot
val mont_one: n:pos -> r:pos -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mont_one n r = 1 * r % n
val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r =
false
null
false
1 * r % n
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mont_one: n:pos -> r:pos -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mont_one
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.pos -> Lib.NatMod.nat_mod n
{ "end_col": 28, "end_line": 20, "start_col": 19, "start_line": 20 }
Prims.Tot
val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b
val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b =
false
null
false
M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Hacl.Spec.Montgomery.Lemmas.mont_mul", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> Lib.NatMod.nat_mod n
{ "end_col": 32, "end_line": 155, "start_col": 2, "start_line": 154 }
Prims.Tot
val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mont_mul n d a b = a * b * d % n
val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b =
false
null
false
(a * b) * d % n
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.int", "Lib.NatMod.nat_mod", "Prims.op_Modulus", "FStar.Mul.op_Star" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mont_mul
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> d: Prims.int -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> Lib.NatMod.nat_mod n
{ "end_col": 36, "end_line": 23, "start_col": 23, "start_line": 23 }
FStar.Pervasives.Lemma
val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c
val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
[]
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_assoc
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> c: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu (Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a b) c == Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a (Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu b c))
{ "end_col": 32, "end_line": 186, "start_col": 51, "start_line": 177 }
Prims.Tot
val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu
val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu =
false
null
false
M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Hacl.Spec.Montgomery.Lemmas.mont_one", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_one_lemma", "Lib.NatMod.nat_mod" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mont_one_ll
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> Lib.NatMod.nat_mod n
{ "end_col": 28, "end_line": 149, "start_col": 2, "start_line": 148 }
FStar.Pervasives.Lemma
val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a
val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Hacl.Spec.Montgomery.Lemmas.mont_one_lemma", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n ->
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a)
[]
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one_ll
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a (Hacl.Spec.Exponentiation.Lemmas.mont_one_ll pbits rLen n mu) == a)
{ "end_col": 24, "end_line": 169, "start_col": 41, "start_line": 160 }
Prims.Tot
val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mod_exp_mont_ll pbits rLen n mu a b = let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc
val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont_ll pbits rLen n mu a b =
false
null
false
let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.from_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.from_mont", "Lib.Exponentiation.Definition.pow", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Spec.Montgomery.Lemmas.to_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.to_mont" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_ll
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> Lib.NatMod.nat_mod n
{ "end_col": 5, "end_line": 256, "start_col": 41, "start_line": 250 }
FStar.Pervasives.Lemma
val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b
val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_comm", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
[]
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_comm
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a b == Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu b a)
{ "end_col": 29, "end_line": 200, "start_col": 48, "start_line": 193 }
Prims.Tot
val mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; }
val mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) let mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) =
false
null
false
{ LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d }
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Prims.int", "Prims.b2t", "Prims.op_Equality", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.Exponentiation.Definition.Mkcomm_monoid", "Lib.NatMod.nat_mod", "Hacl.Spec.Exponentiation.Lemmas.mont_one", "Hacl.Spec.Exponentiation.Lemmas.mont_mul", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_comm", "Lib.Exponentiation.Definition.comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = ()
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n)
[]
Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.nat -> d: Prims.int{r * d % n = 1} -> Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod n)
{ "end_col": 46, "end_line": 71, "start_col": 2, "start_line": 67 }
Prims.Tot
val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc
val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b =
false
null
false
let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "total" ]
[ "Prims.pos", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "Prims.nat", "Lib.Exponentiation.Definition.pow", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n
[]
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.pos -> d: Prims.int{r * d % n == 1} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> Lib.NatMod.nat_mod n
{ "end_col": 5, "end_line": 115, "start_col": 28, "start_line": 111 }
FStar.Pervasives.Lemma
val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mod_exp_mont_ll_lemma pbits rLen n mu a b = let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow k aM b in assert (accM == LE.pow k aM b /\ accM < n); Math.Lemmas.small_mod accM n; mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM
val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b) let mod_exp_mont_ll_lemma pbits rLen n mu a b =
false
null
true
let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow k aM b in assert (accM == LE.pow k aM b /\ accM < n); Math.Lemmas.small_mod accM n; mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_ll_mod_lemma", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims._assert", "Prims.l_and", "Prims.eq2", "Lib.Exponentiation.Definition.pow", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Montgomery.Lemmas.to_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.to_mont", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont_ll pbits rLen n mu a b = let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b)) let mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; assert (aM == a * r % n); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b; assert (accM % n == LE.pow k2 aM b); let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; assert (acc == accM * d % n); Math.Lemmas.lemma_mod_mul_distr_l accM d n; mod_exp_mont_lemma n r d a b val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b)
[]
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_ll_lemma
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_ll pbits rLen n mu a b == Lib.NatMod.pow_mod a b)
{ "end_col": 52, "end_line": 303, "start_col": 47, "start_line": 295 }
FStar.Pervasives.Lemma
val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; assert (aM == a * r % n); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b; assert (accM % n == LE.pow k2 aM b); let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; assert (acc == accM * d % n); Math.Lemmas.lemma_mod_mul_distr_l accM d n; mod_exp_mont_lemma n r d a b
val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b)) let mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; assert (aM == a * r % n); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b; assert (accM % n == LE.pow k2 aM b); let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; assert (acc == accM * d % n); Math.Lemmas.lemma_mod_mul_distr_l accM d n; mod_exp_mont_lemma n r d a b
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_lemma", "Prims.unit", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Hacl.Spec.Montgomery.Lemmas.from_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.from_mont", "Lib.Exponentiation.Definition.pow", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_is_pow_nat_mont", "Hacl.Spec.Montgomery.Lemmas.to_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.to_mont", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont_ll pbits rLen n mu a b = let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b))
[]
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_ll_mod_lemma
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> accM: Prims.nat -> FStar.Pervasives.Lemma (requires (let r = Prims.pow2 (pbits * rLen) in let k = Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == Lib.Exponentiation.Definition.pow k (a * r % n) b)) (ensures (let aM = Hacl.Spec.Montgomery.Lemmas.to_mont pbits rLen n mu a in let acc = Hacl.Spec.Montgomery.Lemmas.from_mont pbits rLen n mu accM in acc == Lib.NatMod.pow_mod a b))
{ "end_col": 30, "end_line": 288, "start_col": 56, "start_line": 269 }
FStar.Pervasives.Lemma
val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); }
val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c =
false
null
true
calc ( == ) { mont_mul n d (mont_mul n d a b) c; ( == ) { () } (((a * b) * d % n) * c) * d % n; ( == ) { Math.Lemmas.paren_mul_right ((a * b) * d % n) c d } ((a * b) * d % n) * (c * d) % n; ( == ) { M.lemma_mod_mul_distr3 1 ((a * b) * d) (c * d) n } ((a * b) * d) * (c * d) % n; ( == ) { Math.Lemmas.paren_mul_right ((a * b) * d) c d } (((a * b) * d) * c) * d % n; ( == ) { (Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c) } (a * ((b * d) * c)) * d % n; ( == ) { (Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d) } (a * ((b * c) * d)) * d % n; ( == ) { M.lemma_mod_mul_distr3 a ((b * c) * d) d n } mont_mul n d a (mont_mul n d b c); }
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "Lib.NatMod.nat_mod", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.Exponentiation.Lemmas.mont_mul", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Modulus", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.paren_mul_right", "Hacl.Spec.Montgomery.Lemmas.lemma_mod_mul_distr3" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c))
[]
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> d: Prims.int -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> c: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul n d (Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a b) c == Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a (Hacl.Spec.Exponentiation.Lemmas.mont_mul n d b c))
{ "end_col": 5, "end_line": 59, "start_col": 2, "start_line": 43 }
FStar.Pervasives.Lemma
val pow_nat_mont_ll_mod_base: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in LE.pow k a b == LE.pow k (a % n) b))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let pow_nat_mont_ll_mod_base pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_comm_monoid n r d in let k2 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in calc (==) { LE.pow k2 a b; (==) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b } LE.pow k1 a b; (==) { pow_nat_mont_is_pow n r d a b } pow (a * d % n) b * r % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l a d n } pow (a % n * d % n) b * r % n; (==) { pow_nat_mont_is_pow n r d (a % n) b } LE.pow k1 (a % n) b; (==) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu (a % n) b } LE.pow k2 (a % n) b; }
val pow_nat_mont_ll_mod_base: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in LE.pow k a b == LE.pow k (a % n) b)) let pow_nat_mont_ll_mod_base pbits rLen n mu a b =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_comm_monoid n r d in let k2 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in calc ( == ) { LE.pow k2 a b; ( == ) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b } LE.pow k1 a b; ( == ) { pow_nat_mont_is_pow n r d a b } pow (a * d % n) b * r % n; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l a d n } pow ((a % n) * d % n) b * r % n; ( == ) { pow_nat_mont_is_pow n r d (a % n) b } LE.pow k1 (a % n) b; ( == ) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu (a % n) b } LE.pow k2 (a % n) b; }
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Lib.NatMod.nat_mod", "Prims.int", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Exponentiation.Definition.pow", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Mul.op_Star", "Lib.NatMod.pow", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_is_pow_nat_mont", "Prims.squash", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_is_pow", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont_ll pbits rLen n mu a b = let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b)) let mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; assert (aM == a * r % n); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b; assert (accM % n == LE.pow k2 aM b); let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; assert (acc == accM * d % n); Math.Lemmas.lemma_mod_mul_distr_l accM d n; mod_exp_mont_lemma n r d a b val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b) let mod_exp_mont_ll_lemma pbits rLen n mu a b = let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow k aM b in assert (accM == LE.pow k aM b /\ accM < n); Math.Lemmas.small_mod accM n; mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM val from_mont_exp_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> aM:nat -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = LE.pow k aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in a < n /\ c == pow_mod #n a b)) let from_mont_exp_lemma pbits rLen n mu aM b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let cM = LE.pow k1 aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in M.from_mont_lemma pbits rLen n mu cM; M.from_mont_lemma pbits rLen n mu aM; //assert (c == cM * d % n); calc (==) { cM * d % n; (==) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b } LE.pow k2 aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } pow (aM * d % n) b * r % n * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow a b % n; (==) { Lib.NatMod.lemma_pow_mod #n a b } pow_mod #n a b; }; assert (a < n /\ c == pow_mod #n a b) val pow_nat_mont_ll_mod_base: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in LE.pow k a b == LE.pow k (a % n) b))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val pow_nat_mont_ll_mod_base: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in LE.pow k a b == LE.pow k (a % n) b))
[]
Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> FStar.Pervasives.Lemma (requires Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu) (ensures (let k = Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid pbits rLen n mu in Lib.Exponentiation.Definition.pow k a b == Lib.Exponentiation.Definition.pow k (a % n) b))
{ "end_col": 5, "end_line": 377, "start_col": 50, "start_line": 357 }
FStar.Pervasives.Lemma
val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; }
val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a =
false
null
true
calc ( == ) { (a * (1 * r % n)) * d % n; ( == ) { M.lemma_mod_mul_distr3 a r d n } (a * r) * d % n; ( == ) { (Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n) } a * (r * d % n) % n; ( == ) { assert (r * d % n = 1) } a % n; ( == ) { Math.Lemmas.small_mod a n } a; }
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "Prims.b2t", "Prims.op_Equality", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "FStar.Calc.calc_finish", "Prims.eq2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Montgomery.Lemmas.lemma_mod_mul_distr3", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.paren_mul_right", "Prims._assert", "FStar.Math.Lemmas.small_mod" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a)
[]
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.pos -> d: Prims.int{r * d % n = 1} -> a: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a (Hacl.Spec.Exponentiation.Lemmas.mont_one n r) == a)
{ "end_col": 5, "end_line": 38, "start_col": 2, "start_line": 28 }
FStar.Pervasives.Lemma
val from_mont_exp_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> aM:nat -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = LE.pow k aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in a < n /\ c == pow_mod #n a b))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let from_mont_exp_lemma pbits rLen n mu aM b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let cM = LE.pow k1 aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in M.from_mont_lemma pbits rLen n mu cM; M.from_mont_lemma pbits rLen n mu aM; //assert (c == cM * d % n); calc (==) { cM * d % n; (==) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b } LE.pow k2 aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } pow (aM * d % n) b * r % n * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow a b % n; (==) { Lib.NatMod.lemma_pow_mod #n a b } pow_mod #n a b; }; assert (a < n /\ c == pow_mod #n a b)
val from_mont_exp_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> aM:nat -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = LE.pow k aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in a < n /\ c == pow_mod #n a b)) let from_mont_exp_lemma pbits rLen n mu aM b =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let cM = LE.pow k1 aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in M.from_mont_lemma pbits rLen n mu cM; M.from_mont_lemma pbits rLen n mu aM; calc ( == ) { cM * d % n; ( == ) { pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b } LE.pow k2 aM b * d % n; ( == ) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; ( == ) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; ( == ) { () } pow a b % n; ( == ) { Lib.NatMod.lemma_pow_mod #n a b } pow_mod #n a b; }; assert (a < n /\ c == pow_mod #n a b)
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.int", "Prims._assert", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.NatMod.pow_mod", "Prims.unit", "FStar.Calc.calc_finish", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Lib.NatMod.pow", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_is_pow_nat_mont", "Prims.squash", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_is_pow", "Hacl.Spec.Montgomery.Lemmas.lemma_mont_id", "Lib.NatMod.lemma_pow_mod", "Hacl.Spec.Montgomery.Lemmas.from_mont_lemma", "Hacl.Spec.Montgomery.Lemmas.from_mont", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end val mod_exp_mont_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont_ll pbits rLen n mu a b = let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) aM b in let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; acc val mod_exp_mont_ll_mod_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> accM:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in accM < r /\ accM % n == LE.pow k (a * r % n) b)) (ensures (let aM = M.to_mont pbits rLen n mu a in let acc = M.from_mont pbits rLen n mu accM in acc == pow_mod #n a b)) let mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let k2 = mk_nat_mont_comm_monoid n r d in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; assert (aM == a * r % n); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu aM b; assert (accM % n == LE.pow k2 aM b); let acc = M.from_mont pbits rLen n mu accM in M.from_mont_lemma pbits rLen n mu accM; assert (acc == accM * d % n); Math.Lemmas.lemma_mod_mul_distr_l accM d n; mod_exp_mont_lemma n r d a b val mod_exp_mont_ll_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont_ll pbits rLen n mu a b == pow_mod #n a b) let mod_exp_mont_ll_lemma pbits rLen n mu a b = let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let aM = M.to_mont pbits rLen n mu a in M.to_mont_lemma pbits rLen n mu a; let accM = LE.pow k aM b in assert (accM == LE.pow k aM b /\ accM < n); Math.Lemmas.small_mod accM n; mod_exp_mont_ll_mod_lemma pbits rLen n mu a b accM val from_mont_exp_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> aM:nat -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = LE.pow k aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in a < n /\ c == pow_mod #n a b))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val from_mont_exp_lemma: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> aM:nat -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = LE.pow k aM b in let c = M.from_mont pbits rLen n mu cM in let a = M.from_mont pbits rLen n mu aM in a < n /\ c == pow_mod #n a b))
[]
Hacl.Spec.Exponentiation.Lemmas.from_mont_exp_lemma
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat -> aM: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (requires Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu /\ aM < n) (ensures (let k = Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid pbits rLen n mu in let cM = Lib.Exponentiation.Definition.pow k aM b in let c = Hacl.Spec.Montgomery.Lemmas.from_mont pbits rLen n mu cM in let a = Hacl.Spec.Montgomery.Lemmas.from_mont pbits rLen n mu aM in a < n /\ c == Lib.NatMod.pow_mod a b))
{ "end_col": 39, "end_line": 344, "start_col": 46, "start_line": 316 }
FStar.Pervasives.Lemma
val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b))
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then begin LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1 end else begin LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; //assert (LE.pow k1 a b == k1.LE.fmul a (LE.pow k1 a (b - 1))); M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); () end
val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b)) let rec pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a b =
false
null
true
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let k0 = mk_nat_mont_comm_monoid n r d in let k1 = mk_nat_mont_ll_comm_monoid pbits rLen n mu in if b = 0 then (LE.lemma_pow0 k0 a; LE.lemma_pow0 k1 a; M.to_mont_lemma pbits rLen n mu 1) else (LE.lemma_pow_unfold k0 a b; LE.lemma_pow_unfold k1 a b; M.mont_mul_lemma pbits rLen n mu a (LE.pow k1 a (b - 1)); pow_nat_mont_ll_is_pow_nat_mont pbits rLen n mu a (b - 1); ())
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Lib.NatMod.nat_mod", "Prims.int", "Prims.op_Equality", "Hacl.Spec.Montgomery.Lemmas.to_mont_lemma", "Prims.unit", "Lib.Exponentiation.Definition.lemma_pow0", "Prims.bool", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_is_pow_nat_mont", "Prims.op_Subtraction", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.Definition.lemma_pow_unfold", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; } val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b))
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val pow_nat_mont_ll_is_pow_nat_mont: pbits:pos -> rLen:pos -> n:pos -> mu:nat -> a:nat_mod n -> b:nat -> Lemma (requires M.mont_pre pbits rLen n mu) (ensures (let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; LE.pow (mk_nat_mont_comm_monoid n r d) a b == LE.pow (mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b))
[ "recursion" ]
Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_is_pow_nat_mont
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> FStar.Pervasives.Lemma (requires Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu) (ensures (let r = Prims.pow2 (pbits * rLen) in let _ = Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd (pbits * rLen) n in (let FStar.Pervasives.Native.Mktuple2 #_ #_ d _ = _ in Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d pbits rLen n; Lib.Exponentiation.Definition.pow (Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid n r d) a b == Lib.Exponentiation.Definition.pow (Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid pbits rLen n mu) a b) <: Type0))
{ "end_col": 10, "end_line": 244, "start_col": 61, "start_line": 226 }
FStar.Pervasives.Lemma
val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b
val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b =
false
null
true
let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in calc ( == ) { LE.pow k aM b * d % n; ( == ) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; ( == ) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; ( == ) { () } pow ((a * r % n) * d % n) b % n; ( == ) { M.lemma_mont_id n r d a } pow (a % n) b % n; ( == ) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "Prims.nat", "Lib.NatMod.lemma_pow_mod", "Prims.unit", "Prims._assert", "Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont", "Lib.NatMod.pow", "FStar.Calc.calc_finish", "Lib.Exponentiation.Definition.pow", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_is_pow", "Prims.squash", "Hacl.Spec.Montgomery.Lemmas.lemma_mont_id", "FStar.Math.Lemmas.small_mod", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b)
[]
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont_lemma
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.pos -> d: Prims.int{r * d % n == 1} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont n r d a b == Lib.NatMod.pow_mod a b)
{ "end_col": 22, "end_line": 141, "start_col": 34, "start_line": 121 }
FStar.Pervasives.Lemma
val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b)
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "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 } ]
false
let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end
val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b =
false
null
true
let k = mk_nat_mont_comm_monoid n r d in if b = 0 then (calc ( == ) { pow (aM * d % n) b * r % n; ( == ) { lemma_pow0 (aM * d % n) } 1 * r % n; ( == ) { LE.lemma_pow0 k aM } LE.pow k aM b; }; ()) else (calc ( == ) { pow (aM * d % n) b * r % n; ( == ) { lemma_pow_unfold (aM * d % n) b } ((aM * d % n) * pow (aM * d % n) (b - 1)) * r % n; ( == ) { (Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n) } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; ( == ) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } (aM * d) * LE.pow k aM (b - 1) % n; ( == ) { (Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d) } (aM * LE.pow k aM (b - 1)) * d % n; ( == ) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; ())
{ "checked_file": "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.int", "Prims.b2t", "Prims.op_Equality", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "Prims.unit", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.NatMod.pow", "Lib.Exponentiation.Definition.pow", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.NatMod.lemma_pow0", "Prims.squash", "Lib.Exponentiation.Definition.lemma_pow0", "Prims.bool", "Prims.op_Subtraction", "Lib.NatMod.lemma_pow_unfold", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.paren_mul_right", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_is_pow", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Lib.Exponentiation.Definition.lemma_pow_unfold", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid" ]
[]
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b)
false
false
Hacl.Spec.Exponentiation.Lemmas.fst
{ "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" }
null
val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b)
[ "recursion" ]
Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_is_pow
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> r: Prims.nat -> d: Prims.int{r * d % n = 1} -> aM: Lib.NatMod.nat_mod n -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Lib.NatMod.pow (aM * d % n) b * r % n == Lib.Exponentiation.Definition.pow (Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid n r d) aM b)
{ "end_col": 15, "end_line": 107, "start_col": 40, "start_line": 78 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2", "short_module": "Spec" }, { "abbrev": true, "full_module": "Spec.SHA2.Constants", "short_module": "Constants" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Core", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "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 } ]
false
let update_nblocks_vec_t (a:sha2_alg) (m:m_spec{is_supported a m}) = upd:update_vec_t a m -> update_nblocks_vec_t' a m
let update_nblocks_vec_t (a: sha2_alg) (m: m_spec{is_supported a m}) =
false
null
false
upd: update_vec_t a m -> update_nblocks_vec_t' a m
{ "checked_file": "Hacl.Impl.SHA2.Generic.fst.checked", "dependencies": [ "Spec.SHA2.Constants.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.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.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Generic.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Hacl.Impl.SHA2.Generic.update_vec_t", "Hacl.Impl.SHA2.Generic.update_nblocks_vec_t'" ]
[]
module Hacl.Impl.SHA2.Generic open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions open Hacl.Spec.SHA2.Vec open Hacl.Impl.SHA2.Core module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module Constants = Spec.SHA2.Constants module Spec = Hacl.Spec.SHA2 module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" (** Top-level constant arrays for the SHA2 algorithms. *) let h224 : x:glbuffer uint32 8ul{witnessed x Constants.h224 /\ recallable x} = createL_global Constants.h224_l let h256 : x:glbuffer uint32 8ul{witnessed x Constants.h256 /\ recallable x} = createL_global Constants.h256_l let h384 : x:glbuffer uint64 8ul{witnessed x Constants.h384 /\ recallable x} = createL_global Constants.h384_l let h512 : x:glbuffer uint64 8ul{witnessed x Constants.h512 /\ recallable x} = createL_global Constants.h512_l noextract inline_for_extraction let index_h0 (a:sha2_alg) (i:size_t) : Stack (word a) (requires (fun _ -> size_v i < 8)) (ensures (fun h0 r h1 -> h0 == h1 /\ r == Seq.index (Spec.h0 a) (size_v i))) = match a with | SHA2_224 -> recall h224; recall_contents h224 Constants.h224; h224.(i) | SHA2_256 -> recall h256; recall_contents h256 Constants.h256; h256.(i) | SHA2_384 -> recall h384; recall_contents h384 Constants.h384; h384.(i) | SHA2_512 -> recall h512; recall_contents h512 Constants.h512; h512.(i) let k224_256 : x:glbuffer uint32 64ul{witnessed x Constants.k224_256 /\ recallable x} = createL_global Constants.k224_256_l let k384_512 : x:glbuffer uint64 80ul{witnessed x Constants.k384_512 /\ recallable x} = createL_global Constants.k384_512_l noextract inline_for_extraction let index_k0 (a:sha2_alg) (i:size_t) : Stack (word a) (requires (fun _ -> size_v i < Spec.size_k_w a)) (ensures (fun h0 r h1 -> h0 == h1 /\ r == Seq.index (Spec.k0 a) (size_v i))) = match a with | SHA2_224 | SHA2_256 -> recall_contents k224_256 Constants.k224_256; k224_256.(i) | SHA2_384 | SHA2_512 -> recall_contents k384_512 Constants.k384_512; k384_512.(i) inline_for_extraction noextract val shuffle_core: #a:sha2_alg -> #m:m_spec -> k_t:word a -> ws_t:element_t a m -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.shuffle_core_spec k_t ws_t (as_seq h0 st)) let shuffle_core #a #m k_t ws_t st = let hp0 = ST.get() in let a0 = st.(0ul) in let b0 = st.(1ul) in let c0 = st.(2ul) in let d0 = st.(3ul) in let e0 = st.(4ul) in let f0 = st.(5ul) in let g0 = st.(6ul) in let h0 = st.(7ul) in let k_e_t = load_element a m k_t in let t1 = h0 +| (_Sigma1 e0) +| (_Ch e0 f0 g0) +| k_e_t +| ws_t in let t2 = (_Sigma0 a0) +| (_Maj a0 b0 c0) in let a1 = t1 +| t2 in let b1 = a0 in let c1 = b0 in let d1 = c0 in let e1 = d0 +| t1 in let f1 = e0 in let g1 = f0 in let h1 = g0 in create8 st a1 b1 c1 d1 e1 f1 g1 h1 #push-options "--z3rlimit 300" inline_for_extraction noextract val ws_next: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.ws_next (as_seq h0 ws)) let ws_next #a #m ws = let h0 = ST.get() in loop1 h0 16ul ws (fun h -> ws_next_inner #a #m) (fun i -> Lib.LoopCombinators.unfold_repeati 16 (ws_next_inner #a #m) (as_seq h0 ws) (v i); let t16 = ws.(i) in let t15 = ws.((i+.1ul) %. 16ul) in let t7 = ws.((i+.9ul) %. 16ul) in let t2 = ws.((i+.14ul) %. 16ul) in let s1 = _sigma1 t2 in let s0 = _sigma0 t15 in ws.(i) <- (s1 +| t7 +| s0 +| t16)) #pop-options inline_for_extraction noextract val shuffle: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> hash:state_t a m -> Stack unit (requires fun h -> live h hash /\ live h ws /\ disjoint hash ws) (ensures fun h0 _ h1 -> modifies2 ws hash h0 h1 /\ as_seq h1 hash == SpecVec.shuffle #a #m (as_seq h0 ws) (as_seq h0 hash)) let shuffle #a #m ws hash = let h0 = ST.get() in loop2 h0 (num_rounds16 a) ws hash (fun h -> shuffle_inner_loop #a #m) (fun i -> Lib.LoopCombinators.unfold_repeati (v (num_rounds16 a)) (shuffle_inner_loop #a #m) (as_seq h0 ws, as_seq h0 hash) (v i); let h1 = ST.get() in loop1 h1 16ul hash (fun h -> shuffle_inner #a #m (as_seq h1 ws) (v i)) (fun j -> Lib.LoopCombinators.unfold_repeati 16 (shuffle_inner #a #m (as_seq h1 ws) (v i)) (as_seq h1 hash) (v j); let k_t = index_k0 a (16ul *. i +. j) in let ws_t = ws.(j) in shuffle_core k_t ws_t hash); if i <. num_rounds16 a -. 1ul then ws_next ws) inline_for_extraction noextract val alloc: a:sha2_alg -> m:m_spec -> StackInline (state_t a m) (requires fun h -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create 8 (zero_element a m))) let alloc a m = Lib.Buffer.create 8ul (zero_element a m) inline_for_extraction noextract let init_vec_t (a:sha2_alg) (m:m_spec) = hash:state_t a m -> Stack unit (requires fun h -> live h hash) (ensures fun h0 _ h1 -> modifies1 hash h0 h1 /\ as_seq h1 hash == SpecVec.init a m) inline_for_extraction noextract val init: #a:sha2_alg -> #m:m_spec -> init_vec_t a m let init #a #m hash = let h0 = ST.get() in fill h0 8ul hash (fun h i -> load_element a m (Seq.index (Spec.h0 a) i)) (fun i -> let hi = index_h0 a i in load_element a m hi); let h1 = ST.get() in LSeq.eq_intro (as_seq h1 hash) (LSeq.createi 8 (fun i -> load_element a m (Seq.index (Spec.h0 a) i))) inline_for_extraction noextract let update_vec_t (a:sha2_alg) (m:m_spec{is_supported a m}) = b:multibuf (lanes a m) (HD.block_len a) -> hash:state_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == SpecVec.update (as_seq_multi h0 b) (as_seq h0 hash)) #push-options "--z3rlimit 200" inline_for_extraction noextract val update: #a:sha2_alg -> #m:m_spec{is_supported a m} -> update_vec_t a m let update #a #m b hash = let h0 = ST.get() in push_frame (); let h1 = ST.get() in let hash_old = create 8ul (zero_element a m) in let ws = create 16ul (zero_element a m) in assert (disjoint_multi b hash_old); assert (disjoint_multi b ws); assert (disjoint ws hash_old); assert (disjoint hash hash_old); assert (disjoint ws hash); copy hash_old hash; let h2 = ST.get() in assert (live_multi h2 b); NTup.(eq_intro (as_seq_multi h2 b) (as_seq_multi h0 b)); load_ws b ws; let h3 = ST.get() in assert (modifies (loc ws |+| loc hash_old) h0 h3); assert (as_seq h3 ws == SpecVec.load_ws (as_seq_multi h2 b)); shuffle ws hash; let h4 = ST.get() in assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h4); assert (as_seq h4 hash == SpecVec.shuffle (as_seq h3 ws) (as_seq h0 hash)); map2T 8ul hash (+|) hash hash_old; let h5 = ST.get() in assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h5); reveal_opaque (`%SpecVec.update) (SpecVec.update #a #m); assert (as_seq h5 hash == SpecVec.update (as_seq_multi h0 b) (as_seq h0 hash)); pop_frame() #pop-options inline_for_extraction noextract let update_last_vec_t' (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen:len_t a -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> hash:state_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h hash /\ disjoint_multi b hash) (ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\ as_seq h1 hash == SpecVec.update_last totlen (v len) (as_seq_multi h0 b) (as_seq h0 hash)) inline_for_extraction noextract let update_last_vec_t (a:sha2_alg) (m:m_spec{is_supported a m}) = upd:update_vec_t a m -> update_last_vec_t' a m #push-options "--z3rlimit 350" inline_for_extraction noextract val update_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> update_last_vec_t a m let update_last #a #m upd totlen len b hash = let h0 = ST.get() in push_frame (); let h1 = ST.get() in let blocks = padded_blocks a len in let fin = blocks *! HD.block_len a in let last = create (size (lanes a m) *! 2ul *! HD.block_len a) (u8 0) in let totlen_buf = create (len_len a) (u8 0) in let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in Lib.ByteBuffer.uint_to_bytes_be #(len_int_type a) totlen_buf total_len_bits; let h2 = ST.get () in NTup.eq_intro (as_seq_multi h2 b) (as_seq_multi h0 b); assert (as_seq h2 totlen_buf == Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits); let (last0,last1) = load_last #a #m totlen_buf len b fin last in let h3 = ST.get () in assert ((as_seq_multi h3 last0, as_seq_multi h3 last1) == SpecVec.load_last #a #m (as_seq h2 totlen_buf) (v fin) (v len) (as_seq_multi h2 b)); assert (disjoint_multi last1 hash); upd last0 hash; let h4 = ST.get() in assert (modifies (loc hash |+| loc last |+| loc totlen_buf) h1 h3); assert (as_seq h4 hash == SpecVec.update (as_seq_multi h3 last0) (as_seq h3 hash)); NTup.eq_intro (as_seq_multi h4 last1) (as_seq_multi h3 last1); assert (v blocks > 1 ==> blocks >. 1ul); assert (blocks >. 1ul ==> v blocks > 1); assert (not (blocks >. 1ul) ==> not (v blocks > 1)); if blocks >. 1ul then ( upd last1 hash; let h5 = ST.get() in assert (as_seq h5 hash == SpecVec.update (as_seq_multi h4 last1) (as_seq h4 hash)); assert (modifies (loc hash |+| loc last |+| loc totlen_buf) h1 h5); assert (as_seq h5 hash == SpecVec.update_last totlen (v len) (as_seq_multi h0 b) (as_seq h0 hash)); pop_frame() ) else ( let h6 = ST.get() in assert (h4 == h6); assert (modifies (loc hash |+| loc totlen_buf |+| loc last) h1 h6); assert (as_seq h6 hash == SpecVec.update_last totlen (v len) (as_seq_multi h0 b) (as_seq h0 hash)); pop_frame()) #pop-options // The type of update_nblocks_vec_t applied to a specific update function inline_for_extraction noextract let update_nblocks_vec_t' (a:sha2_alg) (m:Hacl.Spec.SHA2.Vec.(m:m_spec{is_supported a m})) = let open Lib.IntTypes in let open Lib.MultiBuffer in let open Lib.Buffer in let open Hacl.Spec.SHA2.Vec in let open Hacl.Impl.SHA2.Core in len:size_t -> b:multibuf (lanes a m) len -> st:state_t a m -> Stack unit (requires fun h0 -> live_multi h0 b /\ live h0 st /\ disjoint_multi b st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq h1 st == update_nblocks #a #m (v len) (as_seq_multi h0 b) (as_seq h0 st))) inline_for_extraction noextract
false
false
Hacl.Impl.SHA2.Generic.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_nblocks_vec_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec{Hacl.Spec.SHA2.Vec.is_supported a m} -> Type0
[]
Hacl.Impl.SHA2.Generic.update_nblocks_vec_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Generic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec{Hacl.Spec.SHA2.Vec.is_supported a m} -> Type0
{ "end_col": 53, "end_line": 315, "start_col": 4, "start_line": 315 }